Subject: | issue with z coordinates in transform method |
Date: | Sun, 23 Apr 2017 07:22:04 +1000 |
To: | bug-Geo-Proj4 [...] rt.cpan.org |
From: | Peter Dean <p.dean [...] internode.on.net> |
This came to light when playing with the +geoidgrids option in proj4.
There's 2 off-by-one bugs in one line and in my opinion it isn't wise to
exclude the possibility of a zero z-value.
Here's a patch.
diff -Naur Geo-Proj4-1.06-E4U_U2/Proj4.xs Geo-Proj4-1.06-tANwy_/Proj4.xs
--- Geo-Proj4-1.06-E4U_U2/Proj4.xs 2017-02-23 19:24:50.000000000 +1000
+++ Geo-Proj4-1.06-tANwy_/Proj4.xs 2017-04-23 07:00:37.153647666 +1000
@@ -166,7 +166,7 @@
x[p] = SvNV(*av_fetch(point, 0, 0));
y[p] = SvNV(*av_fetch(point, 1, 0));
- z[p] = av_len(point) < 3 ? 0.0 : SvNV(*av_fetch(point, 1, 0));
+ z[p] = av_len(point) < 2 ? -10000.0 : SvNV(*av_fetch(point, 2, 0));
/* fprintf(stderr, "point=%f %f %f\n", x[p], y[p], z[p]); */
if(degrees && pj_is_latlong(proj_from))
@@ -192,7 +192,7 @@
av_push(res, newSVnv(x[p]));
av_push(res, newSVnv(y[p]));
- if(z[p]!=0.0) av_push(res, newSVnv(z[p]));
+ if(z[p]>-1000.0) av_push(res, newSVnv(z[p]));
av_push(retlist, newRV((SV *)res));
}
regards
Peter Dean