diff --git a/planetiler-benchmarks/src/main/java/com/onthegomap/planetiler/benchmarks/OpenMapTilesMapping.java b/planetiler-benchmarks/src/main/java/com/onthegomap/planetiler/benchmarks/OpenMapTilesMapping.java index c91409d932..4c2bc81eb3 100644 --- a/planetiler-benchmarks/src/main/java/com/onthegomap/planetiler/benchmarks/OpenMapTilesMapping.java +++ b/planetiler-benchmarks/src/main/java/com/onthegomap/planetiler/benchmarks/OpenMapTilesMapping.java @@ -5,6 +5,7 @@ import com.onthegomap.planetiler.reader.SourceFeature; import com.onthegomap.planetiler.reader.osm.OsmElement; import com.onthegomap.planetiler.reader.osm.OsmInputFile; +import com.onthegomap.planetiler.reader.osm.OsmReader; import com.onthegomap.planetiler.stats.ProgressLoggers; import com.onthegomap.planetiler.stats.Stats; import com.onthegomap.planetiler.util.Translations; @@ -48,6 +49,12 @@ public Geometry worldGeometry() { return null; } + @Override + public long featureId() { + int offset = element.type().ordinal(); + return (element.id() * 10) + offset; + } + @Override public boolean isPoint() { return element instanceof OsmElement.Node; diff --git a/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/SimpleFeature.java b/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/SimpleFeature.java index 995886933f..8e531ec080 100644 --- a/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/SimpleFeature.java +++ b/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/SimpleFeature.java @@ -122,7 +122,7 @@ public OsmElement originalElement() { return new OsmElement() { @Override public long id() { - return SimpleOsmFeature.this.id(); + return id(); } @Override @@ -186,6 +186,11 @@ public Geometry worldGeometry() { (worldGeometry = GeoUtils.sortPolygonsByAreaDescending(GeoUtils.latLonToWorldCoords(latLonGeometry))); } + @Override + public long featureId() { + return id(); + } + @Override public Map tags() { return tags; diff --git a/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/SourceFeature.java b/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/SourceFeature.java index 4f32a398db..103e2d77ad 100644 --- a/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/SourceFeature.java +++ b/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/SourceFeature.java @@ -333,6 +333,9 @@ public final long id() { return id; } + /** Returns the ID for this element from the input data source (i.e. OSM element ID). */ + public abstract long featureId(); + /** Returns true if this element has any OSM relation info. */ public boolean hasRelationInfo() { diff --git a/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmElement.java b/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmElement.java index 57c5e203ba..8d2d89c9b4 100644 --- a/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmElement.java +++ b/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmElement.java @@ -27,6 +27,7 @@ public interface OsmElement extends WithTags { Type type(); enum Type { + OTHER, NODE, WAY, RELATION @@ -46,7 +47,7 @@ public int cost() { @Override public Type type() { - return null; + return Type.OTHER; } } diff --git a/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmReader.java b/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmReader.java index 72abb5e792..24333d1543 100644 --- a/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmReader.java +++ b/planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmReader.java @@ -675,6 +675,12 @@ public boolean canBePolygon() { public OsmElement originalElement() { return originalElement; } + + @Override + public long featureId() { + int offset = originalElement().type().ordinal(); + return (id() * 10) + offset; + } } /** A {@link Point} created from an OSM node. */ diff --git a/planetiler-examples/src/test/java/com/onthegomap/planetiler/examples/OsmQaTilesTest.java b/planetiler-examples/src/test/java/com/onthegomap/planetiler/examples/OsmQaTilesTest.java index 656695084c..87d73c8206 100644 --- a/planetiler-examples/src/test/java/com/onthegomap/planetiler/examples/OsmQaTilesTest.java +++ b/planetiler-examples/src/test/java/com/onthegomap/planetiler/examples/OsmQaTilesTest.java @@ -43,6 +43,12 @@ public Geometry worldGeometry() { ); } + @Override + public long featureId() { + int offset = originalElement().type().ordinal(); + return (id() * 10) + offset; + } + @Override public boolean isPoint() { return true;