Skip to content

Commit

Permalink
Merge branch 'upstream-main' into omt_3_15_0
Browse files Browse the repository at this point in the history
  • Loading branch information
phanecak-maptiler committed Oct 30, 2023
2 parents d3434f9 + 7dbbc50 commit 124b1dc
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 42 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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 [email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<planetiler.version>0.6-SNAPSHOT</planetiler.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<planetiler.version>0.7-SNAPSHOT</planetiler.version>
<junit.version>5.10.0</junit.version>

<mainClass>org.openmaptiles.OpenMapTilesMain</mainClass>
Expand Down Expand Up @@ -99,18 +99,18 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.1.2</version>
<version>3.2.1</version>
</plugin>

<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.38.0</version>
<version>2.40.0</version>
<configuration>
<java>
<importOrder/>
Expand Down Expand Up @@ -140,7 +140,7 @@
</executions>
</plugin>

<!-- require building with jdk 17 -->
<!-- require building with jdk 21 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
Expand All @@ -154,7 +154,7 @@
<configuration>
<rules>
<requireJavaVersion>
<version>17</version>
<version>21</version>
</requireJavaVersion>
</rules>
</configuration>
Expand Down Expand Up @@ -209,7 +209,7 @@
<configuration>
<from>
<image>
eclipse-temurin:17-jre
eclipse-temurin:21-jre
</image>
<platforms>
<platform>
Expand Down
25 changes: 9 additions & 16 deletions src/main/java/org/openmaptiles/layers/TransportationName.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -111,14 +113,6 @@ public class TransportationName implements
.put(9, 8_000)
.put(10, 8_000)
.put(11, 8_000);
private static final List<String> 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;
Expand Down Expand Up @@ -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<String> 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) {
Expand Down
41 changes: 41 additions & 0 deletions src/test/java/org/openmaptiles/layers/TransportationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -405,6 +406,46 @@ void testRouteWithoutNetworkType() {
)), rendered);
}

@Test
void testSegmentWithManyRoutes() {
List<OsmRelationInfo> 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", "<null>"
)), rendered);
}

@Test
void testMinorRouteRef() {
var rel1 = new OsmElement.Relation(1);
Expand Down

0 comments on commit 124b1dc

Please sign in to comment.