Skip to content

Commit

Permalink
Merge pull request #277 from wri/fix/TM-851-convert-get-to-post-valid…
Browse files Browse the repository at this point in the history
…ation

[TM-851] convert to post request for polygon validation
  • Loading branch information
cesarLima1 authored Jun 11, 2024
2 parents fb5ee37 + 3b0e3b8 commit a048319
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ public function updateProjectCentroid($polygonGeometry)
} else {
Log::warning("Centroid data for project UUID: $project->uuid is malformed.");
}
Log::info("Updated project centroid for project UUID: $project->uuid with lat: {$centroid['lat']}, lng: {$centroid['lng']}");
if (is_array($centroid) && isset($centroid['lat']) && isset($centroid['lng'])) {
Log::info("Updated project centroid for project UUID: $project->uuid with lat: {$centroid['lat']}, lng: {$centroid['lng']}");
} else {
Log::error('Centroid is not properly defined. Centroid data: ' . print_r($centroid, true));
}

} else {
Log::warning("Project with UUID $relatedSite->project_id not found.");
}
Expand Down
1 change: 0 additions & 1 deletion app/Services/PolygonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public function createCriteriaSite($polygonId, $criteriaId, $valid): bool|string
$criteriaSite->polygon_id = $polygonId;
$criteriaSite->criteria_id = $criteriaId;
$criteriaSite->valid = $valid;
$criteriaSite->created_by = Auth::user()?->id;

try {
$criteriaSite->save();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
summary: Get validation results for a polygon
summary: Run validation for a polygon
parameters:
- in: query
name: uuid
Expand Down
4 changes: 2 additions & 2 deletions openapi-src/V2/paths/_index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2515,13 +2515,13 @@
get:
$ref: './Exports/get-v2-entity-export-uuid.yml'
'/v2/terrafund/validation/polygon':
get:
post:
$ref: './Terrafund/get-v2-terrafund-validation-polygon.yml'
'/v2/terrafund/validation/criteria-data':
get:
$ref: './Terrafund/get-v2-terrafund-validation-criteria-data.yml'
'/v2/terrafund/validation/sitePolygons':
get:
post:
$ref: './Terrafund/get-v2-terrafund-validation-sitepolygons.yml'
'/v2/terrafund/validation/site':
get:
Expand Down
6 changes: 3 additions & 3 deletions resources/docs/swagger-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94312,8 +94312,8 @@ paths:
schema:
type: file
/v2/terrafund/validation/polygon:
get:
summary: Get validation results for a polygon
post:
summary: Run validation for a polygon
parameters:
- in: query
name: uuid
Expand Down Expand Up @@ -94380,7 +94380,7 @@ paths:
type: integer
description: 'Indicates if the criteria is valid or not (1 for valid, 0 for invalid)'
/v2/terrafund/validation/sitePolygons:
get:
post:
summary: Run validation for all polygons in a site
parameters:
- in: query
Expand Down
4 changes: 2 additions & 2 deletions routes/api_v2.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@
Route::get('/validation/overlapping', [TerrafundCreateGeometryController::class, 'validateOverlapping']);
Route::get('/validation/estimated-area', [TerrafundCreateGeometryController::class, 'validateEstimatedArea']);
Route::get('/validation/table-data', [TerrafundCreateGeometryController::class, 'validateDataInDB']);
Route::get('/validation/polygon', [TerrafundCreateGeometryController::class, 'getValidationPolygon']);
Route::get('/validation/sitePolygons', [TerrafundCreateGeometryController::class, 'getSiteValidationPolygon']);
Route::post('/validation/polygon', [TerrafundCreateGeometryController::class, 'getValidationPolygon']);
Route::post('/validation/sitePolygons', [TerrafundCreateGeometryController::class, 'getSiteValidationPolygon']);
Route::get('/validation/site', [TerrafundCreateGeometryController::class, 'getCurrentSiteValidation']);

Route::get('/polygon/{uuid}', [TerrafundEditGeometryController::class, 'getSitePolygonData']);
Expand Down

0 comments on commit a048319

Please sign in to comment.