Skip to content

Commit

Permalink
[TM-1591] add threshold for overlapping intersects (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
egrojMonroy authored Dec 26, 2024
1 parent f938d49 commit b7fc5aa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/Validators/Extensions/Polygons/NotOverlapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b7fc5aa

Please sign in to comment.