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 /src | |
| 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
Diffstat (limited to 'src')
| -rw-r--r-- | src/pj_init.c | 5 | ||||
| -rw-r--r-- | src/pj_transform.c | 10 | ||||
| -rw-r--r-- | src/projects.h | 1 |
3 files changed, 10 insertions, 6 deletions
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__ |
