Skip to content

Commit

Permalink
Add proj_list_* functions that exposes various internal lists (#579)
Browse files Browse the repository at this point in the history
Fixes #173, #187 and #220
  • Loading branch information
kbevers committed Oct 9, 2017
1 parent cb33569 commit 8fc250a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/PJ_cart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
16 changes: 16 additions & 0 deletions src/pj_obs_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);}

Expand Down
4 changes: 4 additions & 0 deletions src/proj.def
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions src/proj.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 8fc250a

Please sign in to comment.