diff options
| author | Frank Warmerdam <warmerdam@pobox.com> | 2010-01-24 22:53:33 +0000 |
|---|---|---|
| committer | Frank Warmerdam <warmerdam@pobox.com> | 2010-01-24 22:53:33 +0000 |
| commit | e525ab9ff2adcf195fc7eea173f2fce45f7fd8f5 (patch) | |
| tree | 3635d149744efd70df66cc2a83c032149169be83 | |
| parent | a32477f71af5103697a0441eaecb74537e2211db (diff) | |
| download | PROJ-e525ab9ff2adcf195fc7eea173f2fce45f7fd8f5.tar.gz PROJ-e525ab9ff2adcf195fc7eea173f2fce45f7fd8f5.zip | |
fix seriously broken lon_wrap support (#62)
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@1789 4e78687f-474d-0410-85f9-8d5e500ac6b2
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rwxr-xr-x | nad/testvarious | 16 | ||||
| -rw-r--r-- | nad/tv_out.dist | 52 | ||||
| -rw-r--r-- | src/pj_init.c | 5 | ||||
| -rw-r--r-- | src/pj_transform.c | 10 | ||||
| -rw-r--r-- | src/projects.h | 1 |
6 files changed, 60 insertions, 27 deletions
@@ -1,5 +1,8 @@ 2010-01-25 Frank Warmerdam <warmerdam@pobox.com> + * src/pj_init,src/projects.h,src/pj_transform.c,nad/testvarious: + Correct seriously broken +lon_wrap implementation. (#62) + * src/pj_mutex.c: fix creation of mutex on win32 to be in unacquired state in pj_init_lock to avoid an extra reference. (#63) diff --git a/nad/testvarious b/nad/testvarious index e329778b..6a7a3206 100755 --- a/nad/testvarious +++ b/nad/testvarious @@ -82,6 +82,22 @@ $EXE +proj=latlong +datum=WGS84 +pm=greenwich \ EOF # echo "##############################################################" >> ${OUT} +echo Test support for the lon_wrap switch. >> ${OUT} +# +$EXE +proj=latlong +datum=WGS84 \ + +to +proj=latlong +datum=WGS84 +lon_wrap=180 \ + -E >>${OUT} <<EOF +1d00'00.000"W 10d00'00.000"N 0.0 +0d00'00.000"W 10d00'00.000"N 0.0 +0d00'00.000"E 10d00'00.000"N 0.0 +1d00'00.000"E 45d00'00.000"N 0.0 +179d00'00.000"E 45d00'00.000"N 0.0 +181d00'00.000"E 45d00'00.000"N 0.0 +350d00'00.000"E 45d00'00.000"N 0.0 +370d00'00.000"E 45d00'00.000"N 0.0 +EOF +# +echo "##############################################################" >> ${OUT} echo Test simple prime meridian handling within a projection. >> ${OUT} # $EXE +proj=utm +zone=11 +datum=WGS84 +pm=3 \ diff --git a/nad/tv_out.dist b/nad/tv_out.dist index cd49b915..ba816a22 100644 --- a/nad/tv_out.dist +++ b/nad/tv_out.dist @@ -1,41 +1,51 @@ ############################################################## Test raw ellipse to raw ellipse -79d58'00.000"W 37d02'00.000"N 0.0 79d58'W 37d2'N 0.000 -79d58'00.000"W 36d58'00.000"N 0.0 79d58'W 36d58'N 0.000 +79d58'00.000"W 37d02'00.000"N 0.0 79d58'W 37d2'N 0.000
+79d58'00.000"W 36d58'00.000"N 0.0 79d58'W 36d58'N 0.000
############################################################## Test NAD27 to raw ellipse -79d00'00.000"W 35d00'00.000"N 0.0 79dW 35dN 0.000 +79d00'00.000"W 35d00'00.000"N 0.0 79dW 35dN 0.000
############################################################## Between two 3parameter approximations on same ellipsoid -0d00'00.000"W 0d00'00.000"N 0.0 0dE 0dN 4.000 -79d00'00.000"W 45d00'00.000"N 0.0 78d59'59.821"W 44d59'59.983"N 0.540 +0d00'00.000"W 0d00'00.000"N 0.0 0dE 0dN 4.000
+79d00'00.000"W 45d00'00.000"N 0.0 78d59'59.821"W 44d59'59.983"N 0.540
############################################################## 3param to raw ellipsoid on same ellipsoid -0d00'00.000"W 0d00'00.000"N 0.0 0dE 0dN 0.000 -79d00'00.000"W 45d00'00.000"N 0.0 79dW 45dN 0.000 +0d00'00.000"W 0d00'00.000"N 0.0 0dE 0dN 0.000
+79d00'00.000"W 45d00'00.000"N 0.0 79dW 45dN 0.000
############################################################## Test simple prime meridian handling. -0d00'00.000"W 0d00'00.000"N 0.0 1dW 0dN 0.000 -79d00'00.000"W 45d00'00.000"N 0.0 80dW 45dN 0.000 +0d00'00.000"W 0d00'00.000"N 0.0 1dW 0dN 0.000
+79d00'00.000"W 45d00'00.000"N 0.0 80dW 45dN 0.000
+############################################################## +Test support for the lon_wrap switch. +1d00'00.000"W 10d00'00.000"N 0.0 359dE 10dN 0.000
+0d00'00.000"W 10d00'00.000"N 0.0 360dE 10dN 0.000
+0d00'00.000"E 10d00'00.000"N 0.0 360dE 10dN 0.000
+1d00'00.000"E 45d00'00.000"N 0.0 1dE 45dN 0.000
+179d00'00.000"E 45d00'00.000"N 0.0 179dE 45dN 0.000
+181d00'00.000"E 45d00'00.000"N 0.0 181dE 45dN 0.000
+350d00'00.000"E 45d00'00.000"N 0.0 350dE 45dN 0.000
+370d00'00.000"E 45d00'00.000"N 0.0 10dE 45dN 0.000
############################################################## Test simple prime meridian handling within a projection. -500000 3000000 113dW 27d7'20.891"N 0.000 +500000 3000000 113dW 27d7'20.891"N 0.000
############################################################## Test geocentric x/y/z generation. -0d00'00.000"W 0d00'00.000"N 0.0 6378137.00 -0.00 0.00 -0d00'00.000"W 0d00'00.000"N 10.0 6378147.00 -0.00 0.00 -79d00'00.000"W 45d00'00.000"N 0.0 861996.98 -4434590.01 4487348.41 -0d00'00.000"W 90d00'00.000"N 0.0 0.00 -0.00 6356752.31 +0d00'00.000"W 0d00'00.000"N 0.0 6378137.00 0.00 0.00
+0d00'00.000"W 0d00'00.000"N 10.0 6378147.00 0.00 0.00
+79d00'00.000"W 45d00'00.000"N 0.0 861996.98 -4434590.01 4487348.41
+0d00'00.000"W 90d00'00.000"N 0.0 0.00 0.00 6356752.31
############################################################## Test geocentric x/y/z consumption. -6378137.00 -0.00 0.00 0dE 0dN 0.000 -6378147.00 -0.00 0.00 0dE 0dN 10.000 -861996.98 -4434590.01 4487348.41 79dW 45dN 0.001 -0.00 -0.00 6356752.31 0dE 90dN -0.004 +6378137.00 -0.00 0.00 0dE 0dN 0.000
+6378147.00 -0.00 0.00 0dE 0dN 10.000
+861996.98 -4434590.01 4487348.41 79dW 45dN 0.001
+0.00 -0.00 6356752.31 0dE 90dN -0.004
############################################################## Test stere projection (re: win32 ticket 12) -105 40 5577808.93 1494569.40 0.00 +105 40 5577808.93 1494569.40 0.00
############################################################## Test sts projection (re: ticket 12) -4.897000 52.371000 383646.09 5997047.89 0.00 -383646.088858 5997047.888175 4d53'49.2"E 52d22'15.6"N 0.000 +4.897000 52.371000 383646.09 5997047.89 0.00
+383646.088858 5997047.888175 4d53'49.2"E 52d22'15.6"N 0.000
diff --git a/src/pj_init.c b/src/pj_init.c index 2d84ef3f..f40d2ad9 100644 --- a/src/pj_init.c +++ b/src/pj_init.c @@ -268,6 +268,7 @@ pj_init(int argc, char **argv) { PIN->params = start; PIN->is_latlong = 0; PIN->is_geocent = 0; + PIN->is_long_wrap_set = 0; PIN->long_wrap_center = 0.0; /* set datum parameters */ @@ -303,7 +304,9 @@ pj_init(int argc, char **argv) { PIN->over = pj_param(start, "bover").i; /* longitude center for wrapping */ - PIN->long_wrap_center = pj_param(start, "rlon_wrap").f; + PIN->is_long_wrap_set = pj_param(start, "tlon_wrap").i; + if (PIN->is_long_wrap_set) + PIN->long_wrap_center = pj_param(start, "rlon_wrap").f; /* central meridian */ PIN->lam0=pj_param(start, "rlon_0").f; diff --git a/src/pj_transform.c b/src/pj_transform.c index 07b84f80..c64b410f 100644 --- a/src/pj_transform.c +++ b/src/pj_transform.c @@ -268,17 +268,17 @@ int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset, /* If a wrapping center other than 0 is provided, rewrap around */ /* the suggested center (for latlong coordinate systems only). */ /* -------------------------------------------------------------------- */ - else if( dstdefn->is_latlong && dstdefn->long_wrap_center != 0 ) + else if( dstdefn->is_latlong && dstdefn->is_long_wrap_set ) { for( i = 0; i < point_count; i++ ) { if( x[point_offset*i] == HUGE_VAL ) continue; - while( x[point_offset*i] < dstdefn->long_wrap_center - HALFPI ) - x[point_offset*i] += PI; - while( x[point_offset*i] > dstdefn->long_wrap_center + HALFPI ) - x[point_offset*i] -= PI; + while( x[point_offset*i] < dstdefn->long_wrap_center - PI ) + x[point_offset*i] += TWOPI; + while( x[point_offset*i] > dstdefn->long_wrap_center + PI ) + x[point_offset*i] -= TWOPI; } } diff --git a/src/projects.h b/src/projects.h index 822a53cc..7fec1ce5 100644 --- a/src/projects.h +++ b/src/projects.h @@ -234,6 +234,7 @@ typedef struct PJconsts { double datum_params[7]; double from_greenwich; /* prime meridian offset (in radians) */ double long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/ + int is_long_wrap_set; #ifdef PROJ_PARMS__ PROJ_PARMS__ |
