diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2017-09-05 13:13:52 +0200 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2017-09-05 18:14:33 +0200 |
| commit | 1c743de193f43f818635235d60330e78dbd4cd96 (patch) | |
| tree | 2b8012b03e4b5b86f35a48712871b9b0688fc95c /src/proj.c | |
| parent | 60970de2d0e47f40c7a30222eba0c1de511ea0a1 (diff) | |
| download | PROJ-1c743de193f43f818635235d60330e78dbd4cd96.tar.gz PROJ-1c743de193f43f818635235d60330e78dbd4cd96.zip | |
proj: Do rad->deg conversion if output units warrants it.
With the introduction of transformation pipelines it is possible to
create a pipeline that has degrees as it's output unit. If that is the
case the output coordinate will be in radians internally. This commit
makes sure that a conversion to degrees is applied before printing to
stdout.
Diffstat (limited to 'src/proj.c')
| -rw-r--r-- | src/proj.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -143,10 +143,17 @@ static void process(FILE *fid) { putchar('\t'); (void)fputs(rtodms(pline, data.v, 'N', 'S'), stdout); } - } else { /* x-y or decimal degree ascii output */ + } else { /* x-y or decimal degree ascii output, scale if warranted by output units */ if (inverse) { - data.v *= RAD_TO_DEG; - data.u *= RAD_TO_DEG; + if (Proj->left == PJ_IO_UNITS_RADIANS || Proj->left == PJ_IO_UNITS_CLASSIC) { + data.v *= RAD_TO_DEG; + data.u *= RAD_TO_DEG; + } + } else { + if (Proj->right == PJ_IO_UNITS_RADIANS) { + data.v *= RAD_TO_DEG; + data.u *= RAD_TO_DEG; + } } if (reverseout) { @@ -177,6 +184,7 @@ static void vprocess(FILE *fid) { projUV dat_ll, dat_xy, temp; int linvers; + if (!oform) oform = "%.3f"; @@ -247,6 +255,12 @@ static void vprocess(FILE *fid) { if (postscale) { dat_xy.u *= fscale; dat_xy.v *= fscale; } } + /* apply rad->deg scaling in case the output from a pipeline has degrees as units */ + if (!inverse && Proj->right == PJ_IO_UNITS_RADIANS) { + dat_xy.u *= RAD_TO_DEG; + dat_xy.v *= RAD_TO_DEG; + } + /* For some reason pj_errno does not work as expected in some */ /* versions of Visual Studio, so using pj_get_errno_ref instead */ if (*pj_get_errno_ref()) { |
