Browse Source

Merge branch 'main' of github.com:IGSD-UoW/WPD-MobileApp

master
GabrielTrettel 3 years ago
parent
commit
cd1bee3b6b
  1. 85
      src/app/hooks/useSocketMarkers.js
  2. 5
      src/app/screens/MapFeedScreen.js

85
src/app/hooks/useSocketMarkers.js

@ -41,7 +41,7 @@ const initialState = { markers: new Map() };
function getImage(name, situation) { function getImage(name, situation) {
if (name == "automaticPluviometer") { if (name == "automaticPluviometer") {
return custom_assets_pin.pluviometer;
return custom_assets_pin.officialPluviometer;
} }
if (name == "pluviometer") { if (name == "pluviometer") {
@ -82,6 +82,46 @@ function getImage(name, situation) {
} }
} }
function getLogo(name, situation) {
if (name == "automaticPluviometer") {
return custom_assets.officialPluviometer;
}
if (name == "pluviometer") {
return custom_assets.pluviometer;
}
if (name == "rain") {
if (situation == "sem chuva") {
return custom_assets.rainLevel[0];
} else if (situation == "chuva fraca") {
return custom_assets.rainLevel[1];
} else if (situation == "chuva moderada") {
return custom_assets.rainLevel[2];
} else if (situation == "chuva forte") {
return custom_assets.rainLevel[3];
} else {
return custom_assets.rainLevel[3];
}
}
if (name == "riverFlood") {
if (situation == "baixo") {
return custom_assets.riverLevel[0];
} else if (situation == "normal") {
return custom_assets.riverLevel[1];
} else if (situation == "alto") {
return custom_assets.riverLevel[2];
} else if (situation == "inundar") {
return custom_assets.riverLevel[3];
}
return custom_assets.riverLevel[0];
}
if (name == "floodZones") {
return custom_assets.floodZones;
}
}
function buildPolygonsObject(response, name) { function buildPolygonsObject(response, name) {
var r = JSON.parse(response); var r = JSON.parse(response);
var coordinate = []; var coordinate = [];
@ -115,20 +155,47 @@ function buildMarkerObject(response, name) {
const resposta = r.formsanswersgeom; const resposta = r.formsanswersgeom;
const formsanswersgeom = JSON.parse(resposta).coordinates; const formsanswersgeom = JSON.parse(resposta).coordinates;
var situation = null;
var address = null;
var date = null;
var time = null;
var comments = null;
var pictures = null;
if (r.fias) {
r.fias.forEach(function (f) {
if (f.fieldname == "situation") {
situation = f.fieldsanswersvalue;
}
if (f.fieldname == "eventaddress") {
address = f.fieldsanswersvalue;
}
if (f.fieldname == "eventdate") {
date = f.fieldsanswersvalue;
}
if (f.fieldname == "eventtime") {
time = f.fieldsanswersvalue;
}
if (f.fieldname == "comments") {
comments = f.fieldsanswersvalue;
}
});
}
return { return {
ID: r.formsanswersid, //response.formsanswersid,
ID: r.formsanswersid,
name: name, name: name,
title: "Titulo", //response.fieldsanswerssituation
address: "Endereço", //response.fieldsanswerseventaddress,
title: situation,
address: address,
coordinate: { coordinate: {
latitude: formsanswersgeom[1], latitude: formsanswersgeom[1],
longitude: formsanswersgeom[0], longitude: formsanswersgeom[0],
}, },
date: "data" + " | " + "hora", //response.fieldsanswerseventdate + " | " + response.fieldsanswerseventtime,
description: "comentário", //response.fielsanswercomment,
logo: custom_assets.pluviometer,
pictures: null,
image: getImage(name, "situacão"), //getMarkerImage(answer.name),
date: date + " | " + time,
description: comments,
logo: getLogo(),
pictures: pictures,
image: getImage(name, situation),
}; };
} }

5
src/app/screens/MapFeedScreen.js

@ -21,18 +21,19 @@ export default function MapFeedScreen(props) {
const [dataOptionsToShow, setDataOptionsToShow] = useState({ const [dataOptionsToShow, setDataOptionsToShow] = useState({
oficial: { oficial: {
automaticPluviometer: false, automaticPluviometer: false,
susceptibilityAreas: true,
susceptibilityAreas: false,
}, },
citzen: { citzen: {
floodRisk: false, floodRisk: false,
pluviometer: false, pluviometer: false,
rain: false,
rain: true,
floodZones: false, floodZones: false,
riverFlood: false, riverFlood: false,
}, },
}); });
const markers = useSocketMarkers(); const markers = useSocketMarkers();
// console.log(markers);
// useEffect(() => { // useEffect(() => {
// loadForms(); // loadForms();

Loading…
Cancel
Save