aboutsummaryrefslogtreecommitdiff
path: root/src/proj.c
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2018-11-10 12:01:26 +0100
committerKristian Evers <kristianevers@gmail.com>2018-11-10 12:48:27 +0100
commit811ea089a00c8f6be9cec3bf0a7a1dfc0b4ff77c (patch)
treefbcccc7628b0cbe7aaa3dd9c9e3cbddd89e7126f /src/proj.c
parent35eb793ff6b411cc88fc578b4d99e34cd25ca613 (diff)
downloadPROJ-811ea089a00c8f6be9cec3bf0a7a1dfc0b4ff77c.tar.gz
PROJ-811ea089a00c8f6be9cec3bf0a7a1dfc0b4ff77c.zip
Disallow use of non-projection operations in proj
Since the introduction of other operations types than projections it has been unclear how proj should treat those. This commit sets record straight once and for all: proj is only allowed to initialize operations that take angular input and produces non-angular output, i.e. projections. This is true to the version of proj before the introduction of the pipeline and other non-projection operations. Users can still initiliaze pipelines with proj as long as the resulting concatenated operation requires angular input and outputs non-angular output.
Diffstat (limited to 'src/proj.c')
-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) {