1-file java | lua | yaml | java project (maven/gradle) | |
---|---|---|---|---|
tools required | ✅ JRE | ✅ JRE | ❌ JDK + maven/gradle | |
can split logic into multiple files | ❌ not yet | ✅ | ❌ | ✅ |
performance | ✅ | ✅✅ fastest | ✅ | |
full access to java API | ✅ | ✅ | ❌ | ✅ |
IDE support | ✅ vscode no-build-tool mode, with planetiler.jar on classpath | ✅ vscode with type definitions | ✅ vscode with planetiler.schema.json | ✅ vscode, intellij, etc. |
untrusted code | ❌ can do anything | ❌ can do anything | ✅ can only make maps | ❌ can do anything |
-
-
Save msbarry/284eff36489ca736c7dab836ace39d24 to your computer and use it in GitHub Desktop.
Planetiler profile options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example 1-file, no-build-tool java profile. run with: | |
// java -cp planetiler.jar Power.java | |
import com.onthegomap.planetiler.FeatureCollector; | |
import com.onthegomap.planetiler.Planetiler; | |
import com.onthegomap.planetiler.Profile; | |
import com.onthegomap.planetiler.config.Arguments; | |
import com.onthegomap.planetiler.reader.SourceFeature; | |
import java.nio.file.Path; | |
class Power implements Profile { | |
public void processFeature(SourceFeature source, FeatureCollector features) { | |
if (source.canBeLine() && source.hasTag("power", "line")) { | |
features | |
.line("power") | |
.setMinZoom(7) | |
.inheritAttrFromSource("power") | |
.inheritAttrFromSource("voltage") | |
.inheritAttrFromSource("cables") | |
.inheritAttrFromSource("operator"); | |
} else if (source.isPoint() && source.hasTag("power", "pole")) { | |
features | |
.point("power") | |
.setMinZoom(13) | |
.inheritAttrFromSource("power") | |
.inheritAttrFromSource("ref") | |
.inheritAttrFromSource("height") | |
.inheritAttrFromSource("operator"); | |
} | |
} | |
public String name() { | |
return "power"; | |
} | |
public static void main(String[] argv) throws Exception { | |
Arguments args = Arguments.fromArgsOrConfigFile(argv); | |
var area = args.getString("area", "geofabrik area to download", "massachusetts"); | |
Planetiler.create(args) | |
.setProfile(new Power()) | |
.addOsmSource("osm", Path.of("data/sources/" + area + ".osm.pbf"), "geofabrik:" + area) | |
.overwriteOutput(Path.of("data/buildings.pmtiles")) | |
.run(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- example lua profile, run with: | |
-- java -jar planetiler.jar power.lua | |
planetiler.output.name = "Power" | |
planetiler.output.path = { "data", "power.pmtiles" } | |
local area = planetiler.args:get_string("area", "geofabrik area to download", "massachusetts") | |
planetiler.add_source('osm', { | |
type = 'osm', | |
url = 'geofabrik:' .. area, | |
-- any java method or field that takes a Path can be called with a list of path parts from lua | |
path = { 'data', 'sources', area .. '.osm.pbf' } | |
}) | |
function planetiler.process_feature(source, features) | |
if source:can_be_line() and source:has_tag("power", "line") then | |
features | |
:line("power") | |
:set_min_zoom(7) | |
:inherit_attr_from_source("power") | |
:inherit_attr_from_source("voltage") | |
:inherit_attr_from_source("cables") | |
:inherit_attr_from_source("operator") | |
elseif source:isPoint() and source:has_tag("power", "pole") then | |
features | |
:point("power") | |
:set_min_zoom(13) | |
:inherit_attr_from_source("power") | |
:inherit_attr_from_source("ref") | |
:inherit_attr_from_source("height") | |
:inherit_attr_from_source("operator") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example yaml profile, run with: | |
# java -jar planetiler.jar power.yml | |
schema_name: Power | |
sources: | |
osm: | |
type: osm | |
url: geofabrik:massachusetts | |
layers: | |
- id: power | |
features: | |
- source: osm | |
geometry: point | |
min_zoom: 13 | |
include_when: | |
power: | |
- pole | |
attributes: | |
- key: power | |
- key: ref | |
- key: height | |
- key: operator | |
- source: osm | |
geometry: line | |
min_zoom: 7 | |
include_when: | |
power: | |
- line | |
attributes: | |
- key: power | |
- key: voltage | |
- key: cables | |
- key: operator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment