query postgis through wms

Richard Duivenvoorde rdmailings at DUIF.NET
Mon Nov 19 23:37:35 PST 2007


Hi Steven,
there are some srid related places places:

1) if you added the column using AddGeometryColumn
SELECT AddGeometryColumn('public', 'kaas', 'wkb_geometry_rd', 28992, 
'POINT', 2)
a record is added to 'geometry_columns' where you can find the srid for 
that table

2) every geometry in the table also holds a srid. Find out bij looking 
at the geometries as GML:
select AsGML(wkb_geometry) from kaas
or just ask for the srid:
select getsrid(wkb_geometry) from kaas

besides that be sure your projection is defined in the spatial_ref_sys 
table (and if you reproject, into the proj definitions of mapserver). 
But 31300 ("Belge 1972 / Belge Lambert 72") shouldn't be the problem.

Biggest problem is probably that mapserver asks for 31300, and your 
columns OR you geometry_columns -table hold different OR mixed(!) srids.

Be sure your data is all one srid and the srid-value in geometry_columns 
corresponds to that.

It's very easy to reproject in postgis:
First add a new column with the new epsg (for example 4326):
SELECT AddGeometryColumn('public', 'kaas', 'wkb_geometry_4326', 4326, 
'POINT', 2)
then fill it using:
UPDATE kaas SET wkb_geometry_4326 = Transform(wkb_geometry, 4326)

If your data is ok, it doesn't mather anymore what mapserver is calling 
for, because (if the srid/epsg is defined in the web-part of you 
mapfile) mapserver will reproject it anyway.

Hope this helps a little :-)

Groeten,

Richard Duivenvoorde


Steven De Vriendt wrote:
> How can I see what SRID the data is using ? I'm quite new to all this...
> 
> Steven
> 
> On Nov 19, 2007 3:41 PM, Marcos Sánchez Provencio <marcos at burke.ath.cx 
> <mailto:marcos at burke.ath.cx>> wrote:
> 
>     Try using the srid your data is stored in instead of 31300. You might
>     use the function getsrid
> 
>     SELECT getsrid(the_geom) from b_capa_percid limit 1;
> 
> 
>     El lun, 19-11-2007 a las 15:26 +0100, Steven De Vriendt escribió:
>      > Marcos,
>      >
>      > When I try your suggestion Mapserver returns:
>      >
>      > −
>      >     <ServiceExceptionReport version="1.1.0">
>      > −
>      >     <ServiceException>
>      >
>      > msDrawMap(): Image handling error. Failed to draw layer named
>      > 'percelen'.
>      > msPOSTGISLayerWhichShapes(): Query error. Error executing POSTGIS SQL
>      > statement (in FETCH ALL): DECLARE mycursor BINARY CURSOR FOR SELECT
>      > asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text from
>      > (SELECT * FROM b_capa_percid) AS foo WHERE the_geom &&
>      > setSRID('BOX3D( 76945.5918856108 189996.502536997,91328.1081143621
>      > 201805.497460877)'::BOX3D, 31300 )
>      > -ERROR:  Operation on two geometries with different SRIDs
>      >
>      >
>      > </ServiceException>
>      > </ServiceExceptionReport>
>      >
>      > On Nov 19, 2007 3:19 PM, Marcos Sánchez Provencio
>      > <marcos at burke.ath.cx <mailto:marcos at burke.ath.cx>> wrote:
>      >         try
>      >         DATA "the_geom from (SELECT * FROM b_capa_percid) as foo
>      >         using srid=31300 using unique gid"
>      >
>      >
>      >
>      >         El lun, 19-11-2007 a las 09:48 +0100, Steven De Vriendt
>      >         escribió:
>      >
>      >         > DATA "the_geom from b_capa_percid"
>      >
>      >
>      >
> 
> 



More information about the MapServer-users mailing list