| From: | "Maya" <mdesseva(at)integral-corp(dot)com> |
|---|---|
| To: | pgsql-bugs(at)postgresql(dot)org |
| Subject: | BUG #4840: Different output from Transform function when used in a function vs. directly |
| Date: | 2009-06-04 19:35:57 |
| Message-ID: | 200906041935.n54JZvAY057722@wwwmaster.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged online:
Bug reference: 4840
Logged by: Maya
Email address: mdesseva(at)integral-corp(dot)com
PostgreSQL version: 8.3.7
Operating system: Windows XP Professional
Description: Different output from Transform function when used in a
function vs. directly
Details:
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.
I'm using XP Professional v.5.1.2600 on a Latitude D820 with Centrino Duo
(2160 MHz) with 3GB RAM and ~3-4 GB disc.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2009-06-04 20:53:24 | Re: BUG #4840: Different output from Transform function when used in a function vs. directly |
| Previous Message | Massa, Harald Armin | 2009-06-04 16:16:49 | Re: BUG #4839: cannot start Postgre server on Windows XP SP3 |