Improve OSM search

This commit is contained in:
Edward Betts 2021-07-11 17:18:45 +02:00
parent 7c075227d7
commit 5a42e100c7
4 changed files with 329 additions and 58 deletions

View file

@ -228,7 +228,10 @@ class MapMixin:
@declared_attr
def geojson_str(cls):
return column_property(func.ST_AsGeoJSON(cls.way), deferred=True)
return column_property(
func.ST_AsGeoJSON(cls.way, maxdecimaldigits=6),
deferred=True
)
@declared_attr
def as_EWKT(cls):
@ -289,6 +292,11 @@ class Line(MapMixin, Base):
class Polygon(MapMixin, Base):
way_area = Column(Float)
@classmethod
def get_osm(cls, osm_type, osm_id):
src_id = osm_id * {'way': 1, 'relation': -1}[osm_type]
return cls.query.get(src_id)
@property
def type(self):
return "way" if self.src_id > 0 else "relation"