Fix duplicate buildings for grb layer; add default flag for filters, performance improvement

This commit is contained in:
Pieter Vander Vennet 2022-02-11 03:57:39 +01:00
parent 31205f3430
commit 695a0867c7
13 changed files with 157 additions and 111 deletions

View file

@ -55,8 +55,7 @@ export default class DynamicGeoJsonTileSource extends DynamicTileSource {
}
}
const seenIds = new Set<string>();
const blackList = new UIEventSource(seenIds)
const blackList = (new Set<string>())
super(
layer,
source.geojsonZoomLevel,
@ -76,10 +75,7 @@ export default class DynamicGeoJsonTileSource extends DynamicTileSource {
featureIdBlacklist: blackList
}
)
src.features.addCallbackAndRunD(feats => {
feats.forEach(feat => seenIds.add(feat.feature.properties.id))
blackList.ping();
})
registerLayer(src)
return src
},

View file

@ -21,7 +21,6 @@ export class TileHierarchyMerger implements TileHierarchy<FeatureSourceForLayer
* Add another feature source for the given tile.
* Entries for this tile will be merged
* @param src
* @param index
*/
public registerTile(src: FeatureSource & Tiled) {

View file

@ -146,7 +146,10 @@ export default class TiledFeatureSource implements Tiled, IndexedFeatureSource,
for (const feature of features) {
const bbox = BBox.get(feature.feature)
if (this.options.dontEnforceMinZoom) {
// There are a few strategies to deal with features that cross tile boundaries
if (this.options.noDuplicates) {
// Strategy 1: We put the feature into a somewhat matching tile
if (bbox.overlapsWith(this.upper_left.bbox)) {
ulf.push(feature)
} else if (bbox.overlapsWith(this.upper_right.bbox)) {
@ -159,6 +162,7 @@ export default class TiledFeatureSource implements Tiled, IndexedFeatureSource,
overlapsboundary.push(feature)
}
} else if (this.options.minZoomLevel === undefined) {
// Strategy 2: put it into a strictly matching tile (or in this tile, which is slightly too big)
if (bbox.isContainedIn(this.upper_left.bbox)) {
ulf.push(feature)
} else if (bbox.isContainedIn(this.upper_right.bbox)) {
@ -171,7 +175,7 @@ export default class TiledFeatureSource implements Tiled, IndexedFeatureSource,
overlapsboundary.push(feature)
}
} else {
// We duplicate a feature on a boundary into every tile as we need to get to the minZoomLevel
// Strategy 3: We duplicate a feature on a boundary into every tile as we need to get to the minZoomLevel
if (bbox.overlapsWith(this.upper_left.bbox)) {
ulf.push(feature)
}
@ -201,10 +205,9 @@ export interface TiledFeatureSourceOptions {
readonly minZoomLevel?: number,
/**
* IF minZoomLevel is set, and if a feature runs through a tile boundary, it would normally be duplicated.
* Setting 'dontEnforceMinZoomLevel' will still allow bigger zoom levels for those features.
* If 'pick_first' is set, the feature will not be duplicated but set to some tile
* Setting 'dontEnforceMinZoomLevel' will assign to feature to some matching subtile.
*/
readonly dontEnforceMinZoom?: boolean | "pick_first",
readonly noDuplicates?: boolean,
readonly registerTile?: (tile: TiledFeatureSource & FeatureSourceForLayer & Tiled) => void,
readonly layer?: FilteredLayer
}