Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions mapmaker/flatmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,15 @@ def get_feature_by_geojson_id(self, geojson_id: int) -> Optional[Feature]:
#=========================================================================
return self.__features_by_geojson_id.get(geojson_id)

def new_feature(self, layer_id: str, geometry, properties, is_group=False) -> Feature:
#=====================================================================================
def new_feature(self, layer_id: str, geometry, properties, is_group=False, update_feature_with_id=False) -> Feature:
#===================================================================================================================
self.__last_geojson_id += 1
properties['layer'] = layer_id
self.properties_store.update_properties(properties) # Update from JSON properties file
feature = Feature(self.__last_geojson_id, geometry, properties, is_group=is_group)
self.__features_by_geojson_id[feature.geojson_id] = feature
if feature.id:
if feature.id in self.__features_with_id:
pass
else:
if update_feature_with_id or feature.id not in self.__features_with_id:
self.__features_with_id[feature.id] = feature
if self.map_kind == MAP_KIND.FUNCTIONAL:
if (name := properties.get('name', '')) != '':
Expand Down
6 changes: 3 additions & 3 deletions mapmaker/flatmap/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def add_group_features(self, group_name: str, features: list[Feature],
region_properties = base_properties.copy()
for region in filter(lambda p: prepared_polygon.contains(p.geometry), regions):
region_properties.update(region.properties)
layer_features.append(self.flatmap.new_feature(self.id, polygon, region_properties))
layer_features.append(self.flatmap.new_feature(self.id, polygon, region_properties, update_feature_with_id=True))
break
else:
for feature in features:
Expand Down Expand Up @@ -442,7 +442,7 @@ def add_group_features(self, group_name: str, features: list[Feature],
feature_group = self.flatmap.new_feature(
self.id,
shapely.MultiPolygon(grouped_polygons).buffer(0),
grouped_properties, is_group=True)
grouped_properties, is_group=True, update_feature_with_id=True)
layer_features.append(feature_group)
# So that any grouped lines don't have a duplicate id
grouped_properties.pop('id', None)
Expand All @@ -459,7 +459,7 @@ def add_group_features(self, group_name: str, features: list[Feature],
feature_group = self.flatmap.new_feature(
self.id,
shapely.MultiLineString(grouped_lines),
grouped_properties, is_group=True)
grouped_properties, is_group=True, update_feature_with_id=True)
layer_features.append(feature_group)

# Feature specific properties have precedence over group's
Expand Down