Fix marshaling of shapefile geometry to GeoJSON
This commit is contained in:
parent
cc3e058d2e
commit
c9889388a3
1 changed files with 4 additions and 10 deletions
|
@ -4,20 +4,14 @@ import json
|
||||||
import shapely
|
import shapely
|
||||||
import shapefile
|
import shapefile
|
||||||
|
|
||||||
from nexrad.db import DatabaseTable
|
from nexrad.db import DatabaseTable
|
||||||
|
from nexrad.coord import COORD_SYSTEM
|
||||||
|
|
||||||
def parse_timestamp(timestamp: str):
|
def parse_timestamp(timestamp: str):
|
||||||
return datetime.datetime.strptime(timestamp, '%Y%m%d%H%M%S').astimezone(datetime.UTC)
|
return datetime.datetime.strptime(timestamp, '%Y%m%d%H%M%S').astimezone(datetime.UTC)
|
||||||
|
|
||||||
def shape_to_geojson(shape: shapefile.Shape):
|
def shape_to_geojson(shape: shapefile.Shape):
|
||||||
ret = json.dumps({
|
return json.dumps(shape.__geo_interface__)
|
||||||
'type': 'Polygon',
|
|
||||||
'coordinates': shape.points
|
|
||||||
})
|
|
||||||
|
|
||||||
print(f"Got a kitty: {ret}")
|
|
||||||
|
|
||||||
return ret
|
|
||||||
|
|
||||||
class VTECType(enum.StrEnum):
|
class VTECType(enum.StrEnum):
|
||||||
OPERATIONAL = 'O'
|
OPERATIONAL = 'O'
|
||||||
|
@ -46,7 +40,7 @@ class VTEC(DatabaseTable):
|
||||||
}
|
}
|
||||||
|
|
||||||
__columns_write__ = {
|
__columns_write__ = {
|
||||||
'poly': 'GeomFromGeoJSON(:poly)'
|
'poly': 'SetSRID(GeomFromGeoJSON(:poly), {crs})'.format(crs=COORD_SYSTEM)
|
||||||
}
|
}
|
||||||
|
|
||||||
__values_write__ = {
|
__values_write__ = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue