diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9df74c73..1904de23 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -17,10 +17,10 @@ jobs: steps: - name: Checkout this PR planetiler-openmaptiles repo uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: 'temurin' cache: 'maven' - name: Ensure code formatted with mvn spotless:apply @@ -33,12 +33,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - jdk: [ 17 ] - include: - - os: ubuntu-latest - jdk: 18 - - os: ubuntu-latest - jdk: 19 + jdk: [ 21 ] runs-on: ${{ matrix.os }} timeout-minutes: 15 steps: @@ -66,10 +61,10 @@ jobs: steps: - name: Checkout this PR planetiler-openmaptiles repo uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: 'temurin' cache: 'maven' - run: ./scripts/regenerate-openmaptiles.sh @@ -88,7 +83,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: 'temurin' cache: 'maven' - name: Build this branch @@ -127,7 +122,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: 'temurin' cache: 'maven' - name: Build and test this branch diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index ca9bcc7a..eb6d8b37 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -23,7 +23,7 @@ jobs: continue-on-error: true steps: - name: 'Cancel previous runs' - uses: styfle/cancel-workflow-action@0.11.0 + uses: styfle/cancel-workflow-action@0.12.0 with: access_token: ${{ github.token }} @@ -45,10 +45,10 @@ jobs: - name: 'Set up JDK' uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: 'temurin' cache: 'maven' - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: '14' - run: npm install -g strip-ansi-cli@3.0.2 diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 227d8e1d..4fe12506 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -14,7 +14,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: 'temurin' cache: 'maven' - name: Login to Docker Hub diff --git a/README.md b/README.md index 6f383863..90ae11ff 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Using pre-built docker image: docker run -v "$(pwd)/data":/data openmaptiles/planetiler-openmaptiles:latest --force --download --area=monaco ``` -Or to build from source, after [installing Java 17+](https://adoptium.net/installation.html): +Or to build from source, after [installing Java 21+](https://adoptium.net/installation.html): ```bash # Build the project (use mvnw.cmd on windows): diff --git a/pom.xml b/pom.xml index b6e6f104..122b41e6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,9 +7,9 @@ UTF-8 - 17 - 17 - 0.6-SNAPSHOT + 21 + 21 + 0.7-SNAPSHOT 5.10.0 org.openmaptiles.OpenMapTilesMain @@ -99,18 +99,18 @@ org.apache.maven.plugins maven-surefire-plugin - 3.1.2 + 3.2.1 org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 + 3.2.1 com.diffplug.spotless spotless-maven-plugin - 2.38.0 + 2.40.0 @@ -140,7 +140,7 @@ - + org.apache.maven.plugins maven-enforcer-plugin @@ -154,7 +154,7 @@ - 17 + 21 @@ -209,7 +209,7 @@ - eclipse-temurin:17-jre + eclipse-temurin:21-jre diff --git a/src/main/java/org/openmaptiles/layers/TransportationName.java b/src/main/java/org/openmaptiles/layers/TransportationName.java index 25d19f8c..9ee452e6 100644 --- a/src/main/java/org/openmaptiles/layers/TransportationName.java +++ b/src/main/java/org/openmaptiles/layers/TransportationName.java @@ -57,8 +57,10 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE import com.onthegomap.planetiler.util.ZoomFunction; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.Function; import org.openmaptiles.OpenMapTilesProfile; import org.openmaptiles.generated.OpenMapTilesSchema; @@ -111,14 +113,6 @@ public class TransportationName implements .put(9, 8_000) .put(10, 8_000) .put(11, 8_000); - private static final List CONCURRENT_ROUTE_KEYS = List.of( - Fields.ROUTE_1, - Fields.ROUTE_2, - Fields.ROUTE_3, - Fields.ROUTE_4, - Fields.ROUTE_5, - Fields.ROUTE_6 - ); private final boolean brunnel; private final boolean sizeForShield; private final boolean limitMerge; @@ -273,14 +267,13 @@ public void process(Tables.OsmHighwayLinestring element, FeatureCollector featur .setSortKey(element.zOrder()) .setMinZoom(minzoom); - // populate route_1, route_2, ... tags; take only unique ones - Object[] routes = relations.stream() - .map(r -> r.network() == null ? null : r.network() + "=" + coalesce(r.ref(), "")) - .distinct() - .limit(CONCURRENT_ROUTE_KEYS.size()) - .toArray(); - for (int i = 0; i < routes.length; i++) { - feature.setAttr(CONCURRENT_ROUTE_KEYS.get(i), routes[i]); + // populate route_1, route_2, ... route_n tags and remove duplicates + Set routes = new HashSet<>(); + for (var route : relations) { + String routeString = route.network() + "=" + coalesce(route.ref(), ""); + if (routes.add(routeString)) { + feature.setAttr("route_" + routes.size(), routeString); + } } if (brunnel) { diff --git a/src/test/java/org/openmaptiles/layers/TransportationTest.java b/src/test/java/org/openmaptiles/layers/TransportationTest.java index 2b66e0e1..7ae1db23 100644 --- a/src/test/java/org/openmaptiles/layers/TransportationTest.java +++ b/src/test/java/org/openmaptiles/layers/TransportationTest.java @@ -12,6 +12,7 @@ import com.onthegomap.planetiler.reader.SimpleFeature; import com.onthegomap.planetiler.reader.SourceFeature; import com.onthegomap.planetiler.reader.osm.OsmElement; +import com.onthegomap.planetiler.reader.osm.OsmRelationInfo; import com.onthegomap.planetiler.stats.Stats; import java.util.ArrayList; import java.util.List; @@ -405,6 +406,46 @@ void testRouteWithoutNetworkType() { )), rendered); } + @Test + void testSegmentWithManyRoutes() { + List relations = new ArrayList<>(); + for (int route = 1; route <= 16; route++) { + int num = (route + 1) / 2; // to make dups + var rel = new OsmElement.Relation(route); + rel.setTag("type", "route"); + rel.setTag("route", "road"); + rel.setTag("network", "US:I"); + rel.setTag("ref", Integer.toString(num)); + rel.setTag("name", "Route " + num); + relations.addAll(profile.preprocessOsmRelation(rel)); + } + + FeatureCollector rendered = process(lineFeatureWithRelation( + relations, + Map.of( + "highway", "motorway", + "name", "New Jersey Turnpike", + "ref", "I 95;NJTP" + ))); + + assertFeatures(13, List.of(mapOf( + "_layer", "transportation", + "class", "motorway", + "_minzoom", 4 + ), mapOf( + "_layer", "transportation_name", + "route_1", "US:I=1", + "route_2", "US:I=2", + "route_3", "US:I=3", + "route_4", "US:I=4", + "route_5", "US:I=5", + "route_6", "US:I=6", + "route_7", "US:I=7", + "route_8", "US:I=8", + "route_9", "" + )), rendered); + } + @Test void testMinorRouteRef() { var rel1 = new OsmElement.Relation(1);