diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Places.java b/tiles/src/main/java/com/protomaps/basemap/layers/Places.java index 342cf5c8..3df3cdd1 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Places.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Places.java @@ -36,13 +36,15 @@ static int getSortKey(double minZoom, int kindRank, int populationRank, long pop // (nvkelso 20230803) floats with significant single decimal precision // but results in "Too many possible values" // Order ASCENDING (smaller manually curated Natural Earth min_zoom win over larger values, across kinds) - .orderByInt((int) minZoom, 0, 15) + // minZoom is a float with 1 significant digit for manually curated places + .orderByInt((int) (minZoom * 10), 0, 150) // Order ASCENDING (smaller values win, countries then locality then neighbourhood, breaks ties for same minZoom) - .thenByInt(kindRank, 0, 6) + .thenByInt(kindRank, 0, 12) // Order DESCENDING (larger values win, San Francisco rank 11 wins over Oakland rank 10) - .thenByInt(populationRank, 15, 0) + // Disabled to allow population log to have larger range + //.thenByInt(populationRank, 15, 0) // Order DESCENDING (larger values win, Millbrea 40k wins over San Bruno 20k, both rank 7) - .thenByLog(population, 1000000000, 1, 100) + .thenByLog(population, 40000000, 1, 100) // Order ASCENDING (shorter strings are better than longer strings for map display and adds predictability) .thenByInt(name == null ? 0 : name.length(), 0, 31) .get(); @@ -55,15 +57,30 @@ static int getSortKey(double minZoom, int kindRank, int populationRank, long pop private static final ZoomFunction LOCALITY_GRID_SIZE_ZOOM_FUNCTION = ZoomFunction.fromMaxZoomThresholds(Map.of( - 6, 32, - 7, 64 + 3, 24, + 4, 24, + 5, 24, + 7, 24, + 8, 32, + 9, 32, + 10, 32, + 11, 24, + 14, 24, + 15, 16 ), 0); private static final ZoomFunction LOCALITY_GRID_LIMIT_ZOOM_FUNCTION = ZoomFunction.fromMaxZoomThresholds(Map.of( - 6, 8, - 7, 6, - 9, 4 + 3, 1, + 4, 1, + 5, 1, + 6, 1, + 8, 1, + 9, 1, + 10, 1, + 11, 1, + 14, 2, + 15, 3 ), 0); public void processOsm(SourceFeature sf, FeatureCollector features) { @@ -148,7 +165,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) { // This minZoom can be changed to smaller value in the NE data join step below minZoom = 11.0f; maxZoom = 15.0f; - kindRank = 3; + kindRank = 4; if (population == 0) { minZoom = 12.0f; population = 1000; @@ -159,7 +176,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) { // This minZoom can be changed to smaller value in the NE data join step below minZoom = 11.0f; maxZoom = 15.0f; - kindRank = 3; + kindRank = 5; if (population == 0) { minZoom = 12.0f; population = 200; @@ -170,7 +187,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) { // This minZoom can be changed to smaller value in the NE data join step below minZoom = 13.0f; maxZoom = 15.0f; - kindRank = 3; + kindRank = 6; if (population == 0) { minZoom = 14.0f; population = 100; @@ -181,7 +198,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) { // This minZoom can be changed to smaller value in the NE data join step below minZoom = 13.0f; maxZoom = 15.0f; - kindRank = 3; + kindRank = 7; if (population == 0) { minZoom = 14.0f; population = 50; @@ -193,7 +210,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) { // This minZoom can be changed to smaller value in the NE data join step below minZoom = 13.0f; maxZoom = 15.0f; - kindRank = 3; + kindRank = 8; if (population == 0) { minZoom = 14.0f; population = 1000; @@ -204,19 +221,19 @@ public void processOsm(SourceFeature sf, FeatureCollector features) { kind = "neighbourhood"; minZoom = 11.0f; maxZoom = 15.0f; - kindRank = 4; + kindRank = 9; break; case "quarter": kind = "macrohood"; minZoom = 10.0f; maxZoom = 15.0f; - kindRank = 5; + kindRank = 10; break; case "neighbourhood": kind = "neighbourhood"; minZoom = 12.0f; maxZoom = 15.0f; - kindRank = 6; + kindRank = 11; break; } @@ -287,12 +304,14 @@ public void processOsm(SourceFeature sf, FeatureCollector features) { //feat.setSortKey(minZoom * 1000 + 400 - populationRank * 200 + placeNumber.incrementAndGet()); feat.setSortKey(getSortKey(minZoom, kindRank, populationRank, population, sf.getString("name"))); + // This is only necessary when prepping for raster renderers + feat.setBufferPixels(16); + // We set the sort keys so the label grid can be sorted predictably (bonus: tile features also sorted) // NOTE: The buffer needs to be consistent with the innteral grid pixel sizes //feat.setPointLabelGridSizeAndLimit(13, 64, 4); // each cell in the 4x4 grid can have 4 items feat.setPointLabelGridPixelSize(LOCALITY_GRID_SIZE_ZOOM_FUNCTION) - .setPointLabelGridLimit(LOCALITY_GRID_LIMIT_ZOOM_FUNCTION) - .setBufferPixels(64); + .setPointLabelGridLimit(LOCALITY_GRID_LIMIT_ZOOM_FUNCTION); // and also whenever you set a label grid size limit, make sure you increase the buffer size so no // label grid squares will be the consistent between adjacent tiles