Skip to content

Commit 60d00d1

Browse files
authored
Merge pull request #446 from mapswipe/fix-duplicated-feature-ids
Fix duplicated feature ids
2 parents 808a5e9 + ddc345a commit 60d00d1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mapswipe_workers/mapswipe_workers/project_types/arbitrary_geometry/grouping_functions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def group_input_geometries(input_geometries_file, group_size):
5555
feature_count = 0
5656
for feature in layer:
5757
feature_count += 1
58+
# feature count starts at 1
59+
# assuming group size would be 10
60+
# when feature_count = 11 then we enter the next group
5861
if feature_count % (group_size + 1) == 0:
5962
group_id += 1
6063
group_id_string = f"g{group_id}"
@@ -70,7 +73,9 @@ def group_input_geometries(input_geometries_file, group_size):
7073
"screen": [],
7174
}
7275

73-
groups[group_id_string]["feature_ids"].append(feature.GetFID())
76+
# we use a new id here based on the count
77+
# since we are not sure that GetFID returns unique values
78+
groups[group_id_string]["feature_ids"].append(feature_count)
7479
groups[group_id_string]["feature_geometries"].append(
7580
json.loads(feature.GetGeometryRef().ExportToJson())
7681
)

0 commit comments

Comments
 (0)