[pgrouting-users] different SRIDs error

Stephen Woodbridge woodbri at swoodbridge.com
Wed Jul 22 21:23:57 EDT 2009


Laura Criscuolo wrote:
>   Hi,
> I created this find_closest_vertex function:
>  
> 
> CREATE OR REPLACE FUNCTION find_closest_vertex(“x” double precision, “y” 
> double precision, “distance” float)
> 
>   RETURNS integer AS
> 
> $BODY$
> 
> SELECT vertices_tmp.id AS vertices_id
> 
> FROM vertices_tmp
> 
> WHERE ST_Within
> 
>         (GeomFromText
> 
> ('POINT('||CAST($1 AS text)||' '||CAST($2 AS text)||')', 23030),
> 
>          ST_buffer
> 
> ('POINT('||CAST($1 AS text)||' '||CAST($2 AS text)||') ', CAST($3 AS 
> float))
> 
>         )
> 
>  = 't'
> 
> ORDER BY distance
> 
>         (GeomFromText
> 
> ('POINT('||CAST($1 AS text)||' '||CAST($2 AS text)||')', 23030),
> 
>          vertices_tmp.the_geom
> 
> ASC
> 
> LIMIT 1
> 
> $BODY$
> 
>   LANGUAGE 'sql' VOLATILE
> 
>   COST 100;
> 
> ALTER FUNCTION find_closest_vertex(double precision, double precision, 
> double precision) OWNER TO postgres;
> 
>  
> 
>  
> 
> but the query:
> 
>  
> 
> SELECT * FROM find_closest_vertex(8.44215190, 45.8838484, 0.0001);

So the coordinates above look like degrees maybe in srid=4326

> returns this error:
> 
>  
> 
> ERROR:  Operation on two GEOMETRIES with different SRIDs
> 
> CONTEXT:  SQL function "find_closest_vertex" statement 1
> 
>  
> 
> The spatial reference of the vertices_tmp table is EPGS:23030 (ED50 / 
> UTM zone 30N) of course, and I don't know how to solve the problem..

In you data, here seems to be in srid=23030

> What advice can you give me?

You need to project everything into a common srid, postgis does not do 
that implicitly for you. You might want to look at ST_Tranform(the_geom, 
target_srid).

If you need more than this then as Anton suggested raise the question on 
the PostGIS list.

-Steve W.

> Thanks
> 
>  
> 
> Laura
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 
> Condividi i tuoi ricordi online con chi vuoi tu chi vuoi tu. 
> <http://www.microsoft.com/italy/windows/windowslive/products/photos-share.aspx?tab=1>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.postlbs.org
> http://lists.postlbs.org/mailman/listinfo/pgrouting-users




More information about the Pgrouting-users mailing list