Fix overlapWith-behaviour wrt points

This commit is contained in:
Pieter Vander Vennet 2021-06-20 03:07:58 +02:00
parent 18eb696c23
commit 4dda8fdcfa

View file

@ -44,17 +44,16 @@ export class GeoOperations {
const coor = feature.geometry.coordinates; const coor = feature.geometry.coordinates;
for (const otherFeature of otherFeatures) { for (const otherFeature of otherFeatures) {
if(feature.id === otherFeature.id){
continue;
}
if (otherFeature.geometry === undefined) { if (otherFeature.geometry === undefined) {
console.error("No geometry for feature ", feature) console.error("No geometry for feature ", feature)
throw "List of other features contains a feature without geometry an undefined" throw "List of other features contains a feature without geometry an undefined"
} }
let otherFeatureBBox = BBox.get(otherFeature); if (GeoOperations.inside(coor, otherFeature)) {
if (!featureBBox.overlapsWith(otherFeatureBBox)) {
continue;
}
if (this.inside(coor, otherFeature)) {
result.push({feat: otherFeature, overlap: undefined}) result.push({feat: otherFeature, overlap: undefined})
} }
} }
@ -64,6 +63,11 @@ export class GeoOperations {
if (feature.geometry.type === "LineString") { if (feature.geometry.type === "LineString") {
for (const otherFeature of otherFeatures) { for (const otherFeature of otherFeatures) {
if(feature.id === otherFeature.id){
continue;
}
const otherFeatureBBox = BBox.get(otherFeature); const otherFeatureBBox = BBox.get(otherFeature);
const overlaps = featureBBox.overlapsWith(otherFeatureBBox) const overlaps = featureBBox.overlapsWith(otherFeatureBBox)
if (!overlaps) { if (!overlaps) {
@ -121,6 +125,18 @@ export class GeoOperations {
if (feature.geometry.type === "Polygon" || feature.geometry.type === "MultiPolygon") { if (feature.geometry.type === "Polygon" || feature.geometry.type === "MultiPolygon") {
for (const otherFeature of otherFeatures) { for (const otherFeature of otherFeatures) {
if(feature.id === otherFeature.id){
continue;
}
if(otherFeature.geometry.type === "Point"){
if (this.inside(otherFeature, feature)) {
result.push({feat: otherFeature, overlap: undefined})
}
continue;
}
const otherFeatureBBox = BBox.get(otherFeature); const otherFeatureBBox = BBox.get(otherFeature);
const overlaps = featureBBox.overlapsWith(otherFeatureBBox) const overlaps = featureBBox.overlapsWith(otherFeatureBBox)
if (!overlaps) { if (!overlaps) {
@ -155,6 +171,10 @@ export class GeoOperations {
return false; return false;
} }
if(pointCoordinate.geometry !== undefined){
pointCoordinate = pointCoordinate.geometry.coordinates
}
if (feature.geometry.type === "MultiPolygon") { if (feature.geometry.type === "MultiPolygon") {
const coordinates = feature.geometry.coordinates[0]; const coordinates = feature.geometry.coordinates[0];
const outerPolygon = coordinates[0]; const outerPolygon = coordinates[0];