Fix marshaling of shapefile geometry to GeoJSON

This commit is contained in:
XANTRONIX Industrial 2025-02-17 23:01:33 -05:00
parent cc3e058d2e
commit c9889388a3

View file

@ -4,20 +4,14 @@ import json
import shapely
import shapefile
from nexrad.db import DatabaseTable
from nexrad.db import DatabaseTable
from nexrad.coord import COORD_SYSTEM
def parse_timestamp(timestamp: str):
return datetime.datetime.strptime(timestamp, '%Y%m%d%H%M%S').astimezone(datetime.UTC)
def shape_to_geojson(shape: shapefile.Shape):
ret = json.dumps({
'type': 'Polygon',
'coordinates': shape.points
})
print(f"Got a kitty: {ret}")
return ret
return json.dumps(shape.__geo_interface__)
class VTECType(enum.StrEnum):
OPERATIONAL = 'O'
@ -46,7 +40,7 @@ class VTEC(DatabaseTable):
}
__columns_write__ = {
'poly': 'GeomFromGeoJSON(:poly)'
'poly': 'SetSRID(GeomFromGeoJSON(:poly), {crs})'.format(crs=COORD_SYSTEM)
}
__values_write__ = {