mirror of
https://github.com/cfpwastaken/planetiler-openmaptiles.git
synced 2026-02-04 12:31:10 +00:00
feat: add raw layer at z15, exclude everything else from z15
This commit is contained in:
@@ -14,6 +14,7 @@ public class ExtraLayers {
|
||||
public static List<Layer> create(Translations translations, PlanetilerConfig config, Stats stats) {
|
||||
return List.of(
|
||||
// Create classes that extend Layer interface in the addons package, then instantiate them here
|
||||
new Raw()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
89
src/main/java/org/openmaptiles/addons/Raw.java
Normal file
89
src/main/java/org/openmaptiles/addons/Raw.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package org.openmaptiles.addons;
|
||||
|
||||
import com.onthegomap.planetiler.FeatureCollector;
|
||||
import com.onthegomap.planetiler.reader.SourceFeature;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.openmaptiles.Layer;
|
||||
import org.openmaptiles.OpenMapTilesProfile;
|
||||
|
||||
public class Raw implements Layer, OpenMapTilesProfile.OsmAllProcessor {
|
||||
|
||||
public static List<String> TAG_WHITELIST = Arrays.asList("amenity", "shop", "name", "opening_hours", "email", "website", "phone", "internet_access", "wheelchair", "cuisine", "indoor_seating", "outdoor_seating", "takeaway", "drive_through");
|
||||
public static List<String> TAG_PREFIX_WHITELIST = Arrays.asList("addr:", "contact:", "payment:", "wheelchair:", "fuel:", "internet_access:");
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "raw";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processAllOsm(SourceFeature feature, FeatureCollector features) {
|
||||
boolean hasTag = false;
|
||||
for (Map.Entry<String, Object> i : feature.tags().entrySet()) {
|
||||
if (TAG_WHITELIST.contains(i.getKey())) {
|
||||
hasTag = true;
|
||||
break;
|
||||
}
|
||||
for (String prefix : TAG_PREFIX_WHITELIST) {
|
||||
if(i.getKey().startsWith(prefix)) {
|
||||
hasTag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasTag) return;
|
||||
|
||||
if(feature.canBePolygon()) {
|
||||
FeatureCollector.Feature ft = features.polygon("raw")
|
||||
.setBufferPixels(4)
|
||||
.setMinZoom(15);
|
||||
|
||||
for (Map.Entry<String, Object> i : feature.tags().entrySet()) {
|
||||
if (TAG_WHITELIST.contains(i.getKey())) {
|
||||
ft.setAttr(i.getKey(), i.getValue());
|
||||
}
|
||||
for (String prefix : TAG_PREFIX_WHITELIST) {
|
||||
if(i.getKey().startsWith(prefix)) {
|
||||
ft.setAttr(i.getKey(), i.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(feature.canBeLine()) {
|
||||
FeatureCollector.Feature ft = features.line("raw")
|
||||
.setBufferPixels(4)
|
||||
.setMinZoom(15);
|
||||
|
||||
for (Map.Entry<String, Object> i : feature.tags().entrySet()) {
|
||||
if (TAG_WHITELIST.contains(i.getKey())) {
|
||||
ft.setAttr(i.getKey(), i.getValue());
|
||||
}
|
||||
for (String prefix : TAG_PREFIX_WHITELIST) {
|
||||
if(i.getKey().startsWith(prefix)) {
|
||||
ft.setAttr(i.getKey(), i.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(feature.isPoint()) {
|
||||
FeatureCollector.Feature ft = features.point("raw")
|
||||
.setBufferPixels(4)
|
||||
.setMinZoom(15);
|
||||
|
||||
for(Map.Entry<String, Object> i : feature.tags().entrySet()) {
|
||||
if(TAG_WHITELIST.contains(i.getKey())) {
|
||||
ft.setAttr(i.getKey(), i.getValue());
|
||||
}
|
||||
for (String prefix : TAG_PREFIX_WHITELIST) {
|
||||
if(i.getKey().startsWith(prefix)) {
|
||||
ft.setAttr(i.getKey(), i.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user