Skip to content

Commit

Permalink
add validator for bbox if no polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
egrojMonroy committed May 6, 2024
1 parent c65c1ce commit 0076676
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/Http/Controllers/V2/Sites/SitePolygonDataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ public function getBboxOfCompleteSite($site)
try {
$sitePolygons = SitePolygon::where('site_id', $site)->get();
$polygonsIds = $sitePolygons->pluck('poly_id');

if ($polygonsIds->isEmpty()) {
return response()->json(['error' => 'No polygon IDs found for the site'], 404);
}
$bboxCoordinates = GeometryHelper::getPolygonsBbox($polygonsIds);

return response()->json(['bbox' => $bboxCoordinates]);
} catch (\Exception $e) {
Log::error($e->getMessage());

return response()->json(['error' => 'An error occurred while fetching the bounding box coordinates'], 404);
}
}

};

0 comments on commit 0076676

Please sign in to comment.