From 0a2565de763397a7a8dfb948a0335118f23294da Mon Sep 17 00:00:00 2001 From: Peter Hanecak Date: Mon, 23 Oct 2023 14:53:07 +0200 Subject: [PATCH 1/2] use same tolerance for all transportation items, like OSM does --- src/main/java/org/openmaptiles/layers/Transportation.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/openmaptiles/layers/Transportation.java b/src/main/java/org/openmaptiles/layers/Transportation.java index 6408c015..3dd3dbba 100644 --- a/src/main/java/org/openmaptiles/layers/Transportation.java +++ b/src/main/java/org/openmaptiles/layers/Transportation.java @@ -157,7 +157,7 @@ public class Transportation implements .put(5, 500) .put(4, 1_000); // "shipway_linestring_gen_z5: ... tolerance: ZRES6", etc. when recalculated from meters to pixels is always: - private static final double FERRY_TOLERANCE = 0.5; + private static final double TOLERANCE = 0.5; // ORDER BY network_type, network, LENGTH(ref), ref) private static final Comparator RELATION_ORDERING = Comparator .comparingInt( @@ -680,12 +680,11 @@ private List postProcessItems(int zoom, List postProcessAllOrNonFerry(int zoom, List items) { - // TODO: use same tolerance as for ferries (see tolerances in OMT `transportation/mapping.yaml`), hence no need to split ferries from the rest in postProcess() - return postProcessItems(zoom, items, config.tolerance(zoom)); + return postProcessItems(zoom, items, TOLERANCE); } private List postProcessFerry(int zoom, List items) { - return postProcessItems(zoom, items, FERRY_TOLERANCE); + return postProcessItems(zoom, items, TOLERANCE); } @Override From 59b3078cbabc35cf51d30bf08bc8e53b661cb91b Mon Sep 17 00:00:00 2001 From: Peter Hanecak Date: Mon, 23 Oct 2023 15:05:05 +0200 Subject: [PATCH 2/2] clean-up, since ferry and non-ferry procesing is now same --- .../openmaptiles/layers/Transportation.java | 37 ++----------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/openmaptiles/layers/Transportation.java b/src/main/java/org/openmaptiles/layers/Transportation.java index 3dd3dbba..1a6d9411 100644 --- a/src/main/java/org/openmaptiles/layers/Transportation.java +++ b/src/main/java/org/openmaptiles/layers/Transportation.java @@ -156,8 +156,6 @@ public class Transportation implements .put(6, 100) .put(5, 500) .put(4, 1_000); - // "shipway_linestring_gen_z5: ... tolerance: ZRES6", etc. when recalculated from meters to pixels is always: - private static final double TOLERANCE = 0.5; // ORDER BY network_type, network, LENGTH(ref), ref) private static final Comparator RELATION_ORDERING = Comparator .comparingInt( @@ -658,7 +656,8 @@ public void process(Tables.OsmHighwayPolygon element, FeatureCollector features) } } - private List postProcessItems(int zoom, List items, double tolerance) { + @Override + public List postProcess(int zoom, List items) { double minLength = coalesce(MIN_LENGTH.apply(zoom), 0).doubleValue(); // don't merge road segments with oneway tag @@ -671,7 +670,8 @@ private List postProcessItems(int zoom, List postProcessItems(int zoom, List postProcessAllOrNonFerry(int zoom, List items) { - return postProcessItems(zoom, items, TOLERANCE); - } - - private List postProcessFerry(int zoom, List items) { - return postProcessItems(zoom, items, TOLERANCE); - } - - @Override - public List postProcess(int zoom, List items) { - if (zoom < 4 || zoom > 10) { - return postProcessAllOrNonFerry(zoom, items); - } else { - // ferries at Z4-Z10 need different treatment - List ferryItems = new ArrayList<>(); - List otherItems = new ArrayList<>(); - for (var item : items) { - if (FieldValues.CLASS_FERRY.equals(item.attrs().get(Fields.CLASS))) { - ferryItems.add(item); - } else { - otherItems.add(item); - } - } - var result = postProcessFerry(zoom, ferryItems); - result.addAll(postProcessAllOrNonFerry(zoom, otherItems)); - return result; - } - } - enum RouteNetwork { US_INTERSTATE("us-interstate"),