aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2017-10-09 11:42:02 +0200
committerGitHub <noreply@github.com>2017-10-09 11:42:02 +0200
commit8fc250a04edbfe81b9b7409187887066baeba29b (patch)
tree87f35314a5bc30f94e738d412f07642cf0eff835 /src
parentcb335699aafc84952d1a6a94eb9d2ee201ad416f (diff)
downloadPROJ-8fc250a04edbfe81b9b7409187887066baeba29b.tar.gz
PROJ-8fc250a04edbfe81b9b7409187887066baeba29b.zip
Add proj_list_* functions that exposes various internal lists (#579)
Fixes #173, #187 and #220
Diffstat (limited to 'src')
-rw-r--r--src/PJ_cart.c21
-rw-r--r--src/pj_obs_api.c16
-rw-r--r--src/proj.def4
-rw-r--r--src/proj.h23
4 files changed, 64 insertions, 0 deletions
diff --git a/src/PJ_cart.c b/src/PJ_cart.c
index d34996eb..914fa94b 100644
--- a/src/PJ_cart.c
+++ b/src/PJ_cart.c
@@ -240,6 +240,11 @@ int pj_cart_selftest (void) {
PJ_DERIVS derivs;
PJ_FACTORS factors;
+ const PJ_OPERATIONS *oper_list;
+ const PJ_ELLPS *ellps_list;
+ const PJ_UNITS *unit_list;
+ const PJ_PRIME_MERIDIANS *pm_list;
+
int err;
size_t n, sz;
double dist, h, t;
@@ -562,6 +567,22 @@ int pj_cart_selftest (void) {
proj_destroy(P);
+ /* Check that proj_list_* functions work by looping through them */
+ n = 0;
+ for (oper_list = proj_list_operations(); oper_list->id; ++oper_list) n++;
+ if (n == 0) return 90;
+
+ n = 0;
+ for (ellps_list = proj_list_ellps(); ellps_list->id; ++ellps_list) n++;
+ if (n == 0) return 91;
+
+ n = 0;
+ for (unit_list = proj_list_units(); unit_list->id; ++unit_list) n++;
+ if (n == 0) return 92;
+
+ n = 0;
+ for (pm_list = proj_list_prime_meridians(); pm_list->id; ++pm_list) n++;
+ if (n == 0) return 93;
return 0;
}
diff --git a/src/pj_obs_api.c b/src/pj_obs_api.c
index 57b47341..9f699fcf 100644
--- a/src/pj_obs_api.c
+++ b/src/pj_obs_api.c
@@ -780,6 +780,22 @@ PJ_FACTORS proj_factors(PJ *P, const LP lp) {
}
+const PJ_ELLPS *proj_list_ellps(void) {
+ return pj_get_ellps_ref();
+}
+
+const PJ_UNITS *proj_list_units(void) {
+ return pj_get_units_ref();
+}
+
+const PJ_OPERATIONS *proj_list_operations(void) {
+ return pj_get_list_ref();
+}
+
+const PJ_PRIME_MERIDIANS *proj_list_prime_meridians(void) {
+ return pj_get_prime_meridians_ref();
+}
+
double proj_torad (double angle_in_degrees) { return PJ_TORAD (angle_in_degrees);}
double proj_todeg (double angle_in_radians) { return PJ_TODEG (angle_in_radians);}
diff --git a/src/proj.def b/src/proj.def
index 12816f1c..598f2824 100644
--- a/src/proj.def
+++ b/src/proj.def
@@ -143,3 +143,7 @@ EXPORTS
proj_derivatives @130
proj_factors @131
+ proj_list_operations @132
+ proj_list_ellps @133
+ proj_list_units @134
+ proj_list_prime_meridians @135
diff --git a/src/proj.h b/src/proj.h
index 167fb1eb..049daf19 100644
--- a/src/proj.h
+++ b/src/proj.h
@@ -205,6 +205,23 @@ typedef struct PJ_GRID_INFO PJ_GRID_INFO;
struct PJ_INIT_INFO;
typedef struct PJ_INIT_INFO PJ_INIT_INFO;
+/* Data types for list of operations, ellipsoids, datums and units used in PROJ.4 */
+struct PJ_LIST;
+typedef struct PJ_LIST PJ_OPERATIONS;
+
+struct PJ_ELLPS;
+typedef struct PJ_ELLPS PJ_ELLPS;
+
+struct PJ_DATUMS;
+typedef struct PJ_DATUMS PJ_DATUMS;
+
+struct PJ_UNITS;
+typedef struct PJ_UNITS PJ_UNITS;
+
+struct PJ_PRIME_MERIDIANS;
+typedef struct PJ_PRIME_MERIDIANS PJ_PRIME_MERIDIANS;
+
+
/* Omega, Phi, Kappa: Rotations */
typedef struct {double o, p, k;} PJ_OPK;
@@ -410,6 +427,12 @@ PJ_PROJ_INFO proj_pj_info(PJ *P);
PJ_GRID_INFO proj_grid_info(const char *gridname);
PJ_INIT_INFO proj_init_info(const char *initname);
+/* List functions: */
+/* Get lists of operations, ellipsoids, units and prime meridians. */
+const PJ_OPERATIONS *proj_list_operations(void);
+const PJ_ELLPS *proj_list_ellps(void);
+const PJ_UNITS *proj_list_units(void);
+const PJ_PRIME_MERIDIANS *proj_list_prime_meridians(void);
/* These are trivial, and while occasionaly useful in real code, primarily here to */
/* simplify demo code, and in acknowledgement of the proj-internal discrepancy between */