diff --git a/osm_rawdata/postgres.py b/osm_rawdata/postgres.py index 412d416..fb11e65 100755 --- a/osm_rawdata/postgres.py +++ b/osm_rawdata/postgres.py @@ -662,7 +662,7 @@ def createDB(self, dburi: uriParser): def execQuery( self, - boundary: Union[FeatureCollection, Feature, dict], + boundary: Union[FeatureCollection, Feature, dict, str], customsql: str = None, allgeom: bool = True, extra_params: dict = {}, @@ -671,7 +671,7 @@ def execQuery( database, or a remote one that uses the Underpass schema. Args: - boundary (FeatureCollection, Feature, dict): The boundary polygon. + boundary (FeatureCollection, Feature, dict, str): The boundary polygon. customsql (str): Don't create the SQL, use the one supplied. allgeom (bool): Whether to return centroids or all the full geometry. @@ -680,6 +680,10 @@ def execQuery( """ log.info("Parsing AOI geojson for data extract") + # Parse JSON string type + if isinstance(boundary, str): + boundary = json.loads(boundary) + if (geom_type := boundary.get("type")) == "FeatureCollection": # Convert each feature into a Shapely geometry geometries = [shape(feature.get("geometry")) for feature in boundary.get("features", [])]