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

AUS-4219 CSW Layer Bounding Boxes #442

Merged
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
23 changes: 11 additions & 12 deletions src/app/browsepanel/browsepanel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class BrowsePanelComponent implements OnInit, AfterViewInit, OnDestroy {
* Initialise Component
*/
public ngOnInit() {
const me = this;
this.sidebarSubscription = this.sidebarService.isSidebarOpen$.subscribe(
isOpen => {
this.isSidebarOpen = isOpen;
Expand All @@ -61,22 +60,23 @@ export class BrowsePanelComponent implements OnInit, AfterViewInit, OnDestroy {
// Initialise layers and groups in sidebar
this.layerHandlerService.getLayerRecord().subscribe(
response => {
me.layerGroupColumn = response;
this.layerGroupColumn = response;
// Loop over each group of layers
for (const group in me.layerGroupColumn) {
for (const group in this.layerGroupColumn) {
// Loop over each layer in a group
for (let layer_idx = 0; layer_idx < me.layerGroupColumn[group].length; layer_idx++) {
for (let layer_idx = 0; layer_idx < this.layerGroupColumn[group].length; layer_idx++) {

// Initialise a list of cesium layers
me.layerGroupColumn[group][layer_idx].csLayers = [];
this.layerGroupColumn[group][layer_idx].csLayers = [];

// Initialise UILayerModel
const uiLayerModel = new UILayerModel(me.layerGroupColumn[group][layer_idx].id, me.renderStatusService.getStatusBSubject(me.layerGroupColumn[group][layer_idx]));
me.uiLayerModelService.setUILayerModel(me.layerGroupColumn[group][layer_idx].id, uiLayerModel);
const uiLayerModel = new UILayerModel(this.layerGroupColumn[group][layer_idx].id, 100, this.renderStatusService.getStatusBSubject(this.layerGroupColumn[group][layer_idx]));
this.uiLayerModelService.setUILayerModel(this.layerGroupColumn[group][layer_idx].id, uiLayerModel);
}
}
// Sort alphabetically by group name
Object.keys(me.layerGroupColumn).forEach(group => {
me.layerGroupColumn[group].sort((a, b) => a.name.localeCompare(b.name));
Object.keys(this.layerGroupColumn).forEach(group => {
this.layerGroupColumn[group].sort((a, b) => a.name.localeCompare(b.name));
});
}
);
Expand All @@ -86,11 +86,10 @@ export class BrowsePanelComponent implements OnInit, AfterViewInit, OnDestroy {
* Called after Angular has initialised the view
*/
public ngAfterViewInit() {
const me = this;
this.userStateService.getBookmarks().subscribe(bookMarkList => {
me.layerBookmarked = {}
this.layerBookmarked = {}
for (const bookMark of bookMarkList) {
me.layerBookmarked[bookMark.fileIdentifier] = true;
this.layerBookmarked[bookMark.fileIdentifier] = true;
}
});
}
Expand Down
129 changes: 63 additions & 66 deletions src/app/cesium-map/csmap.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { catchError, finalize, tap, timeout } from 'rxjs/operators';
import { ToolbarComponent } from 'app/menupanel/toolbar/toolbar.component';

declare var Cesium: any;

Check warning on line 23 in src/app/cesium-map/csmap.component.ts

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected var, use let or const instead

@Component({
selector: 'app-cs-map',
Expand Down Expand Up @@ -343,6 +343,7 @@
this.displayModal(mapClickInfo.clickCoord);

// VT: if it is a csw renderer layer, handling of the click is slightly different
// SW: Note that we no longer use cswrenderer, instead if layer has no WMS/KML etc we look at GeographicElement bbox
if (config.cswrenderer.includes(entity.layer.id) || CsCSWService.cswDiscoveryRendered.includes(entity.layer.id)) {
this.setModalHTML(this.parseCSWtoHTML(entity.cswRecord), entity.cswRecord.name, entity, this.bsModalRef);
}
Expand Down Expand Up @@ -378,95 +379,91 @@
// Build list of GetFeatureInfo requests
const getFeatureInfoRequests: Observable<any>[] = [];
// Total number of features returned from GetFeatureInfo requests
let numberOfFeatures = 0;

Check warning on line 382 in src/app/cesium-map/csmap.component.ts

View workflow job for this annotation

GitHub Actions / build (18)

'numberOfFeatures' is assigned a value but never used

// Process list of layers clicked
for (const maplayer of mapClickInfo.clickedLayerList) {
for (const i of maplayer.clickCSWRecordsIndex) {
const cswRecord = maplayer.cswRecords[i];

// Bail if no OnlineResources
if (!cswRecord.onlineResources || cswRecord.onlineResources.length === 0) {
continue;
}

// Get the WMS OnlineResource, if that fails use the first in the list
let onlineResource = cswRecord.onlineResources.find(or => or.type === ResourceType.WMS);
if (!onlineResource && cswRecord.onlineResources[0]) {
let onlineResource = cswRecord.onlineResources?.find(or => or.type === ResourceType.WMS);

if (!onlineResource && cswRecord.onlineResources?.length > 0) {
onlineResource = cswRecord.onlineResources[0];
}

if (onlineResource) {
// Display CSW record info
if (config.cswrenderer.includes(maplayer.id)) {

if (!UtilitiesService.getLayerHasSupportedOnlineResourceType(maplayer) && UtilitiesService.layerContainsBboxGeographicElement(maplayer)) {
// Display CSW record info
this.displayModal(mapClickInfo.clickCoord);
this.setModalHTML(this.parseCSWtoHTML(cswRecord), cswRecord.name, maplayer, this.bsModalRef);
}

// Display WMS layer info
// Display WMS layer info
const params = this.getParams(maplayer.clickPixel[0], maplayer.clickPixel[1]);
if (!params) {
continue;
}
let sldBody = maplayer.sldBody;
let postMethod = false;
let infoFormat: string;
if (sldBody) {
sldBody = SimpleXMLService.extractIntersectsFiltersFromSld(sldBody);
postMethod = true;
} else {
const params = this.getParams(maplayer.clickPixel[0], maplayer.clickPixel[1]);
if (!params) {
continue;
}
let sldBody = maplayer.sldBody;
let postMethod = false;
let infoFormat: string;
if (sldBody) {
sldBody = SimpleXMLService.extractIntersectsFiltersFromSld(sldBody);
postMethod = true;
} else {
sldBody = '';
}

// WMS 1.3.0 GetFeatureInfo requests will have had their lat,lng coords swapped to lng,lat
if (maplayer.sldBody130) {
sldBody = maplayer.sldBody130;
}
sldBody = '';
}

// Layer specific SLD_BODY, INFO_FORMAT and postMethod
if (onlineResource.name.indexOf('ProvinceFullExtent') >= 0) {
infoFormat = 'application/vnd.ogc.gml';
} else {
infoFormat = 'application/vnd.ogc.gml/3.1.1';
}
// WMS 1.3.0 GetFeatureInfo requests will have had their lat,lng coords swapped to lng,lat
if (maplayer.sldBody130) {
sldBody = maplayer.sldBody130;
}

if (UtilitiesService.resourceIsArcGIS(onlineResource)) {
infoFormat = 'text/xml';
sldBody = '';
postMethod = false;
}
// Layer specific SLD_BODY, INFO_FORMAT and postMethod
if (onlineResource.name.indexOf('ProvinceFullExtent') >= 0) {
infoFormat = 'application/vnd.ogc.gml';
} else {
infoFormat = 'application/vnd.ogc.gml/3.1.1';
}

// GSKY and some Loop3D layers require JSON response
if (config.wmsGetFeatureJSON.indexOf(maplayer.id) !== -1) {
infoFormat = 'application/json';
}
if (UtilitiesService.resourceIsArcGIS(onlineResource)) {
infoFormat = 'text/xml';
sldBody = '';
postMethod = false;
}

if (onlineResource.description.indexOf('EMAG2 - Total Magnetic Intensity') >= 0) {
infoFormat = 'text/xml';
}
// GSKY and some Loop3D layers require JSON response
if (config.wmsGetFeatureJSON.indexOf(maplayer.id) !== -1) {
infoFormat = 'application/json';
}

if (onlineResource.description.indexOf('Onshore Seismic Surveys') >= 0) {
infoFormat = 'text/xml';
}
if (onlineResource.description.indexOf('EMAG2 - Total Magnetic Intensity') >= 0) {
infoFormat = 'text/xml';
}

// Build GetFeatureInfo requests
getFeatureInfoRequests.push(
this.queryWMSService.getFeatureInfo(onlineResource, sldBody, infoFormat, postMethod, maplayer.clickCoord[0],
maplayer.clickCoord[1], params.x, params.y, params.width, params.height, params.bbox).pipe(
timeout(5000),
tap(result => {
// Update the modal features as each request completes
const feature = { onlineResource: onlineResource, layer: maplayer };
const numberOfLayerFeatures = this.setModal(maplayer.id, result, feature, mapClickInfo.clickCoord);
if (numberOfLayerFeatures > 0) {
numberOfFeatures += numberOfLayerFeatures;
}
}), catchError((error) => {
return throwError(error);
})
)
);
if (onlineResource.description.indexOf('Onshore Seismic Surveys') >= 0) {
infoFormat = 'text/xml';
}

// Build GetFeatureInfo requests
getFeatureInfoRequests.push(
this.queryWMSService.getFeatureInfo(onlineResource, sldBody, infoFormat, postMethod, maplayer.clickCoord[0],
maplayer.clickCoord[1], params.x, params.y, params.width, params.height, params.bbox).pipe(
timeout(5000),
tap(result => {
// Update the modal features as each request completes
const feature = { onlineResource: onlineResource, layer: maplayer };
const numberOfLayerFeatures = this.setModal(maplayer.id, result, feature, mapClickInfo.clickCoord);
if (numberOfLayerFeatures > 0) {
numberOfFeatures += numberOfLayerFeatures;
}
}), catchError((error) => {
return throwError(error);
})
)
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@

.activeLayerContent {
width:100%;
color: $text-colour; // XXX Needs to be darker but may be fixed at a higher level
color: $text-colour;
}

.activeLayerDragMessagePanel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ export class ActiveLayersPanelComponent implements AfterViewInit {
* @returns true if supported layer, false otherwise
*/
public isMapSupportedLayer(layer: LayerModel): boolean {
return this.csMapService.isMapSupportedLayer(layer);
return UtilitiesService.isMapSupportedLayer(layer);
}

/**
Expand Down
18 changes: 8 additions & 10 deletions src/app/menupanel/common/filterpanel/filterpanel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export class FilterPanelComponent implements OnInit, AfterViewInit {
}
}

// XXX Sidebar only..?
if (this.layer.filterCollection && this.layer.filterCollection['mandatoryFilters']) {
const mandatoryFilters = this.layer.filterCollection['mandatoryFilters'];
for (const mandatoryFilter of mandatoryFilters) {
Expand Down Expand Up @@ -152,9 +151,8 @@ export class FilterPanelComponent implements OnInit, AfterViewInit {
return optFilt;
});

const me = this;
setTimeout(() => {
for (const optFilter of me.optionalFilters) {
for (const optFilter of this.optionalFilters) {
if (optFilter['value'] && optFilter['type'] === 'OPTIONAL.POLYGONBBOX') {
const geometry = optFilter['value'];
const swappedGeometry = this.csClipboardService.swapGeometry(geometry);
Expand All @@ -170,13 +168,13 @@ export class FilterPanelComponent implements OnInit, AfterViewInit {
this.appRef.tick();
}
}
me.layerManagerService.addLayer(me.layer, me.optionalFilters, me.layerFilterCollection, me.layerTimes.currentTime);
this.layerManagerService.addLayer(this.layer, this.optionalFilters, this.layerFilterCollection, this.layerTimes.currentTime);

// Set opacity of the layer on the map
if (UtilitiesService.layerContainsResourceType(me.layer, ResourceType.WMS)) {
me.csWMSService.setOpacity(this.layer, layerState.opacity / 100.0 );
} else if (this.conf.cswrenderer && this.conf.cswrenderer.includes(me.layer.id)) {
me.csCSWService.setOpacity(this.layer, layerState.opacity / 100.0 );
if (UtilitiesService.layerContainsResourceType(this.layer, ResourceType.WMS)) {
this.csWMSService.setLayerOpacity(this.layer, layerState.opacity / 100.0 );
} else if (UtilitiesService.layerContainsBboxGeographicElement(this.layer)) {
this.csCSWService.setLayerOpacity(this.layer, layerState.opacity / 100.0 );
}
}, 500);
}
Expand Down Expand Up @@ -208,7 +206,7 @@ export class FilterPanelComponent implements OnInit, AfterViewInit {
* @returns true if supported layer, false otherwise
*/
public isMapSupportedLayer(layer: LayerModel): boolean {
return this.csMapService.isMapSupportedLayer(layer);
return UtilitiesService.isMapSupportedLayer(layer);
}

/**
Expand All @@ -217,7 +215,7 @@ export class FilterPanelComponent implements OnInit, AfterViewInit {
*/
public getUnsupportedLayerMessage(): string {
return 'This layer cannot be displayed. Only the following online resource types can be added to the map: ' +
this.csMapService.getSupportedOnlineResourceTypes();
UtilitiesService.getSupportedOnlineResourceTypes();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/app/menupanel/common/model/ui/uilayer.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export class UILayerModel {
statusMap: StatusMapModel;
opacity: number;

constructor(public id: string, public loadingSubject: BehaviorSubject<StatusMapModel>) {
constructor(id: string, opacity: number, loadingSubject: BehaviorSubject<StatusMapModel>) {
this.tabpanel = new UITabPanel();
this.expanded = false;
this.opacity = 100;
this.opacity = opacity;
loadingSubject.subscribe((value) => {
this.statusMap = value;
});
Expand Down
7 changes: 4 additions & 3 deletions src/app/menupanel/custompanel/custompanel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ export class CustomPanelComponent {
for (const layerRec of layerRecs) {
// Make the layer group listing visible in the UI
this.urlLayers.unshift(layerRec);

// Configure layers so they can be added to map
const uiLayerModel = new UILayerModel(layerRec.id, this.renderStatusService.getStatusBSubject(layerRec));
const uiLayerModel = new UILayerModel(layerRec.id, 100, this.renderStatusService.getStatusBSubject(layerRec));
this.uiLayerModelService.setUILayerModel(layerRec.id, uiLayerModel);
}
}
Expand Down Expand Up @@ -391,8 +392,8 @@ export class CustomPanelComponent {
layerRec.group = 'kml-layer';
}
// Configure layers so it can be added to map
const uiLayerModel = new UILayerModel(layerRec.id, me.renderStatusService.getStatusBSubject(layerRec));
me.uiLayerModelService.setUILayerModel(layerRec.id, uiLayerModel);
const uiLayerModel = new UILayerModel(layerRec.id, 100, me.renderStatusService.getStatusBSubject(layerRec));
this.uiLayerModelService.setUILayerModel(layerRec.id, uiLayerModel);
// Make the layer group listing visible in the UI
if (sourceType == "URL" && !this.recordsListContainsRecord(me.urlLayers, name, proxyUrl)) {
me.urlLayers.unshift(layerRec);
Expand Down
5 changes: 3 additions & 2 deletions src/app/menupanel/data-explorer/data-explorer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class DataExplorerComponent implements OnInit {
response["data"].searchErrors[registry.id];
}
for (const item of response["itemLayers"]) {
const uiLayerModel = new UILayerModel(item.id, this.renderStatusService.getStatusBSubject(item));
const uiLayerModel = new UILayerModel(item.id, 100, this.renderStatusService.getStatusBSubject(item));
this.uiLayerModelService.setUILayerModel(item.id, uiLayerModel);
}
response["itemLayers"].useDefaultProxy = true;
Expand Down Expand Up @@ -364,9 +364,10 @@ export class DataExplorerComponent implements OnInit {
registry.recordsMatched = response["data"].recordsMatched;

for (const item of response["itemLayers"]) {
const uiLayerModel = new UILayerModel(item.id, this.renderStatusService.getStatusBSubject(item));
const uiLayerModel = new UILayerModel(item.id, 100, this.renderStatusService.getStatusBSubject(item));
this.uiLayerModelService.setUILayerModel(item.id, uiLayerModel);
}

response["itemLayers"].useDefaultProxy = true;
response["itemLayers"].useProxyWhitelist = false;
if (response["data"].searchErrors && response["data"].searchErrors.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/menupanel/data-explorer/data-explorer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class DataExplorerService {
* @param type
* @param comparison
*/
// XXX GET RID OF THIS AND REPLACE WITH NEXT METHOD
// TODO: GET RID OF THIS AND REPLACE WITH NEXT METHOD
public getFacetedSearch(serviceId: string, start: number, limit: number,
field: string[], value: string[], type: string[], comparison: string[]): Observable<any> {

Expand Down
2 changes: 1 addition & 1 deletion src/app/menupanel/search/searchpanel.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
<span class="layer-header-label" title="{{searchResult.layer.name}}">{{ searchResult.layer.name }}</span>
<span class="csw-label search-result-button" *ngIf="searchResult.layer.id.startsWith('registry-csw:')">CSW</span>
<span class="layer-label search-result-button" *ngIf="!searchResult.layer.id.startsWith('registry-csw:')">Featured</span>
<button *ngIf="!isLayerAdded(searchResult.layer.id)" [disabled]="!csMapService.isMapSupportedLayer(searchResult.layer)" class="btn btn-sm btn-success search-result-button" type="button" title="Add layer" (click)="addLayer(searchResult.layer)"><i class="fa fa-plus-circle"></i>&nbsp;Add</button>
<button *ngIf="!isLayerAdded(searchResult.layer.id)" [disabled]="!isMapSupportedLayer(searchResult.layer)" class="btn btn-sm btn-success search-result-button" type="button" title="Add layer" (click)="addLayer(searchResult.layer)"><i class="fa fa-plus-circle"></i>&nbsp;Add</button>
<button *ngIf="isLayerAdded(searchResult.layer.id)" class="btn btn-sm btn-danger search-result-button" type="button" title="Remove layer" (click)="removeLayer($event, searchResult.layer)"><i class="fa fa-trash"></i>&nbsp;Remove</button>
<button class="btn btn-sm btn-info" type="button" title="Layer information" (click)="showLayerInformation($event, searchResult.layer)"><i class="fa fa-info-circle"></i>&nbsp;Info</button>
<button class="btn btn-sm btn-primary search-result-button" type="button" title="Add to download" [style.visibility]="isCsvDownloadable(searchResult.layer) ? 'visible' : 'hidden'">
Expand Down
Loading
Loading