-
Notifications
You must be signed in to change notification settings - Fork 6
/
Overture.java
60 lines (54 loc) · 2.08 KB
/
Overture.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import java.nio.file.Path;
import com.onthegomap.planetiler.ForwardingProfile;
import com.onthegomap.planetiler.Planetiler;
import com.onthegomap.planetiler.config.Arguments;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.util.Glob;
import overturelayers.Building;
import overturelayers.Transportation;
import overturelayers.Water;
/**
* A more complex profile that generates vector tiles from Overture Maps data
* (https://overturemaps.org/) where logic is broken-out into separate files in
* overturelayers subdirectory.
*
* To run:
* - download a subset of overture data for a bounding box:
* https://docs.overturemaps.org/getting-data/
* - Run java -cp planetiler.jar Overture.java
* - Open data/overture.pmtiles in https://pmtiles.io/
*/
public class Overture extends ForwardingProfile {
Overture(PlanetilerConfig config) {
super(config);
registerHandler(new Water(config));
registerHandler(new Transportation(config));
registerHandler(new Building());
}
@Override
public boolean isOverlay() {
return true;
}
public static void main(String[] args) {
var arguments = Arguments.fromArgsOrConfigFile(args);
Path base = arguments.inputFile("base", "overture base directory", Path.of("data", "overture"));
Planetiler.create(arguments)
.setProfile(pt -> new Overture(pt.config()))
.addParquetSource("overture",
Glob.of(base).resolve("**", "*.parquet").find(),
true, // hive-partitioning
fields -> fields.get("id"), // hash the ID field to generate unique long IDs
fields -> fields.get("type")) // extract "type={}" from the filename to get layer
.overwriteOutput(Path.of("data", "overture.pmtiles"))
.run();
}
@Override
public String attribution() {
return """
<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap</a>
<a href="https://docs.overturemaps.org/attribution" target="_blank">© Overture Maps Foundation</a>
"""
.replace("\n", " ")
.trim();
}
}