Skip to content

Commit

Permalink
Merge pull request #1629 from lat-lon/feature/srsNameStoredQuery-X-2307
Browse files Browse the repository at this point in the history
Add support of srsName in StoredQueries
  • Loading branch information
copierrj authored Apr 10, 2024
2 parents 6abc0e8 + 5fa5ddf commit 775c34f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

import java.io.IOException;
import java.io.StringReader;
import java.math.BigInteger;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -260,10 +259,11 @@ private List<Pair<AdHocQuery, org.deegree.protocol.wfs.query.Query>> convertTemp
try {
String templ = IOUtils.toString(u.openStream());
for (Entry<String, OMElement> e : query.getParams().entrySet()) {
String val = e.getValue().getText();
Pattern p = Pattern.compile("[$][{]" + e.getKey() + "[}]", Pattern.CASE_INSENSITIVE);
templ = p.matcher(templ).replaceAll(val);
String key = e.getKey();
templ = replaceParam(key, e.getValue().getText(), templ);
}
String defaultSrsName = controller.getDefaultQueryCrs().getAlias();
templ = replaceParam("srsName", defaultSrsName, templ);

LOG.debug("Stored query template after replacement: {}", templ);

Expand All @@ -287,6 +287,11 @@ private List<Pair<AdHocQuery, org.deegree.protocol.wfs.query.Query>> convertTemp
}
}

private static String replaceParam(String key, String val, String templ) {
Pattern p = Pattern.compile("[$][{]" + key + "[}]", Pattern.CASE_INSENSITIVE);
return p.matcher(templ).replaceAll(val);
}

private List<Pair<AdHocQuery, org.deegree.protocol.wfs.query.Query>> convertStoredQueries(
List<org.deegree.protocol.wfs.query.Query> wfsQueries) throws OWSException {
List<Pair<AdHocQuery, org.deegree.protocol.wfs.query.Query>> adHocQueries = new ArrayList<Pair<AdHocQuery, org.deegree.protocol.wfs.query.Query>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ StoredQueryDefinition file. Here's an example:
</Parameter>
<QueryExpressionText returnFeatureTypes="ad:Address"
language="urn:ogc:def:queryLanguage:OGC-:WFSQueryExpression">
<Query typeNames="ad:Address">
<Query srsName="${srsName}" typeNames="ad:Address">
<Filter xmlns="http://www.opengis.net/fes/2.0">
<PropertyIsEqualTo>
<ValueReference>
Expand Down Expand Up @@ -866,6 +866,8 @@ Query-Elements should be used. An exception is thrown as
DescribeStoredQueries response, if the configured feature type is not
served by the WFS.

The optional attribute _srsName="${srsName}"_ can be set to support the parameter _srsName_ in the GetFeature request to determine the CRS of the returned geometries. If the paramater is missing in the request, the default CRS of the WFS is returned.

To enable support for the Manage Stored Queries conformance class for WFS 2.0.0 it is required to create a directory storedqueries/managed in your workspace. The stored queries created with _CreateStoredQuery_ requests are stored in this directory. They are loaded during startup of deegree automatically. It is not recommend to put the StoredQueries configured in the WFS configuration with the StoredQuery element into this folder. If the directory is missing the _CreateStoredQuery_ request returns an exception.

TIP: deegree WFS supports the execution of stored queries using
Expand Down

0 comments on commit 775c34f

Please sign in to comment.