Skip to content

Commit

Permalink
docs/typs/comments – get_type()
Browse files Browse the repository at this point in the history
  • Loading branch information
jGaboardi committed Dec 3, 2024
1 parent 43e1da6 commit 6d70c9c
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions sgeop/simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,19 +512,39 @@ def simplify_clusters(
return new_roads


def get_type(edges, shared_edge):
if ( # roundabout special case
edges.coins_group.nunique() == 1 and edges.shape[0] == edges.coins_count.iloc[0]
def get_type(edges: gpd.GeoDataFrame, shared_edge: int) -> str:
"""Classify artifact edges according to the ``{C, E, S}``
schema when considering solutions for pairs of artifacts.
Parameters
----------
edges : geopandas.GeoDataFrame
Artifact edges in consideration.
shared_edge : int
The index location of the shared edge of the pair.
Returns
-------
str
Classification for an edge in ``{C, E, S}``.
"""

if ( # Roundabout special case
edges["coins_group"].nunique() == 1
and edges.shape[0] == edges["coins_count"].iloc[0]
):
return "S"

all_ends = edges[edges.coins_end]
mains = edges[~edges.coins_group.isin(all_ends.coins_group)]
all_ends = edges[edges["coins_end"]]
mains = edges[~edges["coins_group"].isin(all_ends["coins_group"])]
shared = edges.loc[shared_edge]

if shared_edge in mains.index:
return "C"
if shared.coins_count == (edges.coins_group == shared.coins_group).sum():

if shared["coins_count"] == (edges["coins_group"] == shared["coins_group"]).sum():
return "S"

return "E"


Expand Down

0 comments on commit 6d70c9c

Please sign in to comment.