[mapserver-users] PostGIS data in EPSG:31300 using for GoogleMaps overlay

Brent Wood pcreso at pcreso.com
Wed Apr 9 04:17:07 EDT 2008


--- Rahkonen Jukka <Jukka.Rahkonen at mmmtike.fi> wrote:

> Hi,
> 
> In this:
>     DATA "new_geom from (select gid, transform(the_geom,4326) as new_geom
> from
>     table) as mytable using unique gid using srid=4326"
> 
> First, "(select gid ..." is selecting the unique column of your table. Change
> "gid" to suit your table.
> Then "using unique gid" is referring to what was selected in the inner query.
>  If the query is done in this way you must use the name of your unique column
> instead of "gid" also here.
> 
> Perhaps more clear would be to write
> "(SELECT my_unique_column AS gid",... and
> "using unique gid"
> 
> I am not an experienced PostGIS user, let's hope this information is correct.

Hi Jukka,

Indeed it is. I used gid as a default geom id column, but could have been more
explicit.

 
> Brent,
> 
> Maybe quite a basic question, but I'm not used to define my data
> syntax as the one you propose.
> Can you help me out with the <gid> declaration.
> I'm quite confused what to fill in for gid
> 
> Do I leave it like it is and just write gid or doi I have
> or do I have to define my primary key column (f.i.: tbl_b_cabu_pkey).
> 
> For both I get an error message, saying either column OID does not
> exist or column tbl_b_cabu_pkey does not exist.
> However there are both there...
> 
> DATA "new_geom from (select gid, transform(the_geom,4326) as new_geom from
>   table) as mytable using unique gid using srid=4326"


Try:
DATA "new_geom from (select tbl_b_cabu_pkey, transform(the_geom,4326) as
new_geom from table) as mytable using unique tbl_b_cabu_pkey using srid=4326"

This is effectively the same as:
DATA "new_geom from (select tbl_b_cabu_pkey as gid, transform(the_geom,4326) as
new_geom from table) as mytable unique gid using srid=4326"

Hopefully the two examples show how this works. Note that "mytable" is an
arbitrary name, and you can call it anything you want to. Similarly, the
"new_geom" is used as an alias in the SQL, so it becomes the name of the
geometry collumn in the virtual table, so this is the name mapserver is given
in the DATA statement. Again you can use whatever name you like, provided the
same one is used in both places. 


If you need other columns for labels, or classes, etc., just add them to the
SQL that generates "mytable". This facility does not just allow reprojection by
PostGIS, which doesn't offer much really as mapserver can do the same thing,
but allows the "mytable" to be the result of a complex join accross tables,
etc, thus supporting the power of SQL & a relational database behind the
mapping engine.

> 
> Thanks for helping out !


You're welcome,

  Brent


More information about the mapserver-users mailing list