Skip to content

Instantly share code, notes, and snippets.

@msbarry
Last active February 27, 2022 17:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save msbarry/97776d0ff76cae198e1c0fbd26fed6bd to your computer and use it in GitHub Desktop.
// To run:
// 1) Install java 17 (JDK, not JRE)
// 2) Then get latest planetiler.jar: wget https://github.com/onthegomap/planetiler/releases/latest/download/planetiler.jar
// 3) Then run this file with: java -cp planetiler.jar Powerlines.java --area=monaco --download --force
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.FeatureMerge;
import com.onthegomap.planetiler.Planetiler;
import com.onthegomap.planetiler.Profile;
import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.config.Arguments;
import com.onthegomap.planetiler.reader.SourceFeature;
import com.onthegomap.planetiler.reader.osm.OsmElement;
import com.onthegomap.planetiler.reader.osm.OsmRelationInfo;
import java.nio.file.Path;
import java.util.List;
public class Powerlines implements Profile {
@Override
public void processFeature(SourceFeature sourceFeature, FeatureCollector features) {
if (sourceFeature.canBeLine() && sourceFeature.hasTag("power", "line")) {
features.line("power")
.setBufferPixels(4)
.setMinZoom(6)
.setAttr("class", "line");
}
}
@Override
public String name() {
return "Powerlines Overlay";
}
@Override
public String description() {
return "An example overlay showing powerlines";
}
@Override
public boolean isOverlay() {
return true;
}
@Override
public String attribution() {
return """
<a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">&copy; OpenStreetMap contributors</a>
""".trim();
}
public static void main(String[] args) throws Exception {
run(Arguments.fromArgsOrConfigFile(args));
}
static void run(Arguments args) throws Exception {
String area = args.getString("area", "geofabrik area to download", "monaco");
Planetiler.create(args)
.setProfile(new Powerlines())
.addOsmSource("osm", Path.of("data", "sources", area + ".osm.pbf"), "geofabrik:" + area)
.overwriteOutput("mbtiles", Path.of("data", "powerlines.mbtiles"))
.run();
}
}
@wipfli
Copy link

wipfli commented Feb 27, 2022

I removed the line starting with java...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment