Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.filter(feature => {
try {
return (
// Technically, we're doing more than an overlap comparison here.
// `boooleanOverlap` returns features which are strictly overlapping; we
// also want to return features which are entirely contained by the
// buffer.
booleanOverlap(bufferFeature, feature) ||
booleanContains(bufferFeature, feature)
);
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
Mixpanel.track("Error", {
message:
"unable to perform booleanOverlap and booleanContains on features",
error: e,
});
return false;
}
})
.reduce(
let doesBufferContainExtent = false;
if (buffer) {
const bufferGeometry = turf.bboxPolygon([
buffer.minLon,
buffer.minLat,
buffer.maxLon,
buffer.maxLat
]);
const extentGeometry = turf.bboxPolygon([
extent.minLon,
extent.minLat,
extent.maxLon,
extent.maxLat
]);
doesBufferContainExtent = turfBooleanContains(bufferGeometry, extentGeometry);
}
if (!doesBufferContainExtent || currentZoom !== newZoom) {
const scaleFactor = 0.5; // TODO put scale factor in store and fetch with selector
const width = extent.maxLon - extent.minLon;
const height = extent.maxLat - extent.minLat;
dataFilters.buffer = {
minLon: extent.minLon - width * scaleFactor,
minLat: extent.minLat - height * scaleFactor,
maxLon: extent.maxLon + width * scaleFactor,
maxLat: extent.maxLat + height * scaleFactor
};
}
}
dispatch({
let doesBufferContainExtent = false;
if (buffer) {
const bufferGeometry = turf.bboxPolygon([
buffer.minLon,
buffer.minLat,
buffer.maxLon,
buffer.maxLat
]);
const extentGeometry = turf.bboxPolygon([
extent.minLon,
extent.minLat,
extent.maxLon,
extent.maxLat
]);
doesBufferContainExtent = turfBooleanContains(bufferGeometry, extentGeometry);
}
if (!doesBufferContainExtent || currentZoom !== newZoom) {
const scaleFactor = 0.5; // TODO put scale factor in store and fetch with selector
const width = extent.maxLon - extent.minLon;
const height = extent.maxLat - extent.minLat;
dataFilters.buffer = {
minLon: extent.minLon - width * scaleFactor,
minLat: extent.minLat - height * scaleFactor,
maxLon: extent.maxLon + width * scaleFactor,
maxLat: extent.maxLat + height * scaleFactor
};
}
}
dispatch({
let doesBufferContainExtent = false;
if (buffer) {
const bufferGeometry = turf.bboxPolygon([
buffer.minLon,
buffer.minLat,
buffer.maxLon,
buffer.maxLat
]);
const extentGeometry = turf.bboxPolygon([
extent.minLon,
extent.minLat,
extent.maxLon,
extent.maxLat
]);
doesBufferContainExtent = turfBooleanContains(bufferGeometry, extentGeometry);
}
if (!doesBufferContainExtent || currentZoom !== newZoom) {
const scaleFactor = 0.5; // TODO put scale factor in store and fetch with selector
const width = extent.maxLon - extent.minLon;
const height = extent.maxLat - extent.minLat;
dataFilters.buffer = {
minLon: extent.minLon - width * scaleFactor,
minLat: extent.minLat - height * scaleFactor,
maxLon: extent.maxLon + width * scaleFactor,
maxLat: extent.maxLat + height * scaleFactor
};
}
}
dispatch({
return NO_SOURCE_UPDATE_REQUIRED;
}
const previousBufferGeometry = turf.bboxPolygon([
previousBuffer.minLon,
previousBuffer.minLat,
previousBuffer.maxLon,
previousBuffer.maxLat
]);
const newBufferGeometry = turf.bboxPolygon([
newBuffer.minLon,
newBuffer.minLat,
newBuffer.maxLon,
newBuffer.maxLat
]);
const doesPreviousBufferContainNewBuffer = turfBooleanContains(previousBufferGeometry, newBufferGeometry);
const isTrimmed = _.get(meta, 'areResultsTrimmed', false);
return doesPreviousBufferContainNewBuffer && !isTrimmed
? NO_SOURCE_UPDATE_REQUIRED
: SOURCE_UPDATE_REQUIRED;
}
return NO_SOURCE_UPDATE_REQUIRED;
}
const previousBufferGeometry = turf.bboxPolygon([
previousBuffer.minLon,
previousBuffer.minLat,
previousBuffer.maxLon,
previousBuffer.maxLat
]);
const newBufferGeometry = turf.bboxPolygon([
newBuffer.minLon,
newBuffer.minLat,
newBuffer.maxLon,
newBuffer.maxLat
]);
const doesPreviousBufferContainNewBuffer = turfBooleanContains(previousBufferGeometry, newBufferGeometry);
const isTrimmed = _.get(prevMeta, 'areResultsTrimmed', false);
return doesPreviousBufferContainNewBuffer && !isTrimmed
? NO_SOURCE_UPDATE_REQUIRED
: SOURCE_UPDATE_REQUIRED;
}
return (fieldPolygon: any) => contains(fieldPolygon, queryPolygon);
}
return NO_SOURCE_UPDATE_REQUIRED;
}
const previousBufferGeometry = turf.bboxPolygon([
previousBuffer.minLon,
previousBuffer.minLat,
previousBuffer.maxLon,
previousBuffer.maxLat
]);
const newBufferGeometry = turf.bboxPolygon([
newBuffer.minLon,
newBuffer.minLat,
newBuffer.maxLon,
newBuffer.maxLat
]);
const doesPreviousBufferContainNewBuffer = turfBooleanContains(previousBufferGeometry, newBufferGeometry);
const isTrimmed = _.get(prevMeta, 'areResultsTrimmed', false);
return doesPreviousBufferContainNewBuffer && !isTrimmed
? NO_SOURCE_UPDATE_REQUIRED
: SOURCE_UPDATE_REQUIRED;
}
const dim = this.D[d];
if (dim.lookup === null) {
continue;
}
const bbox = tbbox(geometry);
const bboxs = dim.lookup.search({
minX: bbox[0],
minY: bbox[1],
maxX: bbox[2],
maxY: bbox[3]
});
for (let i = 0, len = bboxs.length; i < len; i++) {
const geom = dim.list[bboxs[i].id];
if (!tcontains(geom, geometry)) {
continue;
}
func(geom, count);
count++;
if (options.limit > 0 && options.limit === count) {
return count;
}
}
}
return count;
}
isBboxCompatible: (extent1, extent2) => overlap(extent1, extent2) || contains(extent1, extent2) || contains(extent2, extent1)