Browse Source

Adding official sample pluviometers

master
GabrielTrettel 4 years ago
parent
commit
1c29d74683
  1. 57
      src/app/hooks/selectFromDB.js

57
src/app/hooks/selectFromDB.js

@ -177,11 +177,61 @@ function reducer(state = initialState, action) {
state.markers.add(val);
});
console.log(state.markers);
return {
markers: state.markers,
};
}
function buildRandonData(location, addr) {
const points = [
[
["01/01", 10],
["05/02", 5],
["10/07", 2],
["12/07", 0],
["12/12", 20],
["13/12", 20],
["14/12", 0],
],
[
["01/01", 0],
["03/01", 0],
["05/01", 1],
["07/01", 1],
["10/01", 1],
["13/01", 1],
["15/01", 2],
],
];
var i = 1;
return points.map((points) => {
return {
image: custom_assets.pluviometer,
ID: ++ID,
name: "pluviometer",
title: "Pluviometro Oficial " + i++,
coordinate: {
latitude: location.latitude + i * 0.0003,
longitude: location.longitude - i * 0.0002,
},
address: addr,
data: {
labels: points.map((i) => {
return i[0];
}),
values: points.map((i) => {
return i[1];
}),
},
pictures: "[]",
description: "",
date: points.slice(-1)[0][0],
};
});
}
function compare(a, b) {
if (a == b) return 0;
if (parseInt(a[0].slice(3, 5)) < parseInt(b[0].slice(3, 5))) return -1;
@ -196,6 +246,10 @@ function useMarkers(isFocused) {
const location = context.currentCoordinates;
const addr = context.currentLocation;
const parseOfficialPluviometers = () => {
return buildRandonData(location, addr);
};
const parsePluviometer = (db_result) => {
// if (db_result.rows.length <= 0) return [];
const points = [];
@ -244,8 +298,7 @@ function useMarkers(isFocused) {
...info,
};
console.log(result);
return [result];
return [result, ...parseOfficialPluviometers()];
};
const queriesToParsersMapper = [

Loading…
Cancel
Save