Skip to content

Instantly share code, notes, and snippets.

@roganov
Created March 15, 2018 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roganov/92492aedc2846d6b962b9e1d4ad2554c to your computer and use it in GitHub Desktop.
Save roganov/92492aedc2846d6b962b9e1d4ad2554c to your computer and use it in GitHub Desktop.
ShapelyGeography: integrate shapely and geoalchemy2
class ShapelyGeography(Geography):
def result_processor(self, dialect, coltype):
super_process = super().result_processor(dialect, coltype)
def process(value):
value = super_process(value)
if value is not None:
return to_shape(value)
return process
def bind_processor(self, dialect):
super_process = super().bind_processor(dialect)
def process(bindvalue):
if isinstance(bindvalue, BaseGeometry):
bindvalue = bindvalue.wkt
return super_process(bindvalue)
return process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment