aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Warmerdam <warmerdam@pobox.com>2007-11-26 00:21:59 +0000
committerFrank Warmerdam <warmerdam@pobox.com>2007-11-26 00:21:59 +0000
commitd6636b805e0e8136f427ca79c57b21d421539169 (patch)
treee7b437523ee813ca69a740eee325150a0bcb30a9 /src
parentf14b424fd69930e181f8db5ff853fc0bd06af4b4 (diff)
downloadPROJ-d6636b805e0e8136f427ca79c57b21d421539169.tar.gz
PROJ-d6636b805e0e8136f427ca79c57b21d421539169.zip
Modified PJ structure to hold a_orig, es_orig, ellipsoid definition before
adjustment for spherical projections. Modified pj_datum_transform() to use the original ellipsoid parameters, not the ones adjusted for spherical projections. Modified pj_datum_transform() to not attempt any datum shift via geocentric coordinates if the source *or* destination are raw ellipsoids (ie. PJD_UNKNOWN). All per PROJ bug #1602, GDAL bug #2025. git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@1406 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src')
-rw-r--r--src/pj_init.c12
-rw-r--r--src/pj_transform.c39
-rw-r--r--src/projects.h15
3 files changed, 56 insertions, 10 deletions
diff --git a/src/pj_init.c b/src/pj_init.c
index 4b120080..205b468a 100644
--- a/src/pj_init.c
+++ b/src/pj_init.c
@@ -30,6 +30,15 @@
******************************************************************************
*
* $Log$
+ * Revision 1.19 2007/11/26 00:21:59 fwarmerdam
+ * Modified PJ structure to hold a_orig, es_orig, ellipsoid definition before
+ * adjustment for spherical projections.
+ * Modified pj_datum_transform() to use the original ellipsoid parameters,
+ * not the ones adjusted for spherical projections.
+ * Modified pj_datum_transform() to not attempt any datum shift via
+ * geocentric coordinates if the source *or* destination are raw ellipsoids
+ * (ie. PJD_UNKNOWN). All per PROJ bug #1602, GDAL bug #2025.
+ *
* Revision 1.18 2006/10/12 21:04:39 fwarmerdam
* Added experimental +lon_wrap argument to set a "center point" for
* longitude wrapping of longitude values coming out of pj_transform().
@@ -282,6 +291,9 @@ pj_init(int argc, char **argv) {
/* set ellipsoid/sphere parameters */
if (pj_ell_set(start, &PIN->a, &PIN->es)) goto bum_call;
+ PIN->a_orig = PIN->a;
+ PIN->es_orig = PIN->es;
+
PIN->e = sqrt(PIN->es);
PIN->ra = 1. / PIN->a;
PIN->one_es = 1. - PIN->es;
diff --git a/src/pj_transform.c b/src/pj_transform.c
index 3c2bed1a..40a7bf8d 100644
--- a/src/pj_transform.c
+++ b/src/pj_transform.c
@@ -30,6 +30,15 @@
******************************************************************************
*
* $Log$
+ * Revision 1.23 2007/11/26 00:21:59 fwarmerdam
+ * Modified PJ structure to hold a_orig, es_orig, ellipsoid definition before
+ * adjustment for spherical projections.
+ * Modified pj_datum_transform() to use the original ellipsoid parameters,
+ * not the ones adjusted for spherical projections.
+ * Modified pj_datum_transform() to not attempt any datum shift via
+ * geocentric coordinates if the source *or* destination are raw ellipsoids
+ * (ie. PJD_UNKNOWN). All per PROJ bug #1602, GDAL bug #2025.
+ *
* Revision 1.22 2007/09/11 20:32:25 fwarmerdam
* mark the transient error array const
*
@@ -197,7 +206,7 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
}
}
- if( pj_geocentric_to_geodetic( srcdefn->a, srcdefn->es,
+ if( pj_geocentric_to_geodetic( srcdefn->a_orig, srcdefn->es_orig,
point_count, point_offset,
x, y, z ) != 0)
return pj_errno;
@@ -294,7 +303,7 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
return PJD_ERR_GEOCENTRIC;
}
- pj_geodetic_to_geocentric( dstdefn->a, dstdefn->es,
+ pj_geodetic_to_geocentric( dstdefn->a_orig, dstdefn->es_orig,
point_count, point_offset, x, y, z );
if( dstdefn->fr_meter != 1.0 )
@@ -464,8 +473,8 @@ int pj_compare_datums( PJ *srcdefn, PJ *dstdefn )
{
return 0;
}
- else if( srcdefn->a != dstdefn->a
- || ABS(srcdefn->es - dstdefn->es) > 0.000000000050 )
+ else if( srcdefn->a_orig != dstdefn->a_orig
+ || ABS(srcdefn->es_orig - dstdefn->es_orig) > 0.000000000050 )
{
/* the tolerence for es is to ensure that GRS80 and WGS84 are
considered identical */
@@ -598,6 +607,10 @@ int pj_geocentric_from_wgs84( PJ *defn,
/************************************************************************/
/* pj_datum_transform() */
+/* */
+/* The input should be long/lat/z coordinates in radians in the */
+/* source datum, and the output should be long/lat/z */
+/* coordinates in radians in the destination datum. */
/************************************************************************/
int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
@@ -611,16 +624,26 @@ int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
pj_errno = 0;
/* -------------------------------------------------------------------- */
+/* We cannot do any meaningful datum transformation if either */
+/* the source or destination are of an unknown datum type */
+/* (ie. only a +ellps declaration, no +datum). This is new */
+/* behavior for PROJ 4.6.0. */
+/* -------------------------------------------------------------------- */
+ if( srcdefn->datum_type == PJD_UNKNOWN
+ || dstdefn->datum_type == PJD_UNKNOWN )
+ return 0;
+
+/* -------------------------------------------------------------------- */
/* Short cut if the datums are identical. */
/* -------------------------------------------------------------------- */
if( pj_compare_datums( srcdefn, dstdefn ) )
return 0;
- src_a = srcdefn->a;
- src_es = srcdefn->es;
+ src_a = srcdefn->a_orig;
+ src_es = srcdefn->es_orig;
- dst_a = dstdefn->a;
- dst_es = dstdefn->es;
+ dst_a = dstdefn->a_orig;
+ dst_es = dstdefn->es_orig;
/* -------------------------------------------------------------------- */
/* Create a temporary Z array if one is not provided. */
diff --git a/src/projects.h b/src/projects.h
index 660c4a3b..9270755c 100644
--- a/src/projects.h
+++ b/src/projects.h
@@ -28,6 +28,15 @@
******************************************************************************
*
* $Log$
+ * Revision 1.27 2007/11/26 00:21:59 fwarmerdam
+ * Modified PJ structure to hold a_orig, es_orig, ellipsoid definition before
+ * adjustment for spherical projections.
+ * Modified pj_datum_transform() to use the original ellipsoid parameters,
+ * not the ones adjusted for spherical projections.
+ * Modified pj_datum_transform() to not attempt any datum shift via
+ * geocentric coordinates if the source *or* destination are raw ellipsoids
+ * (ie. PJD_UNKNOWN). All per PROJ bug #1602, GDAL bug #2025.
+ *
* Revision 1.26 2007/03/11 17:03:18 fwarmerdam
* support drive letter prefixes on win32 and related fixes (bug 1499)
*
@@ -289,8 +298,10 @@ typedef struct PJconsts {
int is_geocent; /* proj=geocent ... not really a projection at all */
double
a, /* major axis or radius if es==0 */
- e, /* eccentricity */
+ a_orig, /* major axis before any +proj related adjustment */
es, /* e ^ 2 */
+ es_orig, /* es before any +proj related adjustment */
+ e, /* eccentricity */
ra, /* 1/A */
one_es, /* 1 - e^2 */
rone_es, /* 1/one_es */
@@ -298,7 +309,7 @@ typedef struct PJconsts {
x0, y0, /* easting and northing */
k0, /* general scaling factor */
to_meter, fr_meter; /* cartesian scaling */
-
+
int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
double datum_params[7];
double from_greenwich; /* prime meridian offset (in radians) */