Commit 9ee01644 authored by Rodrigo Tapia-McClung's avatar Rodrigo Tapia-McClung

Comment grijalva DB calls

parent 7423d8cc
......@@ -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() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment