diff --git a/mapmaker/flatmap/__init__.py b/mapmaker/flatmap/__init__.py index e5decea0..39db7f74 100644 --- a/mapmaker/flatmap/__init__.py +++ b/mapmaker/flatmap/__init__.py @@ -263,6 +263,11 @@ def duplicate_feature_id(self, feature_ids: str) -> bool: #======================================================== return self.__features_with_id.get(feature_ids, None) is not None + def remove_feature_id(self, feature_id: str): + #============================================= + # Free up an id so another feature can be registered with it + self.__features_with_id.pop(feature_id, None) + def feature_to_geojson_ids(self, feature_ids: list[str]) -> list[int]: #===================================================================== return [f.geojson_id for id in feature_ids diff --git a/mapmaker/properties/pathways.py b/mapmaker/properties/pathways.py index ad624f7c..6384cc8b 100644 --- a/mapmaker/properties/pathways.py +++ b/mapmaker/properties/pathways.py @@ -944,7 +944,9 @@ def __route_network_connectivity(self, network: Network): # Add a polygon feature for a nerve cuff properties = feature.properties.copy() feature.properties.pop('models', None) # Otherwise we can get two markers on the feature - properties.pop('id', None) # Otherwise we will have a duplicate id... + if (feature_id := feature.properties.pop('id', None)) is not None: + # The polygon, not the dashed outline, should own the feature id + self.__flatmap.remove_feature_id(feature_id) nerve_polygon_feature = self.__flatmap.new_feature( 'pathways', shapely.geometry.Polygon(feature.geometry.coords).buffer(0), properties)