diff --git a/migrations/versions/1.0.6_add_postgis_extension.py b/migrations/versions/1.0.6_add_postgis_extension.py new file mode 100644 index 0000000..d68d9ea --- /dev/null +++ b/migrations/versions/1.0.6_add_postgis_extension.py @@ -0,0 +1,21 @@ +"""Add postgis extension + +Revision ID: 1.0.6 +Revises: +Create Date: 2024-10-01 14:00 + +""" + +from alembic import op +from sqlalchemy import BigInteger, Column, String + +revision = "1.0.6" +down_revision = "1.0.5" +branch_labels = "add_postgis_extension" +depends_on = "1.0.5" + +def upgrade(): + op.execute('create extension postgis') + +def downgrade(): + op.execute('drop extension postgis') \ No newline at end of file diff --git a/src/ump/api/job.py b/src/ump/api/job.py index 57843ea..56e2e2c 100644 --- a/src/ump/api/job.py +++ b/src/ump/api/job.py @@ -246,9 +246,12 @@ def set_results_metadata(self, results_as_json): ) for column in results_df.select_dtypes(include=[object]).to_dict(): - values.append( - {column: {"type": "string", "values": list(set(results_df[column]))}} - ) + try: + values.append( + {column: {"type": "string", "values": list(set(results_df[column]))}} + ) + except Exception as e: + logging.error(f"Unable to store column {column}, skipping: {e}") self.results_metadata = {"values": values} @@ -320,6 +323,8 @@ async def results_to_geoserver(self): try: results = await self.results() + while 'results' in results: + results = results['results'] geoserver = Geoserver() self.set_results_metadata(results) @@ -332,7 +337,7 @@ async def results_to_geoserver(self): except Exception as e: logging.error( - f" --> Could not store results for job {self.process_id_with_prefix} (={self.process_id})/{self.job_id} to geoserver: {e}" + f" --> Could not store results for job {self.process_id_with_prefix} (={self.process_id})/{self.job_id} to geoserver: {e}", e ) def __str__(self): diff --git a/src/ump/geoserver/geoserver.py b/src/ump/geoserver/geoserver.py index b6cd53c..798e51c 100644 --- a/src/ump/geoserver/geoserver.py +++ b/src/ump/geoserver/geoserver.py @@ -140,7 +140,7 @@ def geojson_to_postgis(self, table_name: str, data: dict): engine = create_engine( f"postgresql://{config.postgres_user}:{config.postgres_password}@{config.postgres_host}/{config.postgres_db}" ) - gdf = gpd.GeoDataFrame.from_features(data["features"]) + gdf = gpd.GeoDataFrame.from_features(data["features"], crs = 'EPSG:4326') table = Identifier(table_name) gdf.to_postgis(name=table.string, con=engine)