Skip to content

Commit

Permalink
Fixed issue where user could be told there were no features after cli…
Browse files Browse the repository at this point in the history
…cking even when there were features.
  • Loading branch information
stuartwoodman committed Dec 8, 2023
1 parent c4b5179 commit 37b4211
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
44 changes: 36 additions & 8 deletions src/app/cesium-map/csmap.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,23 @@ export class CsMapComponent implements AfterViewInit {
}
}

/**
* Update the modal with downloading or zoom messages if required
*
* @param numberOfLayersToProcess number of layers left to process
* @param foundFeatures whether features have been found for any of the layers
* @param mayRequireMapZoom whether anyy of the layers may require zooming for accuracy
*/
setModalMessages(numberOfLayersToProcess: number, foundFeatures: boolean, mayRequireMapZoom: boolean) {
if (numberOfLayersToProcess === 0) {
this.bsModalRef.content.downloading = false;
if (!foundFeatures && mayRequireMapZoom) {
this.bsModalRef.content.showZoomMsg = true;
}
}
this.bsModalRef.content.onDataChange();
}

/**
* Handles the map click event
* @param mapClickInfo object with map click information
Expand Down Expand Up @@ -353,7 +370,13 @@ export class CsMapComponent implements AfterViewInit {
*/
}

// Open the modal for display
this.displayModal(mapClickInfo.clickCoord);

// Process list of layers clicked
let foundFeatures = false;
let numberOfLayersToProcess = mapClickInfo.clickedLayerList.length;
let mayRequireMapZoom = false;
for (const maplayer of mapClickInfo.clickedLayerList) {
for (const i of maplayer.clickCSWRecordsIndex ) {
const cswRecord = maplayer.cswRecords[i];
Expand All @@ -379,6 +402,7 @@ export class CsMapComponent implements AfterViewInit {
} else {
const params = this.getParams(maplayer.clickPixel[0], maplayer.clickPixel[1]);
if (!params) {
numberOfLayersToProcess -= 1;
continue;
}
let sldBody = maplayer.sldBody;
Expand Down Expand Up @@ -422,21 +446,24 @@ export class CsMapComponent implements AfterViewInit {
infoFormat = 'text/xml';
}

// Query GetFeatureInfo for current layer
this.queryWMSService.getFeatureInfo(onlineResource, sldBody, infoFormat, postMethod,
maplayer.clickCoord[0], maplayer.clickCoord[1], params.x, params.y, params.width, params.height, params.bbox).subscribe(result => {
numberOfLayersToProcess -= 1;
const feature = {onlineResource: onlineResource, layer: maplayer};
// Display the modal, but only if there are features
const num_feats = this.setModal(maplayer.id, result, feature, mapClickInfo.clickCoord);

// If zoom level is too low and nothing is found then show zoom message
if (num_feats === 0 && params.level <= 3) {
this.displayModal(mapClickInfo.clickCoord);
this.bsModalRef.content.downloading = false;
this.bsModalRef.content.showZoomMsg = true;
if (num_feats > 0) {
foundFeatures = true;
}
// If zoom level is too low and nothing is found then show zoom message (provided no other features found in other layers)
else if (num_feats === 0 && params.level <= 3) {
mayRequireMapZoom = true;
}
this.setModalMessages(numberOfLayersToProcess, foundFeatures, mayRequireMapZoom);
}, () => {
this.bsModalRef.content.onDataChange();
this.bsModalRef.content.downloading = false;
numberOfLayersToProcess -= 1;
this.setModalMessages(numberOfLayersToProcess, foundFeatures, mayRequireMapZoom);
});
}
}
Expand Down Expand Up @@ -476,6 +503,7 @@ export class CsMapComponent implements AfterViewInit {
this.bsModalRef = this.modalService.show(QuerierModalComponent, {class: 'modal-lg'});
this.modalDisplayed = true;
this.bsModalRef.content.downloading = true;
this.bsModalRef.content.showZoomMsg = false;
/*
if (clickCoord) {
const vector = this.csMapService.drawDot(clickCoord);
Expand Down
2 changes: 1 addition & 1 deletion src/app/modalwindow/querier/querier.modal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1 class="page-header">Feature Information</h1>
<!-- BEGIN querier accordion -->
<div id="querier-accordion">
<!-- BEGIN card -->
<div *ngIf="showZoomMsg">
<div *ngIf="showZoomMsg && !downloading">
<h2 style="margin-top:10px;">No results found, try zooming to improve accuracy</h2>
</div>
<div *ngFor="let doc of docs | querierFeatureSearchPipe:selectLayerNameFilter; let i = index;" class="card card-default card-bordered">
Expand Down

0 comments on commit 37b4211

Please sign in to comment.