From b7fc5aa92561f6f02a9b485ff3edf9c93585918c Mon Sep 17 00:00:00 2001 From: Jorge Monroy Date: Thu, 26 Dec 2024 12:38:18 -0400 Subject: [PATCH] [TM-1591] add threshold for overlapping intersects (#634) --- app/Validators/Extensions/Polygons/NotOverlapping.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Validators/Extensions/Polygons/NotOverlapping.php b/app/Validators/Extensions/Polygons/NotOverlapping.php index de9862bc..29b360a1 100644 --- a/app/Validators/Extensions/Polygons/NotOverlapping.php +++ b/app/Validators/Extensions/Polygons/NotOverlapping.php @@ -52,14 +52,15 @@ public static function getIntersectionData(string $polygonUuid): array $mainPolygonArea = PolygonGeometry::where('uuid', $polygonUuid) ->value(DB::raw('ST_Area(geom)')); - $extra_info = $intersects - ->filter(fn ($intersect) => $intersect->intersects) - ->map(function ($intersect) use ($mainPolygonArea) { + ->filter(function ($intersect) { + return $intersect->intersects && $intersect->intersection_area > 1e-10; + }) + ->map(function ($intersect) use ($mainPolygonArea, $sitePolygon) { $minArea = min($mainPolygonArea, $intersect->area); $percentage = $minArea > 0 - ? round(($intersect->intersection_area / $minArea) * 100, 2) - : 100; + ? round(($intersect->intersection_area / $minArea) * 100, 2) + : 100; return [ 'poly_uuid' => $intersect->uuid,