aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Knudsen <busstoptaktik@users.noreply.github.com>2017-10-25 10:39:56 +0200
committerGitHub <noreply@github.com>2017-10-25 10:39:56 +0200
commita3fa749bc4f378d005c9e3fd809c0be25de5ffb2 (patch)
treedadf4aa7d1bf3e88478375f2d6d4e3d72eb60549 /src
parent2ad201bdb0f3408eed0aab07fe255c6ff1cd3249 (diff)
downloadPROJ-a3fa749bc4f378d005c9e3fd809c0be25de5ffb2.tar.gz
PROJ-a3fa749bc4f378d005c9e3fd809c0be25de5ffb2.zip
Remove PJ_OBS from the API surface, rename pj_obs_api.c to pj_4D_api.c (#625)
* Remove PJ_OBS from the API surface, rename pj_obs_api.c to pj_4D_api.c * Repair proj.def
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/PJ_cart.c10
-rw-r--r--src/PJ_helmert.c4
-rw-r--r--src/PJ_latlong.c3
-rw-r--r--src/lib_proj.cmake2
-rw-r--r--src/makefile.vc2
-rw-r--r--src/pj_internal.c55
-rw-r--r--src/proj.def75
-rw-r--r--src/proj.h19
-rw-r--r--src/proj_4D_api.c (renamed from src/pj_obs_api.c)74
-rw-r--r--src/proj_internal.h9
-rw-r--r--src/projects.h6
12 files changed, 115 insertions, 146 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index a039151d..363f2cce 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -85,7 +85,7 @@ libproj_la_SOURCES = \
jniproj.c pj_mutex.c pj_initcache.c pj_apply_vgridshift.c geodesic.c \
pj_strtod.c \
\
- pj_obs_api.c PJ_cart.c PJ_pipeline.c PJ_horner.c PJ_helmert.c \
+ proj_4D_api.c PJ_cart.c PJ_pipeline.c PJ_horner.c PJ_helmert.c \
PJ_vgridshift.c PJ_hgridshift.c PJ_unitconvert.c PJ_molodensky.c \
pj_internal.c
diff --git a/src/PJ_cart.c b/src/PJ_cart.c
index 37aa3b97..99e1af7d 100644
--- a/src/PJ_cart.c
+++ b/src/PJ_cart.c
@@ -387,10 +387,10 @@ int pj_cart_selftest (void) {
b = proj_trans_obs (P, PJ_FWD, obs[1]);
n = proj_transform (
- P, PJ_FWD,
+ P, PJ_FWD,
&(obs[0].coo.lpz.lam), sz, 2,
&(obs[0].coo.lpz.phi), sz, 2,
- &(obs[0].coo.lpz.z), sz, 2,
+ &(obs[0].coo.lpz.z), sz, 2,
0, sz, 0
);
if (2!=n)
@@ -408,10 +408,10 @@ int pj_cart_selftest (void) {
h = 27;
t = 33;
n = proj_transform (
- P, PJ_FWD,
+ P, PJ_FWD,
&(obs[0].coo.lpz.lam), sz, 2,
&(obs[0].coo.lpz.phi), sz, 2,
- &h, 0, 1,
+ &h, 0, 1,
&t, 0, 1
);
if (2!=n)
@@ -429,7 +429,7 @@ int pj_cart_selftest (void) {
obs[0].coo = proj_coord (PJ_TORAD(12), PJ_TORAD(55), 45, 0);
obs[1].coo = proj_coord (PJ_TORAD(12), PJ_TORAD(56), 50, 0);
- if (proj_transform_obs(P, PJ_FWD, 2, obs))
+ if (proj_transform_coord(P, PJ_FWD, 2, (PJ_COORD *) obs))
return 30;
if (a.coo.lpz.lam != obs[0].coo.lpz.lam) return 31;
diff --git a/src/PJ_helmert.c b/src/PJ_helmert.c
index ffbdd01a..503dc392 100644
--- a/src/PJ_helmert.c
+++ b/src/PJ_helmert.c
@@ -668,11 +668,11 @@ int pj_helmert_selftest (void) {
matrix is updated when necessary. Test coordinates from GNSStrans. */
XYZ expect4a = {3370658.18890, 711877.42370, 5349787.12430};
XYZ expect4b = {3370658.18087, 711877.42750, 5349787.12648};
- PJ_OBS in4 = {{{3370658.378, 711877.314, 5349787.086, 2017.0}}, {{ 0, 0, 0}}, 0, 0};
+ PJ_OBS in4 = {{{3370658.378, 711877.314, 5349787.086, 2017.0}}};
PJ_OBS out;
PJ *helmert = proj_create(
- 0,
+ 0,
" +proj=helmert +ellps=GRS80"
" +x=0.0127 +y=0.0065 +z=-0.0209 +s=0.00195"
" +rx=-0.00039 +ry=0.00080 +rz=-0.00114"
diff --git a/src/PJ_latlong.c b/src/PJ_latlong.c
index 1677142a..7ee41e2a 100644
--- a/src/PJ_latlong.c
+++ b/src/PJ_latlong.c
@@ -1,6 +1,6 @@
/******************************************************************************
* Project: PROJ.4
- * Purpose: Stub projection implementation for lat/long coordinates. We
+ * Purpose: Stub projection implementation for lat/long coordinates. We
* don't actually change the coordinates, but we want proj=latlong
* to act sort of like a projection.
* Author: Frank Warmerdam, warmerdam@pobox.com
@@ -29,6 +29,7 @@
/* very loosely based upon DMA code by Bradford W. Drew */
#define PJ_LIB__
+#include "proj_internal.h"
#include <proj.h>
#include "projects.h"
diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake
index 1be10362..053e9ef6 100644
--- a/src/lib_proj.cmake
+++ b/src/lib_proj.cmake
@@ -201,7 +201,7 @@ SET(SRC_LIBPROJ_CORE
pj_mlfn.c
pj_msfn.c
pj_mutex.c
- pj_obs_api.c
+ proj_4D_api.c
pj_internal.c
proj_internal.h
pj_open_lib.c
diff --git a/src/makefile.vc b/src/makefile.vc
index fdf03bd3..1330e9bb 100644
--- a/src/makefile.vc
+++ b/src/makefile.vc
@@ -60,7 +60,7 @@ support = \
pj_internal.obj
pipeline = \
- pj_obs_api.obj PJ_cart.obj PJ_pipeline.obj PJ_horner.obj PJ_helmert.obj \
+ proj_4D_api.obj PJ_cart.obj PJ_pipeline.obj PJ_horner.obj PJ_helmert.obj \
PJ_vgridshift.obj PJ_hgridshift.obj PJ_unitconvert.obj PJ_molodensky.obj
geodesic = geodesic.obj
diff --git a/src/pj_internal.c b/src/pj_internal.c
index 31c299ac..5eb98afb 100644
--- a/src/pj_internal.c
+++ b/src/pj_internal.c
@@ -1,8 +1,9 @@
/******************************************************************************
* Project: PROJ.4
- * Purpose: This is primarily material originating from pj_obs_api.c,
- * that does not fit into the API category. Hence this pile of
- * tubings and fittings for PROJ.4 internal plumbing.
+ * Purpose: This is primarily material originating from pj_obs_api.c
+ * (now proj_4D_api.c), that does not fit into the API
+ * category. Hence this pile of tubings and fittings for
+ * PROJ.4 internal plumbing.
*
* Author: Thomas Knudsen, thokn@sdfe.dk, 2017-07-05
*
@@ -42,12 +43,52 @@
/* Used for zero-initializing new objects */
const PJ_COORD proj_coord_null = {{0, 0, 0, 0}};
const PJ_OBS proj_obs_null = {
- {{0, 0, 0, 0}},
- {{0, 0, 0}},
- 0, 0
+ {{0, 0, 0, 0}}
};
+
+/* Initialize PJ_OBS struct */
+PJ_OBS proj_obs (double x, double y, double z, double t) {
+ PJ_OBS res;
+ res.coo = proj_coord (x, y, z, t);
+ return res;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* Apply the transformation P to the coordinate coo */
+PJ_OBS proj_trans_obs (PJ *P, PJ_DIRECTION direction, PJ_OBS obs) {
+ if (0==P)
+ return obs;
+
+ switch (direction) {
+ case PJ_FWD:
+ return pj_fwdobs (obs, P);
+ case PJ_INV:
+ return pj_invobs (obs, P);
+ case PJ_IDENT:
+ return obs;
+ default:
+ break;
+ }
+
+ proj_errno_set (P, EINVAL);
+ return proj_obs_error ();
+}
+
+
/* Work around non-constness of MSVC HUGE_VAL by providing functions rather than constants */
PJ_COORD proj_coord_error (void) {
PJ_COORD c;
@@ -58,8 +99,6 @@ PJ_COORD proj_coord_error (void) {
PJ_OBS proj_obs_error (void) {
PJ_OBS obs;
obs.coo = proj_coord_error ();
- obs.anc.v[0] = obs.anc.v[1] = obs.anc.v[2] = HUGE_VAL;
- obs.id = obs.flags = 0;
return obs;
}
diff --git a/src/proj.def b/src/proj.def
index 598f2824..86deb24d 100644
--- a/src/proj.def
+++ b/src/proj.def
@@ -100,50 +100,49 @@ EXPORTS
proj_trans_obs @95
proj_trans_coord @96
proj_transform @97
- proj_transform_obs @98
- proj_transform_coord @99
- proj_roundtrip @100
+ proj_transform_coord @98
+ proj_roundtrip @99
- proj_coord @101
- proj_obs @102
- proj_coord_error @103
- proj_obs_error @104
+ proj_coord @100
+ proj_obs @101
+ proj_coord_error @102
+ proj_obs_error @103
- proj_errno @105
- proj_errno_set @106
- proj_errno_reset @107
- proj_errno_restore @108
- proj_context_errno_set @109
+ proj_errno @104
+ proj_errno_set @105
+ proj_errno_reset @106
+ proj_errno_restore @107
+ proj_context_errno_set @108
- proj_context_create @110
- proj_context_set @111
- proj_context_inherit @112
- proj_context_destroy @113
+ proj_context_create @109
+ proj_context_set @110
+ proj_context_inherit @111
+ proj_context_destroy @112
- proj_lp_dist @114
- proj_xy_dist @115
- proj_xyz_dist @116
+ proj_lp_dist @113
+ proj_xy_dist @114
+ proj_xyz_dist @115
- proj_log_level @117
- proj_log_func @118
- proj_log_error @119
- proj_log_debug @120
- proj_log_trace @121
+ proj_log_level @116
+ proj_log_func @117
+ proj_log_error @118
+ proj_log_debug @119
+ proj_log_trace @120
- proj_info @122
- proj_pj_info @123
- proj_grid_info @124
- proj_init_info @125
+ proj_info @121
+ proj_pj_info @122
+ proj_grid_info @123
+ proj_init_info @124
- proj_torad @126
- proj_todeg @127
- proj_rtodms @128
- proj_dmstor @129
+ proj_torad @125
+ proj_todeg @126
+ proj_rtodms @127
+ proj_dmstor @128
- proj_derivatives @130
- proj_factors @131
+ proj_derivatives @129
+ proj_factors @130
- proj_list_operations @132
- proj_list_ellps @133
- proj_list_units @134
- proj_list_prime_meridians @135
+ proj_list_operations @131
+ proj_list_ellps @132
+ proj_list_units @133
+ proj_list_prime_meridians @134
diff --git a/src/proj.h b/src/proj.h
index aa9f3b17..ed885091 100644
--- a/src/proj.h
+++ b/src/proj.h
@@ -90,7 +90,7 @@
* compatible call proj_context_create(0), which will not create
* a new context, but simply provide a pointer to the default one.
*
- * See pj_obs_api_test.c for an example of how to use the API.
+ * See proj_4D_api_test.c for examples of how to use the API.
*
* Author: Thomas Knudsen, <thokn@sdfe.dk>
* Benefitting from a large number of comments and suggestions
@@ -170,10 +170,6 @@ extern char const pj_release[]; /* global release id string */
/* first forward declare everything needed */
-/* Data type for generic geodetic observations */
-struct PJ_OBS;
-typedef struct PJ_OBS PJ_OBS;
-
/* Data type for generic geodetic 3D data */
union PJ_TRIPLET;
typedef union PJ_TRIPLET PJ_TRIPLET;
@@ -299,14 +295,6 @@ union PJ_PAIR {
};
-struct PJ_OBS {
- PJ_COORD coo; /* coordinate data */
- PJ_TRIPLET anc; /* ancillary data */
- int id; /* integer ancillary data - e.g. observation number, EPSG code... */
- unsigned int flags; /* additional data, intended for flags */
-};
-
-
#define PJ_IS_ANAL_XL_YL 01 /* derivatives of lon analytic */
#define PJ_IS_ANAL_XP_YP 02 /* derivatives of lat analytic */
#define PJ_IS_ANAL_HK 04 /* h and k analytic */
@@ -385,7 +373,6 @@ enum PJ_DIRECTION {
};
typedef enum PJ_DIRECTION PJ_DIRECTION;
-PJ_OBS proj_trans_obs (PJ *P, PJ_DIRECTION direction, PJ_OBS obs);
PJ_COORD proj_trans_coord (PJ *P, PJ_DIRECTION direction, PJ_COORD coord);
@@ -398,16 +385,14 @@ size_t proj_transform (
double *t, size_t st, size_t nt
);
-int proj_transform_obs (PJ *P, PJ_DIRECTION direction, size_t n, PJ_OBS *obs);
int proj_transform_coord (PJ *P, PJ_DIRECTION direction, size_t n, PJ_COORD *coord);
/* Initializers */
PJ_COORD proj_coord (double x, double y, double z, double t);
-PJ_OBS proj_obs (double x, double y, double z, double t, double o, double p, double k, int id, unsigned int flags);
/* Measure internal consistency - in forward or inverse direction */
double proj_roundtrip (PJ *P, PJ_DIRECTION direction, int n, PJ_COORD coo);
-
+
/* Geodesic distance between two points with angular 2D coordinates */
double proj_lp_dist (const PJ *P, LP a, LP b);
diff --git a/src/pj_obs_api.c b/src/proj_4D_api.c
index 55da9fa2..b1aa3883 100644
--- a/src/pj_obs_api.c
+++ b/src/proj_4D_api.c
@@ -1,7 +1,7 @@
/******************************************************************************
* Project: PROJ.4
* Purpose: Implement a (currently minimalistic) proj API based primarily
- * on the PJ_OBS generic geodetic data type.
+ * on the PJ_COORD 4D geodetic spatiotemporal data type.
*
* proj thread contexts have not seen widespread use, so one of the
* intentions with this new API is to make them less visible on the
@@ -12,7 +12,7 @@
* Author: Thomas Knudsen, thokn@sdfe.dk, 2016-06-09/2016-11-06
*
******************************************************************************
- * Copyright (c) 2016, 2017 Thomas Knudsen/SDFE
+ * Copyright (c) 2016, 2017 Thomas Knudsen/SDFE
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -32,7 +32,6 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
-#define PJ_OBS_API_C
#include <proj.h>
#include "proj_internal.h"
#include "projects.h"
@@ -51,22 +50,6 @@ PJ_COORD proj_coord (double x, double y, double z, double t) {
return res;
}
-/* Initialize PJ_OBS struct */
-PJ_OBS proj_obs (double x, double y, double z, double t, double o, double p, double k, int id, unsigned int flags) {
- PJ_OBS res;
- res.coo.v[0] = x;
- res.coo.v[1] = y;
- res.coo.v[2] = z;
- res.coo.v[3] = t;
- res.anc.v[0] = o;
- res.anc.v[1] = p;
- res.anc.v[2] = k;
- res.id = id;
- res.flags = flags;
-
- return res;
-}
-
/* Geodesic distance (in meter) between two points with angular 2D coordinates */
@@ -127,40 +110,8 @@ double proj_roundtrip (PJ *P, PJ_DIRECTION direction, int n, PJ_COORD coo) {
unit = direction==PJ_FWD? P->left: P->right;
if (unit==PJ_IO_UNITS_RADIANS)
return hypot (proj_lp_dist (P, coo.lp, o.lp), coo.lpz.z - o.lpz.z);
-
- return proj_xyz_dist (coo.xyz, coo.xyz);
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-/* Apply the transformation P to the coordinate coo */
-PJ_OBS proj_trans_obs (PJ *P, PJ_DIRECTION direction, PJ_OBS obs) {
- if (0==P)
- return obs;
-
- switch (direction) {
- case PJ_FWD:
- return pj_fwdobs (obs, P);
- case PJ_INV:
- return pj_invobs (obs, P);
- case PJ_IDENT:
- return obs;
- default:
- break;
- }
- proj_errno_set (P, EINVAL);
- return proj_obs_error ();
+ return proj_xyz_dist (coo.xyz, coo.xyz);
}
@@ -338,24 +289,6 @@ size_t proj_transform (
}
/*****************************************************************************/
-int proj_transform_obs (PJ *P, PJ_DIRECTION direction, size_t n, PJ_OBS *obs) {
-/******************************************************************************
- Batch transform an array of PJ_OBS.
-
- Returns 0 if all observations are transformed without error, otherwise
- returns error number.
-******************************************************************************/
- size_t i;
- for (i=0; i<n; i++) {
- obs[i] = proj_trans_obs(P, direction, obs[i]);
- if (proj_errno(P))
- return proj_errno(P);
- }
-
- return 0;
-}
-
-/*****************************************************************************/
int proj_transform_coord (PJ *P, PJ_DIRECTION direction, size_t n, PJ_COORD *coord) {
/******************************************************************************
Batch transform an array of PJ_COORD.
@@ -387,6 +320,7 @@ PJ *proj_create_argv (PJ_CONTEXT *ctx, int argc, char **argv) {
return pj_init_ctx (ctx, argc, argv);
}
+
/*****************************************************************************/
PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *srid_from, const char *srid_to, PJ_AREA *area) {
/******************************************************************************
diff --git a/src/proj_internal.h b/src/proj_internal.h
index 0b74b563..5773637c 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -50,6 +50,12 @@ extern "C" {
+struct PJ_OBS {
+ PJ_COORD coo; /* coordinate data */
+};
+typedef struct PJ_OBS PJ_OBS;
+
+
#ifndef PJ_TODEG
#define PJ_TODEG(rad) ((rad)*180.0/M_PI)
#endif
@@ -59,6 +65,9 @@ extern "C" {
+PJ_OBS proj_obs (double x, double y, double z, double t);
+PJ_OBS proj_trans_obs (PJ *P, PJ_DIRECTION direction, PJ_OBS obs);
+
PJ_COORD proj_coord_error (void);
PJ_OBS proj_obs_error (void);
#ifndef PJ_INTERNAL_C
diff --git a/src/projects.h b/src/projects.h
index cbb980ca..b9d88cf3 100644
--- a/src/projects.h
+++ b/src/projects.h
@@ -174,6 +174,9 @@ typedef struct { double u, v, w; } UVW;
/* Forward declarations and typedefs for stuff needed inside the PJ object */
struct PJconsts;
struct PJ_OBS;
+#ifndef PROJ_INTERNAL_H
+typedef struct PJ_OBS PJ_OBS;
+#endif
union PJ_COORD;
struct geod_geodesic;
struct pj_opaque;
@@ -189,7 +192,6 @@ enum pj_io_units {
};
#ifndef PROJ_H
typedef struct PJconsts PJ; /* the PJ object herself */
-typedef struct PJ_OBS PJ_OBS;
typedef union PJ_COORD PJ_COORD;
#endif
@@ -259,7 +261,7 @@ struct PJconsts {
void (*spc)(LP, PJ *, struct FACTORS *);
void *(*destructor)(PJ *, int);
-
+
/*************************************************************************************