Hello again

I found problems when doing a very simple WFS query using the GeoTools WFSDataStore (and GeoServer). When I try to retrieve features, I get a nice exception of the kind "Authority 'URN' is unknown or doesn't match the supplied hints."

I looked around on JIRA and found the following (scary) issue, where the problem was related to using the forcexy hint.
  http://jira.codehaus.org/browse/GEOT-1659

Indeed, over here we need to always use FORCE_LONGITUDE_FIRST_AXIS_ORDER as default both in GeoTools and GeoServer, since our data always comes that way even though the CRS sometimes states otherwise.

I admit, we have a very unorthodox solution here: we added a static code "GLOBAL.put(FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE)" in our version of Hints.java.

Anyway: I tested removing the hint from both GeoTools and GeoServer and - yes! - then everything works. But problems show up if either the GeoTools client or GeoServer are using the hint in the way shown above.

So, my question is:
- How can I have GeoTools with FORCE_LONGITUDE_FIRST_AXIS_ORDER always on, and still be capable of using WFS?

I admit that our hack here was pretty brutal, since we didn't want all our users here to always remember to set this hint. But to end up with a bug like this was also quite awkward. So, I'm not sure if I should reopen GEOT-1659 or not..

Just for you guys to see how I got here, I am sending as an attachment a very simple program that I used to test this bug (it just reads the FeatureTypes from the WFS server and writes them to local shapefiles)

Finally, below is the full exception stacktrace:

Authority "URN" is unknown or doesn't match the supplied hints. Maybe it is defined in an unreachable JAR file?]] at org.geotools.data.store.NoContentIterator.next(NoContentIterator.java:56) at org.geotools.data.store.NoContentIterator.next(NoContentIterator.java:41) at org.geotools.data.AbstractFeatureStore.addFeatures(AbstractFeatureStore.java:261)
        at org.tecgraf.tdk.example.geotools.spike.TestWFS.main(TestWFS.java:60)
Caused by: org.geotools.data.wfs.protocol.wfs.WFSException: WFS returned an exception. Target URL: http://localhost:8080/geoserver/wfs. Originating request is:
<?xml version="1.0" encoding="UTF-8"?>
<wfs:GetFeature handle="GeoTools 2.6.0 WFS DataStore"
 outputFormat="text/xml; subtype=gml/3.1.1" resultType="results"
 service="WFS" version="1.1.0" xmlns:ogc="http://www.opengis.net/ogc";
 xmlns:gml="http://www.opengis.net/gml";
 xmlns:xlink="http://www.w3.org/1999/xlink";
xmlns:ows="http://www.opengis.net/ows"; xmlns:wfs="http://www.opengis.net/wfs";> <wfs:Query srsName="urn:x-ogc:def:crs:EPSG:4326" typeName="topp:tasmania_water_bodies"/>
</wfs:GetFeature>
        [[We have had issues trying to flip axis of GEOGCS[&quot;WGS 84&quot;,
  DATUM[&quot;World Geodetic System 1984&quot;,
SPHEROID[&quot;WGS 84&quot;, 6378137.0, 298.257223563, AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],
    AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],
PRIMEM[&quot;Greenwich&quot;, 0.0, AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],
  UNIT[&quot;degree&quot;, 0.017453292519943295],
  AXIS[&quot;Geodetic longitude&quot;, EAST],
  AXIS[&quot;Geodetic latitude&quot;, NORTH],
  AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]]


Thanks!
Milton

--

Milton Jonathan
Grupo GIS e Meio Ambiente
Tecgraf/PUC-Rio
Tel: +55-21-3527-2502
package org.tecgraf.tdk.example.geotools.spike;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.FeatureSource;
import org.geotools.data.FeatureStore;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.data.wfs.WFSDataStoreFactory;
import org.geotools.feature.FeatureCollection;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;


/**
 * Hello world!
 *
 */
public class TestWFS 
{
    public static void main( String[] args )
    {
		try
		{
		    URL shapeUrlSrc = new URL("http://localhost:8080/geoserver/wfs?request=GetCapabilities&service=WFS&version=1.1.0";);
            
	    	Map<Object,Object> connect = new HashMap<Object,Object>();
            connect.put(WFSDataStoreFactory.URL.key, shapeUrlSrc);
	    	DataStore dataStoreSrc = DataStoreFinder.getDataStore(connect);
	    	
	    	String[] typeNames = dataStoreSrc.getTypeNames();
	    	int i = 0;
	    	for (String typeName : typeNames)
	    	{
    			i++;
	    		try {
		    		FeatureSource<SimpleFeatureType,SimpleFeature> featSource = dataStoreSrc.getFeatureSource(typeName);
		    		FeatureCollection<SimpleFeatureType,SimpleFeature> featSrcCollection = featSource.getFeatures();
	
		    		File f = new File("wfs-" + i + ".shp");
			    	URL shapeUrlDest = f.toURI().toURL();
			    	DataStore dataStoreDest = new ShapefileDataStore(shapeUrlDest);
			    	
		    		SimpleFeatureType schema = dataStoreSrc.getSchema(typeName);
		    		dataStoreDest.createSchema(schema);
		    	    FeatureStore<SimpleFeatureType,SimpleFeature> featStore = (FeatureStore<SimpleFeatureType,SimpleFeature>) dataStoreDest.getFeatureSource(typeName);
		    		featStore.addFeatures(featSrcCollection);
	    		}
	    		catch (Exception ex) {
	    			ex.printStackTrace();
	    		}
	    	}
	        System.out.println( "DONE" );
		}
		catch (MalformedURLException e)
		{
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
    }
}
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to