Skip to content

Commit ae33e95

Browse files
phanecak-maptilerofalvai
authored andcommitted
OpenMapTiles 3.15.0 SNAPSHOT (2) (openmaptiles#144)
* version bumped from 3.14.0 to 3.15.0-SNAPSHOT * regenerate-openmaptiles.sh 07f243c5d9efa558fa539d7a31b2ae50507aaa9d (to match content of OMT PR 1457) * SQL -> Java re-implementation of OMT PR 1457 * version bumped from 3.14.0 to 3.15.0-SNAPSHOT * WaterName.areaToMinZoom(): improved handling of rounding and precission + added unit tests * mvn spotless:apply * water label min. zoom calculation simplified * comment adjusted to be hopefully more useful * mvn spotless:apply * minzoom for CA_TRANSCANADA and US_INTERSTATE trunk now 4 (to match OMT PR 1440) * minzoom for some other Canada trunks now 4 (to match OMT PR 1446) * equals() simplified + clean-up of comments * regenerate-openmaptiles.sh 5f7b2c11b3224759a21133381ca7d959a1f3cf51 (to match content of OMT PR 1465) * GB road relations processing adjusted to match OMT PR 1465, e.g. handle also primary and secondary roads * regenerate-openmaptiles.sh edb42f2db3c2b0ec37045367720eed84d7bbd71f (to match content of OMT PR 1466) * IE road relations processing adjusted to match OMT PR 1466, e.g. handle IE roates in similar way as GB routes * fixed handling of networkType for secondary GB routes * clean-up: case statements simplified * mvn spotless:apply * clazz calculation moved up so that minzoom can be set to 3 for only lakes (to match OMT PR 1475) * unit tests adjusted + extended to cover 'minzoom=3 fore lakes' change * fixed minor typo from previous PR * render POIs for large universities at low zoom (to match OMT PR 1479) * clean-up, to make the diff/PR smaller * regenerate-openmaptiles.sh 5e9b7c475d53a5bd5ea394da361594d3f4ce2d66 (to match content of OMT PR 1485) * handle 'grade1' and 'tracktype' as per OMT PR 1485 * added implementation of agg_stop It is based on OMT PR 1480 (which contains latest the fix) and the rest of older code (which was not worling properly until the fix). * clean-up: mvn spotless:apply * Long ferries (as per OMT PR 1486) * regenerate-openmaptiles.sh b3d67ed5b327c9059aeea0b3304772c6b4c8c7e9 (to match content of OMT PR 1489) * Add aboriginal lands (as per OMT PR 1489) * handle duplicate route relations (to match OMT PR 1501) * regenerate-openmaptiles.sh master, to match several OMT PRs which adjusted only YML * URLs in comments adjusted to match OMT PR 1560 * Convert separated addresses to dashed addresses * add brunnel (and layer) attributes only for certain zoomlevels, depending on feature size (matching OMT PR 1579) * unit test testInterstateMotorway(): brunnel tag for test line no longer available at Z8 * unit test testInterstateMotorway() clean-up: Z13 was tested twice * minor clean-up: fixed unit test naming * partial fix for differences in transportation_name layer The difference is between OpenMapTiles/master (OMT) and planetiler-openmaptiles/omt_3_15_0 (PT-OMT) (e.g. development versions). The point is, that while PT-OMT was using limit of "8km" for Z9-Z11, OMT is using limit "ST_Length(geometry) > 8000 / POWER(2, zoom_level - 9) AND zoom_level BETWEEN 9 AND 11". Some further differences still visible, hence further commits expected. * further adjustments to better match what is done with ferries in OMT ... (as per OMT PR 1486) But FERRY_MIN_PIXEL_SIZE is "too much" in the contexct of Planetiler, since it is applied within tiles, hence causes gaps in lines if a line "strikes a little" certain tile. Hence we will need to divert a little. * ferry minLength tweak + clean-up * mvn spotless:apply * fixed minor typo * minor reformatting * ferry line length filter replaced with min. zoom calculation hence the results are much closer to what OMT is doing for Z4-Z9 * testFerry() adjusted to match previous commit ferry test polygon with area 1 now qualifies for min. zoom 5 * clea-up of unused stuff + mvn spotless:apply * mvn spotless:apply * added TODO node for follow-up pull-request/simplification * clean-up: common getMinZoom() code moved to Utils * minzoom clipping for brunnel was adjusted do Z9-Z12 -> test adjusted too * clean-up * use same tolerance for all transportation items, like OSM does * clean-up, since ferry and non-ferry procesing is now same * we need regenerate to work with master branch for now * first sub-class search for agg_stop simplified a little * contains() used instead of indexOf() for better readability * numbers as list, not array, so that getFirst() and getLast() can be used * better trimming and filtring of housenumbers * adjusted handling of large house numbers * several unit tests collapsed to one with @ParameterizedTest + @CsvSource * AGG_STOP_SUBCLASS_ORDER simplified from Map to List * fixed major omission from previous commit * clamp() used to replace min()&max() combo * agg_stop now implemented * fixed typo in the error message * prepare IE and GB boundary geometry outside of synchronized{} * fixed typo in the error message * mvn spotless:apply * switch statements for IE and GB route networks simplified * avoid RouteNetwork->String mapping, not needed for anyMatch() * fix: attr. brunnel optional based on size on Z4-Z11, attr. layer optional between Z9-Z11 * tolerance change in transportation reverted, added note to README as per why * fix: monzoom for sea&co. is Z0-Z14 based on area, for the rest it is Z3-Z14 again based on area * clean-up: avoid doing area->side->area, do just area * regenerate-openmaptiles.sh 6c31841f4674f15e15afde346a060cf7c22e6cdd (to match content of OMT PR 1591) * relevant process() functions adjusted to match changes in transportation/mapping.yaml * regenerate-openmaptiles.sh master, instead of 6c31841f4674f15e15afde346a060cf7c22e6cdd (to match content of OMT PR 1591, in a cleaner way) * introduce duplicate housenumber filtering (matching OMT PR 1391) * (less related) clean-up: use isEmpty() instead if size check * testContainsHousenumber UT adjusted, since duplicate housenumber filtering is reducing amount of house numbers * use combination of uic_ref, name, network and operator as key for agg_stop sets If we rely on only on `uic_ref` we group together also stations which are too far apart (even different cities). With this combo results seem OK, e.g. all grouped stations are within around 950m (1000 pixels at Z14) of each other (1000 being used in `PARTITION BY LabelGrid(...` in `layers/poi/poi.sql` in OpenMapTiles). * agg_stop comparison made more explicit, since we want to match same exact one * mvn spotless:apply * name now important for agg_stop processing, hence name:es (ab)used for unit tests * agg_stop: simplified processing of nearest station Results still same, only ordering is different: - previously: agg_stop=1 first - now: FIFO * agg_stop: forther code simplification * fixed major typo introduced in previous merge * setMinPixelSize() + setMinZoom() used instead of areaToMinZoom() * clean-up: unused stuff removed * mvn spotless:apply * setAttrWithMinSize() used instead of getBrunnelMinzoom() getFerryMinzoom() kept since we'd like to replicate `sql_filter: ST_Length(...` from OMT * getMinZoomForLength() no longer used, hence removed * MIN_LENGTH value halved, to partially counter the effect of Planetiler applying the limit before merging * clean-up: LOG2 not used, hence removed * Revert "MIN_LENGTH value halved, to partially counter the effect of Planetiler applying the limit before merging" This reverts commit 8fb6707. * use 256px as buffer pixel override instead of MIN_LENGTH Make sure we have enough room (=whole next tile) when checking MIN_LENGTH, to avoid pieces of otherwise "long enough" lines to be excluded (thus creating "holes" or missing ends) in some tiles just because length in that particular tile is bellow limit. Given that MIN_LENGTH values translated to pixels are quite big (compared to {@code BUFFER_SIZE}), such missing pieces would be quite noticeable. This improves items mainly in Z12-Z13. * added BY_TEMP_HAS_NAME comparator to avoid its repeated construction during run-time * duplicate houcenumber processing simplified further * clean-up: get(0) replaced with getFirst() * clean-up: CPU-intensive prepare() moved out of synchronized block * regenerate-openmaptiles.sh 3cf77e2a542d8a369bb08bf2538cdde0b3effb2b (to match content of OMT PR 1423) * unit test adjusted for POI office class changes * regenerate-openmaptiles.sh master (to match content of OMT PR 1544) * added charging_station implementation matching OMT PR 1544 * use setMinPixelSizeBelowZoom() instead of uniAreaToMinZoom() * use setMinPixelSizeBelowZoom() instead of getFerryMinzoom() * fixed unit test, to match recent tweaks * regenerate-openmaptiles.sh master (to match content of OMT PR 1605) * Fix university office/amenity collision (to match OSM PR 1607) * Remove expressway from ramps * OsmMarinePoint+ne_10m_geography_marine_polys join via name limited to 50km distance * regenerate-openmaptiles.sh master (to match content of OMT PR 1604) * Revert "Add aboriginal lands (as per OMT PR 1489)" This reverts commit 899a0c5. * added handling of aboriginal_lands/OsmBoundaryPolygon into Boundary and Place layers * big islands can now get rank lower than 3 * Add e-road and a-road for transportation z4 * testPolishHighwayIssue165() adjusted: e-road now takes precendence * regenerate-openmaptiles.sh master (to match content of OMT PR 1627) * regenerate-openmaptiles.sh fff7110aeb61882abfafe22d1618fbe6181d96cb (to match content of OMT PR 1620) * Expanded road route attributes (to match OMT PR 1620) * unrelated clean-up: use getFirst() * adjusted handling or null and empty ref * regenerate-openmaptiles.sh master (to match content of OMT PR 1620) * pointOnSurface() used instead of centroid() to make sure the point is within the boundary * adjusted deduplication of route_<n>_<something> attributes * clean-up of some previous adjustments of importantMarinePoints * clean-up: removed unused imports * mvn spotless:apply
1 parent 47fb586 commit ae33e95

13 files changed

+608
-227
lines changed

src/main/java/org/openmaptiles/generated/OpenMapTilesSchema.java

+153-52
Large diffs are not rendered by default.

src/main/java/org/openmaptiles/generated/Tables.java

+63-44
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,9 @@ public OsmParkPolygon(SourceFeature source, String mappingKey) {
248248
}
249249

250250
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
251-
public static final Expression MAPPING = and(or(matchAny("leisure", "nature_reserve"),
252-
matchAny("boundary", "national_park", "protected_area", "aboriginal_lands")), matchType("polygon"));
251+
public static final Expression MAPPING =
252+
and(or(matchAny("leisure", "nature_reserve"), matchAny("boundary", "national_park", "protected_area")),
253+
matchType("polygon"));
253254

254255
/**
255256
* Interface for layer implementations to extend to subscribe to OSM elements filtered and parsed as
@@ -259,6 +260,25 @@ public interface Handler {
259260
void process(OsmParkPolygon element, FeatureCollector features);
260261
}
261262
}
263+
/** An OSM element that would appear in the {@code osm_boundary_polygon} table generated by imposm3. */
264+
public record OsmBoundaryPolygon(@Override String name, @Override String boundary, @Override SourceFeature source)
265+
implements Row, WithName, WithBoundary, WithSource {
266+
public OsmBoundaryPolygon(SourceFeature source, String mappingKey) {
267+
this(source.getString("name"), source.getString("boundary"), source);
268+
}
269+
270+
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
271+
public static final Expression MAPPING =
272+
and(matchAny("boundary", "aboriginal_lands"), matchAny("type", "boundary"), matchType("polygon"));
273+
274+
/**
275+
* Interface for layer implementations to extend to subscribe to OSM elements filtered and parsed as
276+
* {@link OsmBoundaryPolygon}.
277+
*/
278+
public interface Handler {
279+
void process(OsmBoundaryPolygon element, FeatureCollector features);
280+
}
281+
}
262282
/** An OSM element that would appear in the {@code osm_aeroway_polygon} table generated by imposm3. */
263283
public record OsmAerowayPolygon(@Override String ref, @Override String aeroway, @Override SourceFeature source)
264284
implements Row, WithRef, WithAeroway, WithSource {
@@ -320,24 +340,23 @@ public interface Handler {
320340
public record OsmHighwayLinestring(@Override String highway, @Override String construction,
321341
@Override String tracktype, @Override String ref, @Override String network, @Override int zOrder,
322342
@Override long layer, @Override long level, @Override boolean indoor, @Override String name,
323-
@Override String nameEn, @Override String nameDe, @Override String shortName, @Override boolean isTunnel,
324-
@Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord, @Override int isOneway,
325-
@Override boolean isArea, @Override String service, @Override String access, @Override boolean toll,
326-
@Override String usage, @Override String publicTransport, @Override String manMade, @Override String bicycle,
327-
@Override String foot, @Override String horse, @Override String mtbScale, @Override String sacScale,
328-
@Override String surface, @Override boolean expressway, @Override SourceFeature source)
343+
@Override String nameEn, @Override String nameDe, @Override boolean isTunnel, @Override boolean isBridge,
344+
@Override boolean isRamp, @Override boolean isFord, @Override int isOneway, @Override boolean isArea,
345+
@Override String service, @Override String access, @Override boolean toll, @Override String usage,
346+
@Override String publicTransport, @Override String manMade, @Override String bicycle, @Override String foot,
347+
@Override String horse, @Override String mtbScale, @Override String sacScale, @Override String surface,
348+
@Override boolean expressway, @Override SourceFeature source)
329349
implements Row, WithHighway, WithConstruction, WithTracktype, WithRef, WithNetwork, WithZOrder, WithLayer,
330-
WithLevel, WithIndoor, WithName, WithNameEn, WithNameDe, WithShortName, WithIsTunnel, WithIsBridge, WithIsRamp,
331-
WithIsFord, WithIsOneway, WithIsArea, WithService, WithAccess, WithToll, WithUsage, WithPublicTransport,
332-
WithManMade, WithBicycle, WithFoot, WithHorse, WithMtbScale, WithSacScale, WithSurface, WithExpressway, WithSource {
350+
WithLevel, WithIndoor, WithName, WithNameEn, WithNameDe, WithIsTunnel, WithIsBridge, WithIsRamp, WithIsFord,
351+
WithIsOneway, WithIsArea, WithService, WithAccess, WithToll, WithUsage, WithPublicTransport, WithManMade,
352+
WithBicycle, WithFoot, WithHorse, WithMtbScale, WithSacScale, WithSurface, WithExpressway, WithSource {
333353
public OsmHighwayLinestring(SourceFeature source, String mappingKey) {
334354
this(source.getString("highway"), source.getString("construction"), source.getString("tracktype"),
335355
source.getString("ref"), source.getString("network"), source.getWayZorder(), source.getLong("layer"),
336356
source.getLong("level"), source.getBoolean("indoor"), source.getString("name"), source.getString("name:en"),
337-
source.getString("name:de"), source.getString("short_name"), source.getBoolean("tunnel"),
338-
source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"),
339-
source.getDirection("oneway"), source.getBoolean("area"), source.getString("service"),
340-
source.getString("access"), source.getBoolean("toll"), source.getString("usage"),
357+
source.getString("name:de"), source.getBoolean("tunnel"), source.getBoolean("bridge"),
358+
source.getBoolean("ramp"), source.getBoolean("ford"), source.getDirection("oneway"), source.getBoolean("area"),
359+
source.getString("service"), source.getString("access"), source.getBoolean("toll"), source.getString("usage"),
341360
source.getString("public_transport"), source.getString("man_made"), source.getString("bicycle"),
342361
source.getString("foot"), source.getString("horse"), source.getString("mtb:scale"),
343362
source.getString("sac_scale"), source.getString("surface"), source.getBoolean("expressway"), source);
@@ -363,17 +382,17 @@ public interface Handler {
363382
/** An OSM element that would appear in the {@code osm_railway_linestring} table generated by imposm3. */
364383
public record OsmRailwayLinestring(@Override String railway, @Override String ref, @Override String network,
365384
@Override int zOrder, @Override long layer, @Override long level, @Override boolean indoor, @Override String name,
366-
@Override String nameEn, @Override String nameDe, @Override String shortName, @Override boolean isTunnel,
367-
@Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord, @Override boolean isArea,
368-
@Override String service, @Override String usage, @Override SourceFeature source) implements Row, WithRailway,
369-
WithRef, WithNetwork, WithZOrder, WithLayer, WithLevel, WithIndoor, WithName, WithNameEn, WithNameDe, WithShortName,
370-
WithIsTunnel, WithIsBridge, WithIsRamp, WithIsFord, WithIsArea, WithService, WithUsage, WithSource {
385+
@Override String nameEn, @Override String nameDe, @Override boolean isTunnel, @Override boolean isBridge,
386+
@Override boolean isRamp, @Override boolean isFord, @Override boolean isArea, @Override String service,
387+
@Override String usage, @Override SourceFeature source) implements Row, WithRailway, WithRef, WithNetwork,
388+
WithZOrder, WithLayer, WithLevel, WithIndoor, WithName, WithNameEn, WithNameDe, WithIsTunnel, WithIsBridge,
389+
WithIsRamp, WithIsFord, WithIsArea, WithService, WithUsage, WithSource {
371390
public OsmRailwayLinestring(SourceFeature source, String mappingKey) {
372391
this(source.getString("railway"), source.getString("ref"), source.getString("network"), source.getWayZorder(),
373392
source.getLong("layer"), source.getLong("level"), source.getBoolean("indoor"), source.getString("name"),
374-
source.getString("name:en"), source.getString("name:de"), source.getString("short_name"),
375-
source.getBoolean("tunnel"), source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"),
376-
source.getBoolean("area"), source.getString("service"), source.getString("usage"), source);
393+
source.getString("name:en"), source.getString("name:de"), source.getBoolean("tunnel"),
394+
source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"), source.getBoolean("area"),
395+
source.getString("service"), source.getString("usage"), source);
377396
}
378397

379398
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
@@ -391,16 +410,15 @@ public interface Handler {
391410
}
392411
/** An OSM element that would appear in the {@code osm_aerialway_linestring} table generated by imposm3. */
393412
public record OsmAerialwayLinestring(@Override String aerialway, @Override int zOrder, @Override long layer,
394-
@Override String name, @Override String nameEn, @Override String nameDe, @Override String shortName,
395-
@Override boolean isTunnel, @Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord,
396-
@Override int isOneway, @Override boolean isArea, @Override String service, @Override String usage,
397-
@Override SourceFeature source)
398-
implements Row, WithAerialway, WithZOrder, WithLayer, WithName, WithNameEn, WithNameDe, WithShortName, WithIsTunnel,
399-
WithIsBridge, WithIsRamp, WithIsFord, WithIsOneway, WithIsArea, WithService, WithUsage, WithSource {
413+
@Override String name, @Override String nameEn, @Override String nameDe, @Override boolean isTunnel,
414+
@Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord, @Override int isOneway,
415+
@Override boolean isArea, @Override String service, @Override String usage, @Override SourceFeature source)
416+
implements Row, WithAerialway, WithZOrder, WithLayer, WithName, WithNameEn, WithNameDe, WithIsTunnel, WithIsBridge,
417+
WithIsRamp, WithIsFord, WithIsOneway, WithIsArea, WithService, WithUsage, WithSource {
400418
public OsmAerialwayLinestring(SourceFeature source, String mappingKey) {
401419
this(source.getString("aerialway"), source.getWayZorder(), source.getLong("layer"), source.getString("name"),
402-
source.getString("name:en"), source.getString("name:de"), source.getString("short_name"),
403-
source.getBoolean("tunnel"), source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"),
420+
source.getString("name:en"), source.getString("name:de"), source.getBoolean("tunnel"),
421+
source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"),
404422
source.getDirection("oneway"), source.getBoolean("area"), source.getString("service"),
405423
source.getString("usage"), source);
406424
}
@@ -419,16 +437,16 @@ public interface Handler {
419437
}
420438
/** An OSM element that would appear in the {@code osm_shipway_linestring} table generated by imposm3. */
421439
public record OsmShipwayLinestring(@Override String shipway, @Override int zOrder, @Override long layer,
422-
@Override String name, @Override String nameEn, @Override String nameDe, @Override String shortName,
423-
@Override boolean isTunnel, @Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord,
424-
@Override boolean isArea, @Override String service, @Override String usage, @Override SourceFeature source)
425-
implements Row, WithShipway, WithZOrder, WithLayer, WithName, WithNameEn, WithNameDe, WithShortName, WithIsTunnel,
426-
WithIsBridge, WithIsRamp, WithIsFord, WithIsArea, WithService, WithUsage, WithSource {
440+
@Override String name, @Override String nameEn, @Override String nameDe, @Override boolean isTunnel,
441+
@Override boolean isBridge, @Override boolean isRamp, @Override boolean isFord, @Override boolean isArea,
442+
@Override String service, @Override String usage, @Override SourceFeature source)
443+
implements Row, WithShipway, WithZOrder, WithLayer, WithName, WithNameEn, WithNameDe, WithIsTunnel, WithIsBridge,
444+
WithIsRamp, WithIsFord, WithIsArea, WithService, WithUsage, WithSource {
427445
public OsmShipwayLinestring(SourceFeature source, String mappingKey) {
428446
this(source.getString("route"), source.getWayZorder(), source.getLong("layer"), source.getString("name"),
429-
source.getString("name:en"), source.getString("name:de"), source.getString("short_name"),
430-
source.getBoolean("tunnel"), source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"),
431-
source.getBoolean("area"), source.getString("service"), source.getString("usage"), source);
447+
source.getString("name:en"), source.getString("name:de"), source.getBoolean("tunnel"),
448+
source.getBoolean("bridge"), source.getBoolean("ramp"), source.getBoolean("ford"), source.getBoolean("area"),
449+
source.getString("service"), source.getString("usage"), source);
432450
}
433451

434452
/** Imposm3 "mapping" to filter OSM elements that should appear in this "table". */
@@ -1236,11 +1254,6 @@ public interface WithShipway {
12361254
String shipway();
12371255
}
12381256

1239-
/** Rows with a String shortName attribute. */
1240-
public interface WithShortName {
1241-
String shortName();
1242-
}
1243-
12441257
/** Rows with a SourceFeature source attribute. */
12451258
public interface WithSource {
12461259
SourceFeature source();
@@ -1331,6 +1344,8 @@ public interface WithZOrder {
13311344
OsmMountainLinestring.MAPPING),
13321345
MultiExpression.entry(new RowClassAndConstructor(OsmParkPolygon.class, OsmParkPolygon::new),
13331346
OsmParkPolygon.MAPPING),
1347+
MultiExpression.entry(new RowClassAndConstructor(OsmBoundaryPolygon.class, OsmBoundaryPolygon::new),
1348+
OsmBoundaryPolygon.MAPPING),
13341349
MultiExpression.entry(new RowClassAndConstructor(OsmAerowayPolygon.class, OsmAerowayPolygon::new),
13351350
OsmAerowayPolygon.MAPPING),
13361351
MultiExpression.entry(new RowClassAndConstructor(OsmAerowayLinestring.class, OsmAerowayLinestring::new),
@@ -1406,6 +1421,10 @@ public static Map<Class<? extends Row>, List<RowHandlerAndClass<?>>> generateDis
14061421
result.computeIfAbsent(OsmParkPolygon.class, cls -> new ArrayList<>())
14071422
.add(new RowHandlerAndClass<>(typedHandler.getClass(), typedHandler::process));
14081423
}
1424+
if (handler instanceof OsmBoundaryPolygon.Handler typedHandler) {
1425+
result.computeIfAbsent(OsmBoundaryPolygon.class, cls -> new ArrayList<>())
1426+
.add(new RowHandlerAndClass<>(typedHandler.getClass(), typedHandler::process));
1427+
}
14091428
if (handler instanceof OsmAerowayPolygon.Handler typedHandler) {
14101429
result.computeIfAbsent(OsmAerowayPolygon.class, cls -> new ArrayList<>())
14111430
.add(new RowHandlerAndClass<>(typedHandler.getClass(), typedHandler::process));

src/main/java/org/openmaptiles/layers/Boundary.java

+14
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7979
import org.locationtech.jts.operation.polygonize.Polygonizer;
8080
import org.openmaptiles.OpenMapTilesProfile;
8181
import org.openmaptiles.generated.OpenMapTilesSchema;
82+
import org.openmaptiles.generated.Tables;
83+
import org.openmaptiles.util.OmtLanguageUtils;
8284
import org.slf4j.Logger;
8385
import org.slf4j.LoggerFactory;
8486

@@ -95,6 +97,7 @@ public class Boundary implements
9597
OpenMapTilesProfile.NaturalEarthProcessor,
9698
OpenMapTilesProfile.OsmRelationPreprocessor,
9799
OpenMapTilesProfile.OsmAllProcessor,
100+
Tables.OsmBoundaryPolygon.Handler,
98101
OpenMapTilesProfile.FeaturePostProcessor,
99102
OpenMapTilesProfile.FinishHandler {
100103

@@ -127,6 +130,7 @@ public class Boundary implements
127130
private final Map<Long, List<Geometry>> regionGeometries = new HashMap<>();
128131
private final Map<CountryBoundaryComponent, List<Geometry>> boundariesToMerge = new HashMap<>();
129132
private final PlanetilerConfig config;
133+
private final Translations translations;
130134

131135
public Boundary(Translations translations, PlanetilerConfig config, Stats stats) {
132136
this.config = config;
@@ -141,6 +145,7 @@ public Boundary(Translations translations, PlanetilerConfig config, Stats stats)
141145
false
142146
);
143147
this.stats = stats;
148+
this.translations = translations;
144149
}
145150

146151
private static boolean isDisputed(Map<String, Object> tags) {
@@ -306,6 +311,15 @@ public void processAllOsm(SourceFeature feature, FeatureCollector features) {
306311
}
307312
}
308313

314+
@Override
315+
public void process(Tables.OsmBoundaryPolygon element, FeatureCollector features) {
316+
features.polygon(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
317+
.putAttrs(OmtLanguageUtils.getNames(element.source().tags(), translations))
318+
.setAttr(OpenMapTilesSchema.Boundary.Fields.CLASS, element.boundary())
319+
.setMinPixelSizeBelowZoom(13, 4) // for Z4: `sql_filter: area>power(ZRES3,2)`, etc.
320+
.setMinZoom(4);
321+
}
322+
309323
@Override
310324
public void finish(String sourceName, FeatureCollector.Factory featureCollectors,
311325
Consumer<FeatureCollector.Feature> emit) {

src/main/java/org/openmaptiles/layers/Park.java

+8-13
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,15 @@ public Park(Translations translations, PlanetilerConfig config, Stats stats) {
9191

9292
@Override
9393
public void process(Tables.OsmParkPolygon element, FeatureCollector features) {
94-
String clazz;
95-
if ("aboriginal_lands".equals(element.boundary())) {
96-
clazz = "aboriginal_lands";
97-
} else {
98-
String protectionTitle = element.protectionTitle();
99-
if (protectionTitle != null) {
100-
protectionTitle = protectionTitle.replace(' ', '_').toLowerCase(Locale.ROOT);
101-
}
102-
clazz = coalesce(
103-
nullIfEmpty(protectionTitle),
104-
nullIfEmpty(element.boundary()),
105-
nullIfEmpty(element.leisure())
106-
);
94+
String protectionTitle = element.protectionTitle();
95+
if (protectionTitle != null) {
96+
protectionTitle = protectionTitle.replace(' ', '_').toLowerCase(Locale.ROOT);
10797
}
98+
String clazz = coalesce(
99+
nullIfEmpty(protectionTitle),
100+
nullIfEmpty(element.boundary()),
101+
nullIfEmpty(element.leisure())
102+
);
108103

109104
// park shape
110105
var outline = features.polygon(LAYER_NAME).setBufferPixels(BUFFER_SIZE)

src/main/java/org/openmaptiles/layers/Place.java

+23-3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public class Place implements
8888
Tables.OsmIslandPoint.Handler,
8989
Tables.OsmIslandPolygon.Handler,
9090
Tables.OsmCityPoint.Handler,
91+
Tables.OsmBoundaryPolygon.Handler,
9192
OpenMapTilesProfile.FeaturePostProcessor {
9293

9394
/*
@@ -96,8 +97,10 @@ public class Place implements
9697
* and minimum zoom level to use for those points.
9798
*/
9899

99-
private static final TreeMap<Double, Integer> ISLAND_AREA_RANKS = new TreeMap<>(Map.of(
100-
Double.MAX_VALUE, 3,
100+
private static final TreeMap<Double, Integer> AREA_RANKS = new TreeMap<>(Map.of(
101+
Double.MAX_VALUE, 1,
102+
squareMetersToWorldArea(640_000_000), 2,
103+
squareMetersToWorldArea(160_000_000), 3,
101104
squareMetersToWorldArea(40_000_000), 4,
102105
squareMetersToWorldArea(15_000_000), 5,
103106
squareMetersToWorldArea(1_000_000), 6
@@ -282,7 +285,7 @@ public void process(Tables.OsmStatePoint element, FeatureCollector features) {
282285
public void process(Tables.OsmIslandPolygon element, FeatureCollector features) {
283286
try {
284287
double area = element.source().area();
285-
int rank = ISLAND_AREA_RANKS.ceilingEntry(area).getValue();
288+
int rank = AREA_RANKS.ceilingEntry(area).getValue();
286289
int minzoom = rank <= 3 ? 8 : rank <= 4 ? 9 : 10;
287290

288291
features.pointOnSurface(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
@@ -369,6 +372,23 @@ public void process(Tables.OsmCityPoint element, FeatureCollector features) {
369372
}
370373
}
371374

375+
@Override
376+
public void process(Tables.OsmBoundaryPolygon element, FeatureCollector features) {
377+
try {
378+
int rank = AREA_RANKS.ceilingEntry(element.source().area()).getValue();
379+
int minzoom = rank <= 4 ? rank + 5 : 10;
380+
381+
features.pointOnSurface(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
382+
.putAttrs(OmtLanguageUtils.getNames(element.source().tags(), translations))
383+
.setAttr(OpenMapTilesSchema.Boundary.Fields.CLASS, element.boundary())
384+
.setAttr(Fields.RANK, rank)
385+
.setMinZoom(minzoom);
386+
} catch (GeometryException e) {
387+
e.log(stats, "omt_boundary_poly",
388+
"Unable to get point for OSM boundary polygon " + element.source().id());
389+
}
390+
}
391+
372392
@Override
373393
public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> items) {
374394
// infer the rank field from ordering of the place labels with each label grid square

0 commit comments

Comments
 (0)