WFS-NG Plugin ------------- Web feature server "next generation". This plugin allows the GeoTools library to interact with a Web Feature Server using the normal DataStore API. The WFS-NG Plugin is currently unsupported. **Maven**:: org.geotools gt-wfs-ng ${geotools.version} Connection Parameters ^^^^^^^^^^^^^^^^^^^^^ The following connection parameters are defined for WFS. +----------------------------------------------+------------------------------------------------------------------+ | Parameter | Description | +==============================================+==================================================================+ | ``WFSDataStoreFactory:GET_CAPABILITIES_URL`` | Link to capabilities document. | | | The implementation supports both WFS 1.0 (read/write) and | | | WFS 1.1 (read-only). | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:PROTOCOL`` | Optional: True for Post, False for GET, null for auto | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:USERNAME`` | Optional | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:PASSWORD`` | Optional | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:ENCODING`` | Optional with a default of UTF-8 | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:TIMEOUT`` | Optional with a 3000ms default | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:BUFFER_SIZE`` | Optional number of features to read in one gulp, defaults of 10 | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:TRY_GZIP`` | Optional with a default of true, try compression if available | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:LENIENT`` | Optional default of true. | | | WFS implementations are terrible for actually obeying their | | | ``DescribeFeatureType`` schema, setting this to true will try a | | | few tricks to support implementations that are mostly correct: | | | | | | * Accepting the data in any order | | | * Not getting too upset if the case of the attributes is wrong | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:MAXFEATURES`` | Limit on the number of features | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:WFS_STRATEGY`` | Optional used to engage specific workarounds for known servers. | | | | | | * ``arcgis`` | | | * ``cuberx`` | | | * ``geoserver`` | | | * ``ionic`` | | | * ``mapserver`` | | | * ``nonstrict`` | | | * ``strict`` | | | * ``null`` - automatic based GET_CAPABILITIES URL | | | | | | You may need use this override if you are using MapServer | | | with a custom URL not recognized by auto detection. | | | WFS 1.1 supports auto detection based on full capabilities doc | | | for greater accuracy. | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:FILTER_COMPLIANCE`` | Optional used override how ``GetFeature`` operations encodes | | | filters | | | * 0 (low compliance) full range of GeoTools filters represented | | | * 1 (medium compliance) Id filters mixed with ``bbox`` only | | | * 2 (strict compliance) Id filters cannot be combined at all | | | | | | In general compliance levels stress the handling of Id filters | | | which are not allowed with other filters (AND / OR / NOT). | | | You may relax this constraint when working with some WFS | | | implementations such as GeoServer. | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:USEDEFAULTSRS`` | Optional used override how ``GetFeature`` operations send CRS | | | to WFS server | | | | | | * false use ``OtherSRS`` if query matches one of them | | | * true always use ``DefaultSRS`` and reproject locally to | | | query CRS | | | | | | Choose if you prefer to always use ``DefaultSRS`` declared in | | | capabilities and reproject using GeoTools if necessary, or | | | use also ``OtherSRS`` if available. | | | The false value is currently supported in 1.1.0 protocol only. | +----------------------------------------------+------------------------------------------------------------------+ | ``WFSDataStoreFactory:SCHEMA_CACHE_LOCATION``| Optional used for having a cache of the XSD-files. In each | | | response there will be a header with a set of corresponding | | | schema files. To avoid downloading these each time, we will by | | | this parameter specify a location on disk that should be used | | | for downloading files. | +----------------------------------------------+------------------------------------------------------------------+ Historical Note: We apologize for the long connection parameter keys, WFS was one of the first ``DataStores`` written and we were unsure at the time if they keys for each datastore would need to be unique or not. On the plus side you can see our devotion to stability. Hints: * The ``WFSDataStoreFactory`` provides keys as static constants if you need to look up the key, definition or expected data type programmatically * The capabilities URL you provide is important: * Q: Does it include "VERSION=1.0.0"? If so you are using well tested code parsing GML-2, and if available WFS-T will be supported. * Q: does it include "VERSION=1.1.0" ? If so you are using newer code parsing GML-3, and only WFS is implemented at this time. * You really should spend some time adjusting these parameters for your data source and application; in particular the performance is greatly effected by changing the BUFFER_SIZE. * Some servers that can serve up lots of small features benefit from higher values such as 100. * Slower servers respond well to smaller numbers. * You are advised that no features will be returned to code until the buffer is filled, and that the higher the number the more memory the WFS will use. Web Feature Server ^^^^^^^^^^^^^^^^^^ Support for **Web Feature Server Example (WFS)** offers access to the raw features being served up from an external server. * You are advised that when using read/write access you will need to use a transaction - see the section of WFS-T for more details. The following is a quick example; only the connection parameter code is specific to the ``WFSDataStore``. You can connect to a Web Feature Server via the DataStore API; the connection parameters are as follows:: String getCapabilities = "http://localhost:8080/geoserver/wfs?REQUEST=GetCapabilities"; Map connectionParameters = new HashMap(); connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", getCapabilities ); // Step 2 - connection DataStore data = DataStoreFinder.getDataStore( connectionParameters ); // Step 3 - discovery String typeNames[] = data.getTypeNames(); String typeName = typeNames[0]; SimpleFeatureType schema = data.getSchema( typeName ); // Step 4 - target FeatureSource source = data.getFeatureSource( typeName ); System.out.println( "Metadata Bounds: " + source.getBounds() ); // Step 5 - query String geomName = schema.getDefaultGeometry().getLocalName(); Envelope bbox = new Envelope( -100.0, -70, 25, 40 ); FilterFactory ff = CommonFactoryFinder.getFilterFactory( GeoTools.getDefaultHints() ); Object polygon = JTS.toGeometry( bbox ); Intersects filter = ff.intersects( ff.property( geomName ), ff.literal( polygon ) ); Query query = new Query( typeName, filter, new String[]{ geomName } ); FeatureCollection features = source.getFeatures( query ); ReferencedEnvelope bounds = new ReferencedEnvelope(); Iterator iterator = features.iterator(); try { while( iterator.hasNext() ) { Feature feature = (Feature) iterator.next(); bounds.include( feature.getBounds() ); } System.out.println( "Calculated Bounds: " + bounds ); } finally { features.close( iterator ); }