aboutsummaryrefslogtreecommitdiff
path: root/src/geod_set.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-18 20:24:11 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-26 10:08:53 +0100
commit610957f7035242f15743c399ffd429b92bc36206 (patch)
tree73f0d51147e2f4860c4bfc875f7a4bf9359386d4 /src/geod_set.cpp
parent355d681ed88019e97742344bd642c2fd97e700a1 (diff)
downloadPROJ-610957f7035242f15743c399ffd429b92bc36206.tar.gz
PROJ-610957f7035242f15743c399ffd429b92bc36206.zip
cpp conversion: minimal steps to fix compilation errors, not warnings
Diffstat (limited to 'src/geod_set.cpp')
-rw-r--r--src/geod_set.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/geod_set.cpp b/src/geod_set.cpp
new file mode 100644
index 00000000..b5bd0667
--- /dev/null
+++ b/src/geod_set.cpp
@@ -0,0 +1,75 @@
+#define _IN_GEOD_SET
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "proj.h"
+#include "projects.h"
+#include "geod_interface.h"
+#include "emess.h"
+
+ void
+geod_set(int argc, char **argv) {
+ paralist *start = 0, *curr;
+ double es;
+ char *name;
+ int i;
+
+ /* put arguments into internal linked list */
+ if (argc <= 0)
+ emess(1, "no arguments in initialization list");
+ start = curr = pj_mkparam(argv[0]);
+ if (!curr)
+ emess(1, "memory allocation failed");
+ for (i = 1; curr != 0 && i < argc; ++i) {
+ curr->next = pj_mkparam(argv[i]);
+ if (!curr->next)
+ emess(1, "memory allocation failed");
+ curr = curr->next;
+ }
+ /* set elliptical parameters */
+ if (pj_ell_set(pj_get_default_ctx(),start, &geod_a, &es)) emess(1,"ellipse setup failure");
+ /* set units */
+ if ((name = pj_param(NULL,start, "sunits").s) != NULL) {
+ const char *s;
+ const struct PJ_UNITS *unit_list = proj_list_units();
+ for (i = 0; (s = unit_list[i].id) && strcmp(name, s) ; ++i) ;
+ if (!s)
+ emess(1,"%s unknown unit conversion id", name);
+ to_meter = unit_list[i].factor;
+ fr_meter = 1 / to_meter;
+ } else
+ to_meter = fr_meter = 1;
+ geod_f = es/(1 + sqrt(1 - es));
+ geod_ini();
+ /* check if line or arc mode */
+ if (pj_param(NULL,start, "tlat_1").i) {
+ double del_S;
+#undef f
+ phi1 = pj_param(NULL,start, "rlat_1").f;
+ lam1 = pj_param(NULL,start, "rlon_1").f;
+ if (pj_param(NULL,start, "tlat_2").i) {
+ phi2 = pj_param(NULL,start, "rlat_2").f;
+ lam2 = pj_param(NULL,start, "rlon_2").f;
+ geod_inv();
+ geod_pre();
+ } else if ((geod_S = pj_param(NULL,start, "dS").f) != 0.) {
+ al12 = pj_param(NULL,start, "rA").f;
+ geod_pre();
+ geod_for();
+ } else emess(1,"incomplete geodesic/arc info");
+ if ((n_alpha = pj_param(NULL,start, "in_A").i) > 0) {
+ if ((del_alpha = pj_param(NULL,start, "rdel_A").f) == 0.0)
+ emess(1,"del azimuth == 0");
+ } else if ((del_S = fabs(pj_param(NULL,start, "ddel_S").f)) != 0.) {
+ n_S = (int)(geod_S / del_S + .5);
+ } else if ((n_S = pj_param(NULL,start, "in_S").i) <= 0)
+ emess(1,"no interval divisor selected");
+ }
+ /* free up linked list */
+ for ( ; start; start = curr) {
+ curr = start->next;
+ pj_dalloc(start);
+ }
+}