diff --git a/imports/api/ActiveFires/server/publications.js b/imports/api/ActiveFires/server/publications.js index d4b389a..b0b2329 100644 --- a/imports/api/ActiveFires/server/publications.js +++ b/imports/api/ActiveFires/server/publications.js @@ -32,12 +32,12 @@ const falsePositives = (fires) => { } }); - /* console.log(`False positive total: ${falsePos.count()}`); - * console.log(`False positives: ${JSON.stringify(falsePos.fetch())}`); */ + /* console.log(`False positive total: ${falsePos.count()}`); + console.log(`False positives: ${JSON.stringify(falsePos.fetch())}`); */ return falsePos; }; -const activefires = (northEastLng, northEastLat, southWestLng, southWestLat) => { +const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, withMarks) => { const fires = ActiveFires.find({ ourid: { $geoWithin: { @@ -56,23 +56,29 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat) => } }); - const group = new L.FeatureGroup(); - const remap = fires.fetch().map(function remap(doc) { - return { location: { lat: doc.lat, lon: doc.lon }, distance: doc.scan }; - }); - const result = calcUnion(remap, group, sub => sub); - const falsePos = falsePositives(result[0]); // console.log(JSON.stringify(result)); // console.log(`Fires total: ${fires.count()}`); - return [fires, falsePos]; + + if (withMarks && fires.fetch().length > 0) { + const group = new L.FeatureGroup(); + const remap = fires.fetch().map(function remap(doc) { + return { location: { lat: doc.lat, lon: doc.lon }, distance: doc.scan }; + }); + const result = calcUnion(remap, group, sub => sub); + const falsePos = falsePositives(result[0]); + return [fires, falsePos]; + } + + return fires; }; -Meteor.publish('activefiresmyloc', function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat) { +Meteor.publish('activefiresmyloc', function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) { // latitude -90 and 90 and the longitude between -180 and 180 check(northEastLng, NumberBetween(-180, 180)); check(southWestLat, NumberBetween(-90, 90)); check(southWestLng, NumberBetween(-180, 180)); check(northEastLat, NumberBetween(-90, 90)); + check(withMarks, Boolean); - return activefires(northEastLng, northEastLat, southWestLng, southWestLat); + return activefires(northEastLng, northEastLat, southWestLng, southWestLat, withMarks); }); diff --git a/imports/ui/pages/FiresMap/FiresMap.js b/imports/ui/pages/FiresMap/FiresMap.js index caf011e..c1b3b7b 100644 --- a/imports/ui/pages/FiresMap/FiresMap.js +++ b/imports/ui/pages/FiresMap/FiresMap.js @@ -146,6 +146,7 @@ class FiresMap extends React.Component { useMarkers(use) { this.setState({ useMarkers: use }); store.set('firesmap_marks', use); + marks.set(use); } addScale(map) { @@ -183,7 +184,7 @@ class FiresMap extends React.Component { render() { const { t } = this.props; - console.log(`Rendering ${this.props.loading ? 'loading' : 'LOADED'} map ${this.props.activefires.length + this.props.firealerts.length} of ${this.props.activefirestotal} total. False positives: ${this.props.falsePositives.length}. Reactive ${this.state.viewport.zoom >= MAXZOOMREACTIVE}`); + console.log(`Rendering ${this.props.loading ? 'loading' : 'LOADED'}, zoom ${this.state.viewport.zoom}, map ${this.props.activefires.length + this.props.firealerts.length} of ${this.props.activefirestotal} total. False positives: ${this.props.falsePositives.length}. Reactive ${this.state.viewport.zoom >= MAXZOOMREACTIVE}`); const title = `${t('AppName')}: ${t('Fuegos activos')}`; if (Meteor.isDevelopment) { console.log(`False positives total: ${this.props.falsePositives.length}`); @@ -361,7 +362,8 @@ export default translate([], { wait: true })(withTracker(() => { mapSize.get()[0].lng, mapSize.get()[0].lat, mapSize.get()[1].lng, - mapSize.get()[1].lat + mapSize.get()[1].lat, + marks.get() && zoom.get() >= MAXZOOM ); alertSubscription = Meteor.subscribe( 'fireAlerts',