Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ <h1>OpenGeoMetadata Viewer Preview</h1>
>
Temperature (Points, GeoJSON)
</button>
<button
data-record-url="https://raw.githubusercontent.com/OpenGeoMetadata/edu.stanford.purl/b74664cbb36fb985fe2ebee8d0d6d9657f06ada1/metadata-aardvark/zy/089/tj/2215/geoblacklight.json"
>
Peatland (Index Map, Polygons)
</button>
<button data-record-url="https://gist.githubusercontent.com/thatbudakguy/dcf881807aea33739a8cbb8fcefa42d0/raw/67b80876bdd17c21d654024bc77a1e4ece8a7fb6/hopkins.json">
Hopkins (Index Map, Points)
</button>
<button
data-record-url="https://raw.githubusercontent.com/OpenGeoMetadata/edu.stanford.purl/b74664cbb36fb985fe2ebee8d0d6d9657f06ada1/metadata-aardvark/cg/357/zz/0321/geoblacklight.json"
>
Expand Down
18 changes: 18 additions & 0 deletions src/lib/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const getRecordSource = async (record: OgmRecord): Promise<AddSourceObject | und
// Methods that create new sources are added here in order of preference
// The first one that returns a valid source will be used
await recordPMTilesSource(record),
recordIndexMapGeoJSONSource(record),
recordGeoJSONSource(record),
recordWMSSource(record),
recordTMSSource(record),
Expand Down Expand Up @@ -172,6 +173,23 @@ const recordGeoJSONSource = (record: OgmRecord): AddSourceObject | undefined =>
};
};

// Given a record, create a MapLibre GeoJSON source from an index map URL, if possible
const recordIndexMapGeoJSONSource = (record: OgmRecord): AddSourceObject | undefined => {
// If no index map reference, nothing to do
const indexMapUrl = record.references.indexMapUrl;
if (!indexMapUrl) return;

// Create a GeoJSON source with the record's ID and attribution
return {
id: record.id,
source: {
type: 'geojson',
data: indexMapUrl,
attribution: record.attribution,
},
};
};

// Given a record, create a PMTiles source, if possible
const recordPMTilesSource = async (record: OgmRecord): Promise<AddSourceObject | undefined> => {
// If no PMTiles reference, nothing to do
Expand Down
Loading