Postgis and EXPRESSION
Clint Johnson
cjohnson at REFRACTIONS.NET
Wed Feb 22 13:14:32 PST 2006
I believe your script is failing at the DATA clause -- or because there
exists no data within your tables that is join-able.
*[Malformed DATA clause]*
I've run into a similar problem myself before.
I am pretty sure your problem is with your DATA statement. In fact it
may be throwing an exception that you haven't been able to see (rather
than ignoring the expression).
See the advanced-usage at:
http://postgis.refractions.net/docs/ch04.html#id2789268
Note that the SQL used within the DATA tag is "pseudo-SQL"
Do not use the WHERE clause to perform your join; instead, use the
NATURAL JOIN operator. Instead, only use the WHERE clause to filter
upon items as you would with the FILTER tag (such as regions_view.name =
'foo'). I believe the FILTER and WHERE clauses to be coupled (which
further complicates matters when doing a complex join in your DATA clause).
Therefore, try this and let me know if it works:
DATA "the_geom FROM (SELECT countries.the_geom AS the_geom,
regions_view.name AS name, countries.oid AS oid FROM countries NATURAL
JOIN regions_view ON countries.geo_region = regions_view.id) AS foo
using unique oid using srid=-1"
*[Nothing to join]*
Perhaps there is nothing to join -- in that case try using LEFT JOIN
instead of the NATURAL JOIN
Clint
Stefan Schwarzer wrote:
> Hi,
>
> I migrated from mysql to postgres/postgis and update now all my
> map-queries. But I have a problem getting it working. I wonder if this
> is a major problem or some minor issue. The doc says :
> *
> *
> *"**Logical expressions allow you to build fairly complex tests based
> on one or more attributes and therefore are only available with
> shapefiles"*
>
> So, i would almost presume that using EXPRESSIONS is not possible via
> postgis. But I can't imagine that this is true... In the moment it
> runs the query but with no result - meaning that it "ignores" the
> epression. I couldn't find anything similar in the archives either...
>
>
> LAYER
> NAME bg_shape
> CONNECTIONTYPE postgis
> CONNECTION 'user=xxx password=xxx dbname=xxx'
> TYPE POLYGON
> DATA 'the_geom FROM (SELECT countries.the_geom AS the_geom,
> regions_view.name AS name, countries.oid AS oid FROM countries,
> regions_view WHERE countries.geo_region = regions_view.id) AS foo
> USING UNIQUE oid USING srid=-1'
> CLASSITEM 'name'
> CLASS
> NAME ''
> EXPRESSION ([name] ne 'Africa')
> OUTLINECOLOR 230 230 230
> COLOR 230 230 230
> END
> END # LAYER
>
>
> Thanks for any help!
>
> Stef
>
--
Clint Johnson
Refractions Research Inc.
Cjohnson at refractions.net
More information about the MapServer-users
mailing list