Issue Type: Bug Bug
Affects Versions: 9.5
Assignee: Gabriel Roldan
Attachments: gt-wfs.log, response_formatted.xml, response.xml
Components: wfs plugin
Created: 10/Sep/13 5:42 AM
Description:

Hi all,

It's very well possible that I'm not using the gt-wfs plugin correctly, but here's an error I'm getting.

The test code looks like this:

package foo.bar;

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

import org.geotools.data.DataStore;
import org.geotools.data.DefaultQuery;
import org.geotools.data.FeatureSource;
import org.geotools.data.Query;
import org.geotools.data.wfs.WFSDataStoreFactory;
import org.geotools.data.wfs.protocol.wfs.Version;
import org.geotools.factory.CommonFactoryFinder;
import org.geotools.factory.GeoTools;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
import org.opengis.feature.Feature;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.filter.Filter;
import org.opengis.filter.FilterFactory;

public class WFSClient
{

    private DataStore wfs;

    public WFSClient( URL endPointUrl )
    {
        final WFSDataStoreFactory wfsDataStoreFactory = new WFSDataStoreFactory();
        final Map params = new HashMap();

        params.put( WFSDataStoreFactory.URL.key,
                    WFSDataStoreFactory.createGetCapabilitiesRequest( endPointUrl, Version.v1_1_0 ) );

        try
        {
            this.wfs = wfsDataStoreFactory.createDataStore( params );
        }
        catch ( IOException e )
        {
            e.printStackTrace();
        }
    }

    public void getFoo( String propertyId ) throws IOException
    {
        final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory( GeoTools.getDefaultHints() );
        final Filter filter = filterFactory.equal( filterFactory.property( "ktjkiiwfs:kiinteistotunnus" ),
                                                   filterFactory.literal( propertyId ), true );
        final Query query = new DefaultQuery( "ktjkiiwfs:RekisteriyksikonTietoja", filter );

        final FeatureSource<SimpleFeatureType, SimpleFeature> source = wfs.getFeatureSource( "ktjkiiwfs:RekisteriyksikonTietoja" );
        final FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = source.getFeatures( query );

        final FeatureIterator<SimpleFeature> iterator = featureCollection.features();
        try
        {
            while ( iterator.hasNext() )
            {
                Feature feature = iterator.next();
                System.out.println( feature );
            }
        }
        finally
        {
            iterator.close();
        }

    }
}

...

WFSClient client = new WFSClient(new URL("http://foo.bar/kiinteistotieto/karttapalvelut/ktjkii/wfs/wfs"));
client.getFoo("21442500160044");

I'll attach the stack trace and the XML returned from the GetFeature request. Unfortunately, the WFS server itself requires authentication, so I can't link directly to it.

Let me know if there's anything I can do that would help solve the problem.

Project: GeoTools
Priority: Major Major
Reporter: Sakumatti Luukkonen
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to