|
@ -1,22 +1,41 @@ |
|
|
import { useEffect, useReducer } from "react"; |
|
|
import { useEffect, useReducer } from "react"; |
|
|
import "../config/globals"; |
|
|
import "../config/globals"; |
|
|
|
|
|
|
|
|
const floodZoneAsset = require("../assets/pontos_alagamento_peq.png"); |
|
|
|
|
|
|
|
|
const assets = { |
|
|
|
|
|
floodZones: require("../assets/pontos_alagamento_peq.png"), |
|
|
|
|
|
riverLevel: [ |
|
|
|
|
|
require("../assets/rio_baixo.png"), |
|
|
|
|
|
require("../assets/rio_normal.png"), |
|
|
|
|
|
require("../assets/rio_alto.png"), |
|
|
|
|
|
require("../assets/rio_transbordando.png"), |
|
|
|
|
|
], |
|
|
|
|
|
rainLevel: [ |
|
|
|
|
|
require("../assets/sem_chuva.png"), |
|
|
|
|
|
require("../assets/chuva_peq.png"), |
|
|
|
|
|
require("../assets/chuva_peq.png"), |
|
|
|
|
|
require("../assets/chuva_forte.png"), |
|
|
|
|
|
require("../assets/chuva_muito_forte.png"), |
|
|
|
|
|
require("../assets/chuva_pancadas.png"), |
|
|
|
|
|
], |
|
|
|
|
|
pluviometer: require("../assets/diario_pluviometrico.png"), |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
// NOTE: For debug pourposes
|
|
|
// NOTE: For debug pourposes
|
|
|
var offset = 0.001; |
|
|
var offset = 0.001; |
|
|
var displacement = 0; |
|
|
var displacement = 0; |
|
|
|
|
|
|
|
|
|
|
|
var ID = 0; |
|
|
|
|
|
|
|
|
function partsePluviometer(row) { |
|
|
function partsePluviometer(row) { |
|
|
displacement += offset; |
|
|
displacement += offset; |
|
|
return { |
|
|
return { |
|
|
key: 999, |
|
|
|
|
|
title: "pluviometro", |
|
|
|
|
|
|
|
|
key: ++ID, |
|
|
|
|
|
title: "Pluviometro", |
|
|
coordinate: { |
|
|
coordinate: { |
|
|
latitude: row["Latitude"] + displacement, |
|
|
latitude: row["Latitude"] + displacement, |
|
|
longitude: row["Longitude"], |
|
|
longitude: row["Longitude"], |
|
|
}, |
|
|
}, |
|
|
image: floodZoneAsset, |
|
|
|
|
|
|
|
|
image: assets.pluviometer, |
|
|
description: row["Pluviometer"], |
|
|
description: row["Pluviometer"], |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
@ -24,17 +43,56 @@ function partsePluviometer(row) { |
|
|
function parseFloodZones(row) { |
|
|
function parseFloodZones(row) { |
|
|
displacement += offset; |
|
|
displacement += offset; |
|
|
return { |
|
|
return { |
|
|
key: row["Id"], |
|
|
|
|
|
|
|
|
key: ++ID, |
|
|
title: row["Passable"] == 0 ? "Transponível" : "Intransponível", |
|
|
title: row["Passable"] == 0 ? "Transponível" : "Intransponível", |
|
|
coordinate: { |
|
|
coordinate: { |
|
|
latitude: row["Latitude"], |
|
|
latitude: row["Latitude"], |
|
|
longitude: row["Longitude"] + displacement, |
|
|
longitude: row["Longitude"] + displacement, |
|
|
}, |
|
|
}, |
|
|
image: floodZoneAsset, |
|
|
|
|
|
|
|
|
image: assets.floodZones, |
|
|
description: row["Description"], |
|
|
description: row["Description"], |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function parseRiverLevel(row) { |
|
|
|
|
|
displacement += offset; |
|
|
|
|
|
const riverLevel = ["Baixo", "Rio normal", "Alto", "Transfordando"]; |
|
|
|
|
|
const riverIdx = row["RiverIdx"]; |
|
|
|
|
|
return { |
|
|
|
|
|
key: ++ID, |
|
|
|
|
|
title: "Nível do rio", |
|
|
|
|
|
coordinate: { |
|
|
|
|
|
latitude: row["Latitude"], |
|
|
|
|
|
longitude: row["Longitude"] + displacement, |
|
|
|
|
|
}, |
|
|
|
|
|
image: assets.riverLevel[riverIdx], |
|
|
|
|
|
description: riverLevel[riverIdx], |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function parseRainLevel(row) { |
|
|
|
|
|
displacement += offset; |
|
|
|
|
|
const rainLevel = [ |
|
|
|
|
|
"Sem chuva", |
|
|
|
|
|
"Chuva fraca", |
|
|
|
|
|
"Chuva moderada", |
|
|
|
|
|
"Chuva forte", |
|
|
|
|
|
"Chuva muito forte", |
|
|
|
|
|
"Pancada de chuva", |
|
|
|
|
|
]; |
|
|
|
|
|
const rainIdx = row["RainIdx"]; |
|
|
|
|
|
return { |
|
|
|
|
|
key: ++ID, |
|
|
|
|
|
title: "Nível da chuva", |
|
|
|
|
|
coordinate: { |
|
|
|
|
|
latitude: row["Latitude"], |
|
|
|
|
|
longitude: row["Longitude"] + displacement, |
|
|
|
|
|
}, |
|
|
|
|
|
image: assets.rainLevel[rainIdx], |
|
|
|
|
|
description: rainLevel[rainIdx], |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function parseResult(db_result, parseRow) { |
|
|
function parseResult(db_result, parseRow) { |
|
|
var warnings = []; |
|
|
var warnings = []; |
|
|
|
|
|
|
|
@ -70,6 +128,8 @@ function useMarkers() { |
|
|
const queriesToParsersMapper = [ |
|
|
const queriesToParsersMapper = [ |
|
|
["SELECT * FROM FloodZones;", parseFloodZones], |
|
|
["SELECT * FROM FloodZones;", parseFloodZones], |
|
|
["SELECT * FROM Pluviometer;", partsePluviometer], |
|
|
["SELECT * FROM Pluviometer;", partsePluviometer], |
|
|
|
|
|
["SELECT * FROM RiverLevel;", parseRiverLevel], |
|
|
|
|
|
["SELECT * FROM RainLevel;", parseRainLevel], |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
queriesToParsersMapper.forEach(([query, parser]) => { |
|
|
queriesToParsersMapper.forEach(([query, parser]) => { |
|
|