0

I am trying to use this documentation:

https://docs.geoserver.org/stable/en/user/services/wfs/reference.html#getfeature

to figure out a way where I can limit the attributes returned by a wfs call. If we use this example, I am expecting that this call would only return the GEOMETRY and the LOCALITY attribute

https://openmaps.gov.bc.ca/geo/pub/wfs?
SERVICE=WFS&
VERSION=2.0.0&
REQUEST=GetFeature&
outputFormat=application%2Fjson&
typeNames=WHSE_IMAGERY_AND_BASE_MAPS.GSR_AIRPORTS_SVW&
SRSNAME=EPSG%3A3005&
propertyName=LOCALITY&
COUNT=10
3

Check also the schema with DescribeFeatureType.

https://openmaps.gov.bc.ca/geo/pub/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=DescribeFeatureType&typenames=WHSE_IMAGERY_AND_BASE_MAPS.GSR_AIRPORTS_SVW

<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:pub="http://openmaps.gov.bc.ca/geo/" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://openmaps.gov.bc.ca/geo/">
  <xsd:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="http://openmaps.gov.bc.ca/geo/schemas/gml/3.2.1/gml.xsd"/>
  <xsd:complexType name="WHSE_IMAGERY_AND_BASE_MAPS.GSR_AIRPORTS_SVWType">
    <xsd:complexContent>
      <xsd:extension base="gml:AbstractFeatureType">
        <xsd:sequence>
          <xsd:element maxOccurs="1" minOccurs="1" name="CUSTODIAN_ORG_DESCRIPTION" nillable="false" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="1" name="BUSINESS_CATEGORY_CLASS" nillable="false" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="1" name="BUSINESS_CATEGORY_DESCRIPTION" nillable="false" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="1" name="OCCUPANT_TYPE_DESCRIPTION" nillable="false" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="1" name="SOURCE_DATA_ID" nillable="false" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="1" name="SUPPLIED_SOURCE_ID_IND" nillable="false" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="1" name="AIRPORT_NAME" nillable="false" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="DESCRIPTION" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="PHYSICAL_ADDRESS" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="ALIAS_ADDRESS" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="STREET_ADDRESS" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="POSTAL_CODE" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="1" name="LOCALITY" nillable="false" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="CONTACT_PHONE" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="CONTACT_EMAIL" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="CONTACT_FAX" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="WEBSITE_URL" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="IMAGE_URL" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="1" name="LATITUDE" nillable="false" type="xsd:decimal"/>
          <xsd:element maxOccurs="1" minOccurs="1" name="LONGITUDE" nillable="false" type="xsd:decimal"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="KEYWORDS" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="DATE_UPDATED" nillable="true" type="xsd:date"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="SITE_GEOCODED_IND" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="AERODROME_STATUS" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="AIRCRAFT_ACCESS_IND" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="DATA_SOURCE" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="DATA_SOURCE_YEAR" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="ELEVATION" nillable="true" type="xsd:decimal"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="FUEL_AVAILABILITY_IND" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="HELICOPTER_ACCESS_IND" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="IATA_CODE" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="ICAO_CODE" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="MAX_RUNWAY_LENGTH" nillable="true" type="xsd:decimal"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="NUMBER_OF_RUNWAYS" nillable="true" type="xsd:decimal"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="OIL_AVAILABILITY_IND" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="RUNWAY_SURFACE" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="SEAPLANE_ACCESS_IND" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="TC_LID_CODE" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="SHAPE" nillable="true" type="gml:GeometryPropertyType"/>
          <xsd:element maxOccurs="1" minOccurs="1" name="SEQUENCE_ID" nillable="false" type="xsd:decimal"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="SE_ANNO_CAD_DATA" nillable="true" type="xsd:hexBinary"/>
        </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>
  <xsd:element name="WHSE_IMAGERY_AND_BASE_MAPS.GSR_AIRPORTS_SVW" substitutionGroup="gml:AbstractFeature" type="pub:WHSE_IMAGERY_AND_BASE_MAPS.GSR_AIRPORTS_SVWType"/>
</xsd:schema>

WFS server must send all the attributes which are not nillable in addition to what user requests with the PropertyName list. Therefory you get for example SOURCE_DATA_ID but you do not get AERODROME_STATUS and other nillable attributes.

Geometry is nillable and you do not ask for it and therefore it is not included in the result.

"SHAPE" nillable="true" type="gml:GeometryPropertyType"
  • 1
    +1 was just about to post this. Can also check minOccurs, if minOccurs="1" then the attribute gets returned. – user2856 Apr 4 at 22:02
  • Interesting. So the implication are the some attributes are "sticky" and can't be dropped. What would the rationale be behind that? – boshek Apr 4 at 22:41
  • The rational is that the schema says they are not optional and so they must be included as your returned feature is required to be of that schema – Ian Turton Apr 5 at 7:14

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.