Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getBoundaryRectangleFilter(clean, do_geometric_filters_apply) {
// check to see if boundary.rect.min_lat/min_lon/max_lat/max_lon are all available
if (do_geometric_filters_apply && ['min_lat', 'min_lon', 'max_lat', 'max_lon'].every((f) => {
return _.has(clean, `boundary.rect.${f}`);
})) {
const polygon = [
{ latitude: clean['boundary.rect.min_lat'], longitude: clean['boundary.rect.min_lon'] },
{ latitude: clean['boundary.rect.max_lat'], longitude: clean['boundary.rect.min_lon'] },
{ latitude: clean['boundary.rect.max_lat'], longitude: clean['boundary.rect.max_lon'] },
{ latitude: clean['boundary.rect.min_lat'], longitude: clean['boundary.rect.max_lon'] }
];
// isPointInPolygon takes polygon last, so create a function that has it pre-populated
const isPointInsidePolygon = _.partialRight(geolib.isPointInPolygon, polygon);
return _.partial(isInsideGeometry, isPointInsidePolygon);
}
// there's no bbox filter, so return a function that always returns true
return () => true;
}