diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/PJ_cart.c | 23 | ||||
| -rw-r--r-- | src/pj_obs_api.c | 31 | ||||
| -rw-r--r-- | src/proj.def | 62 | ||||
| -rw-r--r-- | src/proj.h | 1 |
4 files changed, 85 insertions, 32 deletions
diff --git a/src/PJ_cart.c b/src/PJ_cart.c index 26acac2d..9155dd03 100644 --- a/src/PJ_cart.c +++ b/src/PJ_cart.c @@ -422,6 +422,29 @@ int pj_cart_selftest (void) { /* Clean up */ proj_destroy (P); + + /* test proj_create_crs_to_crs() */ + P = proj_create_crs_to_crs(0, "epsg:25832", "epsg:25833"); + if (P==0) + return 30; + + a.coo.xy.x = 700000.0; + a.coo.xy.y = 6000000.0; + b.coo.xy.x = 307788.8761171057; + b.coo.xy.y = 5999669.3036037628; + + a = proj_trans_obs(P, PJ_FWD, a); + if (dist > 1e-7) + return 31; + proj_destroy(P); + + /* let's make sure that only entries in init-files results in a usable PJ */ + P = proj_create_crs_to_crs(0, "proj=utm +zone=32 +datum=WGS84", "proj=utm +zone=33 +datum=WGS84"); + if (P != 0) { + proj_destroy(P); + return 32; + } + return 0; } #endif diff --git a/src/pj_obs_api.c b/src/pj_obs_api.c index d8395b0f..e52d9c1c 100644 --- a/src/pj_obs_api.c +++ b/src/pj_obs_api.c @@ -314,6 +314,36 @@ 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) { +/****************************************************************************** + Create a transformation pipeline between two known coordinate reference + systems. + + srid_from and srid_to should be the value part of a +init=... parameter + set, i.e. "epsg:25833" or "IGNF:AMST63". Any projection definition that is + can be found in a init-file in PROJ_LIB is a valid input to this function. + + For now the function mimics the cs2cs app: An input and an output CRS is + given and coordinates are transformed via a hub datum (WGS84). This + transformation strategy is referred to as "early-binding" by the EPSG. The + function can be extended to support "late-binding" transformations in the + future without affecting users of the function. + + Example call: + + PJ *P = proj_create_crs_to_crs(0, "epsg:25832", "epsg:25833"); + +******************************************************************************/ + PJ *P; + char buffer[256]; + + sprintf(buffer, "+proj=pipeline +step +init=%s +inv +step +init=%s", srid_from, srid_to); + P = proj_create(ctx, buffer); + + return P; +} + PJ *proj_destroy (PJ *P) { pj_free (P); return 0; @@ -447,4 +477,3 @@ double proj_todeg (double angle_in_radians) { return PJ_TODEG (angle_in_radians) int proj_transform_obs (PJ *P, enum proj_direction direction, size_t n, PJ_OBS *obs); int proj_transform_coord (PJ *P, enum proj_direction direction, size_t n, PJ_COORD *coord); PJ_OBS proj_obs (double x, double y, double z, double t, double o, double p, double k, int id, unsigned int flags); -PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *def_from, const char *def_to); diff --git a/src/proj.def b/src/proj.def index 314c4385..c8f8be10 100644 --- a/src/proj.def +++ b/src/proj.def @@ -92,42 +92,42 @@ EXPORTS proj_create @90 proj_create_argv @91 - proj_destroy @92 + proj_create_crs_to_crs @92 + proj_destroy @93 - proj_trans_obs @93 - proj_trans_coord @94 - proj_transform @95 - proj_roundtrip @96 + proj_trans_obs @94 + proj_trans_coord @95 + proj_transform @96 + proj_roundtrip @97 - proj_coord @97 - proj_coord_error @98 - proj_obs_error @99 + proj_coord @98 + proj_coord_error @99 + proj_obs_error @100 - proj_errno @100 - proj_errno_set @101 - proj_errno_reset @102 - proj_errno_restore @103 - proj_context_errno_set @104 + proj_errno @101 + proj_errno_set @102 + proj_errno_reset @103 + proj_errno_restore @104 + proj_context_errno_set @105 - proj_context_create @105 - proj_context_set @106 - proj_context_inherit @107 - proj_context_destroy @108 + proj_context_create @106 + proj_context_set @107 + proj_context_inherit @108 + proj_context_destroy @109 - proj_lp_dist @109 - proj_xy_dist @110 - proj_xyz_dist @111 + proj_lp_dist @110 + proj_xy_dist @111 + proj_xyz_dist @112 - proj_log_level @112 - proj_log_func @113 - proj_log_error @114 - proj_log_debug @115 - proj_log_trace @116 + proj_log_level @113 + proj_log_func @114 + proj_log_error @115 + proj_log_debug @116 + proj_log_trace @117 - proj_definition_retrieve @117 - proj_release @118 - proj_torad @119 - proj_todeg @120 + proj_definition_retrieve @118 + proj_release @119 + proj_torad @120 + proj_todeg @121 - - pj_find_file @121 + pj_find_file @122 @@ -286,6 +286,7 @@ void 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); +PJ *proj_create_crs_to_crs(PJ_CONTEXT *ctx, const char *srid_from, const char *srid_to); PJ *proj_destroy (PJ *P); |
