[postgis-users] srid of columns in views

strk at refractions.net strk at refractions.net
Sat Apr 23 19:56:48 PDT 2005


Hello Vortex,
The SRID is included in *every* geometry object, where its absence
means a SRID of -1, which is *unknown*.
The srid() function fetches this "embedded" value.
The && operator fetches this "embedded" value.
The find_srid() function queries geometry_columns, which might
be wrong and complex.
Mapserver uses find_srid() so it is probably "confused" in this
complexity. For this purpose you can specify a SRID to use "explicitly",
which will avoid the call to find_srid() and use the supplied value
directly. It is something like:

DATA "the_geom from view using SRID=4326

Read Mapserver manual for deeper info.

About the queries you show below I can't really understand them:
what's "path" in geo_links ? If it's a projection of the real 
data the srid() function should return the same result for both..

--strk;

On Sat, Apr 23, 2005 at 11:19:43PM +0200, Vortex wrote:
> Hi!
> 
> I managed to work with mapserver and geometries in
> views which have an srid of -1. But it fails with
> real srids:
> 
> Warning: [MapServer Error]: msPOSTGISLayerWhichShapes(): Error executing POSTGIS SQL statement (in FETCH ALL): DECLARE mycursor BINARY CURSOR FOR SELECT status::text,speed::text,asbinary(force_collection(force_2d(path)),'NDR'),OID::text from geo_links WHERE path && setSRID('BOX3D(8.07886769806061 48.0274258737248,9.91534773350125 49.2335618636517)'::BOX3D, find_srid('','geo_links','path') ) -ERROR: Operation on two geometries with different SRIDs Error with POSTGIS data variable. You specified ''.
> 
> that's not astonishing, since srid() for the "path"
> column returns:
> 
>  select srid(path) from geo_links limit 1;
>  srid 
> ------
>    -1
> (1 row)
> 
> while find_srid('','geo_links','path') returns the correct value of 4326.
> So the && Operator fails.
> 
> But i thought i had made the correct entry in postgis.geometry_columns for the geo_links view:
> 
>   f_table_catalog | f_table_schema |   f_table_name    | f_geometry_column | coord_dimension | srid |      type       
> -----------------+----------------+-------------------+-------------------+-----------------+------+-----------------
>                  | public         | geo_links         | path              |               2 | 4326 | LINE
>                  | public         | geo_stations      | position          |               2 | 4326 | POINT
>                  | geodata        | countryboundaries | the_geom          |               2 | 4269 | MULTIPOLYGON
>                  | geodata        | majorcities       | the_geom          |               2 | 4269 | POINT
> 
> and for real tables it seems to work:
> 
> eclaim=# select srid(the_geom) from geodata.railroads_l limit 1;
>  srid 
> ------
>  4326
> (1 row)
> 
> But i must confess that i still don't get this srid stuff very well.
> It seems that there are "geometries" which are including srid settings
> and others who don't. I suppose the srid information isn't stored in
> every dataset but instead in the table definition by geometry_columns?
> And than it is re-applied when i get the data out of the table?
> But is it part of the geometry itself or does the srid() function
> look at geometry_columns too? I suppose only find_srid() looks at
> the geometry_columns table while srid() gets the information directly
> from the geometry? But why is it different in my example?
> Or am i completely wrong?
> 
> Thank you very much!
> 
> Klaus
> 
> -- 
> ======================================================
> " WWW:   http://db0fhn.efi.fh-nuernberg.de/~dg1nav?em
> " LOCAL: klaus at castle.kwsnet
> " EMAIL: klauXweg at gmx.de (remove "X"!)
> " AX.25: dg1nav at db0fhn.#bay.deu.eu
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list