Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fordecyt_2019
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rodrigo Tapia-McClung
fordecyt_2019
Commits
9ee01644
Commit
9ee01644
authored
Sep 12, 2019
by
Rodrigo Tapia-McClung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comment grijalva DB calls
parent
7423d8cc
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
109 deletions
+126
-109
centropais_basemap.js
public/fordecyt_2019/js/centropais_basemap.js
+99
-99
centropais_functions.js
public/fordecyt_2019/js/centropais_functions.js
+27
-10
No files found.
public/fordecyt_2019/js/centropais_basemap.js
View file @
9ee01644
This diff is collapsed.
Click to expand it.
public/fordecyt_2019/js/centropais_functions.js
View file @
9ee01644
...
...
@@ -85,6 +85,7 @@ d3.json("https://unpkg.com/d3-time-format@2.1.1/locale/es-MX.json").then(locale
timeFormat
=
d3
.
timeFormat
(
"%B_%Y"
);
setupTimeDimensionControl
();
// FIX: Need to remove setup and populate dates and only setup and populate map
setupDates
()
.
then
(
dates
=>
populateDates
(
dates
))
.
then
(
userData
=>
setupMap
(
userData
))
...
...
@@ -308,7 +309,8 @@ const setupMap = (dates) => {
//console.log(userFiles);
// query db to get min/max values per month and indicator and store them in an object
queryFiles
().
then
(
minmax
=>
{
// FIX: comment out to avoid DB calls
/*queryFiles().then(minmax => {
minmax.map(minmaxMonth => {
indicators.forEach((indicator) => {
minIndicators[indicator] = Math.min(minIndicators[indicator], minmaxMonth[`min${indicator}`]);
...
...
@@ -316,7 +318,9 @@ const setupMap = (dates) => {
});
});
resolve({ "map": map, "minIndicators": minIndicators, "maxIndicators": maxIndicators });
});
});*/
// FIX: resolve with fake values
resolve
({
"map"
:
map
,
"minIndicators"
:
minIndicators
,
"maxIndicators"
:
maxIndicators
});
});
}
...
...
@@ -342,7 +346,14 @@ const getMinMax = table => {
const
populateMap
=
async
(
mapData
)
=>
{
const
chartData
=
await
getData
();
// FIX: comment out to avoid DB calls
//const chartData = await getData();
// fake null data to avoid DB requests
chartData
=
[];
indicators
.
map
(
indicator
=>
{
chartData
[
indicator
]
=
[];
chartData
[
indicator
].
push
({
name
:
`
${
indicator
}
0`
,
values
:
[{
"date"
:
new
Date
(
"2016-01-01T06:00:00.000Z"
),
"value"
:
0
}]});
})
// Define charts with reusable components
indicators
.
map
(
async
(
indicator
,
index
)
=>
{
...
...
@@ -397,10 +408,11 @@ const populateMap = async(mapData) => {
//map.createPane("wb-Tiles");
//map.getPane("wb-Tiles").style.zIndex = 450;
// FIX: comment out to avoid DB calls
// create mvt layers
userFiles
.
forEach
(
f
=>
{
/*
userFiles.forEach(f => {
f = mapboxLayer(f);
});
});
*/
glmap
=
L
.
mapboxGL
({
accessToken
:
"no-token"
,
...
...
@@ -413,7 +425,8 @@ const populateMap = async(mapData) => {
// after mapboxGL map is ready with styles do this:
glmap
.
getMapboxMap
().
on
(
"style.load"
,
()
=>
{
userFiles
.
forEach
(
monthYear
=>
{
// FIX: comment out to avoid DB calls
/*userFiles.forEach(monthYear => {
glmap.getMapboxMap().addLayer(currentTiles[monthYear]);
});
...
...
@@ -421,7 +434,7 @@ const populateMap = async(mapData) => {
if (layer == userFiles[0]) {
glmap.getMapboxMap().setPaintProperty(layer, "fill-opacity", 0.7)
}
});
});
*/
timeDimensionControl
.
addTo
(
map
);
// Pass dummy geojson layer to timeDimension in order to register and sync
...
...
@@ -433,10 +446,12 @@ const populateMap = async(mapData) => {
});
timeLayer
.
addTo
(
map
);
// FIX: comment out to avoid DB calls
// style currentTiles
let
option
=
$
(
"#indicatorSelect"
).
val
();
// option selected from dropdrown
/*
let option = $("#indicatorSelect").val(); // option selected from dropdrown
styleTiles(option, minIndicators, maxIndicators)
.then(legend.addTo(map)); // add legend control -> it updates
*/
let
baseLayers
=
{
"Carto Dark"
:
cartoDarkLayer
,
...
...
@@ -444,7 +459,7 @@ const populateMap = async(mapData) => {
"OpenStreetMap"
:
osmLayer
};
var
overlays
=
{
"<span id=
\"
cuencaOverlay
\"
>Agua en la cuenca del Grijalva</span>"
:
timeLayer
//
"<span id=\"cuencaOverlay\">Agua en la cuenca del Grijalva</span>": timeLayer
};
layerControl
=
L
.
control
.
layers
(
baseLayers
,
overlays
).
addTo
(
map
);
...
...
@@ -455,8 +470,9 @@ const populateMap = async(mapData) => {
const
updateMap
=
(
mapData
)
=>
{
//console.log(userFiles);
// FIX: comment out to avoid DB calls
// clear tiles
currentTiles
=
{};
/*
currentTiles = {};
//retrieve or create tiles for current dates
userFiles.forEach(monthYear => {
if (Object.keys(allTiles).includes(monthYear)) {
...
...
@@ -504,6 +520,7 @@ const updateMap = (mapData) => {
});
// Update charts
updateCharts();
*/
}
const
updateCharts
=
async
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment