[Geoserver-devel] [Geotools-devel] How to create BBOX Filter with FilterFactory2

Thank Jody, I’ll give it a try and dig into the WFS module to create requests and handle responses. Justin is mentioned as a module maintainer in the pom of the WFS module. Could he or anybody else answer questions like

  • Where to start,
  • DO’s and DONT’s
  • What I have to care about (e.g. side effects)
  • Changes between 2.5.x and trunk (I need functionality in an older gt-version for a project but would like to provide a patch for trunk too)

Cheers,
Frank

2010/11/1 Jody Garnett <jody.garnett@anonymised.com>

Back to your original request; the code could be modified to issue a single request for all the GetFeatureType information; and then parse out the results into FeatureTypes. I could see how that would make things faster; it is up to you if you would like to proceed with the idea.

I just looked into the wfs pom to see who ist the modul maintainer. Justin, do you know other feature requests like this for the wfs module? I’m interested in implementing this behaviour but need a hint where to start and what I have to take care about.

Jody

On 26/10/2010, at 7:23 PM, Frank Gasdorf wrote:

2010/10/26 Jody Garnett <jody.garnett@anonymised.com>

The WFS datastore does not support a query across several feature
types in a single request. In part this is due to our feature
collections being restricted to a single feature type.

Yes I recognized that a FeatureColection can only contain one SimpeFeatureType. Could I find any utility classes to query a WFSServer and get a Map SimpleFeatureTypes as keys and FeatureCollection as values? Or with other words, how can I get access to as WFS Server without using creating a DataStore. I guess there are Response classes which can handle mixed results of types.

If not, could that be a feature anybody else could need? Does anybody have use case to requests queries like the geoserver demo-MulitFeature request? Who had created the demo-request?

There should be way to refer to the default geometry with a simple
xpath expression that works for all features; not sure if it applys to
WFS or only to the SLD rendering engine.

Could you give an example. I’ve no clue how to define a xpath expression … Thanks

Frank

Jody

On Tue, Oct 26, 2010 at 5:14 PM, Roy Braam <roybraam@anonymised.com> wrote:

Hi Frank,

Yep it’s a work around for if you want to use the BBOX param… Hmmmzzz,
actually I never used the BBOX param with geotools… It can only be used
with a http-get command… I don’t think it’s supported in the WFS
module… Maybe someone else knows something about it?

Met vriendelijke groet,

Roy Braam
B3partners BV
030 214 2082


From: Frank Gasdorf [mailto:fgdrf@anonymised.com]
To: Roy Braam [mailto:roybraam@anonymised.com],
geotools-devel@lists.sourceforge.net
Sent: Mon, 25 Oct 2010 17:40:07 +0200
Subject: Re: [Geotools-devel] How to create BBOX Filter with FilterFactory2

Thanks Roy!

This would a be possible solution -but from my point of view a workaround.
The reason of defining a “general” BBOX Filter is a single request and a
single response for that. I don’t want to have a lot of server roundtrip to
query each layer separate.
Is there an other way to use the gt-wfs module to create a query like that.
There is no reason to have a dataStore because the client is not enabled for
editig features. What I’d expect is a simple featureCollection that
repesents the resullt of the query with the given URL (see below).

Any hints?

Frank

2010/10/25 Roy Braam <roybraam@anonymised.com>

Hello Frank,

When using the FilterFactory you are creating a filter and that’s not the
same as the param BBOX. See the ogc wfs specs 1.1.0 chapter 14.3.3.

If you like to query with a bbox filter then you have to specify the
geometry attribute name.
So you can do something like this: (i added the code in you code snippet)

for(String typeName; typeNames){
SimpleFeatureType type=dataStore.getSchema(typeName);
String geomName=type.getGeometryDescriptor().getLocalName();

BBOX bbox = filterFactory.bbox(geomName, 13.35, 52.43, 13.45, 52.53,
“4326”); //$NON-NLS-1$
FeatureSource<SimpleFeatureType, SimpleFeature> view =
dataStore.getView(new DefaultQuery(null, bbox));
FeatureCollection<SimpleFeatureType, SimpleFeature> features =
view.getFeatures();

Iterator iterator = features.iterator();

while (iterator != null && iterator.hasNext()) {
SimpleFeature next = iterator.next();
SimpleFeatureType type = next.getType();
System.out.println(type.getTypeName() + “\n\t” +
next.getDefaultGeometry());
}
}

I didn’t tested it but it must be something like this.

Roy


From: Frank Gasdorf [mailto:fgdrf@anonymised.com]
To: geotools-devel@lists.sourceforge.net,
geoserver-devel@lists.sourceforge.net, geoserver-users@anonymised.comourceforge.net
Sent: Mon, 25 Oct 2010 13:34:59 +0200
Subject: [Geotools-devel] How to create BBOX Filter with FilterFactory2

Hallo gt- and gs- developers,

Sorry for cross posting!

I’m using geoserver 2.x (means 2.0.x and 2.1-beta2) and try to connect
with geotools gt-wfs client to query features from different types with a
bbox filter. This should be an alternative way to the WMS getFeature
requests.

I defined a query using the DEMO request on the geoserver home, the URL
request looks like this:

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=naturalEarth:ne-10m-populated-places,naturalEarth:ne-10m-admin-0-countries&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326

Note: the value for typeName parameter is a comma separated list of
feature type names. The result I got for this request is what I expected :
features are returned from more than one feature type.

Now I’d like to query using the filterFactory2.bbox method to define the
filter. How can I create a request like described before with the GT API?
The bbox method expects an expression or a string for geometry attribute
name. How can I gain it with GT API?

Any suggestions?

Thanks a lot,
Frank

code snippet:

Map<String, String> connectionParameters = new HashMap<String,
String>();
connectionParameters.put(
“WFSDataStoreFactory:GET_CAPABILITIES_URL”, connectionURL);
//$NON-NLS-1$
DataStore dataStore =
DataStoreFinder.getDataStore(connectionParameters);

String typeNames = dataStore.getTypeNames();
FilterFactory2 filterFactory = CommonFactoryFinder
.getFilterFactory2(GeoTools.getDefaultHints());
// berlin 13.40 52.48
String nullString = null;
BBOX bbox = filterFactory.bbox(nullString, 13.35, 52.43, 13.45,
52.53, “4326”); //$NON-NLS-1$
FeatureSource<SimpleFeatureType, SimpleFeature> view =
dataStore.getView(new DefaultQuery(null, bbox));
FeatureCollection<SimpleFeatureType, SimpleFeature> features =
view.getFeatures();

Iterator iterator = features.iterator();

while (iterator != null && iterator.hasNext()) {
SimpleFeature next = iterator.next();
SimpleFeatureType type = next.getType();
System.out.println(type.getTypeName() + “\n\t” +
next.getDefaultGeometry());
}


Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev


Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

The module is not supported right now; so you will do better to send
your questions to the list rather than to any specific developer.

In the past I *have* seen teams dig into WFS code and use specific
sections .. most usually this was the FCBuffer class used to "parse"
the results of a WFS 1.0 GetFeatures request.

The GTXML parser has a couple of configurations that are far easier to
use so I don't recommend the use of FCBuffer if you can avoid it.

As for where to start;
- create a simple application that grabs a single feature from the 1st
feature type published from the WFS
- step through with the debugger and watch it issue the getCaps
request; and parse the results
- watch it issue DescribeFeatureType when a FeatureType object is
needed; this sounded like the code you would like to optimize?
- finally watch it request a feature; and parse the result

Jody

On Mon, Nov 1, 2010 at 9:34 PM, Frank Gasdorf
<fgdrf@anonymised.com> wrote:

Thank Jody, I'll give it a try and dig into the WFS module to create
requests and handle responses. Justin is mentioned as a module maintainer
in the pom of the WFS module. Could he or anybody else answer questions like
- Where to start,
- DO's and DONT's
- What I have to care about (e.g. side effects)
- Changes between 2.5.x and trunk (I need functionality in an older
gt-version for a project but would like to provide a patch for trunk too)

Cheers,
Frank

2010/11/1 Jody Garnett <jody.garnett@anonymised.com>

Back to your original request; the code could be modified to issue a
single request for all the GetFeatureType information; and then parse out
the results into FeatureTypes. I could see how that would make things
faster; it is up to you if you would like to proceed with the idea.

I just looked into the wfs pom to see who ist the modul maintainer. Justin,
do you know other feature requests like this for the wfs module? I'm
interested in implementing this behaviour but need a hint where to start and
what I have to take care about.

Jody
On 26/10/2010, at 7:23 PM, Frank Gasdorf wrote:

2010/10/26 Jody Garnett <jody.garnett@anonymised.com>

The WFS datastore does not support a query across several feature
types in a single request. In part this is due to our feature
collections being restricted to a single feature type.

Yes I recognized that a FeatureColection can only contain one
SimpeFeatureType. Could I find any utility classes to query a WFSServer and
get a Map SimpleFeatureTypes as keys and FeatureCollection as values? Or
with other words, how can I get access to as WFS Server without using
creating a DataStore. I guess there are Response classes which can handle
mixed results of types.
If not, could that be a feature anybody else could need? Does anybody have
use case to requests queries like the geoserver demo-MulitFeature request?
Who had created the demo-request?

There should be way to refer to the default geometry with a simple
xpath expression that works for all features; not sure if it applys to
WFS or only to the SLD rendering engine.

Could you give an example. I've no clue how to define a xpath expression
... Thanks
Frank

Jody

On Tue, Oct 26, 2010 at 5:14 PM, Roy Braam <roybraam@anonymised.com>
wrote:
> Hi Frank,
>
> Yep it's a work around for if you want to use the BBOX param....
> Hmmmzzz,
> actually I never used the BBOX param with geotools... It can only be
> used
> with a http-get command... I don't think it's supported in the WFS
> module.... Maybe someone else knows something about it?
>
> Met vriendelijke groet,
>
> Roy Braam
> B3partners BV
> 030 214 2082
>
> ________________________________
> From: Frank Gasdorf [mailto:fgdrf@anonymised.com]
> To: Roy Braam [mailto:roybraam@anonymised.com],
> geotools-devel@lists.sourceforge.net
> Sent: Mon, 25 Oct 2010 17:40:07 +0200
> Subject: Re: [Geotools-devel] How to create BBOX Filter with
> FilterFactory2
>
> Thanks Roy!
>
> This would a be possible solution -but from my point of view a
> workaround.
> The reason of defining a "general" BBOX Filter is a single request and
> a
> single response for that. I don't want to have a lot of server
> roundtrip to
> query each layer separate.
> Is there an other way to use the gt-wfs module to create a query like
> that.
> There is no reason to have a dataStore because the client is not
> enabled for
> editig features. What I'd expect is a simple featureCollection that
> repesents the resullt of the query with the given URL (see below).
>
> Any hints?
>
> Frank
>
>
> 2010/10/25 Roy Braam <roybraam@anonymised.com>
>>
>> Hello Frank,
>>
>> When using the FilterFactory you are creating a filter and that's not
>> the
>> same as the param BBOX. See the ogc wfs specs 1.1.0 chapter 14.3.3.
>>
>> If you like to query with a bbox filter then you have to specify the
>> geometry attribute name.
>> So you can do something like this: (i added the code in you code
>> snippet)
>>
>> for(String typeName; typeNames){
>> SimpleFeatureType type=dataStore.getSchema(typeName);
>> String geomName=type.getGeometryDescriptor().getLocalName();
>>
>> BBOX bbox = filterFactory.bbox(geomName, 13.35, 52.43, 13.45,
>> 52.53,
>> "4326"); //$NON-NLS-1$
>> FeatureSource<SimpleFeatureType, SimpleFeature> view =
>> dataStore.getView(new DefaultQuery(null, bbox));
>> FeatureCollection<SimpleFeatureType, SimpleFeature> features =
>> view.getFeatures();
>>
>> Iterator<SimpleFeature> iterator = features.iterator();
>>
>> while (iterator != null && iterator.hasNext()) {
>> SimpleFeature next = iterator.next();
>> SimpleFeatureType type = next.getType();
>> System.out.println(type.getTypeName() + "\n\t" +
>> next.getDefaultGeometry());
>> }
>> }
>>
>> I didn't tested it but it must be something like this.
>>
>> Roy
>>
>> ________________________________
>> From: Frank Gasdorf [mailto:fgdrf@anonymised.com]
>> To: geotools-devel@lists.sourceforge.net,
>> geoserver-devel@lists.sourceforge.net,
>> geoserver-users@lists.sourceforge.net
>> Sent: Mon, 25 Oct 2010 13:34:59 +0200
>> Subject: [Geotools-devel] How to create BBOX Filter with
>> FilterFactory2
>>
>> Hallo gt- and gs- developers,
>>
>> Sorry for cross posting!
>>
>> I'm using geoserver 2.x (means 2.0.x and 2.1-beta2) and try to connect
>> with geotools gt-wfs client to query features from different types
>> with a
>> bbox filter. This should be an alternative way to the WMS getFeature
>> requests.
>>
>> I defined a query using the DEMO request on the geoserver home, the
>> URL
>> request looks like this:
>>
>>
>>
>> http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=naturalEarth:ne-10m-populated-places,naturalEarth:ne-10m-admin-0-countries&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326
>>
>> Note: the value for typeName parameter is a comma separated list of
>> feature type names. The result I got for this request is what I
>> expected :
>> features are returned from more than one feature type.
>>
>> Now I'd like to query using the filterFactory2.bbox method to define
>> the
>> filter. How can I create a request like described before with the GT
>> API?
>> The bbox method expects an expression or a string for geometry
>> attribute
>> name. How can I gain it with GT API?
>>
>> Any suggestions?
>>
>> Thanks a lot,
>> Frank
>>
>> code snippet:
>>
>> Map<String, String> connectionParameters = new HashMap<String,
>> String>();
>> connectionParameters.put(
>> "WFSDataStoreFactory:GET_CAPABILITIES_URL", connectionURL);
>> //$NON-NLS-1$
>> DataStore dataStore =
>> DataStoreFinder.getDataStore(connectionParameters);
>>
>> String typeNames = dataStore.getTypeNames();
>> FilterFactory2 filterFactory = CommonFactoryFinder
>> .getFilterFactory2(GeoTools.getDefaultHints());
>> // berlin 13.40 52.48
>> String nullString = null;
>> BBOX bbox = filterFactory.bbox(nullString, 13.35, 52.43,
>> 13.45,
>> 52.53, "4326"); //$NON-NLS-1$
>> FeatureSource<SimpleFeatureType, SimpleFeature> view =
>> dataStore.getView(new DefaultQuery(null, bbox));
>> FeatureCollection<SimpleFeatureType, SimpleFeature> features =
>> view.getFeatures();
>>
>> Iterator<SimpleFeature> iterator = features.iterator();
>>
>> while (iterator != null && iterator.hasNext()) {
>> SimpleFeature next = iterator.next();
>> SimpleFeatureType type = next.getType();
>> System.out.println(type.getTypeName() + "\n\t" +
>> next.getDefaultGeometry());
>> }
>>
>
>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America
> contest
> Create new apps & games for the Nokia N8 for consumers in U.S. and
> Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in
> marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi
> Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Geotools-devel mailing list
> Geotools-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
>

Hello geoserver developers!

I started implementing a simple wfs client based on the OWS infrastructure to get features from a getFeatures Request with a BBOX Filter and mixed types for the typeName attribute. See the following request:

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=ne-50m-admin-0-countries,ne-10m-populated-places&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326&OUTPUTFORMAT=GML2

The two types are taken from http://www.naturalearthdata.com/ and added as shapefile datastores/layers to a geoserver 2.0.2

The schemlocation of the response gml file is wrong, the DescribeFeatureType has the two requested typenames, one with the namespace and the other one without.

<wfs:FeatureCollection xsi:schemaLocation=“http://www.naturalearthdata.com/ http://mapserv1:80/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=naturalEarth%3Ane-50m-admin-0-countries,ne-10m-populated-places http://www.opengis.net/wfs http://mapserv1:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd”>

A ServerException occures requesting the DescribeFeatureType

Could not find type: ne-10m-populated-places

I tried an older geoserver version (1.7.5) and the response looks good, the typename is always append after namespace.

I added the namespace for the typenames in the GetFeature Request for both types but that end up into the same resulting response.

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=naturalEarth%3Ane-50m-admin-0-countries,naturalEarth%3Ane-10m-populated-places&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326&outputFormat=GML2

Do you have any suggestions? Maybe it has to deal with changes of GML2OutputFormat.java

Frank

2010/11/2 Jody Garnett <jody.garnett@anonymised.com>

The module is not supported right now; so you will do better to send
your questions to the list rather than to any specific developer.

In the past I have seen teams dig into WFS code and use specific
sections … most usually this was the FCBuffer class used to “parse”
the results of a WFS 1.0 GetFeatures request.

The GTXML parser has a couple of configurations that are far easier to
use so I don’t recommend the use of FCBuffer if you can avoid it.

As for where to start;

  • create a simple application that grabs a single feature from the 1st
    feature type published from the WFS
  • step through with the debugger and watch it issue the getCaps
    request; and parse the results
  • watch it issue DescribeFeatureType when a FeatureType object is
    needed; this sounded like the code you would like to optimize?
  • finally watch it request a feature; and parse the result

Jody

On Mon, Nov 1, 2010 at 9:34 PM, Frank Gasdorf
<fgdrf@anonymised.com> wrote:

Thank Jody, I’ll give it a try and dig into the WFS module to create
requests and handle responses. Justin is mentioned as a module maintainer
in the pom of the WFS module. Could he or anybody else answer questions like

  • Where to start,
  • DO’s and DONT’s
  • What I have to care about (e.g. side effects)
  • Changes between 2.5.x and trunk (I need functionality in an older
    gt-version for a project but would like to provide a patch for trunk too)

Cheers,
Frank

2010/11/1 Jody Garnett <jody.garnett@anonymised.com>

Back to your original request; the code could be modified to issue a
single request for all the GetFeatureType information; and then parse out
the results into FeatureTypes. I could see how that would make things
faster; it is up to you if you would like to proceed with the idea.

I just looked into the wfs pom to see who ist the modul maintainer. Justin,
do you know other feature requests like this for the wfs module? I’m
interested in implementing this behaviour but need a hint where to start and
what I have to take care about.

Jody
On 26/10/2010, at 7:23 PM, Frank Gasdorf wrote:

2010/10/26 Jody Garnett <jody.garnett@anonymised.com>

The WFS datastore does not support a query across several feature
types in a single request. In part this is due to our feature
collections being restricted to a single feature type.

Yes I recognized that a FeatureColection can only contain one
SimpeFeatureType. Could I find any utility classes to query a WFSServer and
get a Map SimpleFeatureTypes as keys and FeatureCollection as values? Or
with other words, how can I get access to as WFS Server without using
creating a DataStore. I guess there are Response classes which can handle
mixed results of types.
If not, could that be a feature anybody else could need? Does anybody have
use case to requests queries like the geoserver demo-MulitFeature request?
Who had created the demo-request?

There should be way to refer to the default geometry with a simple
xpath expression that works for all features; not sure if it applys to
WFS or only to the SLD rendering engine.

Could you give an example. I’ve no clue how to define a xpath expression
… Thanks
Frank

Jody

On Tue, Oct 26, 2010 at 5:14 PM, Roy Braam <roybraam@anonymised.com>
wrote:

Hi Frank,

Yep it’s a work around for if you want to use the BBOX param…
Hmmmzzz,
actually I never used the BBOX param with geotools… It can only be
used
with a http-get command… I don’t think it’s supported in the WFS
module… Maybe someone else knows something about it?

Met vriendelijke groet,

Roy Braam
B3partners BV
030 214 2082


From: Frank Gasdorf [mailto:fgdrf@anonymised.com]
To: Roy Braam [mailto:roybraam@anonymised.com],
geotools-devel@lists.sourceforge.net
Sent: Mon, 25 Oct 2010 17:40:07 +0200
Subject: Re: [Geotools-devel] How to create BBOX Filter with
FilterFactory2

Thanks Roy!

This would a be possible solution -but from my point of view a
workaround.
The reason of defining a “general” BBOX Filter is a single request and
a
single response for that. I don’t want to have a lot of server
roundtrip to
query each layer separate.
Is there an other way to use the gt-wfs module to create a query like
that.
There is no reason to have a dataStore because the client is not
enabled for
editig features. What I’d expect is a simple featureCollection that
repesents the resullt of the query with the given URL (see below).

Any hints?

Frank

2010/10/25 Roy Braam <roybraam@anonymised.com>

Hello Frank,

When using the FilterFactory you are creating a filter and that’s not
the
same as the param BBOX. See the ogc wfs specs 1.1.0 chapter 14.3.3.

If you like to query with a bbox filter then you have to specify the
geometry attribute name.
So you can do something like this: (i added the code in you code
snippet)

for(String typeName; typeNames){
SimpleFeatureType type=dataStore.getSchema(typeName);
String geomName=type.getGeometryDescriptor().getLocalName();

BBOX bbox = filterFactory.bbox(geomName, 13.35, 52.43, 13.45,
52.53,
“4326”); //$NON-NLS-1$
FeatureSource<SimpleFeatureType, SimpleFeature> view =
dataStore.getView(new DefaultQuery(null, bbox));
FeatureCollection<SimpleFeatureType, SimpleFeature> features =
view.getFeatures();

Iterator iterator = features.iterator();

while (iterator != null && iterator.hasNext()) {
SimpleFeature next = iterator.next();
SimpleFeatureType type = next.getType();
System.out.println(type.getTypeName() + “\n\t” +
next.getDefaultGeometry());
}
}

I didn’t tested it but it must be something like this.

Roy


From: Frank Gasdorf [mailto:fgdrf@anonymised.com]
To: geotools-devel@lists.sourceforge.net,
geoserver-devel@lists.sourceforge.net,
geoserver-users@lists.sourceforge.net
Sent: Mon, 25 Oct 2010 13:34:59 +0200
Subject: [Geotools-devel] How to create BBOX Filter with
FilterFactory2

Hallo gt- and gs- developers,

Sorry for cross posting!

I’m using geoserver 2.x (means 2.0.x and 2.1-beta2) and try to connect
with geotools gt-wfs client to query features from different types
with a
bbox filter. This should be an alternative way to the WMS getFeature
requests.

I defined a query using the DEMO request on the geoserver home, the
URL
request looks like this:

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=naturalEarth:ne-10m-populated-places,naturalEarth:ne-10m-admin-0-countries&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326

Note: the value for typeName parameter is a comma separated list of
feature type names. The result I got for this request is what I
expected :
features are returned from more than one feature type.

Now I’d like to query using the filterFactory2.bbox method to define
the
filter. How can I create a request like described before with the GT
API?
The bbox method expects an expression or a string for geometry
attribute
name. How can I gain it with GT API?

Any suggestions?

Thanks a lot,
Frank

code snippet:

Map<String, String> connectionParameters = new HashMap<String,
String>();
connectionParameters.put(
“WFSDataStoreFactory:GET_CAPABILITIES_URL”, connectionURL);
//$NON-NLS-1$
DataStore dataStore =
DataStoreFinder.getDataStore(connectionParameters);

String typeNames = dataStore.getTypeNames();
FilterFactory2 filterFactory = CommonFactoryFinder
.getFilterFactory2(GeoTools.getDefaultHints());
// berlin 13.40 52.48
String nullString = null;
BBOX bbox = filterFactory.bbox(nullString, 13.35, 52.43,
13.45,
52.53, “4326”); //$NON-NLS-1$
FeatureSource<SimpleFeatureType, SimpleFeature> view =
dataStore.getView(new DefaultQuery(null, bbox));
FeatureCollection<SimpleFeatureType, SimpleFeature> features =
view.getFeatures();

Iterator iterator = features.iterator();

while (iterator != null && iterator.hasNext()) {
SimpleFeature next = iterator.next();
SimpleFeatureType type = next.getType();
System.out.println(type.getTypeName() + “\n\t” +
next.getDefaultGeometry());
}


Nokia and AT&T present the 2010 Calling All Innovators-North America
contest
Create new apps & games for the Nokia N8 for consumers in U.S. and
Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in
marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi
Store
http://p.sf.net/sfu/nokia-dev2dev


Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Hello again,

just an update!
First : Sorry!
Why? mess up in maven dependency project hierarchy.
The solution: I cleaned up my project maven dependencies. It was a mess to have in parent pom different gt-dependencies (older) than in my module. I had no compiler warnings or errors but at runtime where strange NoSuchMethod Exceptions in the opengis.util class.
Fixed and DONE!

Frank

2010/11/10 Frank Gasdorf <fgdrf@anonymised.com>

Hello geoserver developers!

I started implementing a simple wfs client based on the OWS infrastructure to get features from a getFeatures Request with a BBOX Filter and mixed types for the typeName attribute. See the following request:

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=ne-50m-admin-0-countries,ne-10m-populated-places&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326&OUTPUTFORMAT=GML2

The two types are taken from http://www.naturalearthdata.com/ and added as shapefile datastores/layers to a geoserver 2.0.2

The schemlocation of the response gml file is wrong, the DescribeFeatureType has the two requested typenames, one with the namespace and the other one without.

<wfs:FeatureCollection xsi:schemaLocation=“http://www.naturalearthdata.com/ http://mapserv1:80/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=naturalEarth%3Ane-50m-admin-0-countries,ne-10m-populated-places http://www.opengis.net/wfs http://mapserv1:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd”>

A ServerException occures requesting the DescribeFeatureType

Could not find type: ne-10m-populated-places

I tried an older geoserver version (1.7.5) and the response looks good, the typename is always append after namespace.

I added the namespace for the typenames in the GetFeature Request for both types but that end up into the same resulting response.

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=naturalEarth%3Ane-50m-admin-0-countries,naturalEarth%3Ane-10m-populated-places&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326&outputFormat=GML2

Do you have any suggestions? Maybe it has to deal with changes of GML2OutputFormat.java

Frank

2010/11/2 Jody Garnett <jody.garnett@anonymised.com>

The module is not supported right now; so you will do better to send
your questions to the list rather than to any specific developer.

In the past I have seen teams dig into WFS code and use specific
sections … most usually this was the FCBuffer class used to “parse”
the results of a WFS 1.0 GetFeatures request.

The GTXML parser has a couple of configurations that are far easier to
use so I don’t recommend the use of FCBuffer if you can avoid it.

As for where to start;

  • create a simple application that grabs a single feature from the 1st
    feature type published from the WFS
  • step through with the debugger and watch it issue the getCaps
    request; and parse the results
  • watch it issue DescribeFeatureType when a FeatureType object is
    needed; this sounded like the code you would like to optimize?
  • finally watch it request a feature; and parse the result

Jody

On Mon, Nov 1, 2010 at 9:34 PM, Frank Gasdorf
<fgdrf@anonymised.com> wrote:

Thank Jody, I’ll give it a try and dig into the WFS module to create
requests and handle responses. Justin is mentioned as a module maintainer
in the pom of the WFS module. Could he or anybody else answer questions like

  • Where to start,
  • DO’s and DONT’s
  • What I have to care about (e.g. side effects)
  • Changes between 2.5.x and trunk (I need functionality in an older
    gt-version for a project but would like to provide a patch for trunk too)

Cheers,
Frank

2010/11/1 Jody Garnett <jody.garnett@anonymised.com>

Back to your original request; the code could be modified to issue a
single request for all the GetFeatureType information; and then parse out
the results into FeatureTypes. I could see how that would make things
faster; it is up to you if you would like to proceed with the idea.

I just looked into the wfs pom to see who ist the modul maintainer. Justin,
do you know other feature requests like this for the wfs module? I’m
interested in implementing this behaviour but need a hint where to start and
what I have to take care about.

Jody
On 26/10/2010, at 7:23 PM, Frank Gasdorf wrote:

2010/10/26 Jody Garnett <jody.garnett@anonymised.com>

The WFS datastore does not support a query across several feature
types in a single request. In part this is due to our feature
collections being restricted to a single feature type.

Yes I recognized that a FeatureColection can only contain one
SimpeFeatureType. Could I find any utility classes to query a WFSServer and
get a Map SimpleFeatureTypes as keys and FeatureCollection as values? Or
with other words, how can I get access to as WFS Server without using
creating a DataStore. I guess there are Response classes which can handle
mixed results of types.
If not, could that be a feature anybody else could need? Does anybody have
use case to requests queries like the geoserver demo-MulitFeature request?
Who had created the demo-request?

There should be way to refer to the default geometry with a simple
xpath expression that works for all features; not sure if it applys to
WFS or only to the SLD rendering engine.

Could you give an example. I’ve no clue how to define a xpath expression
… Thanks
Frank

Jody

On Tue, Oct 26, 2010 at 5:14 PM, Roy Braam <roybraam@anonymised.com>
wrote:

Hi Frank,

Yep it’s a work around for if you want to use the BBOX param…
Hmmmzzz,
actually I never used the BBOX param with geotools… It can only be
used
with a http-get command… I don’t think it’s supported in the WFS
module… Maybe someone else knows something about it?

Met vriendelijke groet,

Roy Braam
B3partners BV
030 214 2082


From: Frank Gasdorf [mailto:fgdrf@anonymised.com]
To: Roy Braam [mailto:roybraam@anonymised.com],
geotools-devel@lists.sourceforge.net
Sent: Mon, 25 Oct 2010 17:40:07 +0200
Subject: Re: [Geotools-devel] How to create BBOX Filter with
FilterFactory2

Thanks Roy!

This would a be possible solution -but from my point of view a
workaround.
The reason of defining a “general” BBOX Filter is a single request and
a
single response for that. I don’t want to have a lot of server
roundtrip to
query each layer separate.
Is there an other way to use the gt-wfs module to create a query like
that.
There is no reason to have a dataStore because the client is not
enabled for
editig features. What I’d expect is a simple featureCollection that
repesents the resullt of the query with the given URL (see below).

Any hints?

Frank

2010/10/25 Roy Braam <roybraam@anonymised.com>

Hello Frank,

When using the FilterFactory you are creating a filter and that’s not
the
same as the param BBOX. See the ogc wfs specs 1.1.0 chapter 14.3.3.

If you like to query with a bbox filter then you have to specify the
geometry attribute name.
So you can do something like this: (i added the code in you code
snippet)

for(String typeName; typeNames){
SimpleFeatureType type=dataStore.getSchema(typeName);
String geomName=type.getGeometryDescriptor().getLocalName();

BBOX bbox = filterFactory.bbox(geomName, 13.35, 52.43, 13.45,
52.53,
“4326”); //$NON-NLS-1$
FeatureSource<SimpleFeatureType, SimpleFeature> view =
dataStore.getView(new DefaultQuery(null, bbox));
FeatureCollection<SimpleFeatureType, SimpleFeature> features =
view.getFeatures();

Iterator iterator = features.iterator();

while (iterator != null && iterator.hasNext()) {
SimpleFeature next = iterator.next();
SimpleFeatureType type = next.getType();
System.out.println(type.getTypeName() + “\n\t” +
next.getDefaultGeometry());
}
}

I didn’t tested it but it must be something like this.

Roy


From: Frank Gasdorf [mailto:fgdrf@anonymised.com]
To: geotools-devel@lists.sourceforge.net,
geoserver-devel@lists.sourceforge.net,
geoserver-users@lists.sourceforge.net
Sent: Mon, 25 Oct 2010 13:34:59 +0200
Subject: [Geotools-devel] How to create BBOX Filter with
FilterFactory2

Hallo gt- and gs- developers,

Sorry for cross posting!

I’m using geoserver 2.x (means 2.0.x and 2.1-beta2) and try to connect
with geotools gt-wfs client to query features from different types
with a
bbox filter. This should be an alternative way to the WMS getFeature
requests.

I defined a query using the DEMO request on the geoserver home, the
URL
request looks like this:

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=naturalEarth:ne-10m-populated-places,naturalEarth:ne-10m-admin-0-countries&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326

Note: the value for typeName parameter is a comma separated list of
feature type names. The result I got for this request is what I
expected :
features are returned from more than one feature type.

Now I’d like to query using the filterFactory2.bbox method to define
the
filter. How can I create a request like described before with the GT
API?
The bbox method expects an expression or a string for geometry
attribute
name. How can I gain it with GT API?

Any suggestions?

Thanks a lot,
Frank

code snippet:

Map<String, String> connectionParameters = new HashMap<String,
String>();
connectionParameters.put(
“WFSDataStoreFactory:GET_CAPABILITIES_URL”, connectionURL);
//$NON-NLS-1$
DataStore dataStore =
DataStoreFinder.getDataStore(connectionParameters);

String typeNames = dataStore.getTypeNames();
FilterFactory2 filterFactory = CommonFactoryFinder
.getFilterFactory2(GeoTools.getDefaultHints());
// berlin 13.40 52.48
String nullString = null;
BBOX bbox = filterFactory.bbox(nullString, 13.35, 52.43,
13.45,
52.53, “4326”); //$NON-NLS-1$
FeatureSource<SimpleFeatureType, SimpleFeature> view =
dataStore.getView(new DefaultQuery(null, bbox));
FeatureCollection<SimpleFeatureType, SimpleFeature> features =
view.getFeatures();

Iterator iterator = features.iterator();

while (iterator != null && iterator.hasNext()) {
SimpleFeature next = iterator.next();
SimpleFeatureType type = next.getType();
System.out.println(type.getTypeName() + “\n\t” +
next.getDefaultGeometry());
}


Nokia and AT&T present the 2010 Calling All Innovators-North America
contest
Create new apps & games for the Nokia N8 for consumers in U.S. and
Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in
marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi
Store
http://p.sf.net/sfu/nokia-dev2dev


Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

On Wed, Nov 10, 2010 at 9:42 AM, Frank Gasdorf
<fgdrf@anonymised.com> wrote:

Hello geoserver developers!

I started implementing a simple wfs client based on the OWS infrastructure
to get features from a getFeatures Request with a BBOX Filter and mixed
types for the typeName attribute. See the following request:

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=ne-50m-admin-0-countries,ne-10m-populated-places&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326&OUTPUTFORMAT=GML2

The two types are taken from http://www.naturalearthdata.com/ and added as
shapefile datastores/layers to a geoserver 2.0.2

The schemlocation of the response gml file is wrong, the DescribeFeatureType
has the two requested typenames, one with the namespace and the other one
without.

<wfs:FeatureCollection xsi:schemaLocation="http://www.naturalearthdata.com/
http://mapserv1:80/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=naturalEarth%3Ane-50m-admin-0-countries,ne-10m-populated-places
http://www.opengis.net/wfs
http://mapserv1:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd&quot;&gt;

A ServerException occures requesting the DescribeFeatureType

<ServiceExceptionReport version="1.2.0"
xsi:schemaLocation="http://www.opengis.net/ogc
http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd&quot;&gt;
-
<ServiceException>

      Could not find type: ne-10m-populated-places
</ServiceException>
</ServiceExceptionReport>

I tried an older geoserver version (1.7.5) and the response looks good, the
typename is always append after namespace.

I added the namespace for the typenames in the GetFeature Request for both
types but that end up into the same resulting response.

http://localhost:8080/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=naturalEarth%3Ane-50m-admin-0-countries,naturalEarth%3Ane-10m-populated-places&BBOX=-75.102613,40.212597,-72.361859,41.512517,EPSG:4326&outputFormat=GML2

Do you have any suggestions? Maybe it has to deal with changes of
GML2OutputFormat.java

A few suggestions:
- don't hijack an old thread to ask new questions. The subject line
has nothing to do with the question you're posing today.
  Always start a new thread with a consistent subject
- if you're using WFS 1.1 and making a standard client you should be
using GML3, GML2 is not guaranteed to be there
- when reporting issues use a recent nightly build of the 2.0.x
series, the release is very old
  In any case, it seems what you're seeing is still valid, this one
has issues the same way:
  http://demo.opengeo.org/geoserver/wfs?request=GetFeature&typeName=og:archsites,og:bugsites&version=1.1.0&outputFormat=GML2
  and this one as well:
  http://demo.opengeo.org/geoserver/wfs?request=GetFeature&typeName=og:archsites,og:bugsites&version=1.0.0&outputFormat=GML2

So yeah, open a bug report. A test and a patch attached to it to solve
the issue would also go a long way in making
the problem fixed soon :wink:

Cheers
Andrea

-----------------------------------------------------
Ing. Andrea Aime
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584962313
fax: +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-----------------------------------------------------