kopia lustrzana https://github.com/onthegomap/planetiler
Treat boundary and land_area relation types as multipolygons (#50)
rodzic
f7a129168d
commit
bf99918198
|
@ -20,7 +20,7 @@ jobs:
|
|||
- os: ubuntu-latest
|
||||
jdk: 16
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 5
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK ${{ matrix.jdk }}
|
||||
|
@ -39,8 +39,8 @@ jobs:
|
|||
|
||||
regenerate:
|
||||
name: Regenerate
|
||||
runs-on: macos-latest
|
||||
timeout-minutes: 5
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 17
|
||||
|
@ -56,7 +56,7 @@ jobs:
|
|||
examples:
|
||||
name: Example project
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
timeout-minutes: 15
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -81,7 +81,7 @@ jobs:
|
|||
run:
|
||||
name: Build / Run
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Cache data/sources
|
||||
|
|
|
@ -183,7 +183,7 @@ public class OsmReader implements Closeable, MemoryEstimator.HasEstimate {
|
|||
}
|
||||
}
|
||||
// TODO allow limiting multipolygon storage to only ones that profile cares about
|
||||
if (rel.hasTag("type", "multipolygon")) {
|
||||
if (isMultipolygon(rel)) {
|
||||
for (ReaderRelation.Member member : rel.getMembers()) {
|
||||
if (member.getType() == ReaderRelation.Member.WAY) {
|
||||
waysInMultipolygon.add(member.getRef());
|
||||
|
@ -193,6 +193,10 @@ public class OsmReader implements Closeable, MemoryEstimator.HasEstimate {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean isMultipolygon(ReaderRelation relation) {
|
||||
return relation.hasTag("type", "multipolygon", "boundary", "land_area");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs geometries from OSM elements and emits map features as defined by the {@link Profile}.
|
||||
*
|
||||
|
@ -328,7 +332,7 @@ public class OsmReader implements Closeable, MemoryEstimator.HasEstimate {
|
|||
SourceFeature processRelationPass2(ReaderRelation rel, NodeLocationProvider nodeLocations) {
|
||||
// Relation info gets used during way processing, except multipolygons which we have to process after we've
|
||||
// stored all the node IDs for each way.
|
||||
if (rel.hasTag("type", "multipolygon")) {
|
||||
if (isMultipolygon(rel)) {
|
||||
List<RelationMember<OsmRelationInfo>> parentRelations = getRelationMembershipForWay(rel.getId());
|
||||
return new MultipolygonSourceFeature(rel, nodeLocations, parentRelations);
|
||||
} else {
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.locationtech.jts.geom.MultiPolygon;
|
||||
|
@ -900,8 +901,9 @@ public class PlanetilerTests {
|
|||
)), sortListValues(results.tiles));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOsmMultipolygon() throws Exception {
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"multipolygon", "boundary", "land_area"})
|
||||
public void testOsmMultipolygon(String relationType) throws Exception {
|
||||
record TestRelationInfo(long id, String name) implements OsmRelationInfo {}
|
||||
var results = runWithOsmElements(
|
||||
Map.of("threads", "1"),
|
||||
|
@ -927,7 +929,7 @@ public class PlanetilerTests {
|
|||
with(new ReaderWay(16), way -> way.getNodes().add(9, 10, 11, 12, 13)),
|
||||
|
||||
with(new ReaderRelation(17), rel -> {
|
||||
rel.setTag("type", "multipolygon");
|
||||
rel.setTag("type", relationType);
|
||||
rel.setTag("attr", "value");
|
||||
rel.setTag("should_emit", "yes");
|
||||
rel.add(new ReaderRelation.Member(ReaderRelation.Member.WAY, 14, "outer"));
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.Map;
|
|||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
public class OsmReaderTest {
|
||||
|
||||
|
@ -354,8 +356,9 @@ public class OsmReaderTest {
|
|||
private final Function<ReaderElement, Stream<ReaderWay>> ways = elem ->
|
||||
elem instanceof ReaderWay way ? Stream.of(way) : Stream.empty();
|
||||
|
||||
@Test
|
||||
public void testMultiPolygon() throws GeometryException {
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"multipolygon", "boundary", "land_area"})
|
||||
public void testMultiPolygon(String relationType) throws GeometryException {
|
||||
OsmReader reader = newOsmReader();
|
||||
var outerway = new ReaderWay(9);
|
||||
outerway.getNodes().add(1, 2, 3, 4, 1);
|
||||
|
@ -363,7 +366,7 @@ public class OsmReaderTest {
|
|||
innerway.getNodes().add(5, 6, 7, 8, 5);
|
||||
|
||||
var relation = new ReaderRelation(11);
|
||||
relation.setTag("type", "multipolygon");
|
||||
relation.setTag("type", relationType);
|
||||
relation.add(new ReaderRelation.Member(ReaderRelation.WAY, outerway.getId(), "outer"));
|
||||
relation.add(new ReaderRelation.Member(ReaderRelation.WAY, innerway.getId(), "inner"));
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue