Fix API now using track
This commit is contained in:
parent
3ea653552e
commit
df47bef794
5 changed files with 13 additions and 4 deletions
|
|
@ -32,7 +32,9 @@ const findFiresInRegion = (zone) => {
|
||||||
export const countRealFires = (firesCursor) => {
|
export const countRealFires = (firesCursor) => {
|
||||||
const realFires = [];
|
const realFires = [];
|
||||||
firesCursor.forEach((fire) => {
|
firesCursor.forEach((fire) => {
|
||||||
|
if (debug) console.log(`${JSON.stringify(fire)} -----`);
|
||||||
const union = firesUnion([fire]);
|
const union = firesUnion([fire]);
|
||||||
|
if (debug) console.log(`${JSON.stringify(union)} -----`);
|
||||||
const falsePos = whichAreFalsePositives(FalsePositives, union);
|
const falsePos = whichAreFalsePositives(FalsePositives, union);
|
||||||
const industries = whichAreFalsePositives(Industries, union);
|
const industries = whichAreFalsePositives(Industries, union);
|
||||||
if (falsePos.count() === 0 && industries.count() === 0) {
|
if (falsePos.count() === 0 && industries.count() === 0) {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, wit
|
||||||
lat: 1,
|
lat: 1,
|
||||||
lon: 1,
|
lon: 1,
|
||||||
when: 1,
|
when: 1,
|
||||||
scan: 1
|
scan: 1,
|
||||||
|
track: 1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,13 @@ export const firesUnion = (fires) => {
|
||||||
const isNASA = doc.type === 'modis' || doc.type === 'viirs';
|
const isNASA = doc.type === 'modis' || doc.type === 'viirs';
|
||||||
const pixelSize = doc.type === 'viirs' ? 0.375 : 1; // viirs has 375m pixel size, modis 1000m
|
const pixelSize = doc.type === 'viirs' ? 0.375 : 1; // viirs has 375m pixel size, modis 1000m
|
||||||
// default 1 km for neightbor alerts
|
// default 1 km for neightbor alerts
|
||||||
return {
|
const map = {
|
||||||
location: { lat: doc.lat, lon: doc.lon },
|
location: { lat: doc.lat, lon: doc.lon },
|
||||||
distance: isNASA ? doc.scan * pixelSize : 1,
|
distance: isNASA ? doc.scan * pixelSize : 1,
|
||||||
distanceY: isNASA ? doc.track * pixelSize : 1
|
distanceY: isNASA ? doc.track * pixelSize : 1
|
||||||
};
|
};
|
||||||
|
// console.log(map);
|
||||||
|
return map;
|
||||||
});
|
});
|
||||||
const union = calcUnion(L, remap, sub => sub, false);
|
const union = calcUnion(L, remap, sub => sub, false);
|
||||||
return union;
|
return union;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ Meteor.publish('fireAlerts', function fireAlerts(northEastLng, northEastLat, sou
|
||||||
fields: {
|
fields: {
|
||||||
lat: 1,
|
lat: 1,
|
||||||
lon: 1,
|
lon: 1,
|
||||||
scan: 1
|
scan: 1,
|
||||||
|
track: 1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (Meteor.isDevelopment) console.log(`Neighbour alerts total: ${fires.count()}`);
|
if (Meteor.isDevelopment) console.log(`Neighbour alerts total: ${fires.count()}`);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import { Random } from 'meteor/random';
|
||||||
import { subscriptionsInsert } from '/imports/api/Subscriptions/methods.js';
|
import { subscriptionsInsert } from '/imports/api/Subscriptions/methods.js';
|
||||||
import { Mongo } from 'meteor/mongo';
|
import { Mongo } from 'meteor/mongo';
|
||||||
import { upsertFalsePositive } from '/imports/api/FalsePositives/methods.js';
|
import { upsertFalsePositive } from '/imports/api/FalsePositives/methods.js';
|
||||||
|
|
||||||
const debug = false;
|
const debug = false;
|
||||||
|
|
||||||
const uptime = new Date();
|
const uptime = new Date();
|
||||||
|
|
@ -157,11 +158,13 @@ if (!Meteor.settings.private.internalApiToken) {
|
||||||
lon: 1,
|
lon: 1,
|
||||||
when: 1,
|
when: 1,
|
||||||
type: 1, // modis, viirs, vecinal
|
type: 1, // modis, viirs, vecinal
|
||||||
scan: 1
|
scan: 1,
|
||||||
|
track: 1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = { total: fires.count(), real: countRealFires(fires) };
|
const result = { total: fires.count(), real: countRealFires(fires) };
|
||||||
|
if (debug) console.log(`Query for fires in ${lat}, ${lng} in ${km} km radius ${result}`);
|
||||||
|
|
||||||
if (!full) {
|
if (!full) {
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue