Last active
February 27, 2022 17:49
-
-
Save msbarry/97776d0ff76cae198e1c0fbd26fed6bd to your computer and use it in GitHub Desktop.
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
// 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\">© 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(); | |
} | |
} |
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
Should that be a cli instruction?
https://gist.github.com/msbarry/97776d0ff76cae198e1c0fbd26fed6bd#file-powerlines-java-L6