False positives only for active fires
This commit is contained in:
parent
eee1abf3ed
commit
2a6d8bea78
3 changed files with 45 additions and 14 deletions
|
|
@ -4,7 +4,10 @@
|
|||
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { check } from 'meteor/check';
|
||||
import L from 'leaflet-headless';
|
||||
import { NumberBetween } from '/imports/modules/server/other-checks';
|
||||
import FalsePositives from '/imports/api/FalsePositives/FalsePositives';
|
||||
import calcUnion from '/imports/ui/components/Maps/SubsUnion/Unify';
|
||||
import ActiveFires from '../ActiveFires';
|
||||
|
||||
const counter = new Counter('countActiveFires', ActiveFires.find({}));
|
||||
|
|
@ -13,6 +16,27 @@ Meteor.publish('activefirestotal', function total() {
|
|||
return counter;
|
||||
});
|
||||
|
||||
const falsePositives = (fires) => {
|
||||
const falsePos = FalsePositives.find({
|
||||
geo: {
|
||||
$geoWithin: {
|
||||
$geometry: fires.geometry
|
||||
}
|
||||
}
|
||||
}, {
|
||||
fields: {
|
||||
geo: 1,
|
||||
// type: 1,
|
||||
// when: 1,
|
||||
fireId: 1
|
||||
}
|
||||
});
|
||||
|
||||
/* console.log(`False positive total: ${falsePos.count()}`);
|
||||
* console.log(`False positives: ${JSON.stringify(falsePos.fetch())}`); */
|
||||
return falsePos;
|
||||
};
|
||||
|
||||
const activefires = (northEastLng, northEastLat, southWestLng, southWestLat) => {
|
||||
const fires = ActiveFires.find({
|
||||
ourid: {
|
||||
|
|
@ -31,8 +55,16 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat) =>
|
|||
scan: 1
|
||||
}
|
||||
});
|
||||
|
||||
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;
|
||||
return [fires, falsePos];
|
||||
};
|
||||
|
||||
Meteor.publish('activefiresmyloc', function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ const calcUnion = (subs, group, decorated) => {
|
|||
const circle = LGeo.circle([dsub.location.lat, dsub.location.lon], dsub.distance * 1000, copts);
|
||||
circle.addTo(unionGroup);
|
||||
} else {
|
||||
console.error(`Wrong subscription ${JSON.stringify(osub)}`);
|
||||
console.info(`Wrong subscription ${JSON.stringify(osub)}`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e, `Wrong subscription trying to make union ${JSON.stringify(osub)}`);
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ class FiresMap extends React.Component {
|
|||
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}`);
|
||||
const title = `${t('AppName')}: ${t('Fuegos activos')}`;
|
||||
if (Meteor.isDevelopment) {
|
||||
console.log(`False positives total: ${this.props.falsePositivesTotal}`);
|
||||
console.log(`False positives total: ${this.props.falsePositives.length}`);
|
||||
}
|
||||
return (
|
||||
/* Large number of markers:
|
||||
|
|
@ -321,7 +321,6 @@ FiresMap.propTypes = {
|
|||
activefires: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
firealerts: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
falsePositives: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
falsePositivesTotal: PropTypes.number.isRequired,
|
||||
lastCheck: PropTypes.instanceOf(Date),
|
||||
activefirestotal: PropTypes.number.isRequired,
|
||||
center: PropTypes.arrayOf(PropTypes.number),
|
||||
|
|
@ -370,24 +369,25 @@ export default translate([], { wait: true })(withTracker(() => {
|
|||
mapSize.get()[1].lng,
|
||||
mapSize.get()[1].lat
|
||||
);
|
||||
Meteor.subscribe(
|
||||
'falsePositivesMyloc',
|
||||
mapSize.get()[0].lng,
|
||||
mapSize.get()[0].lat,
|
||||
mapSize.get()[1].lng,
|
||||
mapSize.get()[1].lat
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Meteor.subscribe('activefirestotal');
|
||||
Meteor.subscribe('falsePositivesTotal');
|
||||
const settingsSubs = Meteor.subscribe('settings');
|
||||
const lastCheck = SiteSettings.findOne({ name: 'last-fire-check' });
|
||||
const userSubs = SiteSettings.findOne({ name: 'subs-public-union' });
|
||||
const userSubsBounds = SiteSettings.findOne({ name: 'subs-public-union-bounds' });
|
||||
const fireAlerts = FireAlertsCollection.find().fetch();
|
||||
const falsePositives = FalsePositivesCollection.find().fetch();
|
||||
const falsePositives = FalsePositivesCollection.find().fetch().map((odoc) => {
|
||||
const doc = odoc;
|
||||
const geo = doc.geo;
|
||||
doc.lat = geo.coordinates[1];
|
||||
doc.lon = geo.coordinates[0];
|
||||
doc._id = doc.fireId;
|
||||
doc.id = doc.fireId;
|
||||
delete doc.geo;
|
||||
return doc;
|
||||
});
|
||||
return {
|
||||
loading: !subscription ? true : !(subscription.ready() && settingsSubs.ready() && alertSubscription.ready()),
|
||||
userSubs: userSubs ? userSubs.value : null,
|
||||
|
|
@ -396,7 +396,6 @@ export default translate([], { wait: true })(withTracker(() => {
|
|||
// Not reactive query depending on zoom level
|
||||
activefires: ActiveFiresCollection.find({}, { reactive: zoom.get() >= MAXZOOMREACTIVE }).fetch(),
|
||||
activefirestotal: Counter.get('countActiveFires') + fireAlerts.length,
|
||||
falsePositivesTotal: Counter.get('countFalsePositives') + fireAlerts.length,
|
||||
firealerts: fireAlerts,
|
||||
falsePositives,
|
||||
lastCheck: lastCheck ? lastCheck.value : null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue