Skip to content

Commit

Permalink
Merge pull request #66 from RobQuincey-DC/feature-wms-info-formats
Browse files Browse the repository at this point in the history
Add info formats to WMS capabilities
  • Loading branch information
jahow authored Oct 25, 2024
2 parents 407854b + 029b9bb commit bf94a45
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/shared/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export type GenericEndpointInfo = {
* or the list of 'Formats' from a WMS GetCapabilities
*/
outputFormats?: MimeType[];
/**
* Contains a list of formats that can be used for WMS GetFeatureInfo,
* or null for other services such as WFS
*/
infoFormats?: MimeType[];
};

export type MimeType = string;
Expand Down
1 change: 1 addition & 0 deletions src/wms/capabilities.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ describe('WMS capabilities', () => {
'application/x-pdf',
'image/svg+xml',
],
infoFormats: ['text/plain', 'application/vnd.ogc.gml'],
keywords: [
'Géologie',
'BRGM',
Expand Down
21 changes: 19 additions & 2 deletions src/wms/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ export function readOutputFormatsFromCapabilities(
return outputFormats;
}

export function readInfoFormatsFromCapabilities(capabilitiesDoc: XmlDocument) {
const capability = findChildElement(
getRootElement(capabilitiesDoc),
'Capability'
);
const getFeatureInfo = findChildElement(
findChildElement(capability, 'Request'),
'GetFeatureInfo'
);
const outputFormats = findChildrenElement(getFeatureInfo, 'Format').map(
getElementText
);
return outputFormats;
}

/**
* Will read service-related info from the capabilities doc
* @param capabilitiesDoc Capabilities document
Expand All @@ -66,7 +81,8 @@ export function readInfoFromCapabilities(
capabilitiesDoc: XmlDocument
): GenericEndpointInfo {
const service = findChildElement(getRootElement(capabilitiesDoc), 'Service');
const formats = readOutputFormatsFromCapabilities(capabilitiesDoc);
const outputFormats = readOutputFormatsFromCapabilities(capabilitiesDoc);
const infoFormats = readInfoFormatsFromCapabilities(capabilitiesDoc);
const keywords = findChildrenElement(
findChildElement(service, 'KeywordList'),
'Keyword'
Expand All @@ -78,7 +94,8 @@ export function readInfoFromCapabilities(
title: getElementText(findChildElement(service, 'Title')),
name: getElementText(findChildElement(service, 'Name')),
abstract: getElementText(findChildElement(service, 'Abstract')),
outputFormats: formats,
outputFormats: outputFormats,
infoFormats: infoFormats,
fees: getElementText(findChildElement(service, 'Fees')),
constraints: getElementText(findChildElement(service, 'AccessConstraints')),
keywords,
Expand Down
1 change: 1 addition & 0 deletions src/wms/endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ describe('WmsEndpoint', () => {
'application/x-pdf',
'image/svg+xml',
],
infoFormats: ['text/plain', 'application/vnd.ogc.gml'],
keywords: [
'Géologie',
'BRGM',
Expand Down

0 comments on commit bf94a45

Please sign in to comment.