0

In GeoServer, I installed an app-schema linked to a PostGIS database. When I call the layer via the WFS GetFeature I have an INSPIRE compliant GML file that looks like (small portion of the GML):

<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sams="http://www.opengis.net/samplingSpatial/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:nurc="http://www.nurc.nato.int" xmlns:tiger="http://www.census.gov" xmlns:topp="http://www.openplans.org/topp" xmlns:omso="http://inspire.ec.europa.eu/schemas/omso/3.0" xmlns:sf="http://www.openplans.org/spearfish" xmlns:sde="http://geoserver.sf.net" xmlns:nns__3="http://www.opengis.net/sampling/2.0" xmlns:cite="http://www.opengeospatial.net/cite" xmlns:nns__4="http://www.opengis.net/swe/2.0" xmlns:it.geosolutions="http://www.geo-solutions.it" xmlns:om="http://www.opengis.net/om/2.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberMatched="unknown" numberReturned="50" timeStamp="2018-11-13T13:27:39.776Z" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://localhost:8080/geoserver/schemas/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://localhost:8080/geoserver/schemas/gml/3.2.1/gml.xsd http://inspire.ec.europa.eu/schemas/omso/3.0 http://inspire.ec.europa.eu/schemas/omso/3.0/SpecialisedObservations.xsd">
  <wfs:member>
    <omso:PointObservation gml:id="all_values.fid-60e72fae_1670d1c707c_-7d40">    
        <om:parameter xlink:href="ef.EnvironmentalMonitoringFacility.marine.BEFED_ZG03">
            <om:NamedValue>
              <om:name xlink:href="https://inspire.ec.europa.eu/theme/ef"/>
              <om:value>ZG03</om:value>
            </om:NamedValue>
        </om:parameter>

However this app-schema is linked to my entire database (+-2millions points) so I need to be able to filter the GML generated. To perform that I used to use the "viewParams" filter (e.g. http://localhost:8080/geoserver/omso/ows?service=WFS&version=1.1.0&request=GetFeature&typeName=omso%3APointObservation&viewParams=value:ZG03 )

That worked fine for simple features. Now I need to filter on nested property of complex features but I don't know whether it is possible or how to do it.

For instance, how could I extract points from my db where the parameter value is "ZG03" (see GML extract above)?

Edit:

Based on what you suggested. I try to use the filter function but still can't make it works. Here is the code I'm using:

http://localhost:8080/geoserver/omso/ows?service=WFS&version=1.1.0&request=GetFeature&typeName=omso%3APointObservation&Filter=
<fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0"
 xmlns:gml="http://www.opengis.net/gml/3.2"
 xmlns:omso="http://inspire.ec.europa.eu/schemas/omso/3.0"
 xmlns:om="http://www.opengis.net/om/2.0">
         <fes:PropertyIsEqualTo>
                 <fes:PropertyName>/wfs:FeatureCollection[@xmlns:wfs="http://www.opengis.net/wfs/2.0"]/wfs:member[1]/omso:PointObservation/om:parameter/om:NamedValue/om:value/text()</fes:PropertyName>
                 <Literal>ZG03</Literal>
         </fes:PropertyIsEqualTo>
 </fes:Filter> 

Any suggestion?

Edit2

Actually, an answer could be that the schema is not directly visible to the filter. I explain. The schema I use is the INSPIRE specialisedObservation.xsd. If I check the schema with wfs function DescribeFeatureType, the answer is only:

<xsd:schema elementFormDefault="qualified" targetNamespace="http://inspire.ec.europa.eu/schemas/omso/3.0"><xsd:include schemaLocation="http://inspire.ec.europa.eu/schemas/omso/3.0/SpecialisedObservations.xsd"/></xsd:schema>

So the element I'm looking for is not located directly there, but is in another schema imported at the beginning of the SpecializedObservations.xsd schema

<import namespace="http://www.opengis.net/om/2.0" schemaLocation="http://schemas.opengis.net/om/2.0/observation.xsd"/>

Could this explain why the filter function is not working properly?

0

In general it is easiest (and most efficient) to use a filter to restrict the features returned by your WFS request.

So in your case I think you would need something like:

<fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:om=".....">
  <fes:PropertyEquals>
    <fes:ValueReference>om:NamedValue</fes:ValueReference>
    <om:NamedValue>
      <om:name xlink:href="https://inspire.ec.europa.eu/theme/ef"/>
      <om:value>ZG03</om:value>
    </om:NamedValue>
  </fes:PropertyEquals>
</fes:Filter>
  • and is there a way to translate the filter function in the GetFeature request? What I need eventually is a link to download the data from a GeoNetwork – Nicolas deville Nov 13 '18 at 15:23
  • just add filter= and the URLencoded value of the filter – Ian Turton Nov 13 '18 at 15:40
0

I think you'll need something like below (HTTP POST) request

<GetFeature version="2.0.0" service="WFS" 
  xmlns="http://www.opengis.net/wfs/2.0" 
  xmlns:gml="http://www.opengis.net/gml/3.2" 
  xmlns:ef="https://inspire.ec.europa.eu/theme/ef"
  xmlns:om="http://www.opengis.net/om/2.0"
  xmlns:ompr="http://inspire.ec.europa.eu/schemas/ompr/3.0"
  xmlns:omso="http://inspire.ec.europa.eu/schemas/omso/3.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:wfs="http://www.opengis.net/wfs/2.0"
  xmlns:xlink="http://www.w3.org/1999/xlink">
  <Query typeNames="omso:PointObservation">
    <Filter xmlns="http://www.opengis.net/fes/2.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ef="https://inspire.ec.europa.eu/theme/ef">
      <PropertyIsEqualTo>
        <ValueReference>{XPath to the location of the property}</ValueReference>
        <Literal>ZG03</Literal>
      </PropertyIsEqualTo>
    </Filter>
  </Query>
</GetFeature>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.