aboutsummaryrefslogtreecommitdiff
path: root/src/pj_transform.c
diff options
context:
space:
mode:
authorFrank Warmerdam <warmerdam@pobox.com>2002-02-15 14:31:20 +0000
committerFrank Warmerdam <warmerdam@pobox.com>2002-02-15 14:31:20 +0000
commit8103098a2190b70829834c1fdda2876f028a932a (patch)
tree7d210f48420d2362543fbd184d95118a05ebb33c /src/pj_transform.c
parent54fcb51ba0bd5f3992aed44ef6c5a719f251f67c (diff)
downloadPROJ-8103098a2190b70829834c1fdda2876f028a932a.tar.gz
PROJ-8103098a2190b70829834c1fdda2876f028a932a.zip
provide default Z array if none passed in in pj_datum_transform()
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@994 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src/pj_transform.c')
-rw-r--r--src/pj_transform.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/pj_transform.c b/src/pj_transform.c
index 683bdab8..8285878f 100644
--- a/src/pj_transform.c
+++ b/src/pj_transform.c
@@ -30,6 +30,9 @@
******************************************************************************
*
* $Log$
+ * Revision 1.4 2002/02/15 14:30:36 warmerda
+ * provide default Z array if none passed in in pj_datum_transform()
+ *
* Revision 1.3 2001/04/04 21:13:21 warmerda
* do arcsecond/radian and ppm datum parm transformation in pj_set_datum()
*
@@ -355,6 +358,7 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
{
double src_a, src_es, dst_a, dst_es;
+ int z_is_temp = FALSE;
pj_errno = 0;
@@ -371,6 +375,19 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
dst_es = dstdefn->es;
/* -------------------------------------------------------------------- */
+/* Create a temporary Z array if one is not provided. */
+/* -------------------------------------------------------------------- */
+ if( z == NULL )
+ {
+ int bytes = sizeof(double) * point_count * point_offset;
+ z = (double *) pj_malloc(bytes);
+ memset( z, 0, bytes );
+ z_is_temp = TRUE;
+ }
+
+#define CHECK_RETURN {if( pj_errno != 0 ) { if( z_is_temp ) pj_dalloc(z); return pj_errno; }}
+
+/* -------------------------------------------------------------------- */
/* If this datum requires grid shifts, then apply it to geodetic */
/* coordinates. */
/* -------------------------------------------------------------------- */
@@ -378,9 +395,7 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
{
pj_apply_gridshift( pj_param(srcdefn->params,"snadgrids").s, 0,
point_count, point_offset, x, y, z );
-
- if( pj_errno != 0 )
- return pj_errno;
+ CHECK_RETURN;
src_a = SRS_WGS84_SEMIMAJOR;
src_es = 0.006694379990;
@@ -405,9 +420,7 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
/* -------------------------------------------------------------------- */
pj_geodetic_to_geocentric( src_a, src_es,
point_count, point_offset, x, y, z );
-
- if( pj_errno )
- return pj_errno;
+ CHECK_RETURN;
/* -------------------------------------------------------------------- */
/* Convert between datums. */
@@ -416,12 +429,10 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
&& dstdefn->datum_type != PJD_UNKNOWN )
{
pj_geocentric_to_wgs84( srcdefn, point_count, point_offset,x,y,z);
- if( pj_errno != 0 )
- return pj_errno;
-
+ CHECK_RETURN;
+
pj_geocentric_from_wgs84( dstdefn, point_count,point_offset,x,y,z);
- if( pj_errno != 0 )
- return pj_errno;
+ CHECK_RETURN;
}
/* -------------------------------------------------------------------- */
@@ -429,9 +440,7 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
/* -------------------------------------------------------------------- */
pj_geocentric_to_geodetic( dst_a, dst_es,
point_count, point_offset, x, y, z );
-
- if( pj_errno )
- return pj_errno;
+ CHECK_RETURN;
}
/* -------------------------------------------------------------------- */
@@ -441,11 +450,12 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
{
pj_apply_gridshift( pj_param(dstdefn->params,"snadgrids").s, 1,
point_count, point_offset, x, y, z );
-
- if( pj_errno != 0 )
- return pj_errno;
+ CHECK_RETURN;
}
+ if( z_is_temp )
+ pj_dalloc( z );
+
return 0;
}