[postgis-users] Postigs layer in Mapserver
chodgson@refractions.net
chodgson@refractions.net
Thu Nov 14 20:56:47 2002
> DATA "the_geom from (select locarg.the_geom, locarg.oid, count(*) as
> cantidad from locarg, lugar where locarg.codpostal = lugar.codigopostal
> group by 1,2) as prueba"
I'm not familiar with the "group by 1,2" syntax... as far as I know, you need
to group by column names, like "group by column1, column2". Also, when you do a
subselect you should always specify "using SRID=-1 using unique oid" or
something similar with whatever SRID you are actually using. For example:
DATA "the_geom FROM (SELECT a.oid, a.the_geom, a.data, b.data FROM a, b WHERE
a.key = b.key) AS foo USING SRID=-1 USING UNIQUE oid"
The reason for "USING SRID=-1" is that postgis doesn't know what table the
geometry inside a join is coming from (in a complex query the geometries could
actually be coming from multiple different tables) and so it cannot look up in
the "geometry_columns" table to find the SRID. the reason for the "USING UNIQUE
oid" is to tell mapserver to use the oid as the unique id by which to reference
features in map queries. You could tell mapserver to use a different column
than the oid, but this isn't usually necessary. This is also the reason why you
need to include the oid of the geometry table in the sub-select.
Hopefully that will help...
Chris