Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,6 @@ public List<LayerInfo> filterLayersByWfsLinks(String collectionId, List<LayerInf
.filter(link -> link.getAiGroup().contains(WFS_LINK_MARKER))
.toList();

if (wfsLinks.isEmpty()) {
log.warn("Return empty layers if as no WFS links found for collection {}", collectionId);
return Collections.emptyList();
}

// Filter WMS layers based on matching with WFS links
List<LayerInfo> filteredLayers = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,17 @@ public List<LayerInfo> fetchCapabilitiesLayersByUrl(String wmsServerUrl) {
return Collections.emptyList();
}
/**
* Get filtered layers from WMS GetCapabilities for a specific collection
* Get filtered layers from WMS GetCapabilities for a specific collection, we use this function because we do not
* trust the WMS layer value because it can be wrong, we use the WFS link to infer the layer and therefore the layer
* name return will be operational with WFS function.
* First fetches all layers (cached by URL), then filters by WFS links (cached by UUID)
*
* @param collectionId - The uuid
* @param request - The request param
* @return - List of LayerInfo objects filtered by WFS link matching
*/
public List<LayerInfo> getCapabilitiesLayers(String collectionId, FeatureRequest request) {
Optional<String> mapServerUrl = getMapServerUrl(collectionId, request);
Optional<String> mapServerUrl = getMapServerUrl(collectionId, null);

if (mapServerUrl.isPresent()) {
// Fetch all layers from GetCapabilities (this call is cached by URL)
Expand All @@ -594,7 +596,23 @@ public List<LayerInfo> getCapabilitiesLayers(String collectionId, FeatureRequest
if (!allLayers.isEmpty()) {
// Filter layers based on WFS link matching
List<LayerInfo> filteredLayers = wfsServer.filterLayersByWfsLinks(collectionId, allLayers);
log.debug("Returning filteredLayers {}", filteredLayers);

// If filteredLayers empty, that means no layer have wfs operation, but that does not mean
// the layer cannot serve for display only.
if(filteredLayers.isEmpty() && request.getLayerName() != null) {
DescribeLayerResponse dr = describeLayer(collectionId, request);
if(dr != null) {
// That means at least layer is valid just not operational
return List.of(
LayerInfo.builder()
.name(dr.getLayerDescription().getName())
.title(dr.getLayerDescription().getName())
.queryable("0")
.build()
);
}
}
log.debug("Returning layers {}", filteredLayers);

return filteredLayers;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.org.aodn.ogcapi.server.features;

import au.org.aodn.ogcapi.features.model.Collection;
import au.org.aodn.ogcapi.server.core.exception.DownloadableFieldsNotFoundException;
import au.org.aodn.ogcapi.server.core.model.ogc.FeatureRequest;
import au.org.aodn.ogcapi.server.core.model.ogc.wms.FeatureInfoResponse;
import au.org.aodn.ogcapi.server.core.model.ogc.wms.LayerInfo;
Expand Down Expand Up @@ -122,14 +123,18 @@ public ResponseEntity<?> getWmsDownloadableFields(String collectionId, FeatureRe
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
}
else {
List<DownloadableFieldModel> result = wmsServer.getDownloadableFields(collectionId, request);
try {
List<DownloadableFieldModel> result = wmsServer.getDownloadableFields(collectionId, request);

return result.isEmpty() ?
ResponseEntity.notFound().build() :
ResponseEntity.ok(result);
return result.isEmpty() ?
ResponseEntity.notFound().build() :
ResponseEntity.ok(result);
}
catch(DownloadableFieldsNotFoundException nfe) {
return ResponseEntity.notFound().build();
}
}
}

/**
* This is used to get all available layers from WMS GetCapabilities
*
Expand All @@ -144,7 +149,6 @@ public ResponseEntity<?> getWmsLayers(String collectionId, FeatureRequest reques
ResponseEntity.notFound().build() :
ResponseEntity.ok(result);
}

/**
* @param collectionID - uuid
* @param from -
Expand Down
Loading