@@ -36,13 +36,15 @@ static int getSortKey(double minZoom, int kindRank, int populationRank, long pop
36
36
// (nvkelso 20230803) floats with significant single decimal precision
37
37
// but results in "Too many possible values"
38
38
// Order ASCENDING (smaller manually curated Natural Earth min_zoom win over larger values, across kinds)
39
- .orderByInt ((int ) minZoom , 0 , 15 )
39
+ // minZoom is a float with 1 significant digit for manually curated places
40
+ .orderByInt ((int )(minZoom * 10 ), 0 , 150 )
40
41
// Order ASCENDING (smaller values win, countries then locality then neighbourhood, breaks ties for same minZoom)
41
- .thenByInt (kindRank , 0 , 6 )
42
+ .thenByInt (kindRank , 0 , 12 )
42
43
// Order DESCENDING (larger values win, San Francisco rank 11 wins over Oakland rank 10)
43
- .thenByInt (populationRank , 15 , 0 )
44
+ // Disabled to allow population log to have larger range
45
+ //.thenByInt(populationRank, 15, 0)
44
46
// Order DESCENDING (larger values win, Millbrea 40k wins over San Bruno 20k, both rank 7)
45
- .thenByLog (population , 1000000000 , 1 , 100 )
47
+ .thenByLog (population , 40000000 , 1 , 100 )
46
48
// Order ASCENDING (shorter strings are better than longer strings for map display and adds predictability)
47
49
.thenByInt (name == null ? 0 : name .length (), 0 , 31 )
48
50
.get ();
@@ -55,15 +57,30 @@ static int getSortKey(double minZoom, int kindRank, int populationRank, long pop
55
57
56
58
private static final ZoomFunction <Number > LOCALITY_GRID_SIZE_ZOOM_FUNCTION =
57
59
ZoomFunction .fromMaxZoomThresholds (Map .of (
58
- 6 , 32 ,
59
- 7 , 64
60
+ 3 , 24 ,
61
+ 4 , 24 ,
62
+ 5 , 24 ,
63
+ 7 , 24 ,
64
+ 8 , 32 ,
65
+ 9 , 32 ,
66
+ 10 , 32 ,
67
+ 11 , 24 ,
68
+ 14 , 24 ,
69
+ 15 , 16
60
70
), 0 );
61
71
62
72
private static final ZoomFunction <Number > LOCALITY_GRID_LIMIT_ZOOM_FUNCTION =
63
73
ZoomFunction .fromMaxZoomThresholds (Map .of (
64
- 6 , 8 ,
65
- 7 , 6 ,
66
- 9 , 4
74
+ 3 , 1 ,
75
+ 4 , 1 ,
76
+ 5 , 1 ,
77
+ 6 , 1 ,
78
+ 8 , 1 ,
79
+ 9 , 1 ,
80
+ 10 , 1 ,
81
+ 11 , 1 ,
82
+ 14 , 2 ,
83
+ 15 , 3
67
84
), 0 );
68
85
69
86
public void processOsm (SourceFeature sf , FeatureCollector features ) {
@@ -148,7 +165,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
148
165
// This minZoom can be changed to smaller value in the NE data join step below
149
166
minZoom = 11.0f ;
150
167
maxZoom = 15.0f ;
151
- kindRank = 3 ;
168
+ kindRank = 4 ;
152
169
if (population == 0 ) {
153
170
minZoom = 12.0f ;
154
171
population = 1000 ;
@@ -159,7 +176,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
159
176
// This minZoom can be changed to smaller value in the NE data join step below
160
177
minZoom = 11.0f ;
161
178
maxZoom = 15.0f ;
162
- kindRank = 3 ;
179
+ kindRank = 5 ;
163
180
if (population == 0 ) {
164
181
minZoom = 12.0f ;
165
182
population = 200 ;
@@ -170,7 +187,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
170
187
// This minZoom can be changed to smaller value in the NE data join step below
171
188
minZoom = 13.0f ;
172
189
maxZoom = 15.0f ;
173
- kindRank = 3 ;
190
+ kindRank = 6 ;
174
191
if (population == 0 ) {
175
192
minZoom = 14.0f ;
176
193
population = 100 ;
@@ -181,7 +198,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
181
198
// This minZoom can be changed to smaller value in the NE data join step below
182
199
minZoom = 13.0f ;
183
200
maxZoom = 15.0f ;
184
- kindRank = 3 ;
201
+ kindRank = 7 ;
185
202
if (population == 0 ) {
186
203
minZoom = 14.0f ;
187
204
population = 50 ;
@@ -193,7 +210,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
193
210
// This minZoom can be changed to smaller value in the NE data join step below
194
211
minZoom = 13.0f ;
195
212
maxZoom = 15.0f ;
196
- kindRank = 3 ;
213
+ kindRank = 8 ;
197
214
if (population == 0 ) {
198
215
minZoom = 14.0f ;
199
216
population = 1000 ;
@@ -204,19 +221,19 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
204
221
kind = "neighbourhood" ;
205
222
minZoom = 11.0f ;
206
223
maxZoom = 15.0f ;
207
- kindRank = 4 ;
224
+ kindRank = 9 ;
208
225
break ;
209
226
case "quarter" :
210
227
kind = "macrohood" ;
211
228
minZoom = 10.0f ;
212
229
maxZoom = 15.0f ;
213
- kindRank = 5 ;
230
+ kindRank = 10 ;
214
231
break ;
215
232
case "neighbourhood" :
216
233
kind = "neighbourhood" ;
217
234
minZoom = 12.0f ;
218
235
maxZoom = 15.0f ;
219
- kindRank = 6 ;
236
+ kindRank = 11 ;
220
237
break ;
221
238
}
222
239
@@ -287,12 +304,14 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
287
304
//feat.setSortKey(minZoom * 1000 + 400 - populationRank * 200 + placeNumber.incrementAndGet());
288
305
feat .setSortKey (getSortKey (minZoom , kindRank , populationRank , population , sf .getString ("name" )));
289
306
307
+ // This is only necessary when prepping for raster renderers
308
+ feat .setBufferPixels (16 );
309
+
290
310
// We set the sort keys so the label grid can be sorted predictably (bonus: tile features also sorted)
291
311
// NOTE: The buffer needs to be consistent with the innteral grid pixel sizes
292
312
//feat.setPointLabelGridSizeAndLimit(13, 64, 4); // each cell in the 4x4 grid can have 4 items
293
313
feat .setPointLabelGridPixelSize (LOCALITY_GRID_SIZE_ZOOM_FUNCTION )
294
- .setPointLabelGridLimit (LOCALITY_GRID_LIMIT_ZOOM_FUNCTION )
295
- .setBufferPixels (64 );
314
+ .setPointLabelGridLimit (LOCALITY_GRID_LIMIT_ZOOM_FUNCTION );
296
315
297
316
// and also whenever you set a label grid size limit, make sure you increase the buffer size so no
298
317
// label grid squares will be the consistent between adjacent tiles
0 commit comments