Improvement in Subs and FireMap Union

This commit is contained in:
vjrj 2017-12-19 20:02:14 +01:00
parent 497724443f
commit 1742cd4913
19 changed files with 390 additions and 299 deletions

View file

@ -42,7 +42,8 @@ Subscriptions.schema = new SimpleSchema({
'location.lat': Number,
'location.lon': Number,
distance: Number,
owner: String
owner: String,
type: String
});
Subscriptions.attachSchema(Subscriptions.schema);

View file

@ -9,9 +9,10 @@ Meteor.methods({
location: Match.ObjectIncluding({ lat: Number, lon: Number }),
distance: Number
});
const type = 'web';
try {
return Subscriptions.insert({ owner: this.userId, ...doc });
return Subscriptions.insert({ owner: this.userId, type, ...doc });
} catch (exception) {
throw new Meteor.Error('500', exception);
}

View file

@ -18,21 +18,24 @@ Meteor.publishTransformed('userSubsToFires', function transform() {
const location = doc.location;
/* doc.lat = location.lat;
* doc.lon = location.lon; */
let lat;
let lon;
if (location) {
doc.lat = Math.round(location.lat * 10) / 10;
doc.lon = Math.round(location.lon * 10) / 10;
lat = Math.round(location.lat * 10) / 10;
lon = Math.round(location.lon * 10) / 10;
// console.log(`[${lat}, ${lon}]`);
const noiseBase = Perlin.perlin2(lat, lon);
const noise = Math.abs(noiseBase / 3);
// console.log(`Noise ${noise}, abs: ${Math.abs(noise)}`);
lat += noise;
lon += noise;
doc.location.lat = lat;
doc.location.lon = lon;
doc.distance += noiseBase;
}
// console.log(`[${doc.lat}, ${doc.lon}]`);
const noiseBase = Perlin.perlin2(doc.lat, doc.lon);
const noise = Math.abs(noiseBase / 3);
// console.log(`Noise ${noise}, abs: ${Math.abs(noise)}`);
doc.lat += noise;
doc.lon += noise;
doc.distance += noiseBase;
// console.log(`with noise: [${doc.lat}, ${doc.lon}]`);
delete doc.chatId;
delete doc.geo;
delete doc.location;
return doc;
});
});