Fire page now shows also false positives
This commit is contained in:
parent
c962d12374
commit
f0bf995584
8 changed files with 77 additions and 49 deletions
|
|
@ -4,10 +4,8 @@
|
|||
|
||||
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 { whichAreFalsePositives } from '/imports/api/FalsePositives/server/publications';
|
||||
import ActiveFires from '../ActiveFires';
|
||||
|
||||
const counter = new Counter('countActiveFires', ActiveFires.find({}));
|
||||
|
|
@ -16,27 +14,6 @@ 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, withMarks) => {
|
||||
const fires = ActiveFires.find({
|
||||
ourid: {
|
||||
|
|
@ -60,12 +37,7 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, wit
|
|||
// console.log(`Fires total: ${fires.count()}`);
|
||||
|
||||
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]);
|
||||
const falsePos = whichAreFalsePositives(fires);
|
||||
return [fires, falsePos];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,4 +34,15 @@ FalsePositives.schema = new SimpleSchema({
|
|||
|
||||
FalsePositives.attachSchema(FalsePositives.schema);
|
||||
|
||||
export const falsePositivesRemap = (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;
|
||||
};
|
||||
|
||||
export default FalsePositives;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { check } from 'meteor/check';
|
||||
import { NumberBetween } from '/imports/modules/server/other-checks';
|
||||
import L from 'leaflet-headless';
|
||||
import calcUnion from '/imports/ui/components/Maps/SubsUnion/Unify';
|
||||
import FalsePositives from '../FalsePositives';
|
||||
|
||||
const counter = new Counter('countFalsePositives', FalsePositives.find({}));
|
||||
|
|
@ -13,6 +15,33 @@ Meteor.publish('falsePositivesTotal', function total() {
|
|||
return counter;
|
||||
});
|
||||
|
||||
export const whichAreFalsePositives = (fires) => {
|
||||
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.find({
|
||||
geo: {
|
||||
$geoWithin: {
|
||||
$geometry: result[0].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 falsePositives = (northEastLng, northEastLat, southWestLng, southWestLat) => {
|
||||
const fires = FalsePositives.find({
|
||||
geo: {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import NodeGeocoder from 'node-geocoder';
|
|||
import { gmapServerKey } from '/imports/startup/server/IPGeocoder';
|
||||
import ActiveFiresCollection from '/imports/api/ActiveFires/ActiveFires';
|
||||
import FireAlertsCollection from '/imports/api/FireAlerts/FireAlerts';
|
||||
import { whichAreFalsePositives } from '/imports/api/FalsePositives/server/publications';
|
||||
import FiresCollection from '../Fires';
|
||||
|
||||
function findFire(unsealed) {
|
||||
|
|
@ -114,13 +115,14 @@ Meteor.publish('fireFromId', function fireFromId(_id) {
|
|||
const fire = FiresCollection.find(new Meteor.Collection.ObjectID(_id));
|
||||
if (fire.count() !== 0) {
|
||||
// console.info(`Archive fire found: ${_id}`);
|
||||
return fire;
|
||||
const falsePos = whichAreFalsePositives(fire);
|
||||
return [fire, falsePos];
|
||||
}
|
||||
console.info(`Fire not found: ${_id}`);
|
||||
// Not found in active fires!
|
||||
return this.ready();
|
||||
} catch (e) {
|
||||
console.info(`Active fire not found (with error): ${_id}`);
|
||||
console.info(`Archive fire not found (with error): ${_id}`);
|
||||
return this.ready();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue