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 { Meteor } from 'meteor/meteor';
|
||||||
import { check } from 'meteor/check';
|
import { check } from 'meteor/check';
|
||||||
import L from 'leaflet-headless';
|
|
||||||
import { NumberBetween } from '/imports/modules/server/other-checks';
|
import { NumberBetween } from '/imports/modules/server/other-checks';
|
||||||
import FalsePositives from '/imports/api/FalsePositives/FalsePositives';
|
import { whichAreFalsePositives } from '/imports/api/FalsePositives/server/publications';
|
||||||
import calcUnion from '/imports/ui/components/Maps/SubsUnion/Unify';
|
|
||||||
import ActiveFires from '../ActiveFires';
|
import ActiveFires from '../ActiveFires';
|
||||||
|
|
||||||
const counter = new Counter('countActiveFires', ActiveFires.find({}));
|
const counter = new Counter('countActiveFires', ActiveFires.find({}));
|
||||||
|
|
@ -16,27 +14,6 @@ Meteor.publish('activefirestotal', function total() {
|
||||||
return counter;
|
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 activefires = (northEastLng, northEastLat, southWestLng, southWestLat, withMarks) => {
|
||||||
const fires = ActiveFires.find({
|
const fires = ActiveFires.find({
|
||||||
ourid: {
|
ourid: {
|
||||||
|
|
@ -60,12 +37,7 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, wit
|
||||||
// console.log(`Fires total: ${fires.count()}`);
|
// console.log(`Fires total: ${fires.count()}`);
|
||||||
|
|
||||||
if (withMarks && fires.fetch().length > 0) {
|
if (withMarks && fires.fetch().length > 0) {
|
||||||
const group = new L.FeatureGroup();
|
const falsePos = whichAreFalsePositives(fires);
|
||||||
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, falsePos];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,4 +34,15 @@ FalsePositives.schema = new SimpleSchema({
|
||||||
|
|
||||||
FalsePositives.attachSchema(FalsePositives.schema);
|
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;
|
export default FalsePositives;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { check } from 'meteor/check';
|
import { check } from 'meteor/check';
|
||||||
import { NumberBetween } from '/imports/modules/server/other-checks';
|
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';
|
import FalsePositives from '../FalsePositives';
|
||||||
|
|
||||||
const counter = new Counter('countFalsePositives', FalsePositives.find({}));
|
const counter = new Counter('countFalsePositives', FalsePositives.find({}));
|
||||||
|
|
@ -13,6 +15,33 @@ Meteor.publish('falsePositivesTotal', function total() {
|
||||||
return counter;
|
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 falsePositives = (northEastLng, northEastLat, southWestLng, southWestLat) => {
|
||||||
const fires = FalsePositives.find({
|
const fires = FalsePositives.find({
|
||||||
geo: {
|
geo: {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import NodeGeocoder from 'node-geocoder';
|
||||||
import { gmapServerKey } from '/imports/startup/server/IPGeocoder';
|
import { gmapServerKey } from '/imports/startup/server/IPGeocoder';
|
||||||
import ActiveFiresCollection from '/imports/api/ActiveFires/ActiveFires';
|
import ActiveFiresCollection from '/imports/api/ActiveFires/ActiveFires';
|
||||||
import FireAlertsCollection from '/imports/api/FireAlerts/FireAlerts';
|
import FireAlertsCollection from '/imports/api/FireAlerts/FireAlerts';
|
||||||
|
import { whichAreFalsePositives } from '/imports/api/FalsePositives/server/publications';
|
||||||
import FiresCollection from '../Fires';
|
import FiresCollection from '../Fires';
|
||||||
|
|
||||||
function findFire(unsealed) {
|
function findFire(unsealed) {
|
||||||
|
|
@ -114,13 +115,14 @@ Meteor.publish('fireFromId', function fireFromId(_id) {
|
||||||
const fire = FiresCollection.find(new Meteor.Collection.ObjectID(_id));
|
const fire = FiresCollection.find(new Meteor.Collection.ObjectID(_id));
|
||||||
if (fire.count() !== 0) {
|
if (fire.count() !== 0) {
|
||||||
// console.info(`Archive fire found: ${_id}`);
|
// console.info(`Archive fire found: ${_id}`);
|
||||||
return fire;
|
const falsePos = whichAreFalsePositives(fire);
|
||||||
|
return [fire, falsePos];
|
||||||
}
|
}
|
||||||
console.info(`Fire not found: ${_id}`);
|
console.info(`Fire not found: ${_id}`);
|
||||||
// Not found in active fires!
|
// Not found in active fires!
|
||||||
return this.ready();
|
return this.ready();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.info(`Active fire not found (with error): ${_id}`);
|
console.info(`Archive fire not found (with error): ${_id}`);
|
||||||
return this.ready();
|
return this.ready();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import React, { Fragment } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { withTracker } from 'meteor/react-meteor-data';
|
import { withTracker } from 'meteor/react-meteor-data';
|
||||||
import { translate, Trans } from 'react-i18next';
|
import { translate, Trans } from 'react-i18next';
|
||||||
import { FormGroup } from 'react-bootstrap';
|
import { Row, Col, Alert, FormGroup } from 'react-bootstrap';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { Bert } from 'meteor/themeteorchef:bert';
|
import { Bert } from 'meteor/themeteorchef:bert';
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
|
|
@ -15,10 +15,12 @@ import Blaze from 'meteor/gadicc:blaze-react-component';
|
||||||
import DefMapLayers from '/imports/ui/components/Maps/DefMapLayers';
|
import DefMapLayers from '/imports/ui/components/Maps/DefMapLayers';
|
||||||
import NotFound from '/imports/ui/pages/NotFound/NotFound';
|
import NotFound from '/imports/ui/pages/NotFound/NotFound';
|
||||||
import FiresCollection from '/imports/api/Fires/Fires';
|
import FiresCollection from '/imports/api/Fires/Fires';
|
||||||
|
import FireList from '/imports/ui/components/Maps/FireList';
|
||||||
import FromNow from '/imports/ui/components/FromNow/FromNow';
|
import FromNow from '/imports/ui/components/FromNow/FromNow';
|
||||||
import { dateLongFormat } from '/imports/api/Common/dates';
|
import { dateLongFormat } from '/imports/api/Common/dates';
|
||||||
import '/imports/startup/client/comments';
|
import '/imports/startup/client/comments';
|
||||||
import FalsePositiveTypes from '/imports/api/FalsePositives/FalsePositiveTypes';
|
import FalsePositiveTypes from '/imports/api/FalsePositives/FalsePositiveTypes';
|
||||||
|
import FalsePositivesCollection, { falsePositivesRemap } from '/imports/api/FalsePositives/FalsePositives';
|
||||||
import ShareIt from '/imports/ui/components/ShareIt/ShareIt';
|
import ShareIt from '/imports/ui/components/ShareIt/ShareIt';
|
||||||
import './Fires.scss';
|
import './Fires.scss';
|
||||||
|
|
||||||
|
|
@ -67,6 +69,7 @@ class Fire extends React.Component {
|
||||||
const {
|
const {
|
||||||
notfound, loading, fire, t
|
notfound, loading, fire, t
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
if (Meteor.isDevelopment) console.log(`False positives total: ${this.props.falsePositives.length}`);
|
||||||
/* console.log(`loading fire: ${loading}`);
|
/* console.log(`loading fire: ${loading}`);
|
||||||
* console.log(`Not found fire: ${notfound}`); */
|
* console.log(`Not found fire: ${notfound}`); */
|
||||||
if (fire && fire.when) {
|
if (fire && fire.when) {
|
||||||
|
|
@ -105,6 +108,15 @@ class Fire extends React.Component {
|
||||||
radius={fire.scan ? fire.scan * 1000 : 300}
|
radius={fire.scan ? fire.scan * 1000 : 300}
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
<FireList
|
||||||
|
t={t}
|
||||||
|
history={this.props.history}
|
||||||
|
fires={this.props.falsePositives}
|
||||||
|
scale
|
||||||
|
useMarkers
|
||||||
|
nasa={false}
|
||||||
|
falsePositives
|
||||||
|
/>
|
||||||
<DefMapLayers />
|
<DefMapLayers />
|
||||||
</Map>
|
</Map>
|
||||||
<p>{t('Coordenadas:')} {fire.lat}, {fire.lon}</p>
|
<p>{t('Coordenadas:')} {fire.lat}, {fire.lon}</p>
|
||||||
|
|
@ -119,6 +131,11 @@ class Fire extends React.Component {
|
||||||
|
|
||||||
{(fire.type !== 'vecinal') &&
|
{(fire.type !== 'vecinal') &&
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
<Alert bsStyle="success"><Trans>Parece que este fuego no es un fuego forestal.</Trans></Alert>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
<h5>{t('¿No es un fuego forestal?')}</h5>
|
<h5>{t('¿No es un fuego forestal?')}</h5>
|
||||||
<div>
|
<div>
|
||||||
<Trans>Indícanos de que tipo de fuego se trata y ayúdanos así a mejorar nuestras notificaciones:</Trans>
|
<Trans>Indícanos de que tipo de fuego se trata y ayúdanos así a mejorar nuestras notificaciones:</Trans>
|
||||||
|
|
@ -172,6 +189,7 @@ Fire.propTypes = {
|
||||||
history: PropTypes.object.isRequired,
|
history: PropTypes.object.isRequired,
|
||||||
loading: PropTypes.bool.isRequired,
|
loading: PropTypes.bool.isRequired,
|
||||||
notfound: PropTypes.bool.isRequired,
|
notfound: PropTypes.bool.isRequired,
|
||||||
|
falsePositives: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
fromHash: PropTypes.bool.isRequired,
|
fromHash: PropTypes.bool.isRequired,
|
||||||
active: PropTypes.bool.isRequired,
|
active: PropTypes.bool.isRequired,
|
||||||
alert: PropTypes.bool.isRequired,
|
alert: PropTypes.bool.isRequired,
|
||||||
|
|
@ -211,11 +229,13 @@ const FireContainer = withTracker(({ match }) => {
|
||||||
const notfound = !loading && FiresCollection.find().count() === 0;
|
const notfound = !loading && FiresCollection.find().count() === 0;
|
||||||
/* console.log(`loading fire: ${loading}`);
|
/* console.log(`loading fire: ${loading}`);
|
||||||
* console.log(`Not found fire: ${notfound}`); */
|
* console.log(`Not found fire: ${notfound}`); */
|
||||||
|
const falsePositives = FalsePositivesCollection.find().fetch().map(falsePositivesRemap);
|
||||||
return {
|
return {
|
||||||
loading,
|
loading,
|
||||||
active,
|
active,
|
||||||
alert,
|
alert,
|
||||||
fromHash,
|
fromHash,
|
||||||
|
falsePositives,
|
||||||
fire: FiresCollection.findOne(),
|
fire: FiresCollection.findOne(),
|
||||||
notfound,
|
notfound,
|
||||||
when: subscription.ready() && FiresCollection.findOne() ? FiresCollection.findOne().when : null
|
when: subscription.ready() && FiresCollection.findOne() ? FiresCollection.findOne().when : null
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import DefMapLayers from '/imports/ui/components/Maps/DefMapLayers';
|
||||||
import FromNow from '/imports/ui/components/FromNow/FromNow';
|
import FromNow from '/imports/ui/components/FromNow/FromNow';
|
||||||
import ActiveFiresCollection from '/imports/api/ActiveFires/ActiveFires';
|
import ActiveFiresCollection from '/imports/api/ActiveFires/ActiveFires';
|
||||||
import FireAlertsCollection from '/imports/api/FireAlerts/FireAlerts';
|
import FireAlertsCollection from '/imports/api/FireAlerts/FireAlerts';
|
||||||
import FalsePositivesCollection from '/imports/api/FalsePositives/FalsePositives';
|
import FalsePositivesCollection, { falsePositivesRemap } from '/imports/api/FalsePositives/FalsePositives';
|
||||||
import SiteSettings from '/imports/api/SiteSettings/SiteSettings';
|
import SiteSettings from '/imports/api/SiteSettings/SiteSettings';
|
||||||
import { isNotHomeAndMobile, isChrome } from '/imports/ui/components/Utils/isMobile';
|
import { isNotHomeAndMobile, isChrome } from '/imports/ui/components/Utils/isMobile';
|
||||||
import { isHome } from '/imports/ui/components/Utils/location';
|
import { isHome } from '/imports/ui/components/Utils/location';
|
||||||
|
|
@ -185,9 +185,8 @@ class FiresMap extends React.Component {
|
||||||
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}`);
|
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')}`;
|
const title = `${t('AppName')}: ${t('Fuegos activos')}`;
|
||||||
|
|
||||||
if (Meteor.isDevelopment) {
|
if (Meteor.isDevelopment) console.log(`False positives total: ${this.props.falsePositives.length}`);
|
||||||
console.log(`False positives total: ${this.props.falsePositives.length}`);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
/* Large number of markers:
|
/* Large number of markers:
|
||||||
https://stackoverflow.com/questions/43015854/large-dataset-of-markers-or-dots-in-leaflet/43019740#43019740 */
|
https://stackoverflow.com/questions/43015854/large-dataset-of-markers-or-dots-in-leaflet/43019740#43019740 */
|
||||||
|
|
@ -375,16 +374,7 @@ export default translate([], { wait: true })(withTracker(() => {
|
||||||
const userSubs = SiteSettings.findOne({ name: 'subs-public-union' });
|
const userSubs = SiteSettings.findOne({ name: 'subs-public-union' });
|
||||||
const userSubsBounds = SiteSettings.findOne({ name: 'subs-public-union-bounds' });
|
const userSubsBounds = SiteSettings.findOne({ name: 'subs-public-union-bounds' });
|
||||||
const fireAlerts = FireAlertsCollection.find().fetch();
|
const fireAlerts = FireAlertsCollection.find().fetch();
|
||||||
const falsePositives = FalsePositivesCollection.find().fetch().map((odoc) => {
|
const falsePositives = FalsePositivesCollection.find().fetch().map(falsePositivesRemap);
|
||||||
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 {
|
return {
|
||||||
loading: !subscription ? true : !(subscription.ready() && settingsSubs.ready() && alertSubscription.ready()),
|
loading: !subscription ? true : !(subscription.ready() && settingsSubs.ready() && alertSubscription.ready()),
|
||||||
userSubs: userSubs ? userSubs.value : null,
|
userSubs: userSubs ? userSubs.value : null,
|
||||||
|
|
|
||||||
|
|
@ -206,5 +206,7 @@
|
||||||
"Reintentar ahora":
|
"Reintentar ahora":
|
||||||
"Retry now",
|
"Retry now",
|
||||||
"Feedback recibido, gracias...":
|
"Feedback recibido, gracias...":
|
||||||
"Feedback received, thanks..."
|
"Feedback received, thanks...",
|
||||||
|
"Parece que este fuego no es un fuego forestal.":
|
||||||
|
"It seems that this is not a forest fire."
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -293,5 +293,7 @@
|
||||||
"Reintentar ahora":
|
"Reintentar ahora":
|
||||||
"Reintentar ahora",
|
"Reintentar ahora",
|
||||||
"Feedback recibido, gracias...":
|
"Feedback recibido, gracias...":
|
||||||
"Feedback recibido, gracias..."
|
"Feedback recibido, gracias...",
|
||||||
|
"Parece que este fuego no es un fuego forestal.":
|
||||||
|
"Parece que este fuego no es un fuego forestal."
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue