### Build and Run Planetiler from Source Source: https://github.com/openmaptiles/planetiler-openmaptiles/blob/main/README.md Build the Planetiler project from source using Maven, then run the generated JAR file. Requires Java 21+ installed. Use --force to overwrite existing data and --download to fetch necessary data. ```bash # Build the project (use mvnw.cmd on windows): ./mvnw clean package # Then run: java -jar target/*with-deps.jar --force --download --area=monaco ``` -------------------------------- ### Merge Tile Features in Java Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Implement LayerPostProcessor to merge features after initial processing. This example shows merging line strings at low zoom levels and overlapping/nearby polygons at higher zoom levels. ```java package org.openmaptiles.layers; import com.onthegomap.planetiler.FeatureMerge; import com.onthegomap.planetiler.ForwardingProfile; import com.onthegomap.planetiler.VectorTile; import com.onthegomap.planetiler.geo.GeometryException; import java.util.List; public class MergeableLayer implements Layer, ForwardingProfile.LayerPostProcessor { @Override public String name() { return "mergeable"; } @Override public List postProcess(int zoom, List items) throws GeometryException { // Merge adjacent line strings at low zoom levels if (zoom <= 10) { double minLength = 10.0; // minimum length in pixels double tolerance = 0.5; // simplification tolerance int bufferSize = 4; return FeatureMerge.mergeLineStrings(items, minLength, tolerance, bufferSize); } // Merge overlapping polygons if (zoom >= 13) { double minSize = 0.5; return FeatureMerge.mergeOverlappingPolygons(items, minSize); } // Merge nearby polygons (e.g., for buildings) if (zoom == 13) { return FeatureMerge.mergeNearbyPolygons(items, 4, 4, 0.5, 0.5); } return items; } } ``` -------------------------------- ### Custom Power Layer Implementation Source: https://github.com/openmaptiles/planetiler-openmaptiles/blob/main/README.md Example of a custom layer implementation in Java that adds a 'power' layer for power lines. It implements the 'Layer' and 'OpenMapTilesProfile.OsmAllProcessor' interfaces to process OSM elements and define the layer's behavior. ```java package org.openmaptiles.addons; import com.onthegomap.planetiler.FeatureCollector; import com.onthegomap.planetiler.reader.SourceFeature; import org.openmaptiles.Layer; import org.openmaptiles.OpenMapTilesProfile; public class Power implements Layer, OpenMapTilesProfile.OsmAllProcessor { private static final String LAYER_NAME = "power"; @Override public String name() { return LAYER_NAME; } @Override public void processAllOsm(SourceFeature feature, FeatureCollector features) { if (feature.canBeLine() && feature.hasTag("power", "line")) { features.line("power") .setBufferPixels(4) .setMinZoom(6) .setAttr("class", "line"); } } } ``` -------------------------------- ### Regenerate OpenMapTiles Code with Specific Tag Source: https://github.com/openmaptiles/planetiler-openmaptiles/blob/main/README.md Use this script to regenerate code from a specific OpenMapTiles release tag. Ensure you have the necessary permissions and environment setup. ```bash ./scripts/regenerate-openmaptiles.sh v3.16 ``` -------------------------------- ### Add 'name' Attribute to Building Layer (Diff) Source: https://github.com/openmaptiles/planetiler-openmaptiles/blob/main/README.md Example of modifying the Building layer to copy the 'name' attribute from OpenStreetMap elements. This diff shows the addition of a line to set the 'name' attribute. ```diff @@ -166,6 +166,7 @@ public class Building implements .setAttrWithMinzoom(Fields.RENDER_MIN_HEIGHT, renderMinHeight, 14) .setAttrWithMinzoom(Fields.COLOUR, color, 14) .setAttrWithMinzoom(Fields.HIDE_3D, hide3d, 14) + .setAttrWithMinzoom("name", element.source().getTag("name"), 14) .setSortKey(renderHeight); if (mergeZ13Buildings) { feature ``` -------------------------------- ### Build and Run Map Generator from Source Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Build the project from source using Maven Wrapper and then run the generated JAR file to create vector tiles. Requires Java 21+. ```bash ./mvnw clean package java -jar target/*with-deps.jar --force --download --area=monaco ``` -------------------------------- ### Run Planetiler with Docker Source: https://github.com/openmaptiles/planetiler-openmaptiles/blob/main/README.md Execute Planetiler with the OpenMapTiles profile using a pre-built Docker image. Mounts the current directory's 'data' folder to '/data' inside the container. Use --force to overwrite existing data and --download to fetch necessary data. ```bash docker run --rm -v "$(pwd)/data":/data openmaptiles/planetiler-openmaptiles:latest --force --download --area=monaco ``` -------------------------------- ### Run Map Generator with Docker Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Execute the map generator using a pre-built Docker image to create vector tiles for a specified area. Ensure the data directory is mounted correctly. ```bash docker run --rm -v "$(pwd)/data":/data openmaptiles/planetiler-openmaptiles:latest \ --force --download --area=monaco ``` -------------------------------- ### Generate Planet-Wide Tiles Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Generate vector tiles for the entire planet. This process requires significant system resources. ```bash java -jar target/*with-deps.jar \ --force \ --download \ --area=planet \ --mbtiles=data/planet.mbtiles ``` -------------------------------- ### Regenerate Schema Code Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Update generated classes from a specific OpenMapTiles release and verify the build. Run these commands from the project root. ```bash # Regenerate code from OpenMapTiles release v3.16 ./scripts/regenerate-openmaptiles.sh v3.16 # Regenerate from a custom repository ./scripts/regenerate-openmaptiles.sh v3.16 https://raw.githubusercontent.com/openmaptiles/openmaptiles/ # After regeneration, format the code ./mvnw spotless:apply # Verify the build passes ./mvnw clean verify ``` -------------------------------- ### Regenerate OpenMapTiles Code from Custom URL Source: https://github.com/openmaptiles/planetiler-openmaptiles/blob/main/README.md This command regenerates code from a specified OpenMapTiles repository URL and tag. Useful for testing or using forks. ```bash ./scripts/regenerate-openmaptiles.sh v3.16 https://raw.githubusercontent.com/openmaptiles/openmaptiles/ ``` -------------------------------- ### Preprocess OSM Relations for Hiking Routes in Java Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Implement OsmRelationPreprocessor to extract hiking route information from OSM relations. This preprocessed data can then be associated with member ways during way processing. ```java package org.openmaptiles.layers; import com.onthegomap.planetiler.reader.osm.OsmElement; import com.onthegomap.planetiler.reader.osm.OsmRelationInfo; import org.openmaptiles.OpenMapTilesProfile; import java.util.List; public class HikingRoutes implements Layer, ForwardingProfile.OsmRelationPreprocessor { @Override public List preprocessOsmRelation(OsmElement.Relation relation) { // Extract hiking route relations if (relation.hasTag("route", "hiking")) { String network = relation.getString("network"); String ref = relation.getString("ref"); String name = relation.getString("name"); // Return relation info to be associated with member ways return List.of(new HikingRouteInfo( relation.id(), network, ref, name )); } return null; } // Custom record to store relation info record HikingRouteInfo(long id, String network, String ref, String name) implements OsmRelationInfo { @Override public long estimateMemoryUsageBytes() { return 64; // approximate memory usage } } } ``` -------------------------------- ### Custom Water Features Processor in Java Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Implement custom water feature processing by implementing NaturalEarthProcessor, OsmWaterPolygonProcessor, and LakeCenterlineProcessor interfaces. This allows handling different water data sources at various zoom levels. ```java package org.openmaptiles.layers; import com.onthegomap.planetiler.FeatureCollector; import com.onthegomap.planetiler.reader.SourceFeature; import org.openmaptiles.Layer; import org.openmaptiles.OpenMapTilesProfile; public class CustomWaterFeatures implements Layer, OpenMapTilesProfile.NaturalEarthProcessor, OpenMapTilesProfile.OsmWaterPolygonProcessor, OpenMapTilesProfile.LakeCenterlineProcessor { @Override public String name() { return "custom_water"; } // Process Natural Earth features (low zoom levels) @Override public void processNaturalEarth(String table, SourceFeature feature, FeatureCollector features) { if ("ne_10m_lakes".equals(table)) { features.polygon(name()) .setZoomRange(4, 5) .setAttr("class", "lake") .setAttr("name", feature.getString("name")); } } // Process OSM water polygons (oceans at higher zoom) @Override public void processOsmWater(SourceFeature feature, FeatureCollector features) { features.polygon(name()) .setMinZoom(6) .setAttr("class", "ocean"); } // Process lake centerlines for label placement @Override public void processLakeCenterline(SourceFeature feature, FeatureCollector features) { features.line(name()) .setMinZoom(3) .setAttr("class", "centerline"); } } ``` -------------------------------- ### Enable Transportation Paths at z13 Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Enable the display of all transportation paths at zoom level 13. This is disabled by default. ```bash java -jar target/*with-deps.jar \ --force --download --area=monaco \ --transportation_z13_paths=true ``` -------------------------------- ### Generate Tiles for Larger Regions Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Generate vector tiles for larger geographic areas like Rhode Island, specifying the output MBTiles file. ```bash java -jar target/*with-deps.jar \ --force \ --download \ --area=rhode-island \ --mbtiles=data/rhode-island.mbtiles ``` -------------------------------- ### Implement Custom POI Layer Handlers Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Use auto-generated table row handlers to process OSM POI points and polygons. Ensure the class implements the corresponding handler interfaces from the generated Tables class. ```java package org.openmaptiles.layers; import com.onthegomap.planetiler.FeatureCollector; import org.openmaptiles.generated.Tables; import org.openmaptiles.generated.OpenMapTilesSchema; public class CustomPoi implements OpenMapTilesSchema.Poi, Tables.OsmPoiPoint.Handler, Tables.OsmPoiPolygon.Handler { // Process POI points - matches imposm3 table definition @Override public void process(Tables.OsmPoiPoint element, FeatureCollector features) { String name = element.name(); String subclass = element.subclass(); if (name != null && !name.isEmpty()) { features.point(LAYER_NAME) .setBufferPixels(BUFFER_SIZE) .setMinZoom(14) .setAttr(Fields.NAME, name) .setAttr(Fields.SUBCLASS, subclass) .setAttr(Fields.CLASS, element.mapping_key()); } } // Process POI polygons (use centroid as point) @Override public void process(Tables.OsmPoiPolygon element, FeatureCollector features) { String name = element.name(); if (name != null && !name.isEmpty()) { features.centroid(LAYER_NAME) .setBufferPixels(BUFFER_SIZE) .setMinZoom(14) .setAttr(Fields.NAME, name) .setAttr(Fields.SUBCLASS, element.subclass()); } } } ``` -------------------------------- ### Include Brunnel Tag in Transportation Name Layer Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Enable the inclusion of the 'brunnel' tag within the 'transportation_name' layer for more detailed transportation data. ```bash java -jar target/*with-deps.jar \ --force --download --area=monaco \ --transportation-name-brunnel=true ``` -------------------------------- ### Include Only Specific Layers Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Configure the map generator to include only a specified set of layers in the final vector tile output. ```bash java -jar target/*with-deps.jar \ --force --download --area=monaco \ --only-layers=water,transportation,building ``` -------------------------------- ### Add Building Name Attribute in Java Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Extend the Building layer to add the 'name' attribute from OSM tags. Ensure the 'name' tag exists in the source data. ```java import com.onthegomap.planetiler.FeatureCollector; import org.openmaptiles.layers.Building; import org.openmaptiles.layers.OpenMapTilesLayer.Fields; // In Building.java - add name attribute to buildings @Override public void process(Tables.OsmBuildingPolygon element, FeatureCollector features) { // ... existing height calculation code ... var feature = features.polygon(LAYER_NAME) .setBufferPixels(BUFFER_SIZE) .setMinZoom(13) .setMinPixelSize(2) .setAttrWithMinzoom(Fields.RENDER_HEIGHT, renderHeight, 14) .setAttrWithMinzoom(Fields.RENDER_MIN_HEIGHT, renderMinHeight, 14) .setAttrWithMinzoom(Fields.COLOUR, color, 14) .setAttrWithMinzoom(Fields.HIDE_3D, hide3d, 14) // Add building name from OSM tags .setAttrWithMinzoom("name", element.source().getTag("name"), 14) .setSortKey(renderHeight); if (mergeZ13Buildings) { feature.setMinPixelSize(0.1).setPixelTolerance(0.25); } } ``` -------------------------------- ### Disable Building Merge Optimization Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Disable the building merge optimization at zoom level 13. This can affect performance and output quality. ```bash java -jar target/*with-deps.jar \ --force --download --area=monaco \ --building_merge_z13=false ``` -------------------------------- ### Exclude or Include Specific Layers Source: https://github.com/openmaptiles/planetiler-openmaptiles/blob/main/README.md Control which layers are generated by Planetiler using command-line arguments. Use --exclude-layers to omit specific layers or --only-layers to include only specified layers. ```bash --exclude-layers=poi,housenumber,... --only-layers=water,transportation,... ``` -------------------------------- ### Register Custom Layers Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Register custom layer instances, such as the 'Power' layer, within the ExtraLayers registry to include them in the map generation process. ```java package org.openmaptiles.addons; import com.onthegomap.planetiler.config.PlanetilerConfig; import com.onthegomap.planetiler.stats.Stats; import com.onthegomap.planetiler.util.Translations; import java.util.List; import org.openmaptiles.Layer; public class ExtraLayers { public static List create(Translations translations, PlanetilerConfig config, Stats stats) { return List.of( // Register custom layers here new Power(), new CustomBikeRoutes(translations, config, stats), new HistoricSites(translations, config, stats) ); } } ``` -------------------------------- ### Exclude Specific Layers from Output Source: https://context7.com/openmaptiles/planetiler-openmaptiles/llms.txt Configure the map generator to exclude certain layers from the final vector tile output. ```bash java -jar target/*with-deps.jar \ --force --download --area=monaco \ --exclude-layers=poi,housenumber,aerodrome_label ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.