forked from protomaps/basemaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEarth.java
65 lines (58 loc) · 2.23 KB
/
Earth.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.protomaps.basemap.layers;
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.FeatureMerge;
import com.onthegomap.planetiler.ForwardingProfile;
import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SourceFeature;
import com.protomaps.basemap.feature.FeatureId;
import com.protomaps.basemap.names.OsmNames;
import org.locationtech.jts.geom.Point;
import java.util.List;
public class Earth implements ForwardingProfile.LayerPostProcesser {
@Override
public String name() {
return "earth";
}
public void processPreparedOsm(SourceFeature ignoredSf, FeatureCollector features) {
features.polygon(this.name())
.setAttr("kind", "earth")
.setZoomRange(6, 15).setBufferPixels(8);
}
public void processNe(SourceFeature sf, FeatureCollector features) {
var sourceLayer = sf.getSourceLayer();
if (sourceLayer.equals("ne_50m_land")) {
features.polygon(this.name()).setZoomRange(0, 4).setBufferPixels(8).setAttr("kind", "earth");
} else if (sourceLayer.equals("ne_10m_land")) {
features.polygon(this.name()).setZoomRange(5, 5).setBufferPixels(8).setAttr("kind", "earth");
}
if (sourceLayer.equals("ne_10m_glaciated_areas")) {
try {
Point centroid = (Point) sf.centroid();
if (centroid.getY() > 0.7) {
features.polygon("landcover")
.setAttr("kind", "glacier")
.setZoomRange(0, 7)
.setMinPixelSize(0.0);
}
} catch (GeometryException e) {
System.out.println("Error: " + e);
}
}
}
public void processOsm(SourceFeature sf, FeatureCollector features) {
if (sf.canBeLine() && !sf.canBePolygon() && sf.hasTag("natural", "cliff")) {
int minZoom = 12;
var feat = features.line(this.name())
.setId(FeatureId.create(sf))
.setAttr("min_zoom", minZoom + 1)
.setAttr("kind", "cliff")
.setZoomRange(minZoom, 15);
OsmNames.setOsmNames(feat, sf, 0);
}
}
@Override
public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> items) throws GeometryException {
return FeatureMerge.mergeOverlappingPolygons(items, 1);
}
}