Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore duplicate multipolygon relation members #876

Merged
merged 1 commit into from
May 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
Expand Down Expand Up @@ -788,11 +790,15 @@ public MultipolygonSourceFeature(OsmElement.Relation relation, NodeLocationProvi
@Override
protected Geometry computeWorldGeometry() throws GeometryException {
List<LongArrayList> rings = new ArrayList<>(relation.members().size());
Set<Long> added = new HashSet<>();
for (OsmElement.Relation.Member member : relation.members()) {
String role = member.role();
LongArrayList poly = multipolygonWayGeometries.get(member.ref());
if (member.type() == OsmElement.Type.WAY) {
if (poly != null && !poly.isEmpty()) {
if (!added.add(member.ref())) {
// ignore duplicate relation members
stats.dataError("osm_" + relation.getTag("type") + "_duplicate_member");
} else if (poly != null && !poly.isEmpty()) {
rings.add(poly);
} else {
// boundary and land_area relations might not be complete for extracts, but multipolygons should be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ record TestRelationInfo(long id, String name) implements OsmRelationInfo {}
rel.members().add(new OsmElement.Relation.Member(OsmElement.Type.WAY, 14, "outer"));
rel.members().add(new OsmElement.Relation.Member(OsmElement.Type.WAY, 15, null)); // missing
rel.members().add(new OsmElement.Relation.Member(OsmElement.Type.WAY, 16, "inner")); // incorrect
rel.members().add(new OsmElement.Relation.Member(OsmElement.Type.WAY, 14, "outer")); // duplicate
}),
with(new OsmElement.Relation(18), rel -> {
rel.setTag("type", "relation");
Expand Down
Loading