Skip to content

Commit

Permalink
Merge pull request #55 from RobQuincey-DC/feature-layer-keywords
Browse files Browse the repository at this point in the history
Add keywords to WMS and WFS
  • Loading branch information
jahow authored Jul 16, 2024
2 parents 77cdfe1 + 057c3a6 commit 4369f6c
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/src/components/wfs/WfsFeatureTypeInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export default {
...('geometryType' in this.featureType && {
'geometry type': this.featureType.geometryType,
}),
...('keywords' in this.featureType && {
keywords: this.featureType.keywords,
}),
};
},
featureProperties() {
Expand Down
1 change: 1 addition & 0 deletions app/src/components/wms/WmsLayerInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default {
this.layer.attribution.title && {
attribution: this.layer.attribution.title,
}),
...(this.layer.keywords && { keywords: this.layer.keywords }),
};
},
fullMapSrc() {
Expand Down
6 changes: 6 additions & 0 deletions fixtures/wms/capabilities-brgm-1-1-1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
<Keyword>BRGM</Keyword>
<Keyword>INSPIRE:ViewService</Keyword>
<Keyword>infoMapAccessService</Keyword>
<Keyword>WMS 1.1.1</Keyword>
<Keyword>WMS 1.3.0</Keyword>
<Keyword>SLD 1.1.0</Keyword>
</KeywordList>
<SRS>EPSG:4326</SRS>
<SRS>CRS:84</SRS>
Expand Down Expand Up @@ -187,6 +190,7 @@
<KeywordList>
<Keyword>Geologie</Keyword>
<Keyword>INSPIRE:Geology</Keyword>
<Keyword>Geology</Keyword>
</KeywordList>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
Expand Down Expand Up @@ -243,6 +247,7 @@
<KeywordList>
<Keyword>Geologie</Keyword>
<Keyword>INSPIRE:Geology</Keyword>
<Keyword>Geology</Keyword>
</KeywordList>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
Expand Down Expand Up @@ -277,6 +282,7 @@
<KeywordList>
<Keyword>Geologie</Keyword>
<Keyword>INSPIRE:Geology</Keyword>
<Keyword>Geology</Keyword>
</KeywordList>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
Expand Down
4 changes: 4 additions & 0 deletions src/wfs/capabilities.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('WFS capabilities', () => {
abstract:
'Registre Parcellaire Graphique 2010 en Aquitaine - Agence de Service et de Paiement',
defaultCrs: 'EPSG:2154',
keywords: ['features', 'rpg2010'],
latLonBoundingBox: [
-1.9540704007796161, 42.73286181824404, 1.496463327812538,
45.717071228823876,
Expand All @@ -53,6 +54,7 @@ describe('WFS capabilities', () => {
abstract:
'Représentation des moyennes journalières des trafics routiers sur les routes départementales de la\n Charente (16) au 1er Janvier 2021.\n\n Mise à jour : Mars 2021\n ',
defaultCrs: 'EPSG:2154',
keywords: ['features', 'comptages_routiers_l'],
latLonBoundingBox: [
-0.4906009184568518, 45.175543885638376, 0.9778719979726385,
46.14349349624617,
Expand All @@ -72,6 +74,7 @@ describe('WFS capabilities', () => {
abstract:
'Hiérarchisation du réseau routier départemental en fonction des caractéristiques de chaque section\n de route et de son usage au 1er Janvier 2021.\n\n Mise à jour : Mars 2021\n ',
defaultCrs: 'EPSG:2154',
keywords: ['features', 'hierarchisation_l'],
latLonBoundingBox: [
-0.4832134559131876, 45.18037755571674, 0.9725372441782966,
46.13877580094452,
Expand Down Expand Up @@ -131,6 +134,7 @@ describe('WFS capabilities', () => {
expect(featureTypes[0]).toEqual({
abstract: 'Domaine public',
defaultCrs: 'EPSG:2154',
keywords: ['domaine_public_hdf_com', 'domaine', 'public'],
latLonBoundingBox: [
1.3472171890368316, 48.82764887581316, 4.285589467078578,
51.0896786738123,
Expand Down
11 changes: 11 additions & 0 deletions src/wfs/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ function parseFeatureType(
'Format'
).map(getElementText);

const keywords = serviceVersion.startsWith('1.0')
? getElementText(findChildElement(featureTypeEl, 'Keywords'))
.split(',')
.map((keyword) => keyword.trim())
: findChildrenElement(
findChildElement(featureTypeEl, 'Keywords'),
'Keyword'
)
.map(getElementText)
.filter((v, i, arr) => arr.indexOf(v) === i);
return {
name: getElementText(findChildElement(featureTypeEl, 'Name')),
title: getElementText(findChildElement(featureTypeEl, 'Title')),
Expand All @@ -171,5 +181,6 @@ function parseFeatureType(
latLonBoundingBox: serviceVersion.startsWith('1.0')
? parseBBox100()
: parseBBox(),
keywords: keywords,
};
}
2 changes: 2 additions & 0 deletions src/wfs/endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ describe('WfsEndpoint', () => {
46.13877580094452,
],
defaultCrs: 'EPSG:2154',
keywords: ['features', 'hierarchisation_l'],
otherCrs: ['EPSG:32615', 'EPSG:32616', 'EPSG:32617', 'EPSG:32618'],
outputFormats: [
'application/gml+xml; version=3.2',
Expand Down Expand Up @@ -170,6 +171,7 @@ describe('WfsEndpoint', () => {
46.13877580094452,
],
defaultCrs: 'EPSG:2154',
keywords: ['features', 'hierarchisation_l'],
otherCrs: ['EPSG:32615', 'EPSG:32616', 'EPSG:32617', 'EPSG:32618'],
outputFormats: [
'application/gml+xml; version=3.2',
Expand Down
1 change: 1 addition & 0 deletions src/wfs/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export default class WfsEndpoint {
defaultCrs: featureType.defaultCrs,
otherCrs: featureType.otherCrs,
outputFormats: featureType.outputFormats,
keywords: featureType.keywords,
} as WfsFeatureTypeSummary;
}

Expand Down
2 changes: 2 additions & 0 deletions src/wfs/featuretypeinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function parseFeatureTypeInfo(
otherCrs,
outputFormats,
latLonBoundingBox: boundingBox,
keywords,
} = featureType;

const hitsAttr = serviceVersion.startsWith('2.0')
Expand Down Expand Up @@ -77,6 +78,7 @@ export function parseFeatureTypeInfo(
...(geometryName && { geometryName }),
...(geometryType && { geometryType }),
...(!Number.isNaN(objectCount) && { objectCount }),
...(keywords && { keywords }),
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/wfs/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type WfsFeatureTypeInternal = {
otherCrs: CrsCode[];
outputFormats: MimeType[];
latLonBoundingBox?: BoundingBox;
keywords?: string[];
};

export type FeaturePropertyType = string | number | boolean;
Expand Down Expand Up @@ -44,6 +45,7 @@ export type WfsFeatureTypeSummary = {
defaultCrs: CrsCode;
otherCrs: CrsCode[];
outputFormats: MimeType[];
keywords?: string[];
};

export type WfsFeatureTypeFull = {
Expand Down Expand Up @@ -73,6 +75,7 @@ export type WfsFeatureTypeFull = {
* Not defined if object count could not be determined
*/
objectCount?: number;
keywords?: string[];
};

export type WfsFeatureWithProps = {
Expand Down
14 changes: 14 additions & 0 deletions src/wms/capabilities.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ describe('WMS capabilities', () => {
'EPSG:4171': ['-180', '-90', '180', '90'],
'EPSG:4326': ['-180', '-90', '180', '90'],
},
keywords: [
'Géologie',
'BRGM',
'INSPIRE:ViewService',
'infoMapAccessService',
'WMS 1.1.1',
'WMS 1.3.0',
'SLD 1.1.0',
],
name: 'GEOSERVICES_GEOLOGIE',
styles: [
{
Expand All @@ -76,6 +85,7 @@ describe('WMS capabilities', () => {
'EPSG:4171': ['-180', '-90', '180', '90'],
'EPSG:4326': ['-180', '-90', '180', '90'],
},
keywords: [],
name: 'GEOLOGIE',
styles,
title: 'Cartes géologiques',
Expand Down Expand Up @@ -117,6 +127,7 @@ describe('WMS capabilities', () => {
],
'EPSG:4326': ['-5.86764', '41.1701', '11.0789', '51.1419'],
},
keywords: ['Geologie', 'INSPIRE:Geology', 'Geology'],
name: 'SCAN_F_GEOL1M',
styles: [
{
Expand Down Expand Up @@ -167,6 +178,7 @@ describe('WMS capabilities', () => {
],
'EPSG:4326': ['-6.20495', '41.9671', '12.2874', '51.2917'],
},
keywords: ['Geologie', 'INSPIRE:Geology', 'Geology'],
name: 'SCAN_F_GEOL250',
styles,
title: 'Carte géologique image de la France au 1/250000',
Expand Down Expand Up @@ -204,6 +216,7 @@ describe('WMS capabilities', () => {
],
'EPSG:4326': ['-12.2064', '40.681', '11.894', '52.1672'],
},
keywords: ['Geologie', 'INSPIRE:Geology', 'Geology'],
name: 'SCAN_D_GEOL50',
styles,
title: 'Carte géologique image de la France au 1/50 000e',
Expand All @@ -229,6 +242,7 @@ describe('WMS capabilities', () => {
'EPSG:4171': ['-180', '-90', '180', '90'],
'EPSG:4326': ['-180', '-90', '180', '90'],
},
keywords: [],
name: 'INHERIT_BBOX',
styles: [
{
Expand Down
9 changes: 9 additions & 0 deletions src/wms/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ function parseLayer(
Object.keys(boundingBoxes).length > 0 || inheritedBoundingBoxes === null
? boundingBoxes
: inheritedBoundingBoxes;

const keywords = findChildrenElement(
findChildElement(layerEl, 'KeywordList'),
'Keyword'
)
.map(getElementText)
.filter((v, i, arr) => arr.indexOf(v) === i);

const children = findChildrenElement(layerEl, 'Layer').map((layer) =>
parseLayer(layer, version, availableCrs, styles, attribution, boundingBoxes)
);
Expand All @@ -143,6 +151,7 @@ function parseLayer(
styles,
attribution,
boundingBoxes,
keywords,
...(children.length && { children }),
};
}
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 @@ -131,6 +131,7 @@ describe('WmsEndpoint', () => {
'EPSG:4171': ['-180', '-90', '180', '90'],
'EPSG:4326': ['-180', '-90', '180', '90'],
},
keywords: [],
name: 'GEOLOGIE',
styles: [
{
Expand Down
1 change: 1 addition & 0 deletions src/wms/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type WmsLayerFull = {
*/
boundingBoxes: Record<CrsCode, BoundingBox>;
attribution?: WmsLayerAttribution;
keywords?: string[];
/**
* Not defined if the layer is a leaf in the tree
*/
Expand Down

0 comments on commit 4369f6c

Please sign in to comment.