Skip to content

Commit

Permalink
feature: append basemaps options to generated Stac Item files
Browse files Browse the repository at this point in the history
  • Loading branch information
tawera-manaena committed Jan 7, 2025
1 parent daa9c08 commit da8db62
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/commands/basemaps-topo-import/stac/create-base-stac-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { logger } from '../../../log.js';
import { MapSheetStacItem } from '../types/map-sheet-stac-item.js';
import { TiffItem } from '../types/tiff-item.js';

const cliDate = new Date().toISOString();
const CLI_DATE = new Date().toISOString();
const DEFAULT_TRIM_PIXEL_RIGHT = 1.7;

/**
* This function creates a base StacItem object based on the provided parameters.
Expand Down Expand Up @@ -38,12 +39,27 @@ export function createBaseStacItem(fileName: string, tiffItem: TiffItem): MapShe
},
stac_extensions: ['https://stac-extensions.github.io/file/v2.0.0/schema.json'],
properties: {
datetime: cliDate,
datetime: CLI_DATE,
map_code: tiffItem.mapCode,
version: tiffItem.version.replace('-', '.'), // e.g. "v1-00" to "v1.00"
'proj:epsg': tiffItem.epsg.code,
'source.width': tiffItem.size.width,
'source.height': tiffItem.size.height,
'linz_basemaps:options': {
preset: 'webp',
blockSize: 512,
bigTIFF: 'no',
compression: 'webp',
quality: 100,
overviewCompress: 'webp',
overviewQuality: 90,
overviewResampling: 'lanczos',
tileId: fileName,
sourceEpsg: tiffItem.epsg.code,
addalpha: true,
noReprojecting: true,
srcwin: [0, 0, tiffItem.size.width - DEFAULT_TRIM_PIXEL_RIGHT, tiffItem.size.height],
},
},
geometry: { type: 'Polygon', coordinates: tiffItem.bounds.toPolygon() } as GeoJSONPolygon,
bbox: tiffItem.bounds.toBbox(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,10 @@ export interface MapSheetStacItem extends StacItem {
* The height of a map sheet in pixels.
*/
'source.height': number;

/**
* An object of key-value pairs describing options for Basemaps' cogify process.
*/
'linz_basemaps:options': { [key: string]: unknown };
};
}

0 comments on commit da8db62

Please sign in to comment.