Skip to content

Commit

Permalink
fix: download linked objects in a WFS using "resolvedepth"
Browse files Browse the repository at this point in the history
Using "resolvedepth" when trying to download data via WFS is now downloading the linked objects.
As the requested hits to a WFS is better to be setup to UNKNOWN_SIZE, so the size comes as well to be always UNKNOWN_SIZE, the code related to hits and size has been removed and the related methods have been changed accordingly.

ING-4128
Closes halestudio#1084
  • Loading branch information
emanuelaepure10 committed May 24, 2024
1 parent 247bc7c commit dd5d1a5
Showing 1 changed file with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,19 @@ public WfsBackedGmlInstanceCollection(LocatableInputSupplier<? extends InputStre

// Use primordial URI and issue "hits" request to check if the WFS will
// return anything at all
int hits;
if (ignoreNumberMatched) {
hits = UNKNOWN_SIZE;
}
else {
try {
hits = requestHits(primordialUri);
} catch (WFSException e) {
log.debug(MessageFormat.format(
"Failed to perform hits query (REQUESTTYPE=hits): {0}", e.getMessage()), e);
hits = UNKNOWN_SIZE;
}
}
int hits = UNKNOWN_SIZE;
// if (ignoreNumberMatched) {
// hits = UNKNOWN_SIZE;
// }
// else {
// try {
// hits = requestHits(primordialUri);
// } catch (WFSException e) {
// log.debug(MessageFormat.format(
// "Failed to perform hits query (REQUESTTYPE=hits): {0}", e.getMessage()), e);
// hits = UNKNOWN_SIZE;
// }
// }

switch (wfsVersion) {
case "1.1.0":
Expand Down Expand Up @@ -372,20 +372,20 @@ public Instance getInstance(InstanceReference reference) {
}
}

private int requestHits(URI requestUri) throws WFSException {
URIBuilder builder = new URIBuilder(requestUri);
builder.addParameter("RESULTTYPE", "hits");

InputStream in;
try {
in = builder.build().toURL().openStream();
} catch (IOException | URISyntaxException e) {
throw new WFSException(
MessageFormat.format("Unable to execute WFS request: {0}", e.getMessage()), e);
}

return FeatureCollectionHelper.getNumberOfFeatures(in);
}
// private int requestHits(URI requestUri) throws WFSException {
// URIBuilder builder = new URIBuilder(requestUri);
// builder.addParameter("RESULTTYPE", "hits");
//
// InputStream in;
// try {
// in = builder.build().toURL().openStream();
// } catch (IOException | URISyntaxException e) {
// throw new WFSException(
// MessageFormat.format("Unable to execute WFS request: {0}", e.getMessage()), e);
// }
//
// return FeatureCollectionHelper.getNumberOfFeatures(in);
// }

private String getMaxFeaturesParameterName(String version) {
// XXX Use WFSVersion
Expand Down Expand Up @@ -635,4 +635,4 @@ public void skip() {

}

}
}

0 comments on commit dd5d1a5

Please sign in to comment.