Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
drawBorderedPolygon(rectangle) {
if (!rectangle) {
// handles case where model changes to empty vars and we don't want to draw anymore
return
}
const lineWidth =
DistanceUtils.getDistanceInMeters(
this.model.get('lineWidth'),
this.model.get('lineUnits')
) || 1
const turfLine = Turf.lineString(
translateFromOpenlayersCoordinates(rectangle.getCoordinates())
)
const bufferedLine = Turf.buffer(turfLine, lineWidth, 'meters')
const geometryRepresentation = new ol.geom.MultiLineString(
translateToOpenlayersCoordinates(bufferedLine.geometry.coordinates)
)
if (this.vectorLayer) {
this.map.removeLayer(this.vectorLayer)
}
this.billboard = new ol.Feature({
geometry: geometryRepresentation,
})
this.billboard.setId(this.model.cid)
if (!stats.tripVolumes.bins.hour[timeBins.hour][bin]) {
stats.tripVolumes.bins.hour[timeBins.hour][bin] = 0;
}
if (!stats.tripVolumes.bins.minute[timeBins.minute][bin]) {
stats.tripVolumes.bins.minute[timeBins.minute][bin] = 0;
}
// increment hex bins
stats.tripVolumes.bins.day[timeBins.day][bin]++;
stats.tripVolumes.bins.hour[timeBins.hour][bin]++;
stats.tripVolumes.bins.minute[timeBins.minute][bin]++;
});
// sharedstreets aggregation
var refs = new Set();
var line = turf.lineString(
trip.route.features.map(pt => {
return pt.geometry.coordinates;
})
);
match = trip.matches.streets;
if (
match &&
match.segments &&
match.matchedPath &&
match.matchedPath.geometry &&
match.matchedPath.geometry.coordinates &&
match.matchedPath.geometry.coordinates.length === match.segments.length
) {
match.segments
) {
return false;
}
const lineProperties = LINE_PROPERTIES[lineName];
let nearestSegmentCoords = [
t.properties.closestLineSegment.l.geometry.coordinates[0],
t.properties.closestLineSegment.l.geometry.coordinates[1]
];
// TODO: Don't do a reverse reverse when the trip direction is 2 and invertGeometry is 2. XOR this.
if (TRIP_DIRECTION === '2') {
nearestSegmentCoords = nearestSegmentCoords.reverse();
}
if (lineProperties['invertGeometry']) {
nearestSegmentCoords = nearestSegmentCoords.reverse();
}
const offsetLine = lineString(
offsetLatLngs(nearestSegmentCoords, zoom)
);
const nearestOnLine = nearestPointOnLine(
offsetLine,
point([Lon, Lat])
);
return (
) {
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 }
);
stats.geometry.pairs[pair.properties.pair] = pair;
var timeBins = getTimeBins(reportDay, trip.start_time);
// populate time bins
if (!stats.flows.pairs.day[timeBins.day]) {
stats.flows.pairs.day[timeBins.day] = {};
}
if (!stats.flows.pairs.hour[timeBins.hour]) {
// on stocke la géométrie d'origine dans .way_geometry
feature.properties.way_geometry = JSON.parse(JSON.stringify(feature.geometry));
let geom;
switch (feature.geometry.type) {
case 'Polygon':
feature.properties['mesure'] = area(feature.geometry)
geom = polygon(feature.geometry.coordinates);
break;
case 'MultiPolygon':
feature.properties['mesure'] = area(feature.geometry)
geom = multiPolygon(feature.geometry.coordinates);
break;
case 'LineString':
feature.properties['mesure'] = length(feature.geometry)
geom = lineString(feature.geometry.coordinates);
break;
case 'MultiLineString':
feature.properties['mesure'] = length(feature.geometry)
geom = multiLineString(feature.geometry.coordinates);
break;
}
if (geom) {
feature.geometry.coordinates = pointOnSurface(geom).geometry.coordinates;
feature.geometry.type = 'Point';
}
}
}
}
return FeatureCollection;
}
it('parse,parseOption,rocess_Measurement.along,', (done) => {
opt_options = {
attributions: " ",
features: " ",
format: "",
logo: "",
projection: "",
wrapX: "",
};
var openLayerturf = new Turf(opt_options);
expect(turf).not.toBeNull();;
var type = "Measurement.along";
var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);
var options = { units: 'miles' };
var args = {
line: line,
distance: 10,
units: "kilometers"
};
var addFeaturesToMap = false;
openLayerturf.process(type, args, (result) => {
serviceResult = result
}, addFeaturesToMap);
expect(serviceResult).not.toBeNull();
expect(serviceResult.geometry).not.toBeNull();
done();
});
function matchesLINESTRING(value, filter) {
let pointText = filter.value.substring(11)
pointText = pointText.substring(0, pointText.length - 1)
const lineWidth = filter.distance || 0
if (lineWidth <= 0) {
return false
}
const line = pointText
.split(',')
.map(coordinate => coordinate.split(' ').map(value => Number(value)))
const turfLine = Turf.lineString(line)
const bufferedLine = Turf.buffer(turfLine, lineWidth, 'meters')
const polygonToCheck = new Terraformer.Polygon({
type: 'Polygon',
coordinates: bufferedLine.geometry.coordinates,
})
if (intersects(polygonToCheck, value)) {
return true
}
return false
}