

[![Mac OSX builds](https://github.com/geodacenter/geoda/actions/workflows/osx_build.yml/badge.svg)](https://github.com/geodacenter/geoda/actions/workflows/osx_build.yml)
[![Ubuntu builds](https://github.com/geodacenter/geoda/actions/workflows/ubuntu_build.yml/badge.svg)](https://github.com/geodacenter/geoda/actions/workflows/ubuntu_build.yml)
[![Windows builds](https://github.com/geodacenter/geoda/actions/workflows/windows_build.yml/badge.svg)](https://github.com/geodacenter/geoda/actions/workflows/windows_build.yml)

# archeoviz

## Documentation

* doc : https://smileipic.github.io/Smilei/ + voir chat en particulier
* méthode: https://diataxis.fr/
* préciser que Timeline ne fonctionne que si "square_x" et square_y" sont documentés
* ajouter dans la doc des liens vers des exemples de tableaux de données:   
    Amalda : https://zenodo.org/doi/10.5281/zenodo.10828240 (Script & Data)
    Anyskop : https://zenodo.org/doi/10.5281/zenodo.10344546 (Script & Data)
    Bilzingsleben : https://zenodo.org/doi/10.5281/zenodo.8003444 (Script & Data)
    Kieler 1 : https://zenodo.org/doi/10.5281/zenodo.8034064  (Script & Data)
    Madjedebe : https://zenodo.org/doi/10.5281/zenodo.8011982 (Script & Data)
    Camiac : https://zenodo.org/doi/10.5281/zenodo.8281952 (Script & Data)
    
    Grande Rivoire : https://doi.org/10.5281/zenodo.10047451 (data)
    
    Erb Tanks : https://zenodo.org/doi/10.5281/zenodo.10862997  (script)
  
* créer tutoriels:
    "déployer une instance sur un server Rshiny"
    "comment simplifier l'execution d'une instance archeoviz localement"   
        shinyShortcut   Creates an Executable Shortcut for Shiny Applications
        
        En windows
            TODO Powershell?
        En linux (et mac OS?)
            Rscript script_archeoviz.R &
            sleep 4
            firefox  http://127.0.0.1:7390

* reformuler la question des échelles : archeoViz ne doit plus être 'intrasite' mais scale-free 
    from the remain scale, eg. Marathousa dataset 
    to large regional scale, ex. INRAP dataset
* voir gazeteer INRAP dans periodo
 
 

## bugs 

* Si square_x ou square_y ne peut pas être affiché, alors reverse.square.labels n'est pas appliqué en "map" view (y compris sur les labels de l'axe pour lequel les labels sont corrects)
* si les colonnes layer, xmin, ymin, zmin sont placées après object_type, le tableau n'est pas lu correctement 
* tab INPUT, le tableau de verification des données apres chargement montre 2 lignes (plutot que 1)
* orientation du plan et de la chronologie sont inversées (par ex. flageolet)
* export vers applications tierces n'est pas proposé quand il n'y a que deux variables (alors que cela devrait être le cas). par exemple : https://analytics.huma-num.fr/archeoviz/mask/
* forcer les coordonnées comme des entiers, xmin etc.
* les coordonnées trop longs (9 chiffres) posent des pb. Hypothèse : R les formate en notation scientifique (j'ai testé : R passe en not. sc. à partir de 13 chiffers)
* Statistiques / le tableau "variable", lorsqu'utilisé avec "fuzzy" + "exact" modifie les rownames (remplace les espaces par des points)
* bug dans la génération des SVG pour les profils (les lignes qui délimitent la figure sont décalées)
* Densité 2D : erreurs occasionnelles lorsqu'impossibilité de générer les courbes de densité
* si les variables square_x et square_y n'existent pas, et que les params add.x.square.labels ou add.y.square.labels sont utilisés, les labels supplémentaires ne sont pas pris en compte
* si Z n'a qu'une seule valeur, alors les carrés en vue 3D deviennent rectangulaires
* en présence de localisation fuzzy, convexhull est inesthétique (problème d'éclairage du mesh)
* dans les sintances génériques, les liens vers les applications tierces ne s'affichent pas

## simple enhancements

* supprimer "autoscale", "lasso select", "box select"
* permettre la sous-slection des groupes de points pour le calcul des surfaces de régression
* remplacer reshape2 par reshape et supprimer la dépendance à reshape2
* ajouter sliders de selection X, Y, Z dans la vue 3D
* ajouter un test sur map.z.val (vérifiant si les valeurs sont comprises dans celles de zmin, zmax)
* ajouter des axes en Section view et centrer les labels
* desactiver le lasso dans plotly (+ autres options inutiles)
* indiquer sur le logo camera "export as SVG"
* ajouter une animation lors des chargements pour indiquer que l'application calcul
* benchmarker archeoViz (profile pour identifer les bottlenecks)
* ajouter le parametre square.size dans l'interface graphique
* bouton Lancer / Rafraîchir
* add tests for: paramètre reverse.square.names
* étudier le remplacement de la dépendance à knitr par xtable
* améliorer les labels pour les adapter lors de la représentation de grandes surfaces
* employer les données 3D "volcano"  pour voir le comportement de convex hull et reression surface pour représenter des surfaces (ex : structures en creux)
* tab stat: les liens d'export ne sont pas affichés quand archeoviz executé en local (revoir pourquoi)

## new features

* voir si methode pour densité 3D (genre ellipse)
* permettre des croisements de variables  pour les densités (eg. couche & type d'objet)
* permettre de faire des sections avec une orientation particulière (autre que X et Y)
* permettre les enveloppes convexes en section
* supprimer "layer / by.variable" et rendre layer la 1re option dans un menu déroulant
* utiliser les z values pour le calcul des densités (c'est à dire faire des lignes de contours topographiques)
* voir la possibilité d'integration des services de tiles en fonds des visualisations “Map”
* reconnaitre les donnees numeriques dans les variables object_ et les traiter comme des variables continues (plutôt que discrètes, comme c'est le cas actuellement)
* permettre de croiser 2 variables dans les visualisations en employant couleur et symboles
* permettre la timeline par mois ou par jours. Limite: implique une dépendance à shinyWidgets::sliderTextInput()
    https://stackoverflow.com/questions/40392676/r-shiny-date-slider-animation-by-month-currently-by-day/40402610#40402610
        if(sum(grepl("^[0-9]{4}$", timeline.df$year)) == nrow(timeline.df)){
          timeline.df$year <- paste0(timeline.df$year, "-01-01")
          step <- 365
          timeFormat <- "%Y"
        } else if(sum(grepl("^.*-.*$", timeline.df$year)) == nrow(timeline.df)){
          timeline.df$year <- paste0(timeline.df$year, "-01")
          step <- 30
          timeFormat <- "%Y-%m"
        } else if(sum(grepl("^.*-.*-.*$", timeline.df$year)) == nrow(timeline.df)){
          step <- 1
          timeFormat <- "%Y-%m-%d"
        }
        timeline.df$year <- as.Date(timeline.df$year)
* permettre de typer les relations de remontages
* modifier l'interface pour remplacer "remontages" par le concepts de lignes (applicables aux remontages, aux fabriques, au dessin de structure)
* analyse des orientations des remontages / fabrique (reprendre McPherron)
* clustering 3D : https://github.com/CKerouanton/ST-DBSCAN/tree/master
* analyse statistiques 3D : 
    cf spatstat
    Baddeley_2016_analysing-spatial-point-patterns-in-R, p. 653
* rendre possible le rearrangement des labels de carré : square_x, square_x_order, square_y, square_y_order
* ajouter des variables optionnelles square_x.rank et square_y.rank indiquant le rang de chaque label sur l'axe
* permettre de plotter les surfaces (suggestion D Giusti)
    ajouter sélecteur des sous-groupes de points pour lesquels calculer les surfaces
        if surface == TRUE, then display <value selector>
        TODO: reordonner les items dans le menu pour avoir le <value selector> pour les surfaces en bas
    voir tests de Gainesville avec Nico
* calculer des surfaces d'interface entre couches
* étendre les paramètres possibles en URL : toute la listes des "params" + les shinyOptions.
  interfaçage / openarcheo ou nakala: faire qu'il soit possible de lancer avec une url une instance archeoviz mettant en evidence un objet.
    (idée : un convertisseur tranforme l'url et ses parametres en commande archeoviz() adaptée avec les paramètres)
  Solution: une grosse fonction qui teste la présence de chaque paramètre dans l'url:
    query <- shiny::parseQueryString(session$clientData$url_search)
    
    param_static <- names(query)[ names(query) %in% c("class_variable", "class_values", "default.group", "location", "planZ", "map.density", "map.refits", "plot3d.ratio", "cxhull", "surface", "plot3d.refits", "sectionXx", "sectionXy", "refits.sectionX", "sectionYx", "sectionYy", "refits.sectionY", "camera.center", "camera.eye") ]
    
    param_dynamic <- names(query)[ names(query) %in% c("objects.df", "refits.df", "timeline.df", "square.size", "reverse.axis.values", "reverse.square.names", "add.x.square.labels", "add.y.square.labels", "title", "home.text", "lang", "set.theme", "run.plots", "html.export") ]
    
  # param_static
    sapply(param_static,  function(param_name) eval(parse( shinyOptions(param_name = query[[param_name]]) )) )
    for(x in 1:length(param_static)){
        param.list[[ names(param_dynamic) == names(param_dynamic[x]) ]] <- param_dynamic[x]
        
        eval(parse( shinyOptions(param_static[x] = query[[ names(param_static[x]) ]]) )) 
    } 
    
  # param_dynamic
    param.list <- getshinyOptions("params")
    for(x in 1:length(param_dynamic)){
        param.list[[ names(param_dynamic) == names(param_dynamic[x]) ]] <- param_dynamic[x]
    } 
    shinyOptions("params" =  param.list)
                 
                 
* integrer 3 types d'enregistrement 
    * par carré, carroyage 
    * coordonnée absolues
    * coordonnées UTM

DONE:
*  récupérer l'état des paramètres
        https://stackoverflow.com/questions/32460475/export-all-user-inputs-in-a-shiny-app-to-file-and-load-them-later
    
    
 



## Méthode pour remontages

Deux cas de figure sont à distinguer dans les données produites par les archéologues :

1. les remontages physiques sont documentés explicitement (les relations de connexité entre fragments sont documentées par des paires d'identifiants de framents)
2. les remontages sont documentés par ensembles de fragments joins (sans préciser les relations de connexité entre fragments)

Deux variables sont à documenter dans le tableau metadata.csv
* n.refits : nombre de relations de remontage physiques (paires de fragments)
* n.remains.in.refitting.set : nombre de fragments étant inclus dans des ensembles de remontages

Parti pris : les fragments inclus dans des ensembles de remontage ne comprenant que 2 fragments sont considérés comme des "refits" (puisqu'il n'y a pas d'ambiguité à propos de la composition des paires de fragmentes remontables)









df <- demo_objects_data(30)
df <- df[ , c("id", "xmin", "ymin", "zmin", "layer", "object_type")]


df1 <- expand.grid(xmin = 1:51, ymin = 1:51)
df1$zmin <-  trunc(apply(df1, 1, function(x) sqrt((median(df1[, 1]) - x[1])^2 + (median(df1[, 2]) - x[2])^2)))
df1$zmin <- max(df1$zmin) - df1$zmin
df1$layer <- "structure1"
df1$object_type <- "hole1"
df1$id <- ""

df2 <- expand.grid(xmin = 1:51, ymin = 1:51)
df2$zmin <-  trunc(apply(df2, 1, function(x) sqrt(( median(df2[, 1]) - x[1])^2 + (median(df2[, 2]) - x[2])^2))) 
df2 <- df2 + 100
df2$zmin <- max(df2$zmin) - df2$zmin + 50
df2$layer <- "structure2"
df2$object_type <- "hole2"
df2$id <- ""

df <- rbind(df1, df2)
df$id <- 1:nrow(df)

archeoViz::archeoViz(objects.df = df,      # data.frame with data about the objects
                     refits.df = NULL,       # (optional) data.frame for refitting data
                     timeline.df = NULL,     # (optional) data.frame for the excavation timeline
                     title = NULL,           # title of the site / data set
                     home.text = NULL,       # html content to display on the home page
                     lang = "fr",            # language of the app interface
                     set.theme = "simplex")  # graphic theme for the Shiny interface





# CRAN Shiny app

protoshiny  Interactive Dendrograms for Visualizing Hierarchical Clusters with Prototypes
    https://github.com/jacobbien/protoclust
ANOVAShiny  Interactive Document for Working with Analysis of Variance
ANOVAShiny2 Interactive Document for Working with Analysis of Variance
CLUSTShiny  Interactive Document for Working with Cluster Analysis
CTAShiny    Interactive Application for Working with Contingency Tables
CTShiny Interactive Document for Working with Classification Tree Analysis
CTShiny2    Interactive Document for Working with Classification Tree Analysis
CTTinShiny  Shiny Interface for the CTT Package
CTTShiny    Classical Test Theory via Shiny
Factoshiny  Perform Factorial Analysis from 'FactoMineR' with a Shiny Application
visxhclust  A Shiny App for Visual Exploration of Hierarchical Clustering
KCSKNNShiny K-Nearest Neighbour Classifier
KCSNBShiny  Naive Bayes Classifier



fdapaceShiny    A Shiny App for the 'fdapace' Package
FielDHub    A Shiny App for Design of Experiments in Life Sciences
fomantic.plus   Add Extra 'Fomantic UI' Components to 'shiny.semantic'
formods 'Shiny' Modules for General Tasks
FossilSimShiny  Shiny Application for 'FossilSim'
genTS   R Shiny App for Creating Simplified Trial Summary (TS) Domain
GOFShiny    Interactive Document for Working with Goodness of Fit Analysis
grapesAgri1 Collection of Shiny Apps for Agricultural Research Data Analysis
Greymodels  Shiny App for Grey Forecasting Model
GRShiny Graded Response Model
histoslider A Histogram Slider Input for 'Shiny'
IGoRRR  A Shiny Interface for Simple Data Management
KappaGUI    An R-Shiny Application for Calculating Cohen's and Fleiss' Kappa
KNNShiny    Interactive Document for Working with KNN Analysis
lavaan.shiny    Latent Variable Analysis with Shiny
lcars   LCARS Aesthetic for Shiny
MDSPCAShiny Interactive Document for Working with Multidimensional Scaling and Principal Component Analysis
MetSizeR    A Shiny App for Sample Size Estimation in Metabolomic Experiments
mlr3shiny   Machine Learning in 'shiny' with 'mlr3'
MNLR    Interactive Shiny Presentation for Working with Multinomial Logistic Regression
modchart    A 'shiny' Module for Creating Charts of Various Types
monobinShiny    Shiny User Interface for 'monobin' Package
multiActionButton   Multi Action Button for 'Shiny' Applications
mwshiny 'Shiny' for Multiple Windows
netShiny    Tool for Comparison and Visualization of Multiple Networks
nextGenShinyApps    Advanced Tools for Building the Next Generation of 'Shiny' Applications and Dashboards
paramGUI    A Shiny GUI for some Parameter Estimation Examples
PDShiny 'Probability Distribution Shiny'
periscope   Enterprise Streamlined 'Shiny' Application Framework
periscope2  Enterprise Streamlined 'shiny' Application Framework Using 'bs4Dash'
PREPShiny   Interactive Document for Preprocessing the Dataset
PROBShiny   Interactive Document for Working with Basic Probability
PSS.Health  Power and Sample Size for Health Researchers via Shiny
qgshiny A 'shiny' Application for Active Learning Instruction in Introductory Quantitative Genetics
r2resize    In-Text Resizer for Images, Tables and Fancy Resizable Containers in 'Shiny', 'Rmarkdown' and 'Quarto' Documents
r2symbols   Symbols for 'Markdown' and 'Shiny' Application
radiant Business Analytics using R and Shiny
radiant.basics  Basics Menu for Radiant: Business Analytics using R and Shiny
radiant.data    Data Menu for Radiant: Business Analytics using R and Shiny
radiant.design  Design Menu for Radiant: Business Analytics using R and Shiny
radiant.model   Model Menu for Radiant: Business Analytics using R and Shiny
radiant.multivariate    Multivariate Menu for Radiant: Business Analytics using R and Shiny
rclipboard  Shiny/R Wrapper for 'clipboard.js'
reactlog    Reactivity Visualizer for 'shiny'
refund.shiny    Interactive Plotting for Functional Data Analyses
REPPlabShiny    'REPPlab' via a Shiny Application
rhino   A Framework for Enterprise Shiny Applications
rintimg View Images on Full Screen in 'RMarkdown' Documents and 'shiny' Applications
RLumShiny   'Shiny' Applications for the R Package 'Luminescence'
RSP 'shiny' Applications for Statistical and Psychometric Analysis
scenes  Switch Between Alternative 'shiny' UIs
semdrw  'SEM Shiny'
sever   Customise 'Shiny' Disconnected Screens and Error Messages
shidashi    A Shiny Dashboard Template System
shiny.benchmark Benchmark the Performance of 'shiny' Applications
shiny.blueprint Palantir's 'Blueprint' for 'Shiny' Apps
shiny.emptystate    Empty State Components for 'Shiny'
shiny.router    Basic Routing for Shiny Web Applications
shiny.semantic  Semantic UI Support for Shiny
shiny.tailwind  'TailwindCSS' for Shiny Apps
shinyAce    Ace Editor Bindings for Shiny
shinyaframe 'WebVR' Data Visualizations with 'RStudio Shiny' and 'Mozilla A-Frame'
shinybrms   Graphical User Interface ('shiny' App) for 'brms'
shinybrowser    Find Out Information About a User's Web Browser in 'Shiny'
shinyBS Twitter Bootstrap Components for Shiny
shinybusy   Busy Indicators and Notifications for 'Shiny' Applications
shinyChakraSlider   Combined Slider and Numeric Input for 'Shiny'
shinyChakraUI   A Wrapper of the 'React' Library 'Chakra UI' for 'Shiny'
shinyChatR  R Shiny Chat Module
shinyCohortBuilder  Modular Cohort-Building Framework for Analytical Dashboards
shinyCox    Create 'shiny' Applications for Cox Proportional Hazards Models
shinycssloaders Add Loading Animations to a 'shiny' Output While It's Recalculating
shinycustomloader   Custom Loader for Shiny Outputs
shinyCyJS   Create Interactive Network Visualizations in R and 'shiny'
shinydashboard  Create Dashboards with 'Shiny'
shinydashboardPlus  Add More 'AdminLTE2' Components to 'shinydashboard'
shinyDatetimePickers    Some Datetime Pickers for 'Shiny'
shinydisconnect Show a Nice Message When a 'Shiny' App Disconnects or Errors
shinydlplot Add a Download Button to a 'shiny' Plot or 'plotly'
shinyFiles  A Server-Side File System Viewer for Shiny
shinyfilter Use Interdependent Filters on Table Columns in Shiny Apps
shinyfullscreen Display 'HTML' Elements on Full Screen in 'Shiny' Apps
shinyGizmo  Custom Components for Shiny Applications
shinyHugePlot   Efficient Plotting of Large-Sized Data
shinyIRT    Item Response Theory Analysis with a 'shiny' Application
ShinyItemAnalysis   Test and Item Analysis via Shiny
shinyjs Easily Improve the User Experience of Your Shiny Apps in Seconds
shinyKGode  An Interactive Application for ODE Parameter Inference Using Gradient Matching
shinyKnobs  A Collection of Knob Inputs for 'shiny'
ShinyLink   'Shiny' Based Record Linkage Tool
shinyLP Bootstrap Landing Home Pages for Shiny Applications
shinymanager    Authentication Management for 'Shiny' Applications
shinymaterial   Implement Material Design in Shiny Applications
shinyMatrix Shiny Matrix Input Field
shinyML Compare Supervised Machine Learning Models Using Shiny App
shinyMobile Mobile Ready 'shiny' Apps with Standalone Capabilities
shinymodels Interactive Assessments of Models
shinyMonacoEditor   The 'Monaco' Editor in 'Shiny'
shinyNORRRM The Ultimate Igneous Norm
shinyNotes  Shiny Module for Taking Free-Form Notes
shinyobjects    Access Reactive Data Interactively
shinypanel  Shiny Control Panel
shinypanels Shiny Layout with Collapsible Panels
shinypivottabler    Shiny Module to Create Pivot Tables
shinyPredict    Predictions using Shiny
shinyr  Data Insights Through Inbuilt R Shiny App
shinyRadioMatrix    Create a Matrix with Radio Buttons
shinyRatings    An Intuitive Way of Providing Star Rating in a 'shiny' App
shinyrecipes    Gadget to Use the Data Preprocessing 'recipes' Package Interactively
shinyRGL    Shiny Wrappers for RGL
shinySbm    'shiny' Application to Use the Stochastic Block Model
shinyscreenshot Capture Screenshots of Entire Pages or Parts of Pages in 'Shiny'
shinySearchbar  Shiny Searchbar - An Input Widget for Highlighting Text and More
shinySelect A Wrapper of the 'react-select' Library
shinyservicebot Servicebot 'Shiny' Integration
shinystan   Interactive Visual and Numerical Diagnostics and Posterior Analysis for Bayesian Models
shinyStorePlus  Secure in-Browser Storage for 'Shiny' Inputs, Outputs and Variables
shinysurveys    Create and Deploy Surveys in 'Shiny'
shinyTempSignal Explore Temporal Signal of Molecular Phylogenies
shinyvalidate   Input Validation for Shiny Apps
shinyWidgets    Custom Inputs Widgets for Shiny
shinyXYpad  XY Controller for 'Shiny'
SIAmodules  Modules for 'ShinyItemAnalysis'
smvgraph    Various Multivariate Graphics with Variable Choice in Shiny Apps
spoiler Blur 'HTML' Elements in 'Shiny' Applications Using 'Spoiler-Alert.js'
spsComps    'systemPipeShiny' UI and Server Components
spsUtil 'systemPipeShiny' Utility Functions
standby Alerts, Notifications and Loading Screen in 'Shiny'
Statsomat   Shiny Apps for Automated Data Analysis and Automated Interpretation
stmgui  Shiny Application for Creating STM Models
stminsights A 'Shiny' Application for Inspecting Structural Topic Models
tablerDash  'Tabler' API for 'Shiny'
teachingApps    Apps for Teaching Statistics, R Programming, and Shiny App Development
TestAnaAPP  The 'shiny' App for Test Analysis and Visualization
tfrmtbuilder    'shiny' App Companion to the 'tfrmt' Package
vfinputs    Visual Filter Inputs for Shiny
voronoiTreemap  Voronoi Treemaps with Added Interactivity by Shiny
VTShiny Interactive Document for Working with Variance Analysis
WeibullR.shiny  A 'Shiny' App for Weibull Analysis from 'WeibullR'


