Skip to content

Commit

Permalink
Rename Basemap to OpenMapTiles (onthegomap#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
lazaa32 authored May 23, 2022
1 parent 596770a commit a6c8d6c
Show file tree
Hide file tree
Showing 48 changed files with 242 additions and 242 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Planetiler Basemap Profile
# Planetiler OpenMapTiles Profile

This basemap profile is based on [OpenMapTiles](https://github.com/openmaptiles/openmaptiles) v3.13.
See [README.md](../README.md) in the parent directory for instructions on how to run.
This OpenMapTiles profile is based on [OpenMapTiles](https://github.com/openmaptiles/openmaptiles).
See [README.md](https://github.com/onthegomap/planetiler/blob/main/README.md) in the parent repository for instructions on how to run.

## Differences from OpenMapTiles

Expand All @@ -14,30 +14,30 @@ See [README.md](../README.md) in the parent directory for instructions on how to

## Code Layout

[Generate.java](./src/main/java/com/onthegomap/planetiler/basemap/Generate.java) generates code in
the [generated](./src/main/java/com/onthegomap/planetiler/basemap/generated) package from an OpenMapTiles tag in GitHub:
[Generate.java](./src/main/java/com/onthegomap/planetiler/openmaptiles/Generate.java) generates code in
the [generated](./src/main/java/com/onthegomap/planetiler/openmaptiles/generated) package from an OpenMapTiles tag in GitHub:

- [OpenMapTilesSchema](./src/main/java/com/onthegomap/planetiler/basemap/generated/OpenMapTilesSchema.java)
- [OpenMapTilesSchema](./src/main/java/com/onthegomap/planetiler/openmaptiles/generated/OpenMapTilesSchema.java)
contains an interface for each layer with constants for the name, attributes, and allowed values for each tag in that
layer
- [Tables](./src/main/java/com/onthegomap/planetiler/basemap/generated/Tables.java)
- [Tables](./src/main/java/com/onthegomap/planetiler/openmaptiles/generated/Tables.java)
contains a record for each table that OpenMapTiles [imposm3](https://github.com/omniscale/imposm3) configuration
generates (along with the tag-filtering expression) so layers can listen on instances of those records instead of
doing the tag filtering and parsing themselves

The [layers](./src/main/java/com/onthegomap/planetiler/basemap/layers) package contains a port of the SQL logic to
The [layers](./src/main/java/com/onthegomap/planetiler/openmaptiles/layers) package contains a port of the SQL logic to
generate each layer from OpenMapTiles. Layers define how source features (or parsed imposm3 table rows) map to vector
tile features, and logic for post-processing tile geometries.

[BasemapProfile](./src/main/java/com/onthegomap/planetiler/basemap/BasemapProfile.java) dispatches source features to
[OpenMapTilesProfile](./src/main/java/com/onthegomap/planetiler/openmaptiles/OpenMapTilesProfile.java) dispatches source features to
layer handlers and merges the results.

[BasemapMain](./src/main/java/com/onthegomap/planetiler/basemap/BasemapMain.java) is the main driver that registers
[OpenMapTilesMain](./src/main/java/com/onthegomap/planetiler/openmaptiles/OpenMapTilesMain.java) is the main driver that registers
source data and output location.

## Regenerating Code

To run `Generate.java`, use [scripts/regenerate-openmaptiles.sh](../scripts/regenerate-openmaptiles.sh) script with the
To run `Generate.java`, use [scripts/regenerate-openmaptiles.sh](https://github.com/onthegomap/planetiler/blob/main/scripts/regenerate-openmaptiles.sh) script with the
OpenMapTiles release tag:

```bash
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>planetiler-basemap</artifactId>
<artifactId>planetiler-openmaptiles</artifactId>

<parent>
<groupId>com.onthegomap.planetiler</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onthegomap.planetiler.basemap;
package com.onthegomap.planetiler.openmaptiles;

import static com.onthegomap.planetiler.expression.Expression.*;
import static java.util.stream.Collectors.joining;
Expand Down Expand Up @@ -161,9 +161,9 @@ public static void main(String[] args) throws IOException {
tables.putAll(layer.tables);
}

String packageName = "com.onthegomap.planetiler.basemap.generated";
String packageName = "com.onthegomap.planetiler.openmaptiles.generated";
String[] packageParts = packageName.split("\\.");
Path output = Path.of("planetiler-basemap", "src", "main", "java")
Path output = Path.of("planetiler-openmaptiles", "src", "main", "java")
.resolve(Path.of(packageParts[0], Arrays.copyOfRange(packageParts, 1, packageParts.length)));

FileUtils.deleteDirectory(output);
Expand All @@ -188,7 +188,7 @@ private static void emitLayerSchemaDefinitions(OpenmaptilesTileSet info, List<La
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.expression.MultiExpression;
import com.onthegomap.planetiler.basemap.Layer;
import com.onthegomap.planetiler.openmaptiles.Layer;
import com.onthegomap.planetiler.util.Translations;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -225,7 +225,7 @@ public static List<Layer> createInstances(Translations translations, PlanetilerC
info.languages.stream().map(Format::quote).collect(joining(", ")),
layers.stream()
.map(
l -> "new com.onthegomap.planetiler.basemap.layers.%s(translations, config, stats)"
l -> "new com.onthegomap.planetiler.openmaptiles.layers.%s(translations, config, stats)"
.formatted(lowerUnderscoreToUpperCamel(l.layer.id)))
.collect(joining("," + LINE_SEPARATOR))
.indent(6).trim()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.onthegomap.planetiler.basemap;
package com.onthegomap.planetiler.openmaptiles;

import com.onthegomap.planetiler.ForwardingProfile;

/** Interface for all vector tile layer implementations that {@link BasemapProfile} delegates to. */
/** Interface for all vector tile layer implementations that {@link OpenMapTilesProfile} delegates to. */
public interface Layer extends
ForwardingProfile.Handler,
ForwardingProfile.HandlerForLayer {}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.onthegomap.planetiler.basemap;
package com.onthegomap.planetiler.openmaptiles;

import com.onthegomap.planetiler.Planetiler;
import com.onthegomap.planetiler.basemap.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.openmaptiles.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.config.Arguments;
import java.nio.file.Path;

/**
* Main entrypoint for generating a map using the basemap schema.
* Main entrypoint for generating a map using the OpenMapTiles schema.
*/
public class BasemapMain {
public class OpenMapTilesMain {

public static void main(String[] args) throws Exception {
run(Arguments.fromArgsOrConfigFile(args));
Expand All @@ -29,21 +29,21 @@ static void run(Arguments arguments) throws Exception {
.setDefaultLanguages(OpenMapTilesSchema.LANGUAGES)
.fetchWikidataNameTranslations(sourcesDir.resolve("wikidata_names.json"))
// defer creation of the profile because it depends on data from the runner
.setProfile(BasemapProfile::new)
.setProfile(OpenMapTilesProfile::new)
// override any of these with arguments: --osm_path=... or --osm_url=...
// or OSM_PATH=... OSM_URL=... environmental argument
// or osm_path=... osm_url=... in a config file
.addShapefileSource("EPSG:3857", BasemapProfile.LAKE_CENTERLINE_SOURCE,
.addShapefileSource("EPSG:3857", OpenMapTilesProfile.LAKE_CENTERLINE_SOURCE,
sourcesDir.resolve("lake_centerline.shp.zip"),
// was previously using this old build from 2016: https://github.com/lukasmartinelli/osm-lakelines/releases/download/v0.9/lake_centerline.shp.zip
"https://github.com/acalcutt/osm-lakelines/releases/download/latest/lake_centerline.shp.zip")
.addShapefileSource(BasemapProfile.WATER_POLYGON_SOURCE,
.addShapefileSource(OpenMapTilesProfile.WATER_POLYGON_SOURCE,
sourcesDir.resolve("water-polygons-split-3857.zip"),
"https://osmdata.openstreetmap.de/download/water-polygons-split-3857.zip")
.addNaturalEarthSource(BasemapProfile.NATURAL_EARTH_SOURCE,
.addNaturalEarthSource(OpenMapTilesProfile.NATURAL_EARTH_SOURCE,
sourcesDir.resolve("natural_earth_vector.sqlite.zip"),
"https://naciscdn.org/naturalearth/packages/natural_earth_vector.sqlite.zip")
.addOsmSource(BasemapProfile.OSM_SOURCE,
.addOsmSource(OpenMapTilesProfile.OSM_SOURCE,
sourcesDir.resolve(area.replaceAll("[^a-zA-Z]+", "_") + ".osm.pbf"),
"planet".equalsIgnoreCase(area) ? ("aws:latest") : ("geofabrik:" + area))
// override with --mbtiles=... argument or MBTILES=... env var or mbtiles=... in a config file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.onthegomap.planetiler.basemap;
package com.onthegomap.planetiler.openmaptiles;

import static com.onthegomap.planetiler.geo.GeoUtils.EMPTY_LINE;
import static com.onthegomap.planetiler.geo.GeoUtils.EMPTY_POINT;
Expand All @@ -8,10 +8,10 @@
import com.onthegomap.planetiler.ForwardingProfile;
import com.onthegomap.planetiler.Planetiler;
import com.onthegomap.planetiler.Profile;
import com.onthegomap.planetiler.basemap.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.basemap.generated.Tables;
import com.onthegomap.planetiler.basemap.layers.Transportation;
import com.onthegomap.planetiler.basemap.layers.TransportationName;
import com.onthegomap.planetiler.openmaptiles.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.openmaptiles.generated.Tables;
import com.onthegomap.planetiler.openmaptiles.layers.Transportation;
import com.onthegomap.planetiler.openmaptiles.layers.TransportationName;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.expression.MultiExpression;
import com.onthegomap.planetiler.reader.SimpleFeature;
Expand Down Expand Up @@ -41,7 +41,7 @@
* {@link FinishHandler} or post-process features in that layer before rendering the output tile by implementing
* {@link FeaturePostProcessor}.
*/
public class BasemapProfile extends ForwardingProfile {
public class OpenMapTilesProfile extends ForwardingProfile {

// IDs used in stats and logs for each input source, as well as argument/config file overrides to source locations
public static final String LAKE_CENTERLINE_SOURCE = "lake_centerlines";
Expand All @@ -53,11 +53,11 @@ public class BasemapProfile extends ForwardingProfile {
/** Index variant that filters out any table only used by layers that implement IgnoreWikidata class. */
private final MultiExpression.Index<Boolean> wikidataMappings;

public BasemapProfile(Planetiler runner) {
public OpenMapTilesProfile(Planetiler runner) {
this(runner.translations(), runner.config(), runner.stats());
}

public BasemapProfile(Translations translations, PlanetilerConfig config, Stats stats) {
public OpenMapTilesProfile(Translations translations, PlanetilerConfig config, Stats stats) {
List<String> onlyLayers = config.arguments().getList("only_layers", "Include only certain layers", List.of());
List<String> excludeLayers = config.arguments().getList("exclude_layers", "Exclude certain layers", List.of());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*/
// AUTOGENERATED BY Generate.java -- DO NOT MODIFY

package com.onthegomap.planetiler.basemap.generated;
package com.onthegomap.planetiler.openmaptiles.generated;

import static com.onthegomap.planetiler.expression.Expression.*;

import com.onthegomap.planetiler.basemap.Layer;
import com.onthegomap.planetiler.openmaptiles.Layer;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.expression.MultiExpression;
import com.onthegomap.planetiler.stats.Stats;
Expand Down Expand Up @@ -68,22 +68,22 @@ public class OpenMapTilesSchema {
/** Returns a list of expected layer implementation instances from the {@code layers} package. */
public static List<Layer> createInstances(Translations translations, PlanetilerConfig config, Stats stats) {
return List.of(
new com.onthegomap.planetiler.basemap.layers.Water(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Waterway(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Landcover(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Landuse(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.MountainPeak(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Park(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Boundary(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Aeroway(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Transportation(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Building(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.WaterName(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.TransportationName(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Place(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Housenumber(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.Poi(translations, config, stats),
new com.onthegomap.planetiler.basemap.layers.AerodromeLabel(translations, config, stats)
new com.onthegomap.planetiler.openmaptiles.layers.Water(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Waterway(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Landcover(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Landuse(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.MountainPeak(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Park(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Boundary(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Aeroway(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Transportation(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Building(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.WaterName(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.TransportationName(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Place(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Housenumber(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.Poi(translations, config, stats),
new com.onthegomap.planetiler.openmaptiles.layers.AerodromeLabel(translations, config, stats)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*/
// AUTOGENERATED BY Generate.java -- DO NOT MODIFY

package com.onthegomap.planetiler.basemap.generated;
package com.onthegomap.planetiler.openmaptiles.generated;

import static com.onthegomap.planetiler.expression.Expression.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
See https://github.com/openmaptiles/openmaptiles/blob/master/LICENSE.md for details on usage
*/
package com.onthegomap.planetiler.basemap.layers;
package com.onthegomap.planetiler.openmaptiles.layers;

import static com.onthegomap.planetiler.basemap.util.Utils.nullIfEmpty;
import static com.onthegomap.planetiler.basemap.util.Utils.nullOrEmpty;
import static com.onthegomap.planetiler.openmaptiles.util.Utils.nullIfEmpty;
import static com.onthegomap.planetiler.openmaptiles.util.Utils.nullOrEmpty;

import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.basemap.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.basemap.generated.Tables;
import com.onthegomap.planetiler.basemap.util.LanguageUtils;
import com.onthegomap.planetiler.basemap.util.Utils;
import com.onthegomap.planetiler.openmaptiles.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.openmaptiles.generated.Tables;
import com.onthegomap.planetiler.openmaptiles.util.LanguageUtils;
import com.onthegomap.planetiler.openmaptiles.util.Utils;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.expression.MultiExpression;
import com.onthegomap.planetiler.stats.Stats;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
See https://github.com/openmaptiles/openmaptiles/blob/master/LICENSE.md for details on usage
*/
package com.onthegomap.planetiler.basemap.layers;
package com.onthegomap.planetiler.openmaptiles.layers;

import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.basemap.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.basemap.generated.Tables;
import com.onthegomap.planetiler.openmaptiles.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.openmaptiles.generated.Tables;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.util.Translations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
See https://github.com/openmaptiles/openmaptiles/blob/master/LICENSE.md for details on usage
*/
package com.onthegomap.planetiler.basemap.layers;
package com.onthegomap.planetiler.openmaptiles.layers;

import static com.onthegomap.planetiler.util.MemoryEstimator.CLASS_HEADER_BYTES;
import static com.onthegomap.planetiler.util.MemoryEstimator.POINTER_BYTES;
Expand All @@ -45,8 +45,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.FeatureMerge;
import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.basemap.BasemapProfile;
import com.onthegomap.planetiler.basemap.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.openmaptiles.OpenMapTilesProfile;
import com.onthegomap.planetiler.openmaptiles.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.collection.Hppc;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.geo.GeoUtils;
Expand Down Expand Up @@ -92,11 +92,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*/
public class Boundary implements
OpenMapTilesSchema.Boundary,
BasemapProfile.NaturalEarthProcessor,
BasemapProfile.OsmRelationPreprocessor,
BasemapProfile.OsmAllProcessor,
BasemapProfile.FeaturePostProcessor,
BasemapProfile.FinishHandler {
OpenMapTilesProfile.NaturalEarthProcessor,
OpenMapTilesProfile.OsmRelationPreprocessor,
OpenMapTilesProfile.OsmAllProcessor,
OpenMapTilesProfile.FeaturePostProcessor,
OpenMapTilesProfile.FinishHandler {

/*
* Uses natural earth at lower zoom levels and OpenStreetMap at higher zoom levels.
Expand Down Expand Up @@ -296,7 +296,7 @@ public void processAllOsm(SourceFeature feature, FeatureCollector features) {
@Override
public void finish(String sourceName, FeatureCollector.Factory featureCollectors,
Consumer<FeatureCollector.Feature> emit) {
if (BasemapProfile.OSM_SOURCE.equals(sourceName)) {
if (OpenMapTilesProfile.OSM_SOURCE.equals(sourceName)) {
var timer = stats.startStage("boundaries");
LongObjectMap<PreparedGeometry> countryBoundaries = prepareRegionPolygons();

Expand Down
Loading

0 comments on commit a6c8d6c

Please sign in to comment.