Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getMinMaxGeometry(value, field) {
// ex: ["polygon((...))] would use a lib to determine the bounding box and set min max latitude from that.
if (typeof value !== 'undefined') {
let geo = wkt2geojson(value);
let bbox = turf.bbox(geo);
return {
min: bbox[1],
max: bbox[3]
};
} else {
let constantField = changeCase.constantCase(field);
return {
min: facetConfig.fields[constantField].range.min,
max: facetConfig.fields[constantField].range.max
};
}
}
.then(results => {
if (!results.hits.hits.length) {
return results.hits.hits;
}
const points = results.hits.hits.map(doc =>
turf.point(doc._source.coordinates)
);
if (lat && lng && !bounds) {
points.push(turf.point([lng, lat]));
}
// create a bounding box for the results
const envelope = turf.bbox(
turf.buffer(turf.envelope(turf.featureCollection(points)), 0.5, {
units: "miles"
})
);
bounds = {
southwest: {
lat: envelope[1],
lng: envelope[0]
},
northeast: {
lat: envelope[3],
lng: envelope[2]
}
};
function objBbox(obj, id) {
var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
var bbox = {};
var valBbox = turf.bbox(obj);
for (var d = 0; d < valBbox.length; d++) {
bbox[bboxExtent[d]] = valBbox[d];
}
bbox.id = id || obj.properties['@id'];
return bbox;
}
function objBbox(obj, id) {
var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
var bbox = {};
var valBbox = turf.bbox(obj);
for (var d = 0; d < valBbox.length; d++) {
bbox[id || bboxExtent[d]] = valBbox[d];
}
bbox.id = obj.properties['@id'];
return bbox;
}
function objBbox(obj, id) {
var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
var bbox = {};
var valBbox = turf.bbox(obj);
for (var d = 0; d < valBbox.length; d++) {
bbox[bboxExtent[d]] = valBbox[d];
}
bbox.id = id || obj.properties['@id'];
return bbox;
}
function objBbox(obj, id) {
var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
var bbox = {};
var valBbox = turf.bbox(obj);
for (var d = 0; d < valBbox.length; d++) {
bbox[bboxExtent[d]] = valBbox[d];
}
bbox.id = id || obj.properties['@id'];
return bbox;
}
function objBbox(obj, id) {
var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
var bbox = {};
var valBbox = turf.bbox(obj);
for (var d = 0; d < valBbox.length; d++) {
bbox[bboxExtent[d]] = valBbox[d];
}
bbox.id = id || obj.properties['@id'];
return bbox;
}
function objBbox(feature, id) {
var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
var bbox = {};
var valBbox = turf.bbox(feature);
for (var d = 0; d < valBbox.length; d++) {
bbox[bboxExtent[d]] = valBbox[d];
}
bbox.id = id || feature.properties['@id'];
return bbox;
}
function objBbox(obj, id) {
var bboxExtent = ['minX', 'minY', 'maxX', 'maxY'];
var bbox = {};
var valBbox = turf.bbox(obj);
for (var d = 0; d < valBbox.length; d++) {
bbox[id || bboxExtent[d]] = valBbox[d];
}
bbox.id = obj.properties['@id'];
return bbox;
}