diff --git a/app/src/tiles/dataDefinition.ts b/app/src/tiles/dataDefinition.ts index 7977edc6..50c3508a 100644 --- a/app/src/tiles/dataDefinition.ts +++ b/app/src/tiles/dataDefinition.ts @@ -129,6 +129,7 @@ function getHighlightDataConfig(tileset: string, dataParams: any): DataConfig { } export { + BUILDING_LAYER_DEFINITIONS, getBuildingsDataConfig, getHighlightDataConfig }; diff --git a/app/src/tiles/rendererDefinition.ts b/app/src/tiles/rendererDefinition.ts index 55244741..b44f0156 100644 --- a/app/src/tiles/rendererDefinition.ts +++ b/app/src/tiles/rendererDefinition.ts @@ -6,7 +6,12 @@ import { BranchingRenderer } from "./renderers/branchingRenderer"; import { WindowedRenderer } from "./renderers/windowedRenderer"; import { BlankRenderer } from "./renderers/blankRenderer"; import { DatasourceRenderer } from "./renderers/datasourceRenderer"; -import { getBuildingsDataConfig, getHighlightDataConfig } from "./dataDefinition"; +import { getBuildingsDataConfig, getHighlightDataConfig, BUILDING_LAYER_DEFINITIONS } from "./dataDefinition"; + +/** + * A list of all tilesets handled by the tile server + */ +const allTilesets = ['highlight', ...Object.keys(BUILDING_LAYER_DEFINITIONS)]; const buildingDataRenderer = new DatasourceRenderer(getBuildingsDataConfig); @@ -67,6 +72,7 @@ const mainRenderer = new WindowedRenderer( ); export { + allTilesets, mainRenderer, tileCache -}; \ No newline at end of file +}; diff --git a/app/src/tiles/tileserver.ts b/app/src/tiles/tileserver.ts index 88c4e9e1..0eee4a20 100644 --- a/app/src/tiles/tileserver.ts +++ b/app/src/tiles/tileserver.ts @@ -7,7 +7,7 @@ import express from 'express'; import { strictParseInt } from '../parse'; import { TileParams } from './types'; -import { mainRenderer } from './rendererDefinition'; +import { mainRenderer, allTilesets } from './rendererDefinition'; import asyncController from '../api/routes/asyncController'; const handleTileRequest = asyncController(async function (req: express.Request, res: express.Response) { @@ -37,6 +37,8 @@ router.get('/:tileset/:z/:x/:y(\\d+):scale(@\\dx)?.png', handleTileRequest); function parseTileParams(params: any): TileParams { const { tileset, z, x, y, scale } = params; + if (!allTilesets.includes(tileset)) throw new Error('Invalid value for tileset'); + const intZ = strictParseInt(z); if (isNaN(intZ)) throw new Error('Invalid value for z');