Add capability to load tiled geojsons, eventually as overpass-cache

This commit is contained in:
Pieter Vander Vennet 2021-04-22 03:30:46 +02:00
parent 475cdae19f
commit 2da52501a3
16 changed files with 520 additions and 76 deletions

View file

@ -156,8 +156,6 @@ export class Utils {
}
static Merge(source: any, target: any) {
target = JSON.parse(JSON.stringify(target));
source = JSON.parse(JSON.stringify(source));
for (const key in source) {
const sourceV = source[key];
const targetV = target[key]
@ -203,6 +201,26 @@ export class Utils {
static embedded_tile(lat: number, lon: number, z: number): { x: number, y: number, z: number } {
return {x: Utils.lon2tile(lon, z), y: Utils.lat2tile(lat, z), z: z}
}
static TileRangeBetween(zoomlevel: number, lat0: number, lon0: number, lat1:number, lon1: number) : TileRange{
const t0 = Utils.embedded_tile(lat0, lon0, zoomlevel)
const t1 = Utils.embedded_tile(lat1, lon1, zoomlevel)
const xstart = Math.min(t0.x, t1.x)
const xend = Math.max(t0.x, t1.x)
const ystart = Math.min(t0.y, t1.y)
const yend = Math.max(t0.y, t1.y)
const total = (1 + xend - xstart) * (1 + yend - ystart)
return {
xstart: xstart,
xend: xend,
ystart: ystart,
yend: yend,
total: total,
zoomlevel: zoomlevel
}
}
public static MinifyJSON(stringified: string): string {
stringified = stringified.replace(/\|/g, "||");
@ -257,3 +275,13 @@ export class Utils {
return (Math.floor((1 - Math.log(Math.tan(lat * Math.PI / 180) + 1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, zoom)));
}
}
export interface TileRange{
xstart: number,
ystart: number,
xend: number,
yend: number,
total: number,
zoomlevel: number
}