aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2018-11-10 14:07:09 +0100
committerGitHub <noreply@github.com>2018-11-10 14:07:09 +0100
commit94c454012edcad7035a5531afb0529dc3b7e0812 (patch)
tree7cefe77c16034a72ff1b40d51d510f683a76d035
parent811fc90adeb6782dded4ef5c2ab58131e8399c67 (diff)
parent811ea089a00c8f6be9cec3bf0a7a1dfc0b4ff77c (diff)
downloadPROJ-94c454012edcad7035a5531afb0529dc3b7e0812.tar.gz
PROJ-94c454012edcad7035a5531afb0529dc3b7e0812.zip
Merge pull request #1162 from kbevers/proj-output-units
Disallow use of non-projection operations in proj (was: Don't convert non-angular inputs to proj to radians)
-rw-r--r--src/proj.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/proj.c b/src/proj.c
index e01175a5..293193e7 100644
--- a/src/proj.c
+++ b/src/proj.c
@@ -160,12 +160,12 @@ static void process(FILE *fid) {
}
} else { /* x-y or decimal degree ascii output, scale if warranted by output units */
if (inverse) {
- if (Proj->left == PJ_IO_UNITS_ANGULAR) {
+ if (proj_angular_input(Proj, PJ_FWD)) {
data.uv.v *= RAD_TO_DEG;
data.uv.u *= RAD_TO_DEG;
}
} else {
- if (Proj->right == PJ_IO_UNITS_ANGULAR) {
+ if (proj_angular_output(Proj, PJ_FWD)) {
data.uv.v *= RAD_TO_DEG;
data.uv.u *= RAD_TO_DEG;
}
@@ -268,12 +268,6 @@ static void vprocess(FILE *fid) {
if (postscale) { dat_xy.x *= fscale; dat_xy.y *= fscale; }
}
- /* apply rad->deg scaling in case the output from a pipeline has degrees as units */
- if (!inverse && Proj->right == PJ_IO_UNITS_ANGULAR) {
- dat_xy.x *= RAD_TO_DEG;
- dat_xy.y *= 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()) {
@@ -501,10 +495,14 @@ int main(int argc, char **argv) {
emess(3,"projection initialization failure\ncause: %s",
pj_strerrno(pj_errno));
- if( pj_is_latlong( Proj ) )
- {
- emess( 3, "+proj=latlong unsuitable for use with proj program." );
- exit( 0 );
+ if (!proj_angular_input(Proj, PJ_FWD)) {
+ emess(3, "can't initialize operations that take angular input coordinates");
+ exit(0);
+ }
+
+ if (proj_angular_output(Proj, PJ_FWD)) {
+ emess(3, "can't initialize operations that produce angular output coordinates");
+ exit(0);
}
if (inverse) {