aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Knudsen <busstoptaktik@users.noreply.github.com>2017-11-25 06:23:42 +0100
committerGitHub <noreply@github.com>2017-11-25 06:23:42 +0100
commita2a546a74acf16cf0721ce3572534f06c2822b11 (patch)
treec8fe3e4433a687f1a5e115fff10faf1d42b76338 /src
parentbea0c8b0c015ef0a5c136b904d63ad7f4a4427bf (diff)
downloadPROJ-a2a546a74acf16cf0721ce3572534f06c2822b11.tar.gz
PROJ-a2a546a74acf16cf0721ce3572534f06c2822b11.zip
Improve API (#683)
Increase the focus on PJ_COORD as primary datatype: Eliminate use of PJ_TRIPLET etc. Trim proj.h by removing material that has become unnecessary. Improve constness Make proj_factors work in proj.h space, by providing a trimmed down PJ_FACTORS (which even has more meaningful field names)
Diffstat (limited to 'src')
-rw-r--r--src/PJ_cart.c4
-rw-r--r--src/PJ_helmert.c8
-rw-r--r--src/PJ_hgridshift.c4
-rw-r--r--src/PJ_molodensky.c8
-rw-r--r--src/PJ_unitconvert.c12
-rw-r--r--src/PJ_vgridshift.c6
-rw-r--r--src/gie.c26
-rw-r--r--src/pj_deriv.c21
-rw-r--r--src/pj_factors.c2
-rw-r--r--src/proj.def19
-rw-r--r--src/proj.h110
-rw-r--r--src/proj_4D_api.c55
-rw-r--r--src/projects.h5
13 files changed, 113 insertions, 167 deletions
diff --git a/src/PJ_cart.c b/src/PJ_cart.c
index 2bcf3b4b..cd1995c1 100644
--- a/src/PJ_cart.c
+++ b/src/PJ_cart.c
@@ -187,7 +187,7 @@ static LPZ geodetic (XYZ cartesian, PJ *P) {
/* In effect, 2 cartesian coordinates of a point on the ellipsoid. Rather pointless, but... */
static XY cart_forward (LP lp, PJ *P) {
- PJ_TRIPLET point;
+ PJ_COORD point;
point.lp = lp;
point.lpz.z = 0;
@@ -197,7 +197,7 @@ static XY cart_forward (LP lp, PJ *P) {
/* And the other way round. Still rather pointless, but... */
static LP cart_reverse (XY xy, PJ *P) {
- PJ_TRIPLET point;
+ PJ_COORD point;
point.xy = xy;
point.xyz.z = 0;
diff --git a/src/PJ_helmert.c b/src/PJ_helmert.c
index 478a2c82..d0fd8222 100644
--- a/src/PJ_helmert.c
+++ b/src/PJ_helmert.c
@@ -310,7 +310,7 @@ static void build_rot_matrix(PJ *P) {
static XY helmert_forward (LP lp, PJ *P) {
/***********************************************************************/
struct pj_opaque_helmert *Q = (struct pj_opaque_helmert *) P->opaque;
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
double x, y, cr, sr;
point.lp = lp;
@@ -330,7 +330,7 @@ static XY helmert_forward (LP lp, PJ *P) {
static LP helmert_reverse (XY xy, PJ *P) {
/***********************************************************************/
struct pj_opaque_helmert *Q = (struct pj_opaque_helmert *) P->opaque;
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
double x, y, sr, cr;
point.xy = xy;
@@ -350,7 +350,7 @@ static LP helmert_reverse (XY xy, PJ *P) {
static XYZ helmert_forward_3d (LPZ lpz, PJ *P) {
/***********************************************************************/
struct pj_opaque_helmert *Q = (struct pj_opaque_helmert *) P->opaque;
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
double X, Y, Z, scale;
point.lpz = lpz;
@@ -390,7 +390,7 @@ static XYZ helmert_forward_3d (LPZ lpz, PJ *P) {
static LPZ helmert_reverse_3d (XYZ xyz, PJ *P) {
/***********************************************************************/
struct pj_opaque_helmert *Q = (struct pj_opaque_helmert *) P->opaque;
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
double X, Y, Z, scale;
point.xyz = xyz;
diff --git a/src/PJ_hgridshift.c b/src/PJ_hgridshift.c
index 92275e51..5c2b944d 100644
--- a/src/PJ_hgridshift.c
+++ b/src/PJ_hgridshift.c
@@ -5,7 +5,7 @@
PROJ_HEAD(hgridshift, "Horizontal grid shift");
static XYZ forward_3d(LPZ lpz, PJ *P) {
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.lpz = lpz;
if (P->gridlist != NULL) {
@@ -19,7 +19,7 @@ static XYZ forward_3d(LPZ lpz, PJ *P) {
static LPZ reverse_3d(XYZ xyz, PJ *P) {
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.xyz = xyz;
if (P->gridlist != NULL) {
diff --git a/src/PJ_molodensky.c b/src/PJ_molodensky.c
index 1b0eb3a1..765e1d50 100644
--- a/src/PJ_molodensky.c
+++ b/src/PJ_molodensky.c
@@ -193,7 +193,7 @@ static LPZ calc_abridged_params(LPZ lpz, PJ *P) {
static XY forward_2d(LP lp, PJ *P) {
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.lp = lp;
point.xyz = forward_3d(point.lpz, P);
@@ -203,7 +203,7 @@ static XY forward_2d(LP lp, PJ *P) {
static LP reverse_2d(XY xy, PJ *P) {
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.xy = xy;
point.xyz.z = 0;
@@ -215,7 +215,7 @@ static LP reverse_2d(XY xy, PJ *P) {
static XYZ forward_3d(LPZ lpz, PJ *P) {
struct pj_opaque_molodensky *Q = (struct pj_opaque_molodensky *) P->opaque;
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.lpz = lpz;
@@ -243,7 +243,7 @@ static PJ_COORD forward_4d(PJ_COORD obs, PJ *P) {
static LPZ reverse_3d(XYZ xyz, PJ *P) {
struct pj_opaque_molodensky *Q = (struct pj_opaque_molodensky *) P->opaque;
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
LPZ lpz;
/* calculate parameters depending on the mode we are in */
diff --git a/src/PJ_unitconvert.c b/src/PJ_unitconvert.c
index 523d8897..f951ebb6 100644
--- a/src/PJ_unitconvert.c
+++ b/src/PJ_unitconvert.c
@@ -204,7 +204,7 @@ static XY forward_2d(LP lp, PJ *P) {
Forward unit conversions in the plane
************************************************************************/
struct pj_opaque_unitconvert *Q = (struct pj_opaque_unitconvert *) P->opaque;
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.lp = lp;
point.xy.x *= pj_units[Q->xy_in_id].factor / pj_units[Q->xy_out_id].factor;
@@ -220,7 +220,7 @@ static LP reverse_2d(XY xy, PJ *P) {
Reverse unit conversions in the plane
************************************************************************/
struct pj_opaque_unitconvert *Q = (struct pj_opaque_unitconvert *) P->opaque;
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.xy = xy;
point.xy.x *= pj_units[Q->xy_out_id].factor / pj_units[Q->xy_in_id].factor;
@@ -236,7 +236,7 @@ static XYZ forward_3d(LPZ lpz, PJ *P) {
Forward unit conversions the vertical component
************************************************************************/
struct pj_opaque_unitconvert *Q = (struct pj_opaque_unitconvert *) P->opaque;
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.lpz = lpz;
/* take care of the horizontal components in the 2D function */
@@ -253,7 +253,7 @@ static LPZ reverse_3d(XYZ xyz, PJ *P) {
Reverse unit conversions the vertical component
************************************************************************/
struct pj_opaque_unitconvert *Q = (struct pj_opaque_unitconvert *) P->opaque;
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.xyz = xyz;
/* take care of the horizontal components in the 2D function */
@@ -271,7 +271,7 @@ static PJ_COORD forward_4d(PJ_COORD obs, PJ *P) {
Forward conversion of time units
************************************************************************/
struct pj_opaque_unitconvert *Q = (struct pj_opaque_unitconvert *) P->opaque;
- PJ_COORD out;
+ PJ_COORD out = {{0,0,0,0}};
/* delegate unit conversion of physical dimensions to the 3D function */
out.xyz = forward_3d(obs.lpz, P);
@@ -291,7 +291,7 @@ static PJ_COORD reverse_4d(PJ_COORD obs, PJ *P) {
Reverse conversion of time units
************************************************************************/
struct pj_opaque_unitconvert *Q = (struct pj_opaque_unitconvert *) P->opaque;
- PJ_COORD out;
+ PJ_COORD out = {{0,0,0,0}};
/* delegate unit conversion of physical dimensions to the 3D function */
out.lpz = reverse_3d(obs.xyz, P);
diff --git a/src/PJ_vgridshift.c b/src/PJ_vgridshift.c
index 97faa240..850734fc 100644
--- a/src/PJ_vgridshift.c
+++ b/src/PJ_vgridshift.c
@@ -6,7 +6,7 @@ PROJ_HEAD(vgridshift, "Vertical grid shift");
static XYZ forward_3d(LPZ lpz, PJ *P) {
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.lpz = lpz;
if (P->vgridlist_geoid != NULL) {
@@ -20,7 +20,7 @@ static XYZ forward_3d(LPZ lpz, PJ *P) {
static LPZ reverse_3d(XYZ xyz, PJ *P) {
- PJ_TRIPLET point;
+ PJ_COORD point = {{0,0,0,0}};
point.xyz = xyz;
if (P->vgridlist_geoid != NULL) {
@@ -34,7 +34,7 @@ static LPZ reverse_3d(XYZ xyz, PJ *P) {
static PJ_COORD forward_4d(PJ_COORD obs, PJ *P) {
- PJ_COORD point;
+ PJ_COORD point = {{0,0,0,0}};
point.xyz = forward_3d (obs.lpz, P);
return point;
}
diff --git a/src/gie.c b/src/gie.c
index 9553cbe3..476569a5 100644
--- a/src/gie.c
+++ b/src/gie.c
@@ -1040,7 +1040,6 @@ static int pj_cart_selftest (void) {
PJ_GRID_INFO grid_info;
PJ_INIT_INFO init_info;
- PJ_DERIVS derivs;
PJ_FACTORS factors;
const PJ_OPERATIONS *oper_list;
@@ -1335,25 +1334,14 @@ static int pj_cart_selftest (void) {
a.lp.lam = PJ_TORAD(12);
a.lp.phi = PJ_TORAD(55);
- derivs = proj_derivatives(P, a.lp);
- if (proj_errno(P))
- return 80; /* derivs not created correctly */
-
- if ( fabs(derivs.x_l - 1.0) > 1e-5 ) return 81;
- if ( fabs(derivs.x_p - 0.0) > 1e-5 ) return 82;
- if ( fabs(derivs.y_l - 0.0) > 1e-5 ) return 83;
- if ( fabs(derivs.y_p - 1.73959) > 1e-5 ) return 84;
-
-
factors = proj_factors(P, a.lp);
if (proj_errno(P))
return 85; /* factors not created correctly */
/* check a few key characteristics of the Mercator projection */
- if (factors.omega != 0.0) return 86; /* angular distortion should be 0 */
- if (factors.thetap != M_PI_2) return 87; /* Meridian/parallel angle should be 90 deg */
- if (factors.conv != 0.0) return 88; /* meridian convergence should be 0 */
-
+ if (factors.angular_distortion != 0.0) return 86; /* angular distortion should be 0 */
+ if (factors.meridian_parallel_angle != M_PI_2) return 87; /* Meridian/parallel angle should be 90 deg */
+ if (factors.meridian_convergence != 0.0) return 88; /* meridian convergence should be 0 */
proj_destroy(P);
@@ -1474,8 +1462,8 @@ static int test_time(char* args, double tol, double t_in, double t_exp) {
return ret;
}
-static int test_xyz(char* args, double tol, PJ_TRIPLET in, PJ_TRIPLET exp) {
- PJ_COORD out, obs_in;
+static int test_xyz(char* args, double tol, PJ_COORD in, PJ_COORD exp) {
+ PJ_COORD out = {{0,0,0,0}}, obs_in = {{0,0,0,0}};
PJ *P = proj_create(PJ_DEFAULT_CTX, args);
int ret = 0;
@@ -1517,10 +1505,10 @@ static int pj_unitconvert_selftest (void) {
double in4 = 1877.71428, exp4 = 2016.0;
char args5[] = "+proj=unitconvert +xy_in=m +xy_out=dm +z_in=cm +z_out=mm";
- PJ_TRIPLET in5 = {{55.25, 23.23, 45.5}}, exp5 = {{552.5, 232.3, 455.0}};
+ PJ_COORD in5 = {{55.25, 23.23, 45.5, 0}}, exp5 = {{552.5, 232.3, 455.0, 0}};
char args6[] = "+proj=unitconvert +xy_in=m +xy_out=m +z_in=m +z_out=m";
- PJ_TRIPLET in6 = {{12.3, 45.6, 7.89}};
+ PJ_COORD in6 = {{12.3, 45.6, 7.89, 0}};
ret = test_time(args1, 1e-6, in1, in1); if (ret) return ret + 10;
ret = test_time(args2, 1e-6, in2, in2); if (ret) return ret + 20;
diff --git a/src/pj_deriv.c b/src/pj_deriv.c
index 1c969a9d..7c1fcded 100644
--- a/src/pj_deriv.c
+++ b/src/pj_deriv.c
@@ -2,8 +2,12 @@
#define PJ_LIB__
#include "projects.h"
-int pj_deriv(LP lp, double h, PJ *P, struct DERIVS *der) {
+int pj_deriv(LP lp, double h, const PJ *P, struct DERIVS *der) {
XY t;
+ /* get rid of constness until we can do it for real */
+ PJ *Q = (PJ *) P;
+ if (0==Q->fwd)
+ return 1;
lp.lam += h;
lp.phi += h;
@@ -11,7 +15,7 @@ int pj_deriv(LP lp, double h, PJ *P, struct DERIVS *der) {
return 1;
h += h;
- t = (*P->fwd)(lp, P);
+ t = (*Q->fwd)(lp, Q);
if (t.x == HUGE_VAL)
return 1;
@@ -19,11 +23,12 @@ int pj_deriv(LP lp, double h, PJ *P, struct DERIVS *der) {
der->y_p = t.y;
der->x_p = t.x;
der->y_l = t.y;
+
lp.phi -= h;
if (fabs(lp.phi) > M_HALFPI)
return 1;
- t = (*P->fwd)(lp, P);
+ t = (*Q->fwd)(lp, Q);
if (t.x == HUGE_VAL)
return 1;
@@ -31,8 +36,9 @@ int pj_deriv(LP lp, double h, PJ *P, struct DERIVS *der) {
der->y_p -= t.y;
der->x_p -= t.x;
der->y_l += t.y;
+
lp.lam -= h;
- t = (*P->fwd)(lp, P);
+ t = (*Q->fwd)(lp, Q);
if (t.x == HUGE_VAL)
return 1;
@@ -40,8 +46,9 @@ int pj_deriv(LP lp, double h, PJ *P, struct DERIVS *der) {
der->y_p -= t.y;
der->x_p -= t.x;
der->y_l -= t.y;
+
lp.phi += h;
- t = (*P->fwd)(lp, P);
+ t = (*Q->fwd)(lp, Q);
if (t.x == HUGE_VAL)
return 1;
@@ -49,7 +56,9 @@ int pj_deriv(LP lp, double h, PJ *P, struct DERIVS *der) {
der->y_p += t.y;
der->x_p += t.x;
der->y_l -= t.y;
- der->x_l /= (h += h);
+
+ h += h;
+ der->x_l /= h;
der->y_p /= h;
der->x_p /= h;
der->y_l /= h;
diff --git a/src/pj_factors.c b/src/pj_factors.c
index 3c2e97cb..31c0e539 100644
--- a/src/pj_factors.c
+++ b/src/pj_factors.c
@@ -11,7 +11,7 @@
#define EPS 1.0e-12
-int pj_factors(LP lp, PJ *P, double h, struct FACTORS *fac) {
+int pj_factors(LP lp, const PJ *P, double h, struct FACTORS *fac) {
double cosphi, t, n, r;
int err;
PJ_COORD coo = {{0, 0, 0, 0}};
diff --git a/src/proj.def b/src/proj.def
index d5faae91..887f4719 100644
--- a/src/proj.def
+++ b/src/proj.def
@@ -137,16 +137,15 @@ EXPORTS
proj_rtodms @125
proj_dmstor @126
- proj_derivatives @127
- proj_factors @128
+ proj_factors @127
- proj_list_operations @129
- proj_list_ellps @130
- proj_list_units @131
- proj_list_prime_meridians @132
+ proj_list_operations @128
+ proj_list_ellps @129
+ proj_list_units @130
+ proj_list_prime_meridians @131
- proj_angular_input @133
- proj_angular_output @134
+ proj_angular_input @132
+ proj_angular_output @133
- pj_ellipsoid @135
- pj_calc_ellipsoid_params @136
+ pj_ellipsoid @134
+ pj_calc_ellipsoid_params @135
diff --git a/src/proj.h b/src/proj.h
index f4640e15..aa87ae7d 100644
--- a/src/proj.h
+++ b/src/proj.h
@@ -144,10 +144,6 @@ extern char const pj_release[]; /* global release id string */
/* first forward declare everything needed */
-/* Data type for generic geodetic 3D data */
-union PJ_TRIPLET;
-typedef union PJ_TRIPLET PJ_TRIPLET;
-
/* Data type for generic geodetic 3D data plus epoch information */
union PJ_COORD;
typedef union PJ_COORD PJ_COORD;
@@ -155,11 +151,24 @@ typedef union PJ_COORD PJ_COORD;
struct PJ_AREA;
typedef struct PJ_AREA PJ_AREA;
-struct DERIVS;
-typedef struct DERIVS PJ_DERIVS;
-
-struct FACTORS;
-typedef struct FACTORS PJ_FACTORS;
+/* The slimmed down PROJ 5.0.0 version of struct FACTORS */
+/* Will take over the world and the name when we can rid */
+/* the library for deprecated stuff, but it's the typedef */
+/* which is userspace useful, so it does not do much of a */
+/* difference */
+struct P5_FACTORS { /* Common designation */
+ double meridional_scale; /* h */
+ double parallel_scale; /* k */
+ double areal_scale; /* s */
+
+ double angular_distortion; /* omega */
+ double meridian_parallel_angle; /* theta-prime */
+ double meridian_convergence; /* alpha */
+
+ double tissot_semimajor; /* a */
+ double tissot_semiminor; /* b */
+};
+typedef struct P5_FACTORS PJ_FACTORS;
/* Data type for projection/transformation information */
struct PJconsts;
@@ -192,17 +201,11 @@ struct PJ_PRIME_MERIDIANS;
typedef struct PJ_PRIME_MERIDIANS PJ_PRIME_MERIDIANS;
-/* Omega, Phi, Kappa: Rotations */
-typedef struct {double o, p, k;} PJ_OPK;
-
-/* Easting, Northing, and some kind of height (orthometric or ellipsoidal) */
-typedef struct {double e, n, h;} PJ_ENH;
-
-/* Geodetic spatiotemporal coordinate types */
+/* Geodetic, mostly spatiotemporal coordinate types */
typedef struct { double x, y, z, t; } PJ_XYZT;
-typedef struct { double e, n, h, t; } PJ_ENHT;
typedef struct { double u, v, w, t; } PJ_UVWT;
typedef struct { double lam, phi, z, t; } PJ_LPZT;
+typedef struct { double o, p, k; } PJ_OPK; /* Rotations: omega, phi, kappa */
/* Classic proj.4 pair/triplet types */
typedef struct { double u, v; } UV;
@@ -213,60 +216,22 @@ typedef struct { double x, y, z; } XYZ;
typedef struct { double u, v, w; } UVW;
typedef struct { double lam, phi, z; } LPZ;
-/* Ancillary pairs and triplets for geodetic computations */
-
-/* easting and northing */
-typedef struct { double e, n; } PJ_EN;
-
-/* Degrees, minutes, and seconds */
-typedef struct { double d, m, s; } PJ_DMS;
-
-/* Geoid undulation (N) and deflections of the vertical (eta, zeta) */
-typedef struct { double e, z, N; } PJ_EZN;
-
-/* Ellipsoidal parameters */
-typedef struct { double a, f; } PJ_AF;
-/* Avoid preprocessor renaming and implicit type-punning: Use unions to make it explicit */
+/* Avoid preprocessor renaming and implicit type-punning: Use a union to make it explicit */
union PJ_COORD {
+ double v[4]; /* First and foremost, it really is "just 4 numbers in a vector" */
PJ_XYZT xyzt;
PJ_UVWT uvwt;
- PJ_ENHT enht;
PJ_LPZT lpzt;
- PJ_ENH enh;
- PJ_EN en;
- double v[4]; /* It's just a vector */
- XYZ xyz;
- UVW uvw;
- LPZ lpz;
- XY xy;
- UV uv;
- LP lp;
+ PJ_OPK opk;
+ XYZ xyz;
+ UVW uvw;
+ LPZ lpz;
+ XY xy;
+ UV uv;
+ LP lp;
};
-union PJ_TRIPLET {
- PJ_OPK opk;
- PJ_ENH enh;
- PJ_EZN ezn;
- PJ_DMS dms;
- double v[3]; /* It's just a vector */
- XYZ xyz;
- LPZ lpz;
- UVW uvw;
- XY xy;
- LP lp;
- UV uv;
- PJ_AF af;
-};
-
-union PJ_PAIR {
- XY xy;
- LP lp;
- UV uv;
- PJ_AF af;
- PJ_EN en;
- double v[2]; /* Yes - It's really just a vector! */
-};
struct PJ_INFO {
char release[64]; /* Release info. Version + date */
@@ -320,7 +285,6 @@ PJ_CONTEXT *proj_context_create (void);
PJ_CONTEXT *proj_context_destroy (PJ_CONTEXT *ctx);
-
/* Manage the transformation definition object PJ */
PJ *proj_create (PJ_CONTEXT *ctx, const char *definition);
PJ *proj_create_argv (PJ_CONTEXT *ctx, int argc, char **argv);
@@ -342,8 +306,6 @@ enum PJ_DIRECTION {
typedef enum PJ_DIRECTION PJ_DIRECTION;
-
-
int proj_angular_input (PJ *P, enum PJ_DIRECTION dir);
int proj_angular_output (PJ *P, enum PJ_DIRECTION dir);
@@ -360,7 +322,6 @@ size_t proj_trans_generic (
);
-
/* Initializers */
PJ_COORD proj_coord (double x, double y, double z, double t);
@@ -381,14 +342,13 @@ double proj_xyz_dist (XYZ a, XYZ b);
/* Set or read error level */
-int proj_errno (PJ *P);
-int proj_errno_set (PJ *P, int err);
-int proj_errno_reset (PJ *P);
-int proj_errno_restore (PJ *P, int err);
-
+int proj_errno (const PJ *P);
+int proj_errno_set (const PJ *P, int err);
+int proj_errno_reset (const PJ *P);
+int proj_errno_restore (const PJ *P, int err);
-PJ_DERIVS proj_derivatives(PJ *P, const LP lp);
-PJ_FACTORS proj_factors(PJ *P, const LP lp);
+/* Scaling and angular distortion factors */
+PJ_FACTORS proj_factors(PJ *P, LP lp);
/* Info functions - get information about various PROJ.4 entities */
PJ_INFO proj_info(void);
diff --git a/src/proj_4D_api.c b/src/proj_4D_api.c
index 4f044101..9a576997 100644
--- a/src/proj_4D_api.c
+++ b/src/proj_4D_api.c
@@ -515,12 +515,12 @@ PJ *proj_destroy (PJ *P) {
return 0;
}
-int proj_errno (PJ *P) {
- return pj_ctx_get_errno (pj_get_ctx (P));
+int proj_errno (const PJ *P) {
+ return pj_ctx_get_errno (pj_get_ctx ((PJ *) P));
}
/*****************************************************************************/
-int proj_errno_set (PJ *P, int err) {
+int proj_errno_set (const PJ *P, int err) {
/******************************************************************************
Set context-errno, bubble it up to the thread local errno, return err
******************************************************************************/
@@ -529,13 +529,13 @@ int proj_errno_set (PJ *P, int err) {
return 0;
/* For P==0 err goes to the default context */
- proj_context_errno_set (pj_get_ctx (P), err);
+ proj_context_errno_set (pj_get_ctx ((PJ *) P), err);
errno = err;
return err;
}
/*****************************************************************************/
-int proj_errno_restore (PJ *P, int err) {
+int proj_errno_restore (const PJ *P, int err) {
/******************************************************************************
Use proj_errno_restore when the current function succeeds, but the
error flag was set on entry, and stored/reset using proj_errno_reset
@@ -550,7 +550,7 @@ int proj_errno_restore (PJ *P, int err) {
}
/*****************************************************************************/
-int proj_errno_reset (PJ *P) {
+int proj_errno_reset (const PJ *P) {
/******************************************************************************
Clears errno in the context and thread local levels
through the low level pj_ctx interface.
@@ -581,7 +581,7 @@ int proj_errno_reset (PJ *P) {
int last_errno;
last_errno = proj_errno (P);
- pj_ctx_set_errno (pj_get_ctx (P), 0);
+ pj_ctx_set_errno (pj_get_ctx ((PJ *) P), 0);
errno = 0;
return last_errno;
}
@@ -826,28 +826,9 @@ PJ_INIT_INFO proj_init_info(const char *initname){
}
-/*****************************************************************************/
-PJ_DERIVS proj_derivatives(PJ *P, const LP lp) {
-/******************************************************************************
- Derivatives of coordinates.
-
- returns PJ_DERIVS. If unsuccessfull error number is set and the returned
- struct contains NULL data.
-
-******************************************************************************/
- PJ_DERIVS derivs;
-
- if (pj_deriv(lp, 1e-5, P, &derivs)) {
- /* errno set in pj_derivs */
- memset(&derivs, 0, sizeof(PJ_DERIVS));
- }
-
- return derivs;
-}
-
/*****************************************************************************/
-PJ_FACTORS proj_factors(PJ *P, const LP lp) {
+PJ_FACTORS proj_factors(PJ *P, LP lp) {
/******************************************************************************
Cartographic characteristics at point lp.
@@ -858,12 +839,22 @@ PJ_FACTORS proj_factors(PJ *P, const LP lp) {
struct contains NULL data.
******************************************************************************/
- PJ_FACTORS factors;
+ PJ_FACTORS factors = {0,0,0, 0,0,0, 0,0};
+ struct FACTORS f;
- if (pj_factors(lp, P, 0.0, &factors)) {
- /* errno set in pj_factors */
- memset(&factors, 0, sizeof(PJ_FACTORS));
- }
+ if (pj_factors(lp, P, 0.0, &f))
+ return factors;
+
+ factors.meridional_scale = f.h;
+ factors.parallel_scale = f.k;
+ factors.areal_scale = f.s;
+
+ factors.angular_distortion = f.omega;
+ factors.meridian_parallel_angle = f.thetap;
+ factors.meridian_convergence = f.conv;
+
+ factors.tissot_semimajor = f.a;
+ factors.tissot_semiminor = f.b;
return factors;
}
diff --git a/src/projects.h b/src/projects.h
index 91c0e6a3..99df0e3e 100644
--- a/src/projects.h
+++ b/src/projects.h
@@ -178,7 +178,6 @@ union PJ_COORD;
struct geod_geodesic;
struct pj_opaque;
struct ARG_list;
-struct FACTORS;
struct PJ_REGION_S;
typedef struct PJ_REGION_S PJ_Region;
typedef struct ARG_list paralist; /* parameter list */
@@ -704,8 +703,8 @@ double pj_authlat(double, double *);
COMPLEX pj_zpoly1(COMPLEX, COMPLEX *, int);
COMPLEX pj_zpolyd1(COMPLEX, COMPLEX *, int, COMPLEX *);
-int pj_deriv(LP, double, PJ *, struct DERIVS *);
-int pj_factors(LP, PJ *, double, struct FACTORS *);
+int pj_deriv(LP, double, const PJ *, struct DERIVS *);
+int pj_factors(LP, const PJ *, double, struct FACTORS *);
struct PW_COEF { /* row coefficient structure */
int m; /* number of c coefficients (=0 for none) */