Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[trip.route.features[0]].forEach(ping => {
var bin = h3.geoToH3(
ping.geometry.coordinates[1],
ping.geometry.coordinates[0],
Z
);
bins.add(bin);
});
// store bin geometry
states[vehicle_id].forEach(state => {
if (
state.event_type === "available" ||
state.event_type === "unavailable"
) {
var timestamp = moment(state.event_time, "X");
if (timestamp.diff(current) <= 0) {
lastAvailable = state;
}
}
});
if (lastAvailable) {
// onstreet hex bins
var bin = h3.geoToH3(
lastAvailable.event_location.geometry.coordinates[1],
lastAvailable.event_location.geometry.coordinates[0],
Z
);
// store geo
var geo = turf.polygon([h3.h3ToGeoBoundary(bin, true)], {
bin: bin
});
stats.geometry.bins[bin] = geo;
// bootstrap bin
if (!stats.onstreet.bins.minute[current.format(baseDay + "-HH-mm")]) {
stats.onstreet.bins.minute[current.format(baseDay + "-HH-mm")] = {};
}
if (
function flows(startDay, endDay, reportDay, stats, trips, privacyMinimum) {
for (let trip of trips) {
// check for time range
if (
trip.start_time >= startDay.format("X") &&
trip.start_time <= endDay.format("X")
) {
var a = h3.geoToH3(
trip.route.features[0].geometry.coordinates[1],
trip.route.features[0].geometry.coordinates[0],
Z
);
var b = h3.geoToH3(
trip.route.features[trip.route.features.length - 1].geometry
.coordinates[1],
trip.route.features[trip.route.features.length - 1].geometry
.coordinates[0],
Z
);
// store pair geometry
var pair = turf.lineString(
[
turf.centroid(turf.polygon([h3.h3ToGeoBoundary(a, true)])).geometry
.coordinates,
turf.centroid(turf.polygon([h3.h3ToGeoBoundary(b, true)])).geometry
.coordinates
],
{ pair: a + ">" + b }
trip.route.features.forEach(ping => {
var bin = h3.geoToH3(
ping.geometry.coordinates[1],
ping.geometry.coordinates[0],
Z
);
h3s.add(bin);
});
export function getCenterHex({latitude, longitude}, resolution) {
return geoToH3(latitude, longitude, resolution);
}
Metrics.prototype.dropoffs = function(trip, times, provider, done) {
var bin = h3.geoToH3(
trip.route.features[trip.route.features.length - 1].geometry.coordinates[1],
trip.route.features[trip.route.features.length - 1].geometry.coordinates[0],
Z
);
var qtime = queue(1);
times.forEach(time => {
qtime.defer(timecb => {
var id = provider + "!dropoffs!" + time + "!" + bin;
this.store.get(id, (err, record) => {
if (!record) record = 1;
else record++;
this.store.put(id, record, err => {
if (err) throw err;
trip.route.features.forEach(ping => {
var bin = h3.geoToH3(
ping.geometry.coordinates[1],
ping.geometry.coordinates[0],
config.Z
);
bins[bin] = 1;
});
function pointToH3(point:Feature):string {
var lnglat = getCoord(point);
return h3.geoToH3( lnglat[1], lnglat[0], BASE_H3_INDEX_LEVEL);
}
Metrics.prototype.dropoffsvia = function(trip, times, provider, done) {
var binA = h3.geoToH3(
trip.route.features[0].geometry.coordinates[1],
trip.route.features[0].geometry.coordinates[0],
Z
);
var binB = h3.geoToH3(
trip.route.features[trip.route.features.length - 1].geometry.coordinates[1],
trip.route.features[trip.route.features.length - 1].geometry.coordinates[0],
Z
);
var qtime = queue(1);
times.forEach(time => {
qtime.defer(timecb => {
var id = provider + "!dropoffsvia!" + time + "!" + binA + "!" + binB;
this.store.get(id, (err, record) => {
const boundaries = this._circleMap.data().map(row => {
const h3Idx = geoToH3(row[0], row[1], res);
return [h3Idx, h3ToGeoBoundary(h3Idx, false).map(point => [point[1], point[0]]), 1];
});
this._hexMap.data(boundaries);