Skip to content

Commit

Permalink
add error checks for missing crs in the vector module
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepearson committed Sep 3, 2024
1 parent 4ad75dd commit 21eea31
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/geoapis/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,21 @@ def __init__(
def _set_up(self):
"""Ensure the bouding_polygon and CRS are in agreement."""

error_message = "Either the crs or the bounding_polygon with a CRS mus be specified."
if self.crs is None and self.bounding_polygon is None:
logging.error(error_message)
raise ValueError(error_message)

# Set the crs from the bounding_polygon if it's not been set
if self.crs is None and self.bounding_polygon is not None:
self.crs = self.bounding_polygon.crs.to_epsg()
# Set the bounding_polygon crs from the crs if they differ
if self.bounding_polygon is not None:
if self.crs is None and self.bounding_polygon.crs is not None:
self.crs = self.bounding_polygon.crs.to_epsg()
elif self.crs is not None and self.bounding_polygon.crs is None:
self.bounding_polygon.set_crs(self.crs, inplace=True)
elif self.crs is None and self.bounding_polygon.crs is None:
logging.error(error_message)
raise ValueError(error_message)
# Convert the bounding_polygon crs from the crs if they differ
if (
self.bounding_polygon is not None
and self.crs != self.bounding_polygon.crs.to_epsg()
Expand Down

0 comments on commit 21eea31

Please sign in to comment.