Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Jul 8, 2022
1 parent 700c729 commit bd2bd50
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
1 change: 1 addition & 0 deletions packages/config/src/config/tile.set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type TileResizeKernel = 'nearest' | 'lanczos3' | 'lanczos2';
export interface ConfigTileSetBase extends BaseConfig {
title?: string;
description?: string;
category?: string;

/**
* The rendering layer for imagery in this tileset
Expand Down
1 change: 1 addition & 0 deletions packages/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export { ConfigProviderMemory, ConfigBundled } from './memory/memory.config.js';
export { TileSetNameComponents, TileSetNameParser } from './tile.set.name.js';
export { parseHex, parseRgba } from './color.js';
export { ConfigJson } from './json/json.config.js';
export { standardizeLayerName } from './json/name.convertor.js';
2 changes: 2 additions & 0 deletions packages/config/src/memory/memory.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export class ConfigProviderMemory extends BasemapsConfigProvider {
existing = {
type: TileSetType.Raster,
id: targetId,
title: i.title,
category: i.category,
name: targetName,
format: ImageFormat.Webp,
layers: [{ name: targetName, minZoom: 0, maxZoom: 32 }],
Expand Down
32 changes: 20 additions & 12 deletions packages/lambda-tiler/src/tile.set.cache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TileSetNameParser, TileSetType } from '@basemaps/config';
import { standardizeLayerName } from '@basemaps/config';
import { GoogleTms, Nztm2000QuadTms, TileMatrixSet } from '@basemaps/geo';
import { Config } from '@basemaps/shared';
import { TileSet } from './tile.set.js';
Expand Down Expand Up @@ -81,30 +82,37 @@ export class TileSetCache {
}

async getAll(name: string, tileMatrix?: TileMatrixSet | null): Promise<TileSet[]> {
const nameComp = TileSetNameParser.parse(name);
const tileMatrices = tileMatrix == null ? [GoogleTms, Nztm2000QuadTms] : [tileMatrix];

const promises: Promise<TileSet | null>[] = [];
for (const tileMatrix of tileMatrices) promises.push(this.get(name, tileMatrix));
const tileMatrixSets = await Promise.all(promises);

const tileSets: TileSetRaster[] = [];
const tileSets: Promise<TileSet | null>[] = [];
for (const parent of tileMatrixSets) {
if (parent == null) continue;
if (parent.type === TileSetType.Vector) continue;

tileSets.push(parent);
if (nameComp.layer != null) {
parent.components.name = nameComp.name;
} else if (parent.imagery != null && parent.imagery.size > 1) {
for (const imageId of parent.imagery.keys()) {
const childImg = parent.child(imageId);
if (childImg == null) continue;
tileSets.push(childImg);
}
for (const layer of parent.imagery.values()) {
if (layer.projection !== parent.tileMatrix.projection.code) continue;
const tileSetId = standardizeLayerName(layer.name);
// FIXME needs a getAll or this will request one by one
tileSets.push(this.get(tileSetId, parent.tileMatrix));
}
// tileSets.push(parent);
// if (nameComp.layer != null) {
// parent.components.name = nameComp.name;
// } else if (parent.imagery != null && parent.imagery.size > 1) {
// for (const imageId of parent.imagery.keys()) {
// const childImg = parent.child(imageId);
// if (childImg == null) continue;
// tileSets.push(childImg);
// }
// }
}
return tileSets.sort((a, b) => a.title.localeCompare(b.title));
const allTileSets = await Promise.all(tileSets);
const onlyRasters = allTileSets.filter((f) => f != null && f.type === 'raster') as TileSetRaster[];
return onlyRasters.sort((a: TileSetRaster, b: TileSetRaster) => a.title.localeCompare(b.title));
}
}

Expand Down
4 changes: 1 addition & 3 deletions packages/lambda-tiler/src/tile.set.raster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ export class TileSetRaster {
components: TileSetNameComponents;
tileSet: ConfigTileSetRaster;

keywords: string[] = [];

constructor(name: string, tileMatrix: TileMatrixSet) {
this.components = TileSetNameParser.parse(name);
this.tileMatrix = tileMatrix;
Expand Down Expand Up @@ -218,7 +216,7 @@ export class TileSetRaster {
child.tileSet.title = image.title ?? `${title} ${titleizeImageryName(image.name)}`;
child.extentOverride = Bounds.fromJson(image.bounds);

if (image.category) child.keywords.push(image.category);
if (image.category) child.tileSet.category = image.category;

const layer: ConfigLayer = { name: image.name, minZoom: 0, maxZoom: 100 };
layer[this.tileMatrix.projection.code] = image.id;
Expand Down
6 changes: 2 additions & 4 deletions packages/lambda-tiler/src/wmts.capability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ export class WmtsCapabilities {
}

buildKeywords(layer: TileSetRaster): VNodeElement {
return V(
'ows:Keywords',
layer.keywords.map((keyword) => V('ows:Keyword', keyword)),
);
if (layer.tileSet.category == null) return V('ows:Keywords');
return V('ows:Keywords', V('ows:Keyword', layer.tileSet.category));
}

buildStyle(): VNodeElement {
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export async function createServer(opts: ServerOptions, logger: LogType): Promis
logger.info({ path: opts.config, mode: 'config:bundle' }, 'Starting Server');
const configJson = await fsa.read(opts.config);
const mem = ConfigProviderMemory.fromJson(JSON.parse(configJson.toString()));
mem.createVirtualTileSets();
Config.setConfigProvider(mem);
} else {
const mem = await ConfigJson.fromPath(opts.config, logger);
Expand Down

0 comments on commit bd2bd50

Please sign in to comment.