From 69393d0b8552f3cc86c8eccd4bc233ef6ed346db Mon Sep 17 00:00:00 2001 From: Peter Hanecak Date: Tue, 19 Dec 2023 11:29:44 +0100 Subject: [PATCH] use setMinPixelSizeBelowZoom() instead of uniAreaToMinZoom() --- .../java/org/openmaptiles/layers/Poi.java | 23 ++------- .../java/org/openmaptiles/layers/PoiTest.java | 49 ------------------- 2 files changed, 4 insertions(+), 68 deletions(-) diff --git a/src/main/java/org/openmaptiles/layers/Poi.java b/src/main/java/org/openmaptiles/layers/Poi.java index 63d4775c..084f5835 100644 --- a/src/main/java/org/openmaptiles/layers/Poi.java +++ b/src/main/java/org/openmaptiles/layers/Poi.java @@ -123,8 +123,6 @@ public class Poi implements private static final Comparator BY_SUBCLASS = Comparator .comparingInt(s -> AGG_STOP_SUBCLASS_ORDER.indexOf(s.subclass())); private static final Set BRAND_OPERATOR_REF_SUBCLASSES = Set.of("charging_station", "parcel_locker"); - private static final double LOG2 = Math.log(2); - private static final double SQRT10 = Math.sqrt(10); private final MultiExpression.Index classMapping; private final Translations translations; private final Stats stats; @@ -154,14 +152,6 @@ private int minzoom(String subclass, String mappingKey) { return lowZoom ? 12 : 14; } - public static int uniAreaToMinZoom(double areaWorld) { - double oneSideWorld = Math.sqrt(areaWorld); - double zoom = -(Math.log(oneSideWorld * SQRT10) / LOG2); - int result = (int) Math.floor(zoom - 0.1e-10) + 1; - - return Math.clamp(result, 10, 14); - } - @Override public void release() { aggStops.clear(); @@ -308,16 +298,11 @@ private testEntries, double area, int expectedZoom, String name) { - var feature = polygonFeatureWithArea(area, Map.of( - "name", name, - "amenity", "university" - )); - testEntries.add(new TestEntry( - feature, - Math.clamp(expectedZoom, 10, 14) - )); - } - - @Test - void testUniAreaToMinZoom() throws GeometryException { - // threshold is 1/10 of tile area, hence ... - // ... side is 1/sqrt(10) tile side: from pixels to world coord, for say Z14 ... - //final double PORTION_OF_TILE_SIDE = (256d / Math.sqrt(10)) / Math.pow(2d, 14d + 8d); - // ... and then for some lower zoom: - //double testAreaSide = PORTION_OF_TILE_SIDE * Math.pow(2, 14 - zoom); - // all this then simplified to `testArea` calculation bellow - - final List testEntries = new ArrayList<>(); - for (int zoom = 14; zoom >= 0; zoom--) { - double testArea = Math.pow(4, -zoom) / 10; - - // slightly bellow the threshold - createUniAreaForMinZoomTest(testEntries, testArea * 0.999, zoom + 1, "uni-"); - // precisely at the threshold - createUniAreaForMinZoomTest(testEntries, testArea, zoom, "uni="); - // slightly over the threshold - createUniAreaForMinZoomTest(testEntries, testArea * 1.001, zoom, "uni+"); - } - - for (var entry : testEntries) { - assertFeatures(14, List.of(Map.of( - "_layer", "landuse", - "class", "university" - ), Map.of( - "_layer", "poi", - "_type", "point", - "_minzoom", entry.expectedZoom, - "_maxzoom", 14 - )), process(entry.feature)); - } - } }