|
|
@ -28,8 +28,47 @@ const custom_assets_pin = { |
|
|
|
}), |
|
|
|
}; |
|
|
|
|
|
|
|
function getImage(name, situation){ |
|
|
|
//TODO
|
|
|
|
function getImage(name, situation) { |
|
|
|
if (name == "automaticPluviometer") { |
|
|
|
return custom_assets_pin.pluviometer; |
|
|
|
} |
|
|
|
|
|
|
|
if (name == "pluviometer") { |
|
|
|
return custom_assets_pin.pluviometer; |
|
|
|
} |
|
|
|
|
|
|
|
if (name == "rain") { |
|
|
|
if (situation == "sem chuva") { |
|
|
|
return custom_assets_pin.rainLevel[0]; |
|
|
|
} else if (situation == "chuva fraca") { |
|
|
|
return custom_assets_pin.rainLevel[1]; |
|
|
|
} else if (situation == "chuva moderada") { |
|
|
|
return custom_assets_pin.rainLevel[2]; |
|
|
|
} else if (situation == "chuva forte") { |
|
|
|
return custom_assets_pin.rainLevel[3]; |
|
|
|
} |
|
|
|
return custom_assets_pin.rainLevel[3]; |
|
|
|
} |
|
|
|
|
|
|
|
if (name == "riverFlood") { |
|
|
|
if (situation == "baixo") { |
|
|
|
return custom_assets_pin.riverLevel[0]; |
|
|
|
} else if (situation == "normal") { |
|
|
|
return custom_assets_pin.riverLevel[1]; |
|
|
|
} else if (situation == "alto") { |
|
|
|
return custom_assets_pin.riverLevel[2]; |
|
|
|
} else if (situation == "inundar") { |
|
|
|
return custom_assets_pin.riverLevel[3]; |
|
|
|
} |
|
|
|
return custom_assets_pin.riverLevel[0]; |
|
|
|
} |
|
|
|
if (name == "floodZones") { |
|
|
|
if (situation == "transitavel") { |
|
|
|
return custom_assets_pin.floodZones.passable; |
|
|
|
} else { |
|
|
|
return custom_assets_pin.floodZones.not_passable; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function buildPolygonsObject(markers, response, name) { |
|
|
@ -38,7 +77,7 @@ function buildPolygonsObject(markers, response, name) { |
|
|
|
const arrayCoordinates = (JSON.parse(formsanswersgeom)["coordinates"][0]); |
|
|
|
var n = Object.keys(arrayCoordinates).length; |
|
|
|
|
|
|
|
//console.log(arrayCoordinates);
|
|
|
|
// console.log(arrayCoordinates);
|
|
|
|
|
|
|
|
for (let i = 0; i < n; i++) { |
|
|
|
var lat = arrayCoordinates[i][1]; |
|
|
@ -49,36 +88,41 @@ function buildPolygonsObject(markers, response, name) { |
|
|
|
var polygonObject = { |
|
|
|
ID: response.formsanswersid, |
|
|
|
name: name, |
|
|
|
title: response.fias[0].fieldsanswersvalue ? response.fias[0].fieldsanswersvalue : "", //response.fieldsanswerssituation
|
|
|
|
address: response.fias[1].fieldsanswersvalue ? response.fias[1].fieldsanswersvalue : "",//response.fieldsanswerseventaddress,
|
|
|
|
title: "Titulo", //response.fieldsanswerssituation
|
|
|
|
address: "Endereço",//response.fieldsanswerseventaddress,
|
|
|
|
coordinate: { coordinate }, |
|
|
|
date: response.fias[2].fieldsanswersvalue + " | " + response.fias[3].fieldsanswersvalue, //response.fieldsanswerseventdate + " | " + response.fieldsanswerseventtime,
|
|
|
|
description: response.fias[4].fieldsanswersvalue, //response.fielsanswercomment,
|
|
|
|
date: "data" + " | " + "hora", //response.fieldsanswerseventdate + " | " + response.fieldsanswerseventtime,
|
|
|
|
description: "comentário", //response.fielsanswercomment,
|
|
|
|
image: "",//getMarkerImage(answer.name),
|
|
|
|
} |
|
|
|
|
|
|
|
markers.set(polygonObject.ID, polygonObject); |
|
|
|
} |
|
|
|
|
|
|
|
function buildMarkerObject(markers, response, name) { |
|
|
|
const formsanswersgeom = JSON.parse(response.formsanswersgeom)["coordinates"]; |
|
|
|
|
|
|
|
var markerObject = { |
|
|
|
ID: response.formsanswersid, |
|
|
|
name: name, |
|
|
|
title: response.fias[0].fieldsanswersvalue ? response.fias[0].fieldsanswersvalue : "", //response.fieldsanswerssituation
|
|
|
|
address: response.fias[1].fieldsanswersvalue ? response.fias[1].fieldsanswersvalue : "",//response.fieldsanswerseventaddress,
|
|
|
|
title: "Titulo", //response.fieldsanswerssituation
|
|
|
|
address: "Endereço",//response.fieldsanswerseventaddress,
|
|
|
|
coordinate: { |
|
|
|
latitude: response.formsanswerslatitude, |
|
|
|
longitude: response.formsanswerslongitude, |
|
|
|
latitude: formsanswersgeom[1], |
|
|
|
longitude: formsanswersgeom[0], |
|
|
|
}, |
|
|
|
date: response.fias[2].fieldsanswersvalue + " | " + response.fias[3].fieldsanswersvalue, //response.fieldsanswerseventdate + " | " + response.fieldsanswerseventtime,
|
|
|
|
description: response.fias[4].fieldsanswersvalue, //response.fielsanswercomment,
|
|
|
|
image: custom_assets_pin.pluviometer,//getMarkerImage(answer.name),
|
|
|
|
date: "data" + " | " + "hora", //response.fieldsanswerseventdate + " | " + response.fieldsanswerseventtime,
|
|
|
|
description: "comentário", //response.fielsanswercomment,
|
|
|
|
image: getImage(name, "situação"),//getMarkerImage(answer.name),
|
|
|
|
} |
|
|
|
|
|
|
|
markers.set(markerObject.ID, markerObject); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function verifyResponse(markers, data) { |
|
|
|
// console.log(data.response);
|
|
|
|
if (data.response) { |
|
|
|
if (data.response != null) { |
|
|
|
const response = JSON.parse(data.response).responseData.array_to_json; |
|
|
|
response.forEach((r) => r.formcode == "FLOODZONES_OFFICIAL" ? buildPolygonsObject(markers.markers, r, data.name) : buildMarkerObject(markers.markers, r, data.name)); |
|
|
|
|
|
|
@ -86,13 +130,14 @@ function verifyResponse(markers, data) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const getFormsAnswers = (dataOptionObject, focusChanged) => { |
|
|
|
const getFormsAnswers = (dataOptionObject, focusChanged, data) => { |
|
|
|
var markers = { markers: new Map() }; |
|
|
|
const answers = SocketClient(dataOptionObject, focusChanged); |
|
|
|
const answers = SocketClient(dataOptionObject, focusChanged, data); |
|
|
|
|
|
|
|
// console.log("\n\nAnswers: " + JSON.stringify(answers));
|
|
|
|
|
|
|
|
answers.forms.forEach((r) => verifyResponse(markers, r));//buildMarkerObject(markers.markers, r));
|
|
|
|
//console.log("\n\nMarkers: " + JSON.stringify(markers));
|
|
|
|
answers.forEach((r) => verifyResponse(markers, r));//buildMarkerObject(markers.markers, r));
|
|
|
|
// console.log("\n\nMarkers: " + JSON.stringify(markers));
|
|
|
|
return markers; |
|
|
|
|
|
|
|
} |
|
|
|