diff --git a/src/app/menupanel/common/infopanel/subpanel/subpanel.component.html b/src/app/menupanel/common/infopanel/subpanel/subpanel.component.html index a72e0385b..ba9c6bd6d 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..8f1267d8c 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,43 @@ export class InfoPanelSubComponent implements OnChanges { return outStr.replace(/, $/, ""); } + /** + * Is the OnlineResourceModel of a type that supports GetCapabilities? + * + * @param onlineResource the OnlineResourceModel + * @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' || onlineResource.type === 'CSW'; + } + + /** + * 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 + */ + 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.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.substring(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