Porównaj commity

...

5 Commity

Autor SHA1 Wiadomość Data
Michael Barry ebd4343b7e
Merge 7c86699a04 into da9d03c85d 2024-03-30 17:05:18 -07:00
dependabot[bot] da9d03c85d
Bump geotools.version from 30.1 to 31.0 (#856) 2024-03-29 05:04:50 -04:00
dependabot[bot] 1871e230ac
Bump org.sonarsource.scanner.maven:sonar-maven-plugin (#855) 2024-03-28 05:16:13 -04:00
Mike Barry 7c86699a04 undo 2024-03-04 05:13:54 -05:00
Mike Barry b38b8b37a1 encode node/way/relation in vector tile feature id 2024-03-03 20:40:17 -05:00
5 zmienionych plików z 44 dodań i 17 usunięć

Wyświetl plik

@ -16,7 +16,7 @@
</parent>
<properties>
<geotools.version>30.1</geotools.version>
<geotools.version>31.0</geotools.version>
<log4j.version>2.23.1</log4j.version>
<prometheus.version>0.16.0</prometheus.version>
<protobuf.version>3.25.3</protobuf.version>

Wyświetl plik

@ -6,6 +6,8 @@ import com.onthegomap.planetiler.geo.GeoUtils;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.geo.GeometryType;
import com.onthegomap.planetiler.reader.SourceFeature;
import com.onthegomap.planetiler.reader.osm.OsmElement;
import com.onthegomap.planetiler.reader.osm.OsmSourceFeature;
import com.onthegomap.planetiler.render.FeatureRenderer;
import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.util.CacheByZoom;
@ -59,7 +61,7 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
* @return a feature that can be configured further.
*/
public Feature geometry(String layer, Geometry geometry) {
Feature feature = new Feature(layer, geometry, source.id());
Feature feature = new Feature(layer, geometry, source);
output.add(feature);
return feature;
}
@ -81,7 +83,7 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
return geometry(layer, source.worldGeometry());
} catch (GeometryException e) {
e.log(stats, "feature_point", "Error getting point geometry for " + source.id());
return new Feature(layer, EMPTY_GEOM, source.id());
return new Feature(layer, EMPTY_GEOM, source);
}
}
@ -101,7 +103,7 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
return geometry(layer, source.line());
} catch (GeometryException e) {
e.log(stats, "feature_line", "Error constructing line for " + source.id());
return new Feature(layer, EMPTY_GEOM, source.id());
return new Feature(layer, EMPTY_GEOM, source);
}
}
@ -121,7 +123,7 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
return geometry(layer, source.polygon());
} catch (GeometryException e) {
e.log(stats, "feature_polygon", "Error constructing polygon for " + source.id());
return new Feature(layer, EMPTY_GEOM, source.id());
return new Feature(layer, EMPTY_GEOM, source);
}
}
@ -136,7 +138,7 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
return geometry(layer, source.centroid());
} catch (GeometryException e) {
e.log(stats, "feature_centroid", "Error getting centroid for " + source.id());
return new Feature(layer, EMPTY_GEOM, source.id());
return new Feature(layer, EMPTY_GEOM, source);
}
}
@ -153,7 +155,7 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
return geometry(layer, source.centroidIfConvex());
} catch (GeometryException e) {
e.log(stats, "feature_centroid_if_convex", "Error constructing centroid if convex for " + source.id());
return new Feature(layer, EMPTY_GEOM, source.id());
return new Feature(layer, EMPTY_GEOM, source);
}
}
@ -169,7 +171,7 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
return geometry(layer, source.pointOnSurface());
} catch (GeometryException e) {
e.log(stats, "feature_point_on_surface", "Error constructing point on surface for " + source.id());
return new Feature(layer, EMPTY_GEOM, source.id());
return new Feature(layer, EMPTY_GEOM, source);
}
}
@ -191,7 +193,7 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
return geometry(layer, source.innermostPoint(tolerance));
} catch (GeometryException e) {
e.log(stats, "feature_innermost_point", "Error constructing innermost point for " + source.id());
return new Feature(layer, EMPTY_GEOM, source.id());
return new Feature(layer, EMPTY_GEOM, source);
}
}
@ -275,11 +277,21 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
private String numPointsAttr = null;
private Feature(String layer, Geometry geom, long id) {
private Feature(String layer, Geometry geom, SourceFeature source) {
this.layer = layer;
this.geom = geom;
this.geometryType = GeometryType.typeOf(geom);
this.id = id;
if (source instanceof OsmSourceFeature osmSourceFeature) {
long osmId = osmSourceFeature.originalElement().id();
this.id = switch (osmSourceFeature.originalElement()) {
case OsmElement.Node node -> node.id() * 10 + 1;
case OsmElement.Way way -> way.id() * 10 + 2;
case OsmElement.Relation relation -> relation.id() * 10 + 3;
default -> osmId * 10;
};
} else {
this.id = source.id();
}
if (geometryType == GeometryType.POINT) {
minPixelSizeAtMaxZoom = 0;
defaultMinPixelSize = 0;

Wyświetl plik

@ -875,7 +875,7 @@ class PlanetilerTests {
feature(newPoint(128, 128), Map.of(
"attr", "value",
"name", "name value"
))
)).withId(11)
)
), results.tiles);
}
@ -964,7 +964,7 @@ class PlanetilerTests {
feature(newLineString(128, 128, 192, 192), Map.of(
"attr", "value",
"name", "name value"
))
)).withId(32)
)
), results.tiles);
}
@ -1089,7 +1089,7 @@ class PlanetilerTests {
"attr", "value",
"name", "name value",
"relname", "rel name"
))
)).withId(173)
)
), results.tiles);
}

Wyświetl plik

@ -279,7 +279,9 @@ public class TestUtils {
case UNKNOWN -> throw new IllegalArgumentException("cannot decompress \"UNKNOWN\"");
};
var decoded = VectorTile.decode(bytes).stream()
.map(feature -> feature(decodeSilently(feature.geometry()), feature.layer(), feature.attrs())).toList();
.map(
feature -> feature(decodeSilently(feature.geometry()), feature.layer(), feature.attrs()).withId(feature.id()))
.toList();
tiles.put(tile.coord(), decoded);
}
return tiles;
@ -467,12 +469,21 @@ public class TestUtils {
public record ComparableFeature(
GeometryComparision geometry,
String layer,
Map<String, Object> attrs
Map<String, Object> attrs,
Long id
) {
ComparableFeature(
GeometryComparision geometry,
String layer,
Map<String, Object> attrs
) {
this(geometry, layer, attrs, null);
}
@Override
public boolean equals(Object o) {
return o == this || (o instanceof ComparableFeature other &&
(id == null || other.id == null || id.equals(other.id)) &&
geometry.equals(other.geometry) &&
attrs.equals(other.attrs) &&
(layer == null || other.layer == null || Objects.equals(layer, other.layer)));
@ -484,6 +495,10 @@ public class TestUtils {
result = 31 * result + attrs.hashCode();
return result;
}
ComparableFeature withId(long id) {
return new ComparableFeature(geometry, layer, attrs, id);
}
}
public static ComparableFeature feature(Geometry geom, String layer, Map<String, Object> attrs) {

Wyświetl plik

@ -328,7 +328,7 @@
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.10.0.2594</version>
<version>3.11.0.3922</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>