This commit is contained in:
Edward Betts 2023-11-02 10:13:12 +00:00
commit a09fcb6dd5

View file

@ -123,7 +123,7 @@ def make_envelope_around_point(
) )
s = select( s = select(
[ *[
sqlalchemy.func.ST_AsText( sqlalchemy.func.ST_AsText(
sqlalchemy.func.ST_Project(p, distance, sqlalchemy.func.radians(deg)) sqlalchemy.func.ST_Project(p, distance, sqlalchemy.func.radians(deg))
) )
@ -158,11 +158,9 @@ def get_part_of(
s = ( s = (
select( select(
[
polygon.c.osm_id, polygon.c.osm_id,
polygon.c.tags, polygon.c.tags,
sqlalchemy.func.ST_Area(sqlalchemy.func.ST_Collect(polygon.c.way)), sqlalchemy.func.ST_Area(sqlalchemy.func.ST_Collect(polygon.c.way)),
]
) )
.where( .where(
and_( and_(
@ -753,7 +751,6 @@ def find_osm_candidates(item, limit=80, max_distance=450, names=None):
s_point = ( s_point = (
select( select(
[
sqlalchemy.sql.expression.literal("point").label("t"), sqlalchemy.sql.expression.literal("point").label("t"),
point.c.osm_id, point.c.osm_id,
point.c.tags.label("tags"), point.c.tags.label("tags"),
@ -765,7 +762,6 @@ def find_osm_candidates(item, limit=80, max_distance=450, names=None):
sqlalchemy.func.ST_AsText(point.c.way), sqlalchemy.func.ST_AsText(point.c.way),
sqlalchemy.func.ST_AsGeoJSON(point.c.way), sqlalchemy.func.ST_AsGeoJSON(point.c.way),
null_area, null_area,
]
) )
.where( .where(
and_( and_(
@ -784,7 +780,6 @@ def find_osm_candidates(item, limit=80, max_distance=450, names=None):
s_line = ( s_line = (
select( select(
[
sqlalchemy.sql.expression.literal("line").label("t"), sqlalchemy.sql.expression.literal("line").label("t"),
line.c.osm_id, line.c.osm_id,
line.c.tags.label("tags"), line.c.tags.label("tags"),
@ -798,7 +793,6 @@ def find_osm_candidates(item, limit=80, max_distance=450, names=None):
), ),
sqlalchemy.func.ST_AsGeoJSON(sqlalchemy.func.ST_Collect(line.c.way)), sqlalchemy.func.ST_AsGeoJSON(sqlalchemy.func.ST_Collect(line.c.way)),
null_area, null_area,
]
) )
.where( .where(
and_( and_(
@ -817,7 +811,6 @@ def find_osm_candidates(item, limit=80, max_distance=450, names=None):
s_polygon = ( s_polygon = (
select( select(
[
sqlalchemy.sql.expression.literal("polygon").label("t"), sqlalchemy.sql.expression.literal("polygon").label("t"),
polygon.c.osm_id, polygon.c.osm_id,
polygon.c.tags.label("tags"), polygon.c.tags.label("tags"),
@ -827,13 +820,10 @@ def find_osm_candidates(item, limit=80, max_distance=450, names=None):
) )
).label("dist"), ).label("dist"),
sqlalchemy.func.ST_AsText( sqlalchemy.func.ST_AsText(
sqlalchemy.func.ST_Centroid( sqlalchemy.func.ST_Centroid(sqlalchemy.func.ST_Collect(polygon.c.way))
sqlalchemy.func.ST_Collect(polygon.c.way)
)
), ),
sqlalchemy.func.ST_AsGeoJSON(sqlalchemy.func.ST_Collect(polygon.c.way)), sqlalchemy.func.ST_AsGeoJSON(sqlalchemy.func.ST_Collect(polygon.c.way)),
sqlalchemy.func.ST_Area(sqlalchemy.func.ST_Collect(polygon.c.way)), sqlalchemy.func.ST_Area(sqlalchemy.func.ST_Collect(polygon.c.way)),
]
) )
.where( .where(
and_( and_(
@ -856,7 +846,7 @@ def find_osm_candidates(item, limit=80, max_distance=450, names=None):
tables = ([] if item_is_linear_feature else [s_point]) + [s_line, s_polygon] tables = ([] if item_is_linear_feature else [s_point]) + [s_line, s_polygon]
s = ( s = (
select([sqlalchemy.sql.expression.union(*tables).alias()]) select(sqlalchemy.sql.expression.union(*tables).alias())
.where(dist < max_distance) .where(dist < max_distance)
.order_by(dist) .order_by(dist)
) )