Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keywords to WMS and WFS #55

Merged
merged 7 commits into from
Jul 16, 2024
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
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
Loading