Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (distance < closestDistance) {
closest = row;
closestDistance = distance;
} else if (distance == closestDistance && closest.type != 'Point') {
closest = row;
closestDistance = distance;
}
} else if (geometry.type == 'Polygon') {
if (booleanPointInPolygon(centerPoint, geometry)) {
if (closestDistance != 0) {
closest = row;
closestDistance = 0;
}
} else {
var line = polygonToLine(geometry);
var distance = pointToLineDistance(centerPoint, line);
if (distance < closestDistance) {
closest = row;
closestDistance = distance;
}
}
}
}
closest.values.name.should.be.equal('point');
foundFeatures.should.be.deep.equal(['box1', 'box2', 'line', 'point']);
});
for (var row of iterator) {
foundFeatures.push(row);
var geometry = row.geometry;
if (geometry.type == 'Point') {
var distance = pointDistance(centerPoint, geometry);
if (distance < closestDistance) {
closest = row;
closestDistance = distance;
} else if (distance == closestDistance && closest.type != 'Point') {
closest = row;
closestDistance = distance;
}
} else if (geometry.type == 'LineString') {
var distance = pointToLineDistance(centerPoint, geometry);
if (distance < closestDistance) {
closest = row;
closestDistance = distance;
} else if (distance == closestDistance && closest.type != 'Point') {
closest = row;
closestDistance = distance;
}
} else if (geometry.type == 'Polygon') {
if (booleanPointInPolygon(centerPoint, geometry)) {
if (closestDistance != 0) {
closest = row;
closestDistance = 0;
}
} else {
var line = polygonToLine(geometry);
var distance = pointToLineDistance(centerPoint, line);
for (var row of iterator) {
foundFeatures.push(row.values.name);
var geometry = row.getGeometry().toGeoJSON();
if (geometry.type == 'Point') {
var distance = pointDistance(centerPoint, geometry);
if (distance < closestDistance) {
closest = row;
closestDistance = distance;
} else if (distance == closestDistance && closest.type != 'Point') {
closest = row;
closestDistance = distance;
}
} else if (geometry.type == 'LineString') {
var distance = pointToLineDistance(centerPoint, geometry);
if (distance < closestDistance) {
closest = row;
closestDistance = distance;
} else if (distance == closestDistance && closest.type != 'Point') {
closest = row;
closestDistance = distance;
}
} else if (geometry.type == 'Polygon') {
if (booleanPointInPolygon(centerPoint, geometry)) {
if (closestDistance != 0) {
closest = row;
closestDistance = 0;
}
} else {
var line = polygonToLine(geometry);
var distance = pointToLineDistance(centerPoint, line);