Skip to content

Commit

Permalink
POI layers in tiles is deterministic (#207)
Browse files Browse the repository at this point in the history
* remove auto-incrementing integer as part of sort key
  • Loading branch information
bdon authored Jan 14, 2024
1 parent 166e1d7 commit 3a1697d
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions tiles/src/main/java/com/protomaps/basemap/layers/Pois.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.protomaps.basemap.feature.QrankDb;
import com.protomaps.basemap.names.OsmNames;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class Pois implements ForwardingProfile.FeatureProcessor, ForwardingProfile.FeaturePostProcessor {

Expand All @@ -32,13 +31,6 @@ public String name() {
Math.pow(GeoUtils.metersToPixelAtEquator(0, Math.sqrt(70_000)) / 256d, 2);
private static final double LOG2 = Math.log(2);

/*
* Assign every toilet a monotonically increasing ID so that we can limit output at low zoom levels to only the
* highest ID toilet nodes. Be sure to use thread-safe data structures any time a profile holds state since multiple
* threads invoke processFeature concurrently.
*/
private final AtomicInteger poiNumber = new AtomicInteger(0);

@Override
public void processFeature(SourceFeature sf, FeatureCollector features) {
if ((sf.isPoint() || sf.canBePolygon()) && (sf.hasTag("aeroway", "aerodrome") ||
Expand Down Expand Up @@ -482,7 +474,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) {

// Server sort features so client label collisions are pre-sorted
// NOTE: (nvkelso 20230627) This could also include other params like the name
polyLabelPosition.setSortKey(minZoom * 1000 + poiNumber.incrementAndGet());
polyLabelPosition.setSortKey(minZoom * 1000);

// Even with the categorical zoom bucketing above, we end up with too dense a point feature spread in downtown
// areas, so cull the labels which wouldn't label at earlier zooms than the max_zoom of 15
Expand Down Expand Up @@ -567,7 +559,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) {

// Server sort features so client label collisions are pre-sorted
// NOTE: (nvkelso 20230627) This could also include other params like the name
pointFeature.setSortKey(minZoom * 1000 + poiNumber.incrementAndGet());
pointFeature.setSortKey(minZoom * 1000);

// Even with the categorical zoom bucketing above, we end up with too dense a point feature spread in downtown
// areas, so cull the labels which wouldn't label at earlier zooms than the max_zoom of 15
Expand Down

0 comments on commit 3a1697d

Please sign in to comment.