From f23f4549dcf506bd802581a943536e514e2be99c Mon Sep 17 00:00:00 2001 From: "stuart.woodman" Date: Tue, 15 Nov 2022 15:24:04 +1100 Subject: [PATCH 1/3] Fix WMS URLs having a repeated service parameter and WFS URLs having a WMS service parameter. --- .../subpanel/subpanel.component.html | 3 +- .../infopanel/subpanel/subpanel.component.ts | 36 +++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.html b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.html index a72e0385b..1a2034825 100644 --- a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.html +++ b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.html @@ -13,7 +13,8 @@

{{onlineResource.type}}: - {{onlineResource.type}} GetCapabilities Info + {{onlineResource.type}} GetCapabilities Info + {{onlineResource.type}} Info

diff --git a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts index 524f0f330..9ff897dcf 100644 --- a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts +++ b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts @@ -1,11 +1,10 @@ import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; -import { CSWRecordModel } from '@auscope/portal-core-ui'; +import { CSWRecordModel, OnlineResourceModel } from '@auscope/portal-core-ui'; import { LayerModel } from '@auscope/portal-core-ui'; import { LegendService } from '@auscope/portal-core-ui'; import { UtilitiesService } from '@auscope/portal-core-ui'; - @Component({ selector: 'info-sub-panel', templateUrl: './subpanel.component.html', @@ -37,18 +36,16 @@ export class InfoPanelSubComponent implements OnChanges { } } - /** * Remove unwanted and empty strings from metadata constraints fields * @param constraints string array of contraints * @return string constraints in string format */ public cleanConstraints(constraints: string[]) { - let outStr = ""; for (const conStr of constraints) { - if (conStr.indexOf("no conditions apply") < 0 && - conStr.indexOf("#MD_RestrictionCode") < 0 && conStr.trim() != "") { + if (conStr.indexOf("no conditions apply") < 0 && + conStr.indexOf("#MD_RestrictionCode") < 0 && conStr.trim() !== "") { outStr += conStr.trim() + ", "; } } @@ -56,6 +53,33 @@ export class InfoPanelSubComponent implements OnChanges { return outStr.replace(/, $/, ""); } + /** + * Create a WMS/WFS GetCapabilities URL from the provided OnlineResource + * + * @param onlineResource the OnlineResourceModel + * @returns a WMS or WFS GetCapabilities URL as a string + */ + public onlineResourceGetCapabilitiesUrl(onlineResource: OnlineResourceModel): string { + // Determine base path, append mandatory service and request parameters + const paramIndex = onlineResource.url.indexOf('?'); + let path = paramIndex !== -1 ? onlineResource.url.substr(0, onlineResource.url.indexOf('?')) : onlineResource.url; + path += '?service=' + onlineResource.type + '&request=GetCapabilities'; + // Apend any other non-service or request parameters to path + if (paramIndex !== -1 && onlineResource.url.length > paramIndex + 1) { + const paramString = onlineResource.url.substr(paramIndex + 1, onlineResource.url.length); + const paramArray = paramString.split('&'); + for (const keyValueString of paramArray) { + const keyValue = keyValueString.split('='); + if (keyValue.length === 2) { + if (keyValue[0].toLowerCase() !== 'service' && keyValue[0].toLowerCase() !== 'request') { + path += keyValue[0] + '=' + keyValue[1]; + } + } + } + } + return path; + } + /** * Gets called by Angular framework upon any changes * @param changes object which holds the changes From e61621620c794cca560bf5e08fd72d975c665662 Mon Sep 17 00:00:00 2001 From: "stuart.woodman" Date: Tue, 15 Nov 2022 15:48:15 +1100 Subject: [PATCH 2/3] Added WCS to the party. Removed a deprecated method. --- .../infopanel/subpanel/subpanel.component.html | 4 ++-- .../infopanel/subpanel/subpanel.component.ts | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.html b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.html index 1a2034825..ba9c6bd6d 100644 --- a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.html +++ b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.html @@ -13,8 +13,8 @@

{{onlineResource.type}}: - {{onlineResource.type}} GetCapabilities Info - {{onlineResource.type}} Info + {{onlineResource.type}} GetCapabilities Info + {{onlineResource.type}} Info

diff --git a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts index 9ff897dcf..0e52297b8 100644 --- a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts +++ b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts @@ -54,19 +54,29 @@ export class InfoPanelSubComponent implements OnChanges { } /** - * Create a WMS/WFS GetCapabilities URL from the provided OnlineResource + * Is the OnlineResourceModel of a type that supports GetCapabilities? * * @param onlineResource the OnlineResourceModel - * @returns a WMS or WFS GetCapabilities URL as a string + * @returns true if OnlineResource is of type WMS, WFS or WCS + */ + public isGetCapabilitiesType(onlineResource: OnlineResourceModel): boolean { + return onlineResource.type === 'WMS' || onlineResource.type === 'WFS' || onlineResource.type === 'WCS'; + } + + /** + * Create a WMS/WFS/WCS GetCapabilities URL from the provided OnlineResource + * + * @param onlineResource the OnlineResourceModel + * @returns a WMS, WFS or WCS GetCapabilities URL as a string */ public onlineResourceGetCapabilitiesUrl(onlineResource: OnlineResourceModel): string { // Determine base path, append mandatory service and request parameters const paramIndex = onlineResource.url.indexOf('?'); - let path = paramIndex !== -1 ? onlineResource.url.substr(0, onlineResource.url.indexOf('?')) : onlineResource.url; + let path = paramIndex !== -1 ? onlineResource.url.substring(0, onlineResource.url.indexOf('?')) : onlineResource.url; path += '?service=' + onlineResource.type + '&request=GetCapabilities'; // Apend any other non-service or request parameters to path if (paramIndex !== -1 && onlineResource.url.length > paramIndex + 1) { - const paramString = onlineResource.url.substr(paramIndex + 1, onlineResource.url.length); + const paramString = onlineResource.url.substring(paramIndex + 1, onlineResource.url.length); const paramArray = paramString.split('&'); for (const keyValueString of paramArray) { const keyValue = keyValueString.split('='); From e05a63d5c0deced01372a2998f8b7836ae706892 Mon Sep 17 00:00:00 2001 From: "stuart.woodman" Date: Thu, 17 Nov 2022 08:58:50 +1100 Subject: [PATCH 3/3] Added CSW records to GetCapabilities request list. --- .../common/infopanel/subpanel/subpanel.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts index 0e52297b8..8f1267d8c 100644 --- a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts +++ b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts @@ -57,14 +57,14 @@ export class InfoPanelSubComponent implements OnChanges { * Is the OnlineResourceModel of a type that supports GetCapabilities? * * @param onlineResource the OnlineResourceModel - * @returns true if OnlineResource is of type WMS, WFS or WCS + * @returns true if OnlineResource is of type WMS, WFS, WCS or CSW */ public isGetCapabilitiesType(onlineResource: OnlineResourceModel): boolean { - return onlineResource.type === 'WMS' || onlineResource.type === 'WFS' || onlineResource.type === 'WCS'; + return onlineResource.type === 'WMS' || onlineResource.type === 'WFS' || onlineResource.type === 'WCS' || onlineResource.type === 'CSW'; } /** - * Create a WMS/WFS/WCS GetCapabilities URL from the provided OnlineResource + * Create a WMS/WFS/WCS/CSW GetCapabilities URL from the provided OnlineResource * * @param onlineResource the OnlineResourceModel * @returns a WMS, WFS or WCS GetCapabilities URL as a string