Improve OSM search
This commit is contained in:
parent
7c075227d7
commit
5a42e100c7
4 changed files with 329 additions and 58 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue