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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue