[postgis-devel] Issue 89 in postgis: transform() grid-shift 2nd chance logic defective

codesite-noreply at google.com codesite-noreply at google.com
Sun Dec 21 15:20:41 PST 2008


Status: New
Owner: ----

New issue 89 by william.... at acm.org: transform() grid-shift 2nd chance  
logic defective
http://code.google.com/p/postgis/issues/detail?id=89

What steps will reproduce the problem?

select x(transform(pointfromtext('POINT (173 52)',4269),4267)),
y(transform(pointfromtext('POINT (173 52)',4269),4267));
WARNING:  transform: -38 (failed to load NAD27-83 correction file)
ERROR:  transform: couldn't project point: -38 (failed to load NAD27-83
correction file)
<SELECT aborted; no output rows>

What is the output as corrected?

select x(transform(pointfromtext('POINT (173 52)',4269),4267)),
y(transform(pointfromtext('POINT (173 52)',4269),4267));
WARNING:  transform: -38 (failed to load NAD27-83 correction file)
WARNING:  transform: -38 (failed to load NAD27-83 correction file)
   x  |        y
-----+------------------
  173 | 51.9999999990852
(1 row)


Please use labels and text to provide additional information.

The PostGIS transform() function contains logic that intends to substitute
a "2nd chance" non-shifted transformation for an unavailable grid-shift
transformation (e.g., NAD83 to NAD27 transformation of a point outside of
the area covered by the NAD27 grid-shift table, or in the absence of that
table).  The logic handling this situation is located in the
transform_point() function of lwgeom_transform.c but seems outdated with
respect to how recent versions of proj.4 handle the situation.

This discord causes a "SELECT ... transform(geom,srid) ... FROM mytab" to
abort and be rolled back where even a single row of table mytab contains a
geometry geom that lies outside the bounds of an applicable grid-shift
table.  Running on Postgres 8.3.5, PostGIS 1.3.3, and proj.4 4.6.1, such a
SELECT aborts with the twin messages shown in the problem reproduction  
above.

Attached is a patch that seems to be a reasonable solution for this problem.

Although this patch works for me, please scrutinize it carefully.  This is
my first look at PostGIS and proj.4 source code.  Worse, I code in C very
rarely and am especially error-prone when using C pointers and indirection.
  I have not been able to fabricate data that exercises every branch of this
patch, so it may still contain errors.

Thanks so much for PostGIS!  It's a tremendous resource that contributes
materially to the public good.

Attachments:
	lwgeom_transform-1.3.3.diff  3.1 KB

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings



More information about the postgis-devel mailing list