def is_same_geometry(data, data_other):
"""
Check if LineString geometries in two edge data dicts are the same, in
normal or reversed order of points.
Parameters
----------
data : dict
the first edge's data
data_other : dict
the second edge's data
Returns
-------
bool
"""
# extract geometries from each edge data dict
geom1 = [list(coords) for coords in data['geometry'].xy]
geom2 = [list(coords) for coords in data_other['geometry'].xy]
# reverse the first edge's list of x's and y's to look for a match in
# either order
geom1_r = [list(reversed(list(coords))) for coords in data['geometry'].xy]
# if the edge's geometry matches its reverse's geometry in either order,
# return True
return (geom1 == geom2 or geom1_r == geom2)
评论列表
文章目录