-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix (createNewProject): uploadArea - validation added to upload file,… (
#987) * fix (createNewProject): uploadArea - validation added to upload file, where error shown if projection is not WGS84 * feat (utilityFunction): checkWGS84Projection - function that checks if uploaded file is in WGS84 projection * fix (createNewProject): uploadArea - checking WGS84 projection function seperated to utilsFunction, code refactor
- Loading branch information
Showing
2 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function checkWGS84Projection(geojson) { | ||
try { | ||
for (const feature of geojson.features) { | ||
const coordinates = feature.geometry.coordinates; | ||
for (const coord of coordinates[0]) { | ||
const [longitude, latitude] = coord; | ||
if ( | ||
isNaN(latitude) || | ||
isNaN(longitude) || | ||
latitude < -90 || | ||
latitude > 90 || | ||
longitude < -180 || | ||
longitude > 180 | ||
) { | ||
// setIsGeojsonWG84(false); | ||
return false; // Coordinates are out of WGS 84 range | ||
} | ||
} | ||
} | ||
// setIsGeojsonWG84(true); | ||
return true; // All coordinates are within WGS 84 range | ||
} catch (error) { | ||
// setIsGeojsonWG84(false); | ||
return false; | ||
} | ||
} | ||
|
||
export { checkWGS84Projection }; |