planetiler-openmaptiles icon indicating copy to clipboard operation
planetiler-openmaptiles copied to clipboard

Reading water\mapping.yaml always fails on code regeneration

Open adjourn opened this issue 1 year ago • 3 comments

It's especially weird since the file actually exists when you navigate manually: https://raw.githubusercontent.com/openmaptiles/openmaptiles/v3.14/layers/water/mapping.yaml It always fails on water/mapping.yaml, tried 5+ times.

screenshot

Command: ./scripts/regenerate-openmaptiles.sh v3.14 OS: Windows 10 Java version: openjdk 17.0.8.1

adjourn avatar Sep 16 '23 17:09 adjourn

Observe following: .../v3.14/layers\water\..., e.g. the switch from slash to back-slash. Back-slash is a Windows thing and should not be used in URL. First guess, that this might be the problematic code:

https://github.com/openmaptiles/planetiler-openmaptiles/blob/main/src/main/java/org/openmaptiles/Generate.java#L155

But I'm not able to test that since I'm on Linux. Are you able to troubleshoot that yourself?

phanecak-maptiler avatar Sep 18 '23 07:09 phanecak-maptiler

Ah, how did I miss that?! What the heck, it's already my third day with Java, I'll give it a try.

adjourn avatar Sep 18 '23 09:09 adjourn

@phanecak-maptiler

Since my Java API knowledge is limited and I don't know if there's a built-in method to do this (I did try to find out), is the way of knucklehead okay? Open to suggestions.

This fixes it:

// outside the loops
Boolean backwardSlashes = File.separatorChar == '\\';

// inside the loop (this is the problematic line)
String mappingPath = Path.of(layerFile).resolveSibling(datasource.mapping_file).normalize().toString();

if (backwardSlashes) {
  mappingPath = mappingPath.replace('\\', '/');
}

adjourn avatar Sep 18 '23 10:09 adjourn