|
3 | 3 | import com.onthegomap.planetiler.ForwardingProfile;
|
4 | 4 | import com.onthegomap.planetiler.Planetiler;
|
5 | 5 | import com.onthegomap.planetiler.config.Arguments;
|
| 6 | +import com.onthegomap.planetiler.util.Downloader; |
| 7 | +import com.protomaps.basemap.feature.NaturalEarthDb; |
| 8 | +import com.protomaps.basemap.feature.QrankDb; |
6 | 9 | import com.protomaps.basemap.layers.Boundaries;
|
7 | 10 | import com.protomaps.basemap.layers.Buildings;
|
8 | 11 | import com.protomaps.basemap.layers.Earth;
|
|
21 | 24 |
|
22 | 25 | public class Basemap extends ForwardingProfile {
|
23 | 26 |
|
24 |
| - public Basemap(Envelope earthWaterBounds) { |
| 27 | + public Basemap(Envelope earthWaterBounds, NaturalEarthDb naturalEarthDb, QrankDb qrankDb) { |
25 | 28 |
|
26 | 29 | var admin = new Boundaries();
|
27 | 30 | registerHandler(admin);
|
@@ -49,12 +52,12 @@ public Basemap(Envelope earthWaterBounds) {
|
49 | 52 | registerSourceHandler("osm", physicalPoint);
|
50 | 53 | registerSourceHandler("ne", physicalPoint::processNe);
|
51 | 54 |
|
52 |
| - var place = new Places(); |
| 55 | + var place = new Places(naturalEarthDb); |
53 | 56 | registerHandler(place);
|
54 | 57 | registerSourceHandler("osm", place);
|
55 | 58 | registerSourceHandler("ne", place::processNe);
|
56 | 59 |
|
57 |
| - var poi = new Pois(); |
| 60 | + var poi = new Pois(qrankDb); |
58 | 61 | registerHandler(poi);
|
59 | 62 | registerSourceHandler("osm", poi);
|
60 | 63 |
|
@@ -116,20 +119,29 @@ static void run(Arguments args) throws Exception {
|
116 | 119 | // and a complete high-zoom tileset without having to tile earth/water outside the bbox.
|
117 | 120 | Envelope earthWaterBounds = args.bounds("osm-earth-water-bounds", "spatial bbox of osm earth+water");
|
118 | 121 |
|
| 122 | + Path nePath = sourcesDir.resolve("natural_earth_vector.sqlite.zip"); |
| 123 | + String neUrl = "https://naciscdn.org/naturalearth/packages/natural_earth_vector.sqlite.zip"; |
| 124 | + |
119 | 125 | String area = args.getString("area", "geofabrik area to download", "monaco");
|
120 | 126 |
|
121 | 127 | var planetiler = Planetiler.create(args)
|
122 |
| - .setProfile(new Basemap(earthWaterBounds)) |
123 | 128 | // (nvkelso 20230817) Order of operations matters here so all NE places can be added to RTree indexes
|
124 | 129 | // before OSM uses them for data joins
|
125 |
| - .addNaturalEarthSource("ne", sourcesDir.resolve("natural_earth_vector.sqlite.zip"), |
126 |
| - "https://naciscdn.org/naturalearth/packages/natural_earth_vector.sqlite.zip") |
| 130 | + .addNaturalEarthSource("ne", nePath, neUrl) |
127 | 131 | .addOsmSource("osm", Path.of("data", "sources", area + ".osm.pbf"), "geofabrik:" + area)
|
128 |
| - .setOutput(Path.of(area + ".pmtiles")); |
129 |
| - planetiler.addShapefileSource("osm_water", sourcesDir.resolve("water-polygons-split-3857.zip"), |
130 |
| - "https://osmdata.openstreetmap.de/download/water-polygons-split-3857.zip") |
| 132 | + .addShapefileSource("osm_water", sourcesDir.resolve("water-polygons-split-3857.zip"), |
| 133 | + "https://osmdata.openstreetmap.de/download/water-polygons-split-3857.zip") |
131 | 134 | .addShapefileSource("osm_land", sourcesDir.resolve("land-polygons-split-3857.zip"),
|
132 |
| - "https://osmdata.openstreetmap.de/download/land-polygons-split-3857.zip") |
| 135 | + "https://osmdata.openstreetmap.de/download/land-polygons-split-3857.zip"); |
| 136 | + |
| 137 | + Downloader.create(planetiler.config(), planetiler.stats()).add("ne", neUrl, nePath) |
| 138 | + .add("qrank", "https://qrank.wmcloud.org/download/qrank.csv.gz", sourcesDir.resolve("qrank.csv.gz")).run(); |
| 139 | + |
| 140 | + var tmpDir = nePath.resolveSibling(nePath.getFileName() + "-unzipped"); |
| 141 | + var naturalEarthDb = NaturalEarthDb.fromSqlite(nePath, tmpDir); |
| 142 | + var qrankDb = QrankDb.fromCsv(sourcesDir.resolve("qrank.csv.gz")); |
| 143 | + |
| 144 | + planetiler.setProfile(new Basemap(earthWaterBounds, naturalEarthDb, qrankDb)).setOutput(Path.of(area + ".pmtiles")) |
133 | 145 | .run();
|
134 | 146 | }
|
135 | 147 | }
|
0 commit comments