global.R 3.68 KB
Newer Older
Sylvain Falala's avatar
Sylvain Falala committed
1
################### PURPOSE OF THE APP ###################
2
3
# Interface for mapMCDA project
# April 2019, by Sylvain Falala, Unit CIRAD-INRA ASTRE
Sylvain Falala's avatar
Sylvain Falala committed
4

Sylvain Falala's avatar
Sylvain Falala committed
5
6
################### LIBRARIES ################### 

7
8
9
10
11
library(rgdal) # to work with spatial vector
library(raster) # to work with spatial raster
library(igraph) # to work with igraph geonetwork

library(shiny) # to develop web interface
Sylvain Falala's avatar
Sylvain Falala committed
12
library(shinydashboard) # to create dashboard
13
14
15
library(rhandsontable) # to use an editable table
library(shinyFiles) # to load layer files locally

Sylvain Falala's avatar
Sylvain Falala committed
16

17
#### MAIN VARIABLES ####
Sylvain Falala's avatar
Sylvain Falala committed
18

Sylvain Falala's avatar
Sylvain Falala committed
19
appTitle <- "MapMCDA"
Sylvain Falala's avatar
Sylvain Falala committed
20

Sylvain Falala's avatar
Sylvain Falala committed
21

22
#### LANGUAGE ####
Sylvain Falala's avatar
Sylvain Falala committed
23

24
25
# Language to use: 1 = english, 2 = french
indLang <- 1
Sylvain Falala's avatar
Sylvain Falala committed
26

27
28
29
# Radio buttons to select language
langChoiceNames <- list(HTML("English"), HTML("Français"))
langChoiceVal <- list("1","2")
30

Sylvain Falala's avatar
Sylvain Falala committed
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
langDF <- data.frame(
  
  # SIDEBAR
  "MenuFile" = c("Files", "Fichiers"),
  "MenuUnit" = c("Epidemiological units", "Unités épidémiologiques"),
  "MenuRisk" = c("Risk factors", "Facteurs de risque"),
  "MenuWeight" = c("Weights", "Poids"),
  "MenuResult" = c("Results", "Résultats"),
  
  # Files box
  "BoxFile" = c("Files", "Fichiers"),
  "TitleFileInput" = c("Select layers", "Sélectionnez les fichiers de vecteurs et rasters"),
  "ButtonFileInput" = c("Browse...", "Parcourir..."),
  "BoxLayer" = c("Layers", "Couches"),
  
  # Epidemiological units box
  "BoxUnitMap" = c("Map", "Carte"),
  "BoxUnitStat" = c("Statistics", "Statistiques"), 
  
  # Risk factors box
52
53
  "BoxRiskRawMap" = c("Original scale", "Échelle originale"),
  "BoxRiskStandRaster" = c("Risk scale", "Échelle de risque"),
54
  "ABRiskRasterInvert" = c("Invert", "Inverser"),
55
56
  "RBRiskLayer" = c("Scale risk factors",
                     "Mise en échelle des facteurs de risque"),
57
58
  
  # Weights box
59
60
  "BoxWeightMatrix" = c("Pairwise comparison Matrix", "Matrice de comparaison par paires"),
  "BoxWeightBar" = c("Weights Histogram", "Histogramme des poids"),
61
62
  
  # Results box
63
64
65
  "BoxResult" = c("Combined risk", "Risque combiné"),
  "BoxResultPerUnit" = c("Per Epidemiological unit","Par unité épidémiologique"),
  "SIRiskLevel" = c("# Risk categories", "# Catégories de risque"),
66
  "DownButton" = c("Export", "Exporter"),
67

68
stringsAsFactors = FALSE)
Sylvain Falala's avatar
Sylvain Falala committed
69

70
langDF <- t(langDF)
Sylvain Falala's avatar
Sylvain Falala committed
71
72


73
74
75
76
77
78
79
80
81
82
83
84
# Type of layer
lVect <- c("Vector", "Vecteur")

lRast <- c("Raster", "Raster")

lMob <- c("MobGraph","MobGraph")


langFileList <- c("Accepted files", "Fichiers acceptés")
 
# langLayerRemove <- c("Remove", "Supprimer")

Sylvain Falala's avatar
Sylvain Falala committed
85
86
87
88
89
90
91
92

# Columns to retrieve in data frame of layers for editable table
toEditLayerColNames <- c("originalName", "shortName", "layerType", "adminUnit")

# Column names for editable table of layers
langLayerList <- list(c("Name_orig", "Name_new", "Type", "Admin_unit"), 
                      c("Nom_orig", "Nom_modif", "Type", "Unite_admin"))

93

Sylvain Falala's avatar
Sylvain Falala committed
94
95
96
97
98
99
100
101
102
# Columns read only in editable table of layers
lockOrigNameCol <- 1
lockTypeCol <- 3

# Columns editable in editable table of layers
newNameCol <- 2
newAdminCol <- 4


103
# Help text on interface
104
105
langHelpFiles <- c(
  "Import files, including a vector map with epidemiological units.",
106
  "Importer les fichiers, y-compris une carte vectorielle avec des unités épidémiologiques."
107
108
109
110
)

langHelpLayers <- c(
  "Check the epidemiological units layer.",
111
  "Indiquer la couche d'unités épidémiologiques."
112
113
114
115
116
117
118
119
120
121
122
123
124
)

langHelpScale <- c(
  "Harmonise the original scales into a common risk-scale. Use the button to reverse the relationship.",
  "Harmoniser les échelles originales en une échelle de risque commune. Utiliser le bouton pour inverser la relation."
)

langHelpMatrix <- c(
  "The factor in row i is x[i,j] times more important than the factor in column j.",
  "Le facteur de la ligne i est x[i, j] fois plus important que le facteur de la colonne j."
)


Sylvain Falala's avatar
Sylvain Falala committed
125