Created
March 15, 2018 22:30
-
-
Save roganov/92492aedc2846d6b962b9e1d4ad2554c to your computer and use it in GitHub Desktop.
ShapelyGeography: integrate shapely and geoalchemy2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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