[Geoserver-users] CQL Filter DWITHIN. How to use it for getting the features lying within a distance from a complex polygon

Hi All,

I’m still struggling with this functionality.

What I want is a wms request with a CQL Filter DWITHIN to get all features within 25 kilometers from a region (like a state)

So for example I want all roads within 25 kilometer from the state utah.

Because the state has many points I get a very long cql filter (larger then get request max length)

I don’t know if I have the possibility to specify the 2nd parameter to SDO_WITHIN_DISTANCE (yes I’m using Oracle btw.) as some polygon to get form a different table and how to specify that in my CQL Filter.

Or are there other possible solutions for this.

As far as I see it the standards only allow for calculating distances from a point

Hope someone is able to get me further with this

(I already tried to simplify the regions (with convex hull and remove duplicate vertices) but that leaves me with very inaccurate regions)

Cheers

Kris Geusebroek

Consultant



cid:image001.jpg@anonymised.com



Email: kgeusebroek@anonymised.com



Tel: +31 (0)35 538 1921



Fax: +31 (0)35 538 1922



Mobile: +31 (0)6 30 697 223



http://www.xebia.com







Utrechtseweg 49



1213 TL Hilversum



The Netherlands

Xebia Blog ! http://blog.xebia.com/

Xebia Podcast! http://podcast.xebia.com/

Kris Geusebroek ha scritto:

Hi All,

I’m still struggling with this functionality.

What I want is a wms request with a CQL Filter DWITHIN to get all features within 25 kilometers from a region (like a state)

So for example I want all roads within 25 kilometer from the state utah.

Are you're trying to mix distances in km but coordinates
in lat/lon? This is simply not supported by GeoServer right now.
The units in dwithin filter are not parsed, and if they were,
the oracle datastore would not know how to encode the
filter.
Which btw is something you already know, since you reported
a jira here:
http://jira.codehaus.org/browse/GEOT-2384

So maybe you're using all projected coordinates?

Because the state has many points I get a very long cql filter (larger then get request max length)

I don’t know if I have the possibility to specify the 2^nd parameter to SDO_WITHIN_DISTANCE (yes I’m using Oracle btw.) as some polygon to get form a different table and how to specify that in my CQL Filter.

No, there is no way to do so, the WFS specification does not allow
for "joins", a single query element can refer to a single table.

Or are there other possible solutions for this.

Yes, you can bypass the limits of a max length of a request using:
- POST with the same structure of the GET, and assign the content
   type of "forms": application/x-www-form-urlencoded
- make a standard OGC POST request

For GET requests there is no workaround.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Hi,

No i don't try to mix distances. My layers are in ora 90112 projection
so kilometers is valid.
Since there is no way a join can be specified I tried another solution.

I will tell a bit about the solution here maybe someone can benefit :wink:

I created a view with the geometry of the points I wanted to show on the
map.
I joined this data with the regions table (specifying the complex
polygons) and added 3 columns to the view with the following syntax
SDO_WITHIN_DISTANCE(a.geometry, b.geometry, 'distance=0') as WITHIN0KM,
SDO_WITHIN_DISTANCE(a.geometry, b.geometry, 'distance=10000') as
WITHIN10KM,
SDO_WITHIN_DISTANCE(a.geometry, b.geometry, 'distance=25000') as
WITHIN25KM,

Now I can specify a CQL Filter as CQL_FILTER=WITHIN25KM = 'TRUE' and I
get all points within 25 kilometers of the region

Cheers

Kris
-----Original Message-----
From: Andrea Aime [mailto:aaime@anonymised.com]
Sent: Thursday, March 19, 2009 12:18 PM
To: Kris Geusebroek
Cc: geoserver-users
Subject: Re: [Geoserver-users] CQL Filter DWITHIN. How to use it for
getting the features lying within a distance from a complex polygon

Kris Geusebroek ha scritto:

Hi All,

I'm still struggling with this functionality.

What I want is a wms request with a CQL Filter DWITHIN to get all
features within 25 kilometers from a region (like a state)

So for example I want all roads within 25 kilometer from the state

utah.

Are you're trying to mix distances in km but coordinates
in lat/lon? This is simply not supported by GeoServer right now.
The units in dwithin filter are not parsed, and if they were,
the oracle datastore would not know how to encode the
filter.
Which btw is something you already know, since you reported
a jira here:
http://jira.codehaus.org/browse/GEOT-2384

So maybe you're using all projected coordinates?

Because the state has many points I get a very long cql filter (larger

then get request max length)

I don't know if I have the possibility to specify the 2^nd parameter

to

SDO_WITHIN_DISTANCE (yes I'm using Oracle btw.) as some polygon to get

form a different table and how to specify that in my CQL Filter.

No, there is no way to do so, the WFS specification does not allow
for "joins", a single query element can refer to a single table.

Or are there other possible solutions for this.

Yes, you can bypass the limits of a max length of a request using:
- POST with the same structure of the GET, and assign the content
   type of "forms": application/x-www-form-urlencoded
- make a standard OGC POST request

For GET requests there is no workaround.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Kris Geusebroek ha scritto:

Hi,

No i don't try to mix distances. My layers are in ora 90112 projection
so kilometers is valid.
Since there is no way a join can be specified I tried another solution.

I will tell a bit about the solution here maybe someone can benefit :wink:

I created a view with the geometry of the points I wanted to show on the
map.
I joined this data with the regions table (specifying the complex
polygons) and added 3 columns to the view with the following syntax
SDO_WITHIN_DISTANCE(a.geometry, b.geometry, 'distance=0') as WITHIN0KM,
SDO_WITHIN_DISTANCE(a.geometry, b.geometry, 'distance=10000') as
WITHIN10KM, SDO_WITHIN_DISTANCE(a.geometry, b.geometry, 'distance=25000') as
WITHIN25KM,

Now I can specify a CQL Filter as CQL_FILTER=WITHIN25KM = 'TRUE' and I
get all points within 25 kilometers of the region

Ah, interesting twist, a view that computes the predicate you cannot
express in an OGC query. Useful for other databases too.
Good thinking!

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Hi,

I have a feature type that is present in two tables : one table for the geometry and one for the attributes (linked with foreign key). How can I change my shema.xml so my wms and wfs will return the attributes ?

Thanks and long life to GeoServer.

TASSE Gilles ha scritto:

Hi,

I have a feature type that is present in two tables : one table for
the geometry and one for the attributes (linked with foreign key).
How can I change my shema.xml so my wms and wfs will return the
attributes ?

We have no explicit support for joins now.
What you can do is to to create a view in your database and register
the view insetad (remember to add the metadata for the view,
GeoServer won't be able to parse the view and figure out the
original tables, and thus get the metadata from them).

In most databases it will be a read only view, but in the
case of Oracle there are ways to make it writable (only for
a certain set of joins).

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Unfortunately this is not something we support. There is currently work going on to do complex feature support... but i am not sure if joins are in scope at this point.

What we really need to support this is a "hibernate" data store, or a datastore built around an O/R mapper.

TASSE Gilles wrote:

Hi,

I have a feature type that is present in two tables : one table for the geometry and one for the attributes (linked with foreign key). How can I change my shema.xml so my wms and wfs will return the attributes ?

Thanks and long life to GeoServer.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.