Opened 16 years ago
Last modified 16 years ago
#89 closed defect (fixed)
transform() grid-shift 2nd chance logic defective — at Initial Version
Reported by: | Owned by: | mcayland | |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 1.4.0 |
Component: | postgis | Version: | 1.4 |
Keywords: | Cc: |
Description
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.