[postgis-devel] [PostGIS] #194: Different output from Transform function when used in a function vs. directly - redirected here from postgreSQL bug reporting

PostGIS trac at osgeo.org
Thu Jun 4 14:20:49 PDT 2009


#194: Different output from Transform function when used in a function vs.
directly - redirected here from postgreSQL bug reporting
---------------------+------------------------------------------------------
 Reporter:  md       |       Owner:  pramsey
     Type:  defect   |      Status:  new    
 Priority:  medium   |   Milestone:         
Component:  postgis  |     Version:         
 Keywords:           |  
---------------------+------------------------------------------------------
 The follwoing sql creates a table to store coordinates and location names,
 then takes input from arrays and populates the table with transformed
 coordinates:
 ******************
 begin;

 create temporary table z_coo (
    x_t  double precision,
    y_t  double precision,
    location text);

 CREATE OR REPLACE FUNCTION insert_coords(x_ar double precision[],y_ar
 double precision[], loc_ar text[],srid_from integer,srid_to integer)
 RETURNS void AS $$ BEGIN  FOR i IN 1..array_upper(x_ar,1) LOOP
     INSERT INTO z_coo VALUES(X(Transform(GeomFromEWKT('SRID=' || srid_from
 || ';POINT(' || x_ar[i] || ' ' || y_ar[i] || ')'),srid_to)),
                                     Y(Transform(GeomFromEWKT('SRID=' ||
 srid_from || ';POINT(' || x_ar[i] || ' ' || y_ar[i] || ')'),srid_to)),
                                     loc_ar[i]);  END LOOP; END; $$
 LANGUAGE 'plpgsql' VOLATILE STRICT;

 select
 insert_coords(ARRAY[2093904.76854,2169323.2479,2246585.31659,2280791.02076,2
 282685.64095],
 ARRAY[357063.46674,395585.38205,317382.48154,486791.34705,400196.04792],
 ARRAY['aaa',bbb',ccc',ddd',eee'],
 2285,26911);
 commit;

 select * from z_coo;
 *********************

 The transformed coordinates obtained that way for location 'aaa' are:
 x = 346653.25322388
 y = 5205506.92495088

 Hoewever, if the following sql is run separately for location 'aaa':
 *****************
 select
  X(Transform(GeomFromEWKT('SRID=2285;POINT(2093904.76854
 357063.46674)'),26911)),
  Y(Transform(GeomFromEWKT('SRID=2285;POINT(2093904.76854
 357063.46674)'),26911));
 ******************
 then the transformed coordinates for location 'aaa' are:
 x = 352043.233452746
 y = 5314191.37291459

 This is a disturbingly huge differnece.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/194>
PostGIS <http://trac.osgeo.org/postgis/>
PostGIS


More information about the postgis-devel mailing list