Hi,
I am trying to limit the fields returned by a WFS GetFeature request.
This needs to be an enforced policy. Reading the documentation I found
that a schema document could be prepared and added to the data
directory. I followed the instructions and had some success, a
DescribeFeatureType request did not list the field as present.
Then I ran into problems. If I request the data as 'gml3' then the field
is not present, however request 'csv', 'json' or 'shape-zip' and the
field is present.
Is this a know bug and if so is there a workaround? Better still, is
there an easier way of achieving the desired result :-)
Below are instructions for reproducing on a base install of GeoServer
(version 2.0.3 stable) running on Tomcat 6.0.26 with Java JDK 1.6.0_20.
I tried on the latest RC (2.1-RC4) using own data, have not replicated
with this test case but can if necessary. I stripped point data out and
limited this to one feature for sake of brevity, replaced with the text
**snip**. You will see that the attribute CFCC was hidden, not present
in the GML download, but still present in the JSON and CSV downloads.
Issue a DescribeFeatureType request to determine available attributes:
======================================================================
http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=De
scribeFeatureType&typeName=tiger:poly%5Flandmarks
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:cite="http://www.opengeospatial.net/cite"
xmlns:gml="http://www.opengis.net/gml"
xmlns:it.geosolutions="http://www.geo-solutions.it"
xmlns:nurc="http://www.nurc.nato.int"
xmlns:sde="http://geoserver.sf.net"
xmlns:sf="http://www.openplans.org/spearfish"
xmlns:tiger="http://www.census.gov"
xmlns:topp="http://www.openplans.org/topp"
elementFormDefault="qualified" targetNamespace="http://www.census.gov">
<xsd:import namespace="http://www.opengis.net/gml"
schemaLocation="http://localhost:8080/geoserver/schemas/gml/3.1.1/base/g
ml.xsd"/>
<xsd:complexType name="poly_landmarksType">
<xsd:complexContent>
<xsd:extension base="gml:AbstractFeatureType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="the_geom"
nillable="true" type="gml:MultiSurfacePropertyType"/>
<xsd:element maxOccurs="1" minOccurs="0" name="LAND"
nillable="true" type="xsd:double"/>
<xsd:element maxOccurs="1" minOccurs="0" name="CFCC"
nillable="true" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="LANAME"
nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="poly_landmarks" substitutionGroup="gml:_Feature"
type="tiger:poly_landmarksType"/>
</xsd:schema>
Change the schema as shown below (comment out one field):
=========================================================
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:cite="http://www.opengeospatial.net/cite"
xmlns:gml="http://www.opengis.net/gml"
xmlns:it.geosolutions="http://www.geo-solutions.it"
xmlns:nurc="http://www.nurc.nato.int"
xmlns:sde="http://geoserver.sf.net"
xmlns:sf="http://www.openplans.org/spearfish"
xmlns:tiger="http://www.census.gov"
xmlns:topp="http://www.openplans.org/topp"
elementFormDefault="qualified" targetNamespace="http://www.census.gov">
<xsd:import namespace="http://www.opengis.net/gml"
schemaLocation="http://localhost:8080/geoserver/schemas/gml/3.1.1/base/g
ml.xsd"/>
<xsd:complexType name="poly_landmarksType">
<xsd:complexContent>
<xsd:extension base="gml:AbstractFeatureType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="the_geom"
nillable="true" type="gml:MultiSurfacePropertyType"/>
<xsd:element maxOccurs="1" minOccurs="0" name="LAND"
nillable="true" type="xsd:double"/>
<!--
<xsd:element maxOccurs="1" minOccurs="0" name="CFCC"
nillable="true" type="xsd:string"/>
-->
<xsd:element maxOccurs="1" minOccurs="0" name="LANAME"
nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="poly_landmarks" substitutionGroup="gml:_Feature"
type="tiger:poly_landmarksType"/>
</xsd:schema>
Save schema in required directory:
==================================
C:\apache-tomcat-6.0.26\webapps\geoserver\data\workspaces\tiger\nyc\poly
_landmarks\schema.xsd
Restart Tomcat
==============
Issue a DescribeFeatureType request to verify attribute hidden:
===============================================================
http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=De
scribeFeatureType&typeName=tiger:poly%5Flandmarks
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:cite="http://www.opengeospatial.net/cite"
xmlns:gml="http://www.opengis.net/gml"
xmlns:it.geosolutions="http://www.geo-solutions.it"
xmlns:nurc="http://www.nurc.nato.int"
xmlns:sde="http://geoserver.sf.net"
xmlns:sf="http://www.openplans.org/spearfish"
xmlns:tiger="http://www.census.gov"
xmlns:topp="http://www.openplans.org/topp"
elementFormDefault="qualified" targetNamespace="http://www.census.gov">
<xsd:import namespace="http://www.opengis.net/gml"
schemaLocation="http://localhost:8080/geoserver/schemas/gml/3.1.1/base/g
ml.xsd"/>
<xsd:complexType name="poly_landmarksType">
<xsd:complexContent>
<xsd:extension base="gml:AbstractFeatureType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="the_geom"
nillable="true" type="gml:MultiSurfacePropertyType"/>
<xsd:element maxOccurs="1" minOccurs="0" name="LAND"
nillable="true" type="xsd:double"/>
<xsd:element maxOccurs="1" minOccurs="0" name="LANAME"
nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="poly_landmarks" substitutionGroup="gml:_Feature"
type="tiger:poly_landmarksType"/>
</xsd:schema>
Request features as GML
=======================
http://localhost:8080/geoserver/wfs?&service=wfs&version=1.1.0&request=G
etFeature&typeName=tiger:poly_landmarks&outputFormat=gml3&maxFeatures=1
<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection numberOfFeatures="2"
timeStamp="2011-04-20T15:55:11.412+01:00"
xsi:schemaLocation="http://www.census.gov
http://localhost:8080/geoserver/wfs?service=WFS&version=1.1.0&re
quest=DescribeFeatureType&typeName=tiger%3Apoly_landmarks
http://www.opengis.net/wfs
http://localhost:8080/geoserver/schemas/wfs/1.1.0/wfs.xsd"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:tiger="http://www.census.gov"
xmlns:cite="http://www.opengeospatial.net/cite"
xmlns:nurc="http://www.nurc.nato.int"
xmlns:sde="http://geoserver.sf.net"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:topp="http://www.openplans.org/topp"
xmlns:it.geosolutions="http://www.geo-solutions.it"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sf="http://www.openplans.org/spearfish"
xmlns:ows="http://www.opengis.net/ows"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink">
<gml:featureMembers>
<tiger:poly_landmarks gml:id="poly_landmarks.1">
<tiger:the_geom>
<gml:MultiSurface srsDimension="2"
srsName="urn:x-ogc:def:crs:EPSG:4326">
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>**snip**</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:MultiSurface>
</tiger:the_geom>
<tiger:LAND>2.0</tiger:LAND>
<tiger:LANAME>Washington Square Park</tiger:LANAME>
</tiger:poly_landmarks>
</gml:featureMembers>
</wfs:FeatureCollection>
Request feature as JSON:
========================
http://localhost:8080/geoserver/wfs?&service=wfs&version=1.1.0&request=G
etFeature&typeName=tiger:poly_landmarks&outputFormat=json&maxFeatures=1
{
"type":"FeatureCollection",
"features":[
{
"type":"Feature",
"id":"poly_landmarks.1",
"geometry":{
"type":"MultiPolygon",
"coordinates":[
[
[
**snip**
]
]
]
},
"geometry_name":"the_geom",
"properties":{
"LAND":2,
"CFCC":"D85",
"LANAME":"Washington Square Park"
}
}
],
"crs":{
"type":"EPSG",
"properties":{
"code":"4326"
}
},
"bbox":[
40.72999,
-73.99955899999999,
40.738821,
-73.985192
]
}
Request feature as CSV:
=======================
http://localhost:8080/geoserver/wfs?&service=wfs&version=1.1.0&request=G
etFeature&typeName=tiger:poly_landmarks&outputFormat=csv&maxFeatures=1
FID,the_geom,LAND,CFCC,LANAME
poly_landmarks.1,"MULTIPOLYGON ((**snip**))",2,D85,Washington Square
Park
This email is only intended for the person to whom it is addressed and may
contain confidential information. If you have received this email in error,
please notify the sender and delete this email which must not be copied,
distributed or disclosed to any other person.
Unless stated otherwise, the contents of this email are personal to the writer
and do not represent the official view of Ordnance Survey. Nor can any contract
be formed on Ordnance Survey's behalf via email. We reserve the right to
monitor emails and attachments without prior notice.
Thank you for your cooperation.
Ordnance Survey
Adanac Drive
Southampton SO16 0AS
Tel: 08456 050505
http://www.ordnancesurvey.co.uk
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users