diff --git a/src/index.html b/src/index.html index 3da8f70..84b99f2 100644 --- a/src/index.html +++ b/src/index.html @@ -54,6 +54,11 @@ > Sanborn (Scanned Map, COG) + diff --git a/src/utils/references.ts b/src/utils/references.ts index 2949e94..437b53c 100644 --- a/src/utils/references.ts +++ b/src/utils/references.ts @@ -69,6 +69,10 @@ export class References { return this.references['https://github.com/cogeotiff/cog-spec']; } + get indexMap() { + return this.references['https://openindexmaps.org']; + } + // List of download links with URL and label get downloadLinks(): LabelledLinks { const fieldContents = this.references['http://schema.org/downloadUrl']; diff --git a/src/utils/sources.ts b/src/utils/sources.ts index ea470ad..bc7466c 100644 --- a/src/utils/sources.ts +++ b/src/utils/sources.ts @@ -15,8 +15,8 @@ export const getPreviewLayer = (record: OgmRecord): AddLayerObject => { // Map source types to layer types using information from the record const getLayerType = (_record: OgmRecord, source: SourceSpecification): LayerType => { - // For now, we only support raster layers if (source.type === 'raster') return 'raster'; + else if (source.type === 'geojson') return 'fill'; else throw new Error(`Unsupported source type: ${source.type}`); }; @@ -26,6 +26,7 @@ const getRecordSource = (record: OgmRecord): AddSourceObject => { // Methods that create new sources are added here in order of preference // The first one that returns a valid source will be used recordCOGSource(record), + recordOpenIndexMapsSource(record), recordWMSSource(record), ].find(Boolean); }; @@ -99,3 +100,17 @@ const createWMSSource = ({ attribution, }; }; + +const recordOpenIndexMapsSource = (record: OgmRecord): AddSourceObject => { + const indexMapUrl = record.references.indexMap; + if (!indexMapUrl) return null; + + return { + id: record.id, + source: { + type: 'geojson', + data: indexMapUrl, + attribution: record.attribution, + }, + }; +};