-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { BasemapsConfigProvider, getAllImagery, } from '@basemaps/config'; | ||
Check failure on line 1 in packages/server/src/route.link.ts GitHub Actions / build-containers
Check failure on line 1 in packages/server/src/route.link.ts GitHub Actions / build (macos-latest)
|
||
import { Epsg } from '@basemaps/geo'; | ||
import { getPreviewUrl } from '@basemaps/shared'; | ||
|
||
/** | ||
* If a tileset layer of the given id and projection exists, this function returns a Basemaps URL | ||
* path that is already zoomed to the extent of the tileset. Otherwise, this function returns null. | ||
* | ||
Check failure on line 8 in packages/server/src/route.link.ts GitHub Actions / build-containers
Check failure on line 8 in packages/server/src/route.link.ts GitHub Actions / build (macos-latest)
|
||
* @param id - The id of the tileset. | ||
* @example "ashburton-2023-0.1m" | ||
* | ||
Check failure on line 11 in packages/server/src/route.link.ts GitHub Actions / build-containers
Check failure on line 11 in packages/server/src/route.link.ts GitHub Actions / build (macos-latest)
|
||
* @param projection - The projection from the tileset's layers to consider. | ||
* @example Epsg.Google = 3857 | ||
*/ | ||
export async function getTileSetPath(cfg: BasemapsConfigProvider, id: string, projection: Epsg): Promise<string | null> { | ||
Check failure on line 15 in packages/server/src/route.link.ts GitHub Actions / build-containers
Check failure on line 15 in packages/server/src/route.link.ts GitHub Actions / build (macos-latest)
|
||
const tileSet = await cfg.TileSet.get(id) | ||
Check failure on line 16 in packages/server/src/route.link.ts GitHub Actions / build-containers
Check failure on line 16 in packages/server/src/route.link.ts GitHub Actions / build (macos-latest)
|
||
if (!tileSet) return null | ||
Check failure on line 17 in packages/server/src/route.link.ts GitHub Actions / build-containers
Check failure on line 17 in packages/server/src/route.link.ts GitHub Actions / build (macos-latest)
|
||
|
||
const imageryMap = await getAllImagery(cfg, tileSet.layers, [projection]); | ||
Check failure on line 19 in packages/server/src/route.link.ts GitHub Actions / build-containers
Check failure on line 19 in packages/server/src/route.link.ts GitHub Actions / build (macos-latest)
|
||
|
||
const [_, imagery] = Array.from(imageryMap)[0] | ||
Check failure on line 21 in packages/server/src/route.link.ts GitHub Actions / build-containers
Check failure on line 21 in packages/server/src/route.link.ts GitHub Actions / build-containers
Check failure on line 21 in packages/server/src/route.link.ts GitHub Actions / build (macos-latest)
Check failure on line 21 in packages/server/src/route.link.ts GitHub Actions / build (macos-latest)
Check failure on line 21 in packages/server/src/route.link.ts GitHub Actions / build-deploy
|
||
if (!imagery) return null | ||
Check failure on line 22 in packages/server/src/route.link.ts GitHub Actions / build-containers
Check failure on line 22 in packages/server/src/route.link.ts GitHub Actions / build (macos-latest)
|
||
|
||
const url = getPreviewUrl({ imagery }) | ||
|
||
return (`${url.slug}?i=${url.name}`) | ||
} |