forked from MapComplete/MapComplete
Feature: first version of clustering at low zoom levels, filters don't update yet (WIP)
This commit is contained in:
parent
4e033a93a5
commit
8360ab9a8b
11 changed files with 562 additions and 262 deletions
|
@ -10,11 +10,12 @@ import {
|
|||
MultiPolygon,
|
||||
Point,
|
||||
Polygon,
|
||||
Position,
|
||||
Position
|
||||
} from "geojson"
|
||||
import { Tiles } from "../Models/TileRange"
|
||||
import { Utils } from "../Utils"
|
||||
;("use strict")
|
||||
|
||||
("use strict")
|
||||
|
||||
export class GeoOperations {
|
||||
private static readonly _earthRadius: number = 6378137
|
||||
|
@ -536,10 +537,23 @@ export class GeoOperations {
|
|||
* @param features
|
||||
* @param zoomlevel
|
||||
*/
|
||||
public static spreadIntoBboxes(features: Feature[], zoomlevel: number): Map<number, Feature[]> {
|
||||
const perBbox = new Map<number, Feature[]>()
|
||||
|
||||
public static spreadIntoBboxes<T extends Feature = Feature>(features: T[], zoomlevel: number): Map<number, T[]> {
|
||||
const perBbox = new Map<number, T[]>()
|
||||
const z = zoomlevel
|
||||
for (const feature of features) {
|
||||
if (feature.geometry.type === "Point") {
|
||||
const [lon, lat] = feature.geometry.coordinates
|
||||
const tileXYZ = Tiles.embedded_tile(lat, lon, z)
|
||||
const tileNumber = Tiles.tile_index(z, tileXYZ.x, tileXYZ.y)
|
||||
let newFeatureList = perBbox.get(tileNumber)
|
||||
if (newFeatureList === undefined) {
|
||||
newFeatureList = []
|
||||
perBbox.set(tileNumber, newFeatureList)
|
||||
}
|
||||
newFeatureList.push(feature)
|
||||
|
||||
continue
|
||||
}
|
||||
const bbox = BBox.get(feature)
|
||||
const tilerange = bbox.expandToTileBounds(zoomlevel).containingTileRange(zoomlevel)
|
||||
Tiles.MapRange(tilerange, (x, y) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue