[mapserver-dev] WFS 1.0.0 support in MapServer
Daniel Morissette
morissette at dmsolutions.ca
Wed Oct 9 16:12:47 EDT 2002
Hi,
I have committed to the MapServer CVS a first version of OGC WFS 1.0.0
server and client support. There is still some work and testing to do
before it can be called complete, but if anyone feels brave then you can
start playing with it (experienced users only, please!).
The current implementation is complete enough for a MapServer
application to be able to render WFS layers from a remote MapServer WFS
server, including attribute classification, etc... really cool! I'm
still working on supporting queries on WFS layers, and proper projection
support at both client and server ends (for now limit yourselves to
mapfiles and WFS layers in the same projection).
I attached to this message Draft documentation for what will eventually
become the WFS server and WFS client HOWTOs... it should contain enough
information for experienced users to get started with WFS.
Finally, I haven't been able to find any working WFS client or server on
the net to use in validating the MapServer implementation of the
protocol. All I found were either incomplete prototypes or broken
pages. So if anyone knows of a publicly available and functional WFS
1.0 client and/or server that we could use for testing then please let
us know.
Daniel
--
------------------------------------------------------------
Daniel Morissette morissette at dmsolutions.ca
DM Solutions Group http://www.dmsolutions.ca/
------------------------------------------------------------
Don't put for tomorrow what you can do today, because if
you enjoy it today you can do it again tomorrow.
-------------- next part --------------
MapServer WFS Server HOWTO
--------------------------
Support for serving OGC Web Feature Service (WFS) version 1.0.0 requests
has been added to MapServer in version 3.7. This allows remote clients
to connect to a MapServer instance via a standard protocol and access
vector features in GML format.
The current implementation is a "Basic WFS" as defined in the specification.
This means that it provides only read-only access to the data but does not
support transaction requests.
The WFS requests supported are GetCapabilities, DescribeFeatureType and
GetFeature.
A copy of the WFS 1.0.0 specification can be downloaded from:
http://www.opengis.org/techno/specs/02-058.pdf
Special Build considerations:
-----------------------------
WFS support requires PROJ4, GDAL/OGR and libwww support libraries.
Build/install the above libraries on your system and then build MapServer
with the '--with-wfs --with-proj --with-ogr' configure options.
Setting up a mapfile to serve WFS layers:
-----------------------------------------
MapServer will serve and include in its WFS capabilities only the
layers that meet the following conditions:
- Data source is of vector type (Shapefile, OGR, PostGIS, SDE, SDO, ...)
- LAYER NAME must be set
- LAYER TYPE is one of: LINE, POINT, POLYGON
- LAYER DUMP parameter set to TRUE
The following Metadata can be added to your mapfile, most of them are
optional:
** MAP object Metadata **
- wfs_onlineresource
- wfs_title
- wfs_abstract
- wfs_keywordlist
- wfs_accessconstraints
- wfs_fees
- wfs_encoding
Optional XML encoding for all XML documents returned by the server.
The default is ISO-8859-1.
- wfs_schemas_location
Root of the web tree where the family of OGC WFS XMLSchema files are
located. This must be a valid URL where the actual .xsd files are
located if you want your WFS output to validate in a validating XML
parser.
The default if this is not set is to use "../" as the schema files
location, which should correspond to the root of your web server if you
installed mapserv in the cgi-bin directory.
See http://ogc.dmsolutions.ca/ for an example of a valid schema tree.
- wfs_geometry_element_name
Name of the element (i.e. attribute) to use for the geometry in GML
output. If not set then "MS_GEOMETRY" will be used.
The layer-level "wfs_geometry_element_name" takes precedence over this
value.
- wfs_srs
... still being defined.
** LAYER object Metadata **
- wfs_title
- wfs_abstract
- wfs_keywordlist
- wfs_geometry_element_name
Name of the element (i.e. attribute) to use for the geometry in GML
output. If not set then "MS_GEOMETRY" will be used.
This value takes precedence over the value of "wfs_geometry_element_name"
set at the map level (if one was set).
- wfs_srs
... still being defined. Should be the SRS in which this layer
should be served. Contrary to WMS servers, a WFS layer can be served
in only one SRS.
Testing your WFS server:
------------------------
The first thing to test is to issue a GetCapabilities request to your
server and scan the XML output to look for <!-- WARNING: ... --> comments.
Then take actions to fix every warning that you encounter. At the end
of this you should have a compliant WFS server.
To issue a GetCapabilities request to your WFS server, enter a URL like
the following in a web browser:
http://my.wfs.com/cgi-bin/mapserv?map=mywfs.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetCapabilities
TODO, Known limitations:
------------------------
** Before 3.7 release **
- Projection support still incomplete
- Need to validate request results against the corresponding XMLSchema
files.
- It would be nice to test against multiple WFS clients before the 3.7
release if possible... for now we can only test against the MapServer
WFS client.
** Longer term TODO and limitations **
- This is just a basic WFS (read-only): transaction requests are not
supported and probably never will given the nature of MapServer.
- For now we support only GET requests.
The spec also talks about XML-encoded POST requests but we do not
support that.
- We support only the BBOX filter for now. It would be nice to support
attribute filters, but this means supporting the OGC Filter Encoding spec
and we'll keep that for later.
- WFS spec. seems to require that features of a given feature type must
all be of the same geometry type (point, line, polygon). This works fine
for shapefiles, but some data source formats supported by MapServer allow
mixed geometry types in a single layer and this goes against the WFS
spec. Suggestions on how to handle this are welcome.
-------------- next part --------------
MapServer WFS Client HOWTO:
---------------------------
Client support for OGC Web Feature Service (WFS) version 1.0.0 has been
added to MapServer in version 3.7. This allows users to include
references to WFS layers in their MapServer maps, and MapServer will
handle them in a transparent manner.
A copy of the WFS 1.0.0 specification can be downloaded from:
http://www.opengis.org/techno/specs/02-058.pdf
Special Build considerations:
-----------------------------
WFS client requires OGR with GML support, which in turn requires the
Xerces-C++ 1.6.0 library:
1- Download xerces-c-src1_6_0.tar.gz from
http://xml.apache.org/dist/xerces-c/stable/archives/Xerces-C_1_6_0/
2- Extract the archive and follow the build/install instructions in
xerces-c-src1_6_0/doc/html/build.html
On regular Linux systems, this should come back to:
export XERCESCROOT=/path/to/xerces-c-src1_6_0
chmod +x ./configure <-- The file in the distribution is not executable!
./configure
make
sudo make install
sudo /sbin/lcdonfig
3- Build/install GDAL/OGR, making sure you include the '--with-xerces'
configure option
4- Compile MapServer with the '--with-wfsclient' configure option.
Setting up a WFS layer in your mapfile:
---------------------------------------
A WFS layer is a regular mapfile layer, which can use CLASS objects, with
expressions, etc. Instead of a DATA parameter, your use the CONNECTIONTYPE
and CONNECTION parameters to define the data source:
---------
LAYER
# Like any other layers, WFS layers need a NAME and TYPE value
name "mylayer"
TYPE POINT
# Define the WFS connection parameters
# The CONNECTION must include the following WFS GetFeature parameters:
# SERVICE=WFS
# VERSION=1.0.0 (the only version supported for now)
# TYPENAME=... (the feature type for this layer, see WFS capabilites)
#
CONNECTIONTYPE WFS
CONNECTION "http://my.wfs.com/cgi-bin/mapserv?map=mywfs.map&SERVICE=WFS&VERSION=1.0.0&TYPENAME=mypoints"
# projection is optional, like for most layer types in MapServer
PROJECTION
"init=epsg:4326"
END
# Optional Metadata items
METADATA
"wfs_connectiontimeout" "60" # Default is 30 seconds
"wfs_latlonboundingbox" "-75 45 -70 50" # Area covered by this layer
END
# Define some classes, to render the features
CLASSITEM "point_class"
CLASS
EXPRESSION "1"
SYMBOL 'triangle'
COLOR 255 0 0
END
CLASS
SYMBOL 'circle'
COLOR 0 0 0
END
END
---------
You also need to set the IMAGEPATH value in your mapfile since MapServer
uses this directory to store temporary files downloaded from the remote
WFS server:
---------
MAP
...
WEB
IMAGEPATH "/tmp/ms_tmp/"
IMAGEURL ...
END
...
END
---------
TODO, Known limitations:
------------------------
** Before 3.7 release **
- Queries not supported yet, still working on this. For now you can
only render maps but cannot query using WFS layers.
- Projection support incomplete. If you use projections then make sure the
layer's PROJECTION object in the mapfile is set to the same projection
as the SRS supported for this TYPENAME in the remote WFS server.
** Longer term TODO and limitations **
- Need some caching mechanism to avoid downloading the same data multiple
times if the BBOX of the map doesn't change.
- Temporary WFS (gml) files are written to the IMAGEPATH directory, but
this could become a security concern since it makes the raw GML data
downloadable by someone who could guess the gml filename. We should
consider having a "wfs_tmpdir" metadata that, if it is set will define
a directory where temp files should be written. The default would still
be to use the value of IMAGEPATH if "wfs_tmpdir" is not set.
- Xerces is an annoying dependency for GML support in OGR. There have
been discussions about modifying the OGR GML driver to use in internal
XML parser by default. This would save us from the Xerces dependency.
There is no formal plan for when this would happen yet.
More information about the mapserver-dev
mailing list