Adde noise and scale
This commit is contained in:
parent
aced217a7d
commit
5bc9b0b040
12 changed files with 215 additions and 52 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,3 +5,4 @@ settings-production.json
|
||||||
settings-development.json
|
settings-development.json
|
||||||
imports/ui/stylesheets/.sass-cache/
|
imports/ui/stylesheets/.sass-cache/
|
||||||
private/GeoLite2-City.mmdb*
|
private/GeoLite2-City.mmdb*
|
||||||
|
npm-debug.log
|
||||||
|
|
|
||||||
|
|
@ -42,3 +42,4 @@ flowkey:raven # js errors
|
||||||
vjrj:piwik # Stats
|
vjrj:piwik # Stats
|
||||||
mdg:geolocation
|
mdg:geolocation
|
||||||
natestrauser:publish-performant-counts
|
natestrauser:publish-performant-counts
|
||||||
|
maximum:server-transform
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ caching-compiler@1.1.9
|
||||||
caching-html-compiler@1.1.2
|
caching-html-compiler@1.1.2
|
||||||
callback-hook@1.0.10
|
callback-hook@1.0.10
|
||||||
check@1.2.5
|
check@1.2.5
|
||||||
|
coffeescript@1.0.17
|
||||||
|
dburles:mongo-collection-instances@0.3.5
|
||||||
ddp@1.3.1
|
ddp@1.3.1
|
||||||
ddp-client@2.1.3
|
ddp-client@2.1.3
|
||||||
ddp-common@1.2.9
|
ddp-common@1.2.9
|
||||||
|
|
@ -52,10 +54,13 @@ htmljs@1.0.11
|
||||||
http@1.2.12
|
http@1.2.12
|
||||||
id-map@1.0.9
|
id-map@1.0.9
|
||||||
jquery@1.11.10
|
jquery@1.11.10
|
||||||
|
lai:collection-extensions@0.2.1_1
|
||||||
launch-screen@1.1.1
|
launch-screen@1.1.1
|
||||||
livedata@1.0.18
|
livedata@1.0.18
|
||||||
localstorage@1.1.1
|
localstorage@1.1.1
|
||||||
logging@1.1.17
|
logging@1.1.17
|
||||||
|
maximum:package-base@1.1.2
|
||||||
|
maximum:server-transform@0.5.0
|
||||||
mdg:geolocation@1.3.0
|
mdg:geolocation@1.3.0
|
||||||
meteor@1.7.2
|
meteor@1.7.2
|
||||||
meteor-base@1.1.0
|
meteor-base@1.1.0
|
||||||
|
|
@ -78,6 +83,10 @@ oauth2@1.1.11
|
||||||
observe-sequence@1.0.16
|
observe-sequence@1.0.16
|
||||||
ordered-dict@1.0.9
|
ordered-dict@1.0.9
|
||||||
ostrio:cookies@2.1.3
|
ostrio:cookies@2.1.3
|
||||||
|
peerlibrary:assert@0.2.5
|
||||||
|
peerlibrary:fiber-utils@0.6.0
|
||||||
|
peerlibrary:reactive-mongo@0.1.1
|
||||||
|
peerlibrary:server-autorun@0.5.2
|
||||||
promise@0.9.0
|
promise@0.9.0
|
||||||
raix:eventemitter@0.1.3
|
raix:eventemitter@0.1.3
|
||||||
random@1.0.10
|
random@1.0.10
|
||||||
|
|
|
||||||
|
|
@ -245,9 +245,9 @@
|
||||||
borderopacity="1.0"
|
borderopacity="1.0"
|
||||||
inkscape:pageopacity="0.0"
|
inkscape:pageopacity="0.0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:zoom="0.49497475"
|
inkscape:zoom="0.24748737"
|
||||||
inkscape:cx="79.419557"
|
inkscape:cx="680.72767"
|
||||||
inkscape:cy="458.62586"
|
inkscape:cy="654.87036"
|
||||||
inkscape:document-units="mm"
|
inkscape:document-units="mm"
|
||||||
inkscape:current-layer="layer1"
|
inkscape:current-layer="layer1"
|
||||||
showgrid="false"
|
showgrid="false"
|
||||||
|
|
@ -350,5 +350,24 @@
|
||||||
inkscape:connector-curvature="0"
|
inkscape:connector-curvature="0"
|
||||||
sodipodi:nodetypes="cszzcczcsc" />
|
sodipodi:nodetypes="cszzcczcsc" />
|
||||||
</g>
|
</g>
|
||||||
|
<g
|
||||||
|
id="g22585"
|
||||||
|
transform="translate(274.75307,-132.56569)"
|
||||||
|
inkscape:export-filename="/mnt/md1/proyectos/dev/todos-contra-el-fuego-web/public/n-fire-marker.png"
|
||||||
|
inkscape:export-xdpi="6"
|
||||||
|
inkscape:export-ydpi="6">
|
||||||
|
<path
|
||||||
|
style="fill:#ff6600;fill-opacity:1;stroke:none;stroke-width:10.58333302;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m -86.843103,109.40931 c 11.566313,13.88791 17.121584,22.24485 13.751242,33.86832 -2.465387,8.50265 -8.895424,18.62654 -18.100172,25.53211 -9.204777,6.90557 -20.549947,13.51769 -24.263407,17.7288 -3.71348,4.21108 -9.83578,11.6046 -10.97677,21.82688 -2.7252,24.7073 15.03805,45.63926 39.702242,48.35952 11.289242,1.2311 26.632456,-5.2645 34.233168,-10.31973 7.600738,-5.05524 19.812847,-22.28162 22.862963,-36.23326 4.283552,-19.59367 3.495042,-42.42586 -7.944882,-59.64246 -10.679879,-16.07272 -19.75866,-28.39349 -49.264384,-41.12018 z"
|
||||||
|
id="path5329-0"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cszzcczasc" />
|
||||||
|
<path
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:10.58333302;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m -68.724596,172.4593 c 4.018254,8.70077 3.821166,14.69136 0.49964,20.18233 -2.429696,4.01667 -7.112582,8.31964 -12.774983,10.59336 -5.662401,2.27373 -12.38086,4.1034 -14.860826,5.75067 -2.479966,1.64727 -6.630515,4.59399 -8.617875,9.67322 -4.78674,12.28103 1.27127,26.11038 13.530844,30.8887 5.613373,2.17993 11.515354,2.13146 17.442629,-0.0849 5.927223,-2.21636 14.040591,-9.44377 18.02347,-15.42084 6.349021,-9.59829 8.95313,-23.76395 5.456502,-34.15229 -3.26435,-9.69812 -4.622429,-12.3603 -18.699401,-27.43025 z"
|
||||||
|
id="path5331-6"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cszzcczcsc" />
|
||||||
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
|
@ -1,10 +1,14 @@
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import Subscriptions from '../Subscriptions';
|
import Subscriptions from '../Subscriptions';
|
||||||
|
import Perlin from 'loms.perlin';
|
||||||
|
|
||||||
|
Perlin.seed(Math.random());
|
||||||
|
|
||||||
Meteor.publishTransformed('userSubsToFires', function() {
|
Meteor.publishTransformed('userSubsToFires', function() {
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Location_obfuscation
|
// https://en.wikipedia.org/wiki/Location_obfuscation
|
||||||
// https://en.wikipedia.org/wiki/Decimal_degrees#Precision
|
// https://en.wikipedia.org/wiki/Decimal_degrees#Precision
|
||||||
|
// https://gis.stackexchange.com/questions/27792/what-simple-effective-techniques-for-obfuscating-points-are-available
|
||||||
return Subscriptions.find().serverTransform(function(doc) {
|
return Subscriptions.find().serverTransform(function(doc) {
|
||||||
var location = doc.location;
|
var location = doc.location;
|
||||||
/* doc.lat = location.lat;
|
/* doc.lat = location.lat;
|
||||||
|
|
@ -13,6 +17,14 @@ Meteor.publishTransformed('userSubsToFires', function() {
|
||||||
doc.lat = Math.round(location.lat * 10) / 10;
|
doc.lat = Math.round(location.lat * 10) / 10;
|
||||||
doc.lon = Math.round(location.lon * 10) / 10;
|
doc.lon = Math.round(location.lon * 10) / 10;
|
||||||
}
|
}
|
||||||
|
// console.log(`[${doc.lat}, ${doc.lon}]`);
|
||||||
|
var noiseBase = Perlin.perlin2(doc.lat, doc.lon)
|
||||||
|
var noise = Math.abs(noiseBase/3);
|
||||||
|
// console.log(`Noise ${noise}, abs: ${Math.abs(noise)}`);
|
||||||
|
doc.lat += noise;
|
||||||
|
doc.lon += noise;
|
||||||
|
doc.distance += noiseBase;
|
||||||
|
// console.log(`with noise: [${doc.lat}, ${doc.lon}]`);
|
||||||
delete doc.chatId;
|
delete doc.chatId;
|
||||||
delete doc.geo;
|
delete doc.geo;
|
||||||
delete doc.location;
|
delete doc.location;
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,6 @@ import '../../api/Users/server/publications';
|
||||||
import '../../api/Utility/server/methods';
|
import '../../api/Utility/server/methods';
|
||||||
|
|
||||||
import '../../api/ActiveFires/server/publications';
|
import '../../api/ActiveFires/server/publications';
|
||||||
|
import '../../api/FireAlerts/server/publications';
|
||||||
|
import '../../api/Subscriptions/server/publications';
|
||||||
// TODO add rate-limit to these publications
|
// TODO add rate-limit to these publications
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
|
|
||||||
import maxmind from 'maxmind';
|
import maxmind from 'maxmind';
|
||||||
|
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/13969655/how-do-you-check-whether-the-given-ip-is-internal-or-not
|
// https://stackoverflow.com/questions/13969655/how-do-you-check-whether-the-given-ip-is-internal-or-not
|
||||||
function isPrivateIP(ip) {
|
function isPrivateIP(ip) {
|
||||||
var parts = ip.split('.');
|
var parts = ip.split('.');
|
||||||
|
|
@ -39,5 +39,5 @@ Meteor.methods({
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
return promise.await();
|
return promise.await();
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,33 @@
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import { Row, Button, Checkbox } from 'react-bootstrap';
|
import { Row, Col, Button, Checkbox } from 'react-bootstrap';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { Trans, Interpolate, translate } from 'react-i18next';
|
import { Trans, Interpolate, translate } from 'react-i18next';
|
||||||
import 'leaflet/dist/leaflet.css';
|
import 'leaflet/dist/leaflet.css';
|
||||||
import { Circle, CircleMarker, Map, Marker, Popup, TileLayer, PropTypes as MapPropTypes } from 'react-leaflet'
|
import { Circle, CircleMarker, Map, Marker, Popup, TileLayer, PropTypes as MapPropTypes } from 'react-leaflet'
|
||||||
import ActiveFiresCollection from '../../../api/ActiveFires/ActiveFires';
|
import ActiveFiresCollection from '../../../api/ActiveFires/ActiveFires';
|
||||||
|
import FireAlertsCollection from '../../../api/FireAlerts/FireAlerts';
|
||||||
|
import UserSubsToFiresCollection from '../../../api/Subscriptions/Subscriptions';
|
||||||
import { withTracker } from 'meteor/react-meteor-data';
|
import { withTracker } from 'meteor/react-meteor-data';
|
||||||
import Loading from '../../components/Loading/Loading';
|
import Loading from '../../components/Loading/Loading';
|
||||||
import './FiresMap.scss';
|
import './FiresMap.scss';
|
||||||
import Leaflet from 'leaflet'
|
import Leaflet from 'leaflet'
|
||||||
|
import LGeo from 'leaflet-geodesy';
|
||||||
|
import union from 'turf-union';
|
||||||
|
import 'leaflet-graphicscale/dist/Leaflet.GraphicScale.min.css';
|
||||||
|
import 'leaflet-graphicscale/dist/Leaflet.GraphicScale.min.js';
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/35394577/leaflet-js-union-merge-circles
|
||||||
|
function unify(polyList) {
|
||||||
|
for (var i = 0; i < polyList.length; ++i) {
|
||||||
|
if (i == 0) {
|
||||||
|
var unionTemp = polyList[i].toGeoJSON();
|
||||||
|
} else {
|
||||||
|
unionTemp =union(unionTemp, polyList[i].toGeoJSON());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return L.geoJson(unionTemp);
|
||||||
|
}
|
||||||
|
|
||||||
const fireIcon = new Leaflet.Icon({
|
const fireIcon = new Leaflet.Icon({
|
||||||
iconUrl: "/fire-marker.png",
|
iconUrl: "/fire-marker.png",
|
||||||
|
|
@ -21,42 +39,56 @@ const fireIcon = new Leaflet.Icon({
|
||||||
* popupAnchor: [-3, -76]// point from which the popup should open relative to the iconAnchor*/
|
* popupAnchor: [-3, -76]// point from which the popup should open relative to the iconAnchor*/
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const nFireIcon = new Leaflet.Icon({
|
||||||
|
iconUrl: "/n-fire-marker.png",
|
||||||
|
/* shadowUrl: require('../public/marker-shadow.png'), */
|
||||||
|
iconSize: [16, 24], // size of the icon
|
||||||
|
/* shadowSize: [50, 64], // size of the shadow */
|
||||||
|
iconAnchor: [8, 26], // point of the icon which will correspond to marker's location
|
||||||
|
/* shadowAnchor: [4, 62], // the same for the shadow
|
||||||
|
* popupAnchor: [-3, -76]// point from which the popup should open relative to the iconAnchor*/
|
||||||
|
})
|
||||||
|
|
||||||
// http://leafletjs.com/reference-1.2.0.html#icon
|
// http://leafletjs.com/reference-1.2.0.html#icon
|
||||||
const MyPopupMarker = ({ children, lat, lon}) => (
|
const MyPopupMarker = ({ children, lat, lon, nasa}) => (
|
||||||
<div><Marker position={[lat, lon]} icon={fireIcon} >
|
<div><Marker position={[lat, lon]} icon={nasa? fireIcon: nFireIcon} >
|
||||||
{/* <Popup>
|
{/* <Popup>
|
||||||
<span>{children}</span>
|
<span>{children}</span>
|
||||||
</Popup> */}
|
</Popup> */}
|
||||||
</Marker>
|
</Marker>
|
||||||
<CircleMarker center={[lat, lon]} color="red" stroke={false} fillOpacity="1" fill={true} radius={1} />
|
<CircleMarker center={[lat, lon]} color={nasa? "red": "#D35400"} stroke={false} fillOpacity="1" fill={true} radius={1} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
const FireMark = ({ lat, lon, scan }) => (
|
const FireMark = ({ lat, lon, scan, nasa }) => (
|
||||||
<Circle center={[lat, lon]} color="red" stroke={false} fillOpacity="1" fill={true} radius={scan*1000} />
|
<Circle center={[lat, lon]} color="red" stroke={false} fillOpacity="1" fill={true} radius={scan*1000} />
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Less acurate (1 pixel per fire) but faster */
|
/* Less acurate (1 pixel per fire) but faster */
|
||||||
const Fire = ({ lat, lon, scan }) => (
|
const FirePixel = ({ lat, lon, nasa }) => (
|
||||||
<CircleMarker center={[lat, lon]} color="red" stroke={false} fillOpacity="1" fill={true} radius={1} />
|
<CircleMarker center={[lat, lon]} color={nasa? "red": "#D35400"}
|
||||||
|
stroke={false} fillOpacity="1" fill={true} radius={2} />
|
||||||
)
|
)
|
||||||
|
|
||||||
MyPopupMarker.propTypes = {
|
MyPopupMarker.propTypes = {
|
||||||
|
// https://github.com/PaulLeCam/react-leaflet/tree/master/src/propTypes
|
||||||
children: MapPropTypes.children,
|
children: MapPropTypes.children,
|
||||||
lat: PropTypes.number.isRequired,
|
lat: PropTypes.number.isRequired,
|
||||||
lon: PropTypes.number.isRequired,
|
lon: PropTypes.number.isRequired,
|
||||||
|
nasa: PropTypes.bool.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
Fire.propTypes = {
|
FirePixel.propTypes = {
|
||||||
scan: PropTypes.number.isRequired,
|
|
||||||
lat: PropTypes.number.isRequired,
|
lat: PropTypes.number.isRequired,
|
||||||
lon: PropTypes.number.isRequired,
|
lon: PropTypes.number.isRequired,
|
||||||
|
nasa: PropTypes.bool.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
FireMark.propTypes = {
|
FireMark.propTypes = {
|
||||||
scan: PropTypes.number.isRequired,
|
scan: PropTypes.number.isRequired,
|
||||||
lat: PropTypes.number.isRequired,
|
lat: PropTypes.number.isRequired,
|
||||||
lon: PropTypes.number.isRequired,
|
lon: PropTypes.number.isRequired,
|
||||||
|
nasa: PropTypes.bool.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
const MyMarkersList = ({ markers }) => {
|
const MyMarkersList = ({ markers }) => {
|
||||||
|
|
@ -66,10 +98,16 @@ const MyMarkersList = ({ markers }) => {
|
||||||
return <div style={{ display: 'none' }}>{items}</div>
|
return <div style={{ display: 'none' }}>{items}</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
const FireList = ({ activefires, scale, useMarkers }) => {
|
const FireList = ({ fires, scale, useMarkers, nasa }) => {
|
||||||
const items = activefires.map(({ _id, ...props }) => (
|
/* if (nasa) {
|
||||||
useMarkers? <MyPopupMarker key={_id} {...props} />:
|
* console.log(`Scale: ${scale}`);
|
||||||
scale? <Fire key={_id} {...props} />:<FireMark key={_id} {...props} />))
|
* for (var i = 0; i < fires.length; i ++) {
|
||||||
|
* console.log(fires[i].scan);
|
||||||
|
* }
|
||||||
|
* }*/
|
||||||
|
const items = fires.map(({ _id, ...props }) => (
|
||||||
|
useMarkers? <MyPopupMarker key={_id} nasa={nasa} {...props} />:
|
||||||
|
(!nasa && !scale)? <FirePixel key={_id} nasa={nasa} {...props} />:<FireMark key={_id} nasa={nasa} {...props} />))
|
||||||
return <div style={{ display: 'none' }}>{items}</div>
|
return <div style={{ display: 'none' }}>{items}</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,8 +129,10 @@ class FiresMap extends React.Component {
|
||||||
this.state = {
|
this.state = {
|
||||||
viewport: DEFAULT_VIEWPORT,
|
viewport: DEFAULT_VIEWPORT,
|
||||||
modified: false,
|
modified: false,
|
||||||
useMarkers: false
|
useMarkers: false,
|
||||||
|
showSubsUnion: true
|
||||||
}
|
}
|
||||||
|
this.unionGroup = new L.LayerGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
centerOnUserLocation = () => {
|
centerOnUserLocation = () => {
|
||||||
|
|
@ -122,6 +162,7 @@ class FiresMap extends React.Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
height.set(this.divElement.clientHeight);
|
height.set(this.divElement.clientHeight);
|
||||||
width.set(this.divElement.clientWidth);
|
width.set(this.divElement.clientWidth);
|
||||||
|
this.addScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
onViewportChanged = viewport => {
|
onViewportChanged = viewport => {
|
||||||
|
|
@ -130,7 +171,8 @@ class FiresMap extends React.Component {
|
||||||
lat.set(viewport.center[0]);
|
lat.set(viewport.center[0]);
|
||||||
lng.set(viewport.center[1]);
|
lng.set(viewport.center[1]);
|
||||||
this.state.viewport = viewport;
|
this.state.viewport = viewport;
|
||||||
this.state.modified = true
|
this.state.modified = true;
|
||||||
|
this.showSubsUnion(this.state.showSubsUnion);
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickReset = () => {
|
onClickReset = () => {
|
||||||
|
|
@ -143,9 +185,57 @@ class FiresMap extends React.Component {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMap = () => {
|
||||||
|
return this.refs['fireMap'].leafletElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
showSubsUnion = (show) => {
|
||||||
|
this.state.showSubsUnion = show;
|
||||||
|
const map = this.getMap();
|
||||||
|
// http://leafletjs.com/reference-1.2.0.html#layergroup
|
||||||
|
var unionGroup = this.unionGroup;
|
||||||
|
|
||||||
|
if (this.union) {
|
||||||
|
map.removeLayer(this.union);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show) {
|
||||||
|
// http://leafletjs.com/reference-1.2.0.html#path
|
||||||
|
var copts = {
|
||||||
|
parts: 144,
|
||||||
|
};
|
||||||
|
UserSubsToFiresCollection.find().forEach( function(subs){
|
||||||
|
var circle = LGeo.circle([subs.lat, subs.lon], subs.distance * 1000, copts)
|
||||||
|
circle.addTo(unionGroup);
|
||||||
|
});
|
||||||
|
this.union = unify(unionGroup.getLayers());
|
||||||
|
this.union.setStyle({
|
||||||
|
color: "#145A32",
|
||||||
|
fillColor: "green",
|
||||||
|
fillOpacity: .1,
|
||||||
|
});
|
||||||
|
this.union.addTo(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addScale = () => {
|
||||||
|
// https://www.npmjs.com/package/leaflet-graphicscale
|
||||||
|
const map = this.getMap();
|
||||||
|
var options = {
|
||||||
|
fill: 'fill',
|
||||||
|
showSubunits: true,
|
||||||
|
}
|
||||||
|
var graphicScale = L.control.graphicScale([options]).addTo(map);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
this.state.viewport = !this.state.modified && this.props.viewport && Array.isArray(this.props.viewport.center)? this.props.viewport: this.state.viewport;
|
this.state.viewport = !this.state.modified && this.props.viewport && Array.isArray(this.props.viewport.center)? this.props.viewport: this.state.viewport;
|
||||||
|
|
||||||
|
if (this.props.subsready && this.refs['fireMap']) {
|
||||||
|
// Show union of users
|
||||||
|
this.showSubsUnion(this.state.showSubsUnion);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
/* Large number of markers:
|
/* Large number of markers:
|
||||||
https://stackoverflow.com/questions/43015854/large-dataset-of-markers-or-dots-in-leaflet/43019740#43019740 */
|
https://stackoverflow.com/questions/43015854/large-dataset-of-markers-or-dots-in-leaflet/43019740#43019740 */
|
||||||
|
|
@ -159,43 +249,55 @@ class FiresMap extends React.Component {
|
||||||
:""}
|
:""}
|
||||||
<h4 className="page-header"><Trans parent="span">Fuegos activos</Trans></h4>
|
<h4 className="page-header"><Trans parent="span">Fuegos activos</Trans></h4>
|
||||||
<Row>
|
<Row>
|
||||||
{this.props.activefires.length === 0?
|
<Col xs={12} sm={6} md={6} lg={6} >
|
||||||
<Trans parent="p" i18nKey="noActiveFireInMapCount">No hay fuegos activos en esta zona del mapa. Hay un total de <strong>{{countTotal: this.props.activefirestotal}}</strong> fuegos activos detectados en todo el mundo.</Trans>:
|
<p>
|
||||||
<Trans parent="p" i18nKey="activeFireInMapCount">En rojo, <strong>{{count: this.props.activefires.length}}</strong> fuegos activos en el mapa. Hay un total de <strong>{{countTotal: this.props.activefirestotal}}</strong> fuegos activos detectados en todo el mundo.</Trans>
|
{this.props.activefires.length === 0?
|
||||||
}
|
<Trans parent="span" i18nKey="noActiveFireInMapCount">No hay fuegos activos en esta zona del mapa. Hay un total de <strong>{{countTotal: this.props.activefirestotal}}</strong> fuegos activos detectados en todo el mundo.</Trans>:<Trans parent="span" i18nKey="activeFireInMapCount">En rojo, <strong>{{count: this.props.activefires.length}}</strong> fuegos activos en el mapa. Hay un total de <strong>{{countTotal: this.props.activefirestotal}}</strong> fuegos activos detectados en todo el mundo por la NASA.</Trans>
|
||||||
<Checkbox onClick={e => this.useMarkers(e.target.checked)}>
|
}
|
||||||
<Trans parent="span">Resaltar los fuegos con un marcador</Trans></Checkbox>
|
</p>
|
||||||
|
<p><Trans parent="span" i18nKey="activeNeigFireInMapCount">En naranja, los fuegos notificados por nuestros usuarios/as recientemente.</Trans></p>
|
||||||
|
</Col>
|
||||||
|
<Col xs={12} sm={6} md={6} lg={6} >
|
||||||
|
<Checkbox inline={false} defaultChecked={this.state.showSubsUnion} onClick={e => this.showSubsUnion(e.target.checked)}>
|
||||||
|
<Trans className="mark-checkbox" parent="span">Resaltar en verde el área vigilada por nuestros usuarios/as</Trans> (*)
|
||||||
|
</Checkbox>
|
||||||
|
<Checkbox inline={false} onClick={e => this.useMarkers(e.target.checked)}>
|
||||||
|
<Trans className="mark-checkbox" parent="span">Resaltar los fuegos con un marcador</Trans>
|
||||||
|
</Checkbox>
|
||||||
|
<Button bsStyle="default" onClick={() => this.centerOnUserLocation()}>
|
||||||
|
<i className="location"/>
|
||||||
|
<Trans className="location" parent="span">Centrar el mapa en tu ubicación</Trans>
|
||||||
|
</Button>
|
||||||
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<Map
|
<Map ref="fireMap"
|
||||||
animate={true}
|
animate={true}
|
||||||
preferCanvas={false}
|
preferCanvas={true}
|
||||||
onClick={this.onClickReset}
|
onClick={this.onClickReset}
|
||||||
viewport={this.state.viewport}
|
viewport={this.state.viewport}
|
||||||
onViewportChanged={this.onViewportChanged}
|
onViewportChanged={this.onViewportChanged}>
|
||||||
>
|
|
||||||
{/* http://wiki.openstreetmap.org/wiki/Tile_servers */}
|
{/* http://wiki.openstreetmap.org/wiki/Tile_servers */}
|
||||||
<TileLayer
|
<TileLayer
|
||||||
attribution="© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors"
|
attribution="© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors"
|
||||||
url="http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png"
|
url="http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png"
|
||||||
/>
|
/>
|
||||||
<FireList
|
<FireList
|
||||||
activefires={this.props.activefires}
|
fires={this.props.activefires}
|
||||||
scale={this.state.viewport.zoom > 8}
|
scale={this.state.viewport.zoom > 7}
|
||||||
useMarkers={this.state.useMarkers}
|
useMarkers={this.state.useMarkers}
|
||||||
|
nasa={true}
|
||||||
|
/>
|
||||||
|
<FireList
|
||||||
|
fires={this.props.firealerts}
|
||||||
|
scale={false}
|
||||||
|
useMarkers={this.state.useMarkers}
|
||||||
|
nasa={false}
|
||||||
/>
|
/>
|
||||||
</Map>
|
</Map>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<p>
|
(*) <Trans parent="span"><em>Para preservar la privacidad de nuestros usuarios/as, los datos reflejados están aleatoriamente alterados y son solo orientativos.</em></Trans>
|
||||||
<em><Trans parent="span">Fuente NASA y alertas vecinales de nuestr@s usuari@s.</Trans></em>
|
|
||||||
</p>
|
|
||||||
</Row>
|
|
||||||
<Row>
|
|
||||||
<Button bsStyle="default" onClick={() => this.centerOnUserLocation()}>
|
|
||||||
<i className="location"/>
|
|
||||||
<Trans className="location" parent="span">Centrar el mapa en tu ubicación</Trans>
|
|
||||||
</Button>
|
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
@ -210,6 +312,7 @@ const width = new ReactiveVar(400);
|
||||||
|
|
||||||
FiresMap.propTypes = {
|
FiresMap.propTypes = {
|
||||||
loading: PropTypes.bool.isRequired,
|
loading: PropTypes.bool.isRequired,
|
||||||
|
subsready: PropTypes.bool.isRequired,
|
||||||
activefires: PropTypes.arrayOf(PropTypes.object).isRequired,
|
activefires: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
activefirestotal: PropTypes.number.isRequired,
|
activefirestotal: PropTypes.number.isRequired,
|
||||||
viewport: PropTypes.object.isRequired
|
viewport: PropTypes.object.isRequired
|
||||||
|
|
@ -236,13 +339,21 @@ export default translate([], { wait: true }) (withTracker(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Meteor.subscribe('activefirestotal');
|
Meteor.subscribe('activefirestotal');
|
||||||
|
// Right now to all neighborhood alerts
|
||||||
|
Meteor.subscribe('fireAlerts');
|
||||||
|
var userSubs = Meteor.subscribe('userSubsToFires');
|
||||||
// const subscription = Meteor.subscribe('activefiresmyloc', zoom.get());
|
// const subscription = Meteor.subscribe('activefiresmyloc', zoom.get());
|
||||||
console.log(`Active fires ${ActiveFiresCollection.find().fetch().length} of ${Counter.get('countActiveFires')}`);
|
// console.log(`Active fires ${ActiveFiresCollection.find().fetch().length} of ${Counter.get('countActiveFires')}`);
|
||||||
|
// console.log(`Active neighborhood fires ${FireAlertsCollection.find().fetch().length} and users subscribed ${UserSubsToFiresCollection.find().fetch().length}`);
|
||||||
|
// console.log(UserSubsToFiresCollection.find().fetch());
|
||||||
return {
|
return {
|
||||||
loading: !subscription.ready(),
|
loading: !subscription.ready(),
|
||||||
|
subsready: userSubs.ready(),
|
||||||
activefires: ActiveFiresCollection.find().fetch(),
|
activefires: ActiveFiresCollection.find().fetch(),
|
||||||
activefirestotal: Counter.get('countActiveFires'),
|
activefirestotal: Counter.get('countActiveFires'),
|
||||||
|
firealerts: FireAlertsCollection.find().fetch().map(
|
||||||
|
doc => ( { _id: doc['_id'], lat: doc['location'].lat, lon: doc['location'].lon })),
|
||||||
|
userSubs: UserSubsToFiresCollection.find().fetch(),
|
||||||
viewport: {
|
viewport: {
|
||||||
center: [lat.get(), lng.get()], // a point in the sea
|
center: [lat.get(), lng.get()], // a point in the sea
|
||||||
zoom: zoom.get(),
|
zoom: zoom.get(),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
.leaflet-container {
|
.leaflet-container {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-height: 75vh;
|
min-height: 70vh;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: 75vw;
|
min-width: 75vw;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -38,3 +38,7 @@ i.location {
|
||||||
width: 35px;
|
width: 35px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mark-checkbox {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,10 @@
|
||||||
"jquery": "^2.2.4",
|
"jquery": "^2.2.4",
|
||||||
"jquery-validation": "^1.17.0",
|
"jquery-validation": "^1.17.0",
|
||||||
"juice": "^4.1.1",
|
"juice": "^4.1.1",
|
||||||
|
"leaflet-geodesy": "^0.2.1",
|
||||||
|
"leaflet-graphicscale": "0.0.2",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
|
"loms.perlin": "^1.0.1",
|
||||||
"maxmind": "^2.3.0",
|
"maxmind": "^2.3.0",
|
||||||
"meteor-accounts-t9n": "^2.0.3",
|
"meteor-accounts-t9n": "^2.0.3",
|
||||||
"meteor-node-stubs": "^0.2.11",
|
"meteor-node-stubs": "^0.2.11",
|
||||||
|
|
@ -40,7 +43,8 @@
|
||||||
"react-router-bootstrap": "^0.24.3",
|
"react-router-bootstrap": "^0.24.3",
|
||||||
"react-router-dom": "^4.2.2",
|
"react-router-dom": "^4.2.2",
|
||||||
"reactstrap": "^5.0.0-alpha.3",
|
"reactstrap": "^5.0.0-alpha.3",
|
||||||
"simpl-schema": "^0.3.2"
|
"simpl-schema": "^0.3.2",
|
||||||
|
"turf-union": "^3.0.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-jest": "^20.0.3",
|
"babel-jest": "^20.0.3",
|
||||||
|
|
|
||||||
|
|
@ -115,9 +115,9 @@
|
||||||
"noActiveFireInMapCount":
|
"noActiveFireInMapCount":
|
||||||
"No hay fuegos activos en esta zona del mapa. Hay un total de <1><0>{{countTotal}}</0></1> fuegos activos detectados en todo el mundo.",
|
"No hay fuegos activos en esta zona del mapa. Hay un total de <1><0>{{countTotal}}</0></1> fuegos activos detectados en todo el mundo.",
|
||||||
"activeFireInMapCount":
|
"activeFireInMapCount":
|
||||||
"En rojo, <1><0>{{count,number}}</0></1> fuegos activos en el mapa. Hay un total de <3><0>{{countTotal,number}}</0></3> fuegos activos detectados en todo el mundo.",
|
"En rojo, <1><0>{{count,number}}</0></1> fuegos activos en el mapa. Hay un total de <3><0>{{countTotal,number}}</0></3> fuegos activos detectados en todo el mundo por la NASA.",
|
||||||
|
"activeNeigFireInMapCount":
|
||||||
|
"En naranja, los fuegos notificados por nuestros usuarios/as recientemente.",
|
||||||
"Centrar el mapa en tu ubicación":
|
"Centrar el mapa en tu ubicación":
|
||||||
"Centrar el mapa en tu ubicación",
|
"Centrar el mapa en tu ubicación"
|
||||||
"Fuente NASA y alertas vecinales de nuestr@s usuari@s.":
|
|
||||||
"Fuente NASA y alertas vecinales de nuestr@s usuari@s."
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
public/n-fire-marker.png
Normal file
BIN
public/n-fire-marker.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 926 B |
Loading…
Add table
Add a link
Reference in a new issue