kopia lustrzana https://github.com/onthegomap/planetiler
Fix point equality (#1161)
rodzic
11fd6b8ed7
commit
0e161cd6bf
|
@ -340,5 +340,15 @@ public abstract class WithGeometry implements WithGeometryType {
|
|||
public boolean canBeLine() {
|
||||
return worldGeometry instanceof Lineal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj == this || (obj instanceof FromWorld other && other.worldGeometry.equals(worldGeometry));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return worldGeometry.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1561,6 +1561,35 @@ class ConfiguredFeatureTest {
|
|||
any -> assertEquals(expected, (Double) any.getAttrsAtZoom(14).get("attr"), expected / 1e3), 1);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource(value = {
|
||||
"feature.point_along_line(0) == feature.point_along_line(0); true",
|
||||
"feature.point_along_line(0) == feature.point_along_line(0); true",
|
||||
"feature.point_along_line(0) == feature.point_along_line(1); true",
|
||||
"feature.point_along_line(0) == feature.point_along_line(0.5); false",
|
||||
}, delimiter = ';')
|
||||
void testGeometryAttributesLineBoolean(String expression, boolean expected) {
|
||||
var config = """
|
||||
sources:
|
||||
osm:
|
||||
type: osm
|
||||
url: geofabrik:rhode-island
|
||||
local_path: data/rhode-island.osm.pbf
|
||||
layers:
|
||||
- id: testLayer
|
||||
features:
|
||||
- source: osm
|
||||
attributes:
|
||||
- key: attr
|
||||
value: ${%s}
|
||||
""".formatted(expression);
|
||||
var sfMatch =
|
||||
SimpleFeature.createFakeOsmFeature(newLineString(1, 2, 3, 4, 1, 2), Map.of(), "osm", "layer", 1, emptyList(),
|
||||
new OsmElement.Info(2, 3, 4, 5, "user"));
|
||||
testFeature(config, sfMatch,
|
||||
any -> assertEquals(expected, any.getAttrsAtZoom(14).get("attr")), 1);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource(value = {
|
||||
"feature.area('z0 px2'); 1.17743E-10",
|
||||
|
|
Ładowanie…
Reference in New Issue