diff --git a/lib/nexrad/vtec.py b/lib/nexrad/vtec.py index 2a8790e..93d8dfe 100644 --- a/lib/nexrad/vtec.py +++ b/lib/nexrad/vtec.py @@ -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__ = {