forked from cemaden-educacao/WPD-MobileApp
analuizaff
3 years ago
6 changed files with 114 additions and 16 deletions
-
3package-lock.json
-
5src/app/components/MapMarkerList.js
-
2src/app/components/map/LeafLetMap.js
-
15src/app/components/map/OpenStreetMap.js
-
59src/app/hooks/useFiltering.js
-
46src/app/hooks/useFormsAswers.js
@ -0,0 +1,3 @@ |
|||
{ |
|||
"lockfileVersion": 1 |
|||
} |
@ -0,0 +1,59 @@ |
|||
function useFiltering() { |
|||
const filters = { |
|||
"citizen": |
|||
[ |
|||
{ |
|||
name: "floodZones", |
|||
endpoint: "type=FLOODZONES_FORM&lat=-9.98132&lon=-67.81544&buffer=5000&limit=3", |
|||
response: null, |
|||
|
|||
}, { |
|||
name: "rain", |
|||
endpoint: "type=RAIN_FORM&lat=-9.98132&lon=-67.81544&buffer=5000&limit=1", |
|||
response: null, |
|||
}, |
|||
{ |
|||
name: "riverFlood", |
|||
endpoint: "type=RIVERFLOOD_FORM&lat=-9.98132&lon=-67.81544&buffer=5000&limit=1", |
|||
response: null, |
|||
}, |
|||
{ |
|||
name: "pluviometer", |
|||
endpoint: "type=PLUVIOMETER_REGISTRATION&lat=-9.98132&lon=-67.81544&buffer=5000&limit=1", |
|||
response: null, |
|||
} |
|||
], |
|||
"oficial": |
|||
[ |
|||
{ |
|||
name: "susceptibilityAreas", |
|||
endpoint: "type=FLOODZONES_OFFICIAL&lat=-9.98132&lon=-67.81544&buffer=5000&limit=1", |
|||
response: null, |
|||
}, |
|||
{ |
|||
name: "automaticPluviometer", |
|||
endpoint: "type=PLUVIOMETERS_OFFICIAL&lat=-9.98132&lon=-67.81544&buffer=5000&limit=1", |
|||
response: null, |
|||
} |
|||
] |
|||
} |
|||
|
|||
return filters; |
|||
} |
|||
|
|||
const endPoint_susceptibilityAreas = () => { |
|||
return "type=FLOODZONES_OFFICIAL" |
|||
+ "&lat=-9.98132" |
|||
+ "&lon=-67.81544" |
|||
+ "&buffer=5000" |
|||
+ "&limit=1" |
|||
} |
|||
|
|||
const endPoint_automaticPluviometer = () => { |
|||
return "type=PLUVIOMETERS_OFFICIAL" |
|||
+ "&lat=-9.98132" |
|||
+ "&lon=-67.81544" |
|||
+ "&buffer=5000" |
|||
+ "&limit=1" |
|||
} |
|||
export { endPoint_susceptibilityAreas, endPoint_automaticPluviometer, useFiltering }; |
@ -0,0 +1,46 @@ |
|||
import React, { useEffect, useState } from "react"; |
|||
import * as Location from 'expo-location'; |
|||
import SocketClient from "../api/Websockets/SocketClient"; |
|||
import assets from "../config/assets"; |
|||
import PinIntransitavel from "../assets/floodZonesAssets/PinIntransitavel"; |
|||
import PinTransitavel from "../assets/floodZonesAssets/PinTransitavel"; |
|||
|
|||
function buildMarkersArray(markers, answer) { |
|||
if (answer.response) { |
|||
const response = JSON.parse(answer.response).responseData.array_to_json[0]; |
|||
var markerObject = { |
|||
ID: response.formsanswersid, |
|||
name: answer.name, |
|||
address: "",//response.fieldsanswerseventaddress,
|
|||
coordinate: { |
|||
latitude: response.formsanswerslatitude, |
|||
longitude: response.formsanswerslongitude, |
|||
}, |
|||
date: response.fias[0].fieldsanswersdtfilling, //response.fieldsanswerseventdate + " | " + response.fieldsanswerseventtime,
|
|||
description: "", //response.fielsanswercomment,
|
|||
image: "",//getMarkerImage(answer.name),
|
|||
title: "", //response.fieldsanswerssituation
|
|||
} |
|||
markers.set(markerObject.ID, markerObject); |
|||
} |
|||
|
|||
} |
|||
|
|||
const getFormsAnswers = (dataOptionObject) => { |
|||
var markers = { markers: new Map() }; |
|||
const answers = (SocketClient(dataOptionObject)); |
|||
answers.citizen.forEach((r) => buildMarkersArray(markers.markers, r)); |
|||
|
|||
console.log(markers); |
|||
|
|||
return markers; |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
export { getFormsAnswers }; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue