Sketch matching data by best-intersection
This commit is contained in:
parent
37ac60f223
commit
204740e46e
@ -91,8 +91,22 @@ def save_data(cur, props, data_conf, geometry_id):
|
|||||||
def find_geom(cur, feature, epsg_code):
|
def find_geom(cur, feature, epsg_code):
|
||||||
"""Find a building geometry
|
"""Find a building geometry
|
||||||
"""
|
"""
|
||||||
|
# match on TOID
|
||||||
|
|
||||||
|
# match on best intersection
|
||||||
|
wkb_hex = shape(feature['geometry']).wkb_hex
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"""SELECT geometry_id FROM geometries
|
"""SELECT geometry_id,
|
||||||
|
ST_Area(
|
||||||
|
ST_Intersection(
|
||||||
|
ST_Transform(
|
||||||
|
ST_SetSRID(%s::geometry, %s),
|
||||||
|
3857
|
||||||
|
),
|
||||||
|
geometry_geom
|
||||||
|
)
|
||||||
|
) as intersection_area
|
||||||
|
FROM geometries
|
||||||
WHERE
|
WHERE
|
||||||
ST_Intersects(
|
ST_Intersects(
|
||||||
ST_Transform(
|
ST_Transform(
|
||||||
@ -101,16 +115,20 @@ def find_geom(cur, feature, epsg_code):
|
|||||||
),
|
),
|
||||||
geometry_geom
|
geometry_geom
|
||||||
)
|
)
|
||||||
|
ORDER BY intersection_area DESC
|
||||||
""", (
|
""", (
|
||||||
shape(feature['geometry']).wkb_hex,
|
wkb_hex,
|
||||||
|
epsg_code,
|
||||||
|
wkb_hex,
|
||||||
epsg_code
|
epsg_code
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
result = cur.fetchone()
|
results = cur.fetchall()
|
||||||
if result is not None:
|
if results:
|
||||||
return result[0]
|
# print(feature['properties']['fid'], "matched", len(results))
|
||||||
|
return results[0]
|
||||||
else:
|
else:
|
||||||
return result
|
return results
|
||||||
|
|
||||||
|
|
||||||
def update_from_props(doc, props, mapping):
|
def update_from_props(doc, props, mapping):
|
||||||
|
Loading…
Reference in New Issue
Block a user