Skip to content

Commit

Permalink
fix: Depending on the version of dependant libraries, we need to set …
Browse files Browse the repository at this point in the history
…the SRID as it's not always set
  • Loading branch information
rsavoye committed Oct 28, 2023
1 parent d7caf53 commit d951730
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions osm_rawdata/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
from pathlib import Path
from cpuinfo import get_cpu_info
from shapely.geometry import shape
# from geoalchemy2 import shape
import geoalchemy2
import shapely

from pandas import DataFrame
import pyarrow.parquet as pq
Expand Down Expand Up @@ -177,13 +180,15 @@ def parquetThread(
continue
tags = overture.parse(feature)
geom = feature['geometry']
hex = wkb.loads(geom, hex=True)
gdata = geoalchemy2.shape.from_shape(hex, srid=4326, extended=True)
geom_type = wkb.loads(geom).geom_type
scalar = select(cast(tags['properties'], JSONB))
sql = None
if geom_type == 'Polygon':
sql = insert(ways).values(
# osm_id = entry['osm_id'],
geom=geom,
geom=bytes(gdata.data),
tags=scalar,
)
# elif geom_type == 'MultiPolygon':
Expand All @@ -196,13 +201,13 @@ def parquetThread(
elif geom_type == 'Point':
sql = insert(nodes).values(
# osm_id = entry['osm_id'],
geom=geom,
geom=bytes(gdata.data),
tags=scalar,
)
elif geom_type == 'LineString':
sql = insert(lines).values(
# osm_id = entry['osm_id'],
geom=geom,
geom=bytes(gdata.data),
tags=scalar,
)
else:
Expand Down Expand Up @@ -274,7 +279,6 @@ def importOSM(
Args:
infile (str): The file to import
Returns:
(bool): Whether the import finished sucessfully
"""
Expand Down

0 comments on commit d951730

Please sign in to comment.