From e09e24eddbd49cd802ac1334f229f1698ea0b755 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Fri, 7 Jul 2017 17:14:28 +0200 Subject: obs_api revision and improvements: new namespace etc. (#530) * obs_api revision and improvements: new namespace etc. * Minor corrections: use unused functions, add missing prototype, added fwd/invcoord to PJ * Minor correction: MSVC barfs on va_arg type specification. Trying once more with added parens * Reverting paren correction, which appears to be a non-solution * Significant improvements to the OBS_API, plus a number of corrections, mostly in test code, to reflect API changes * Added two missing prototypes * Adding the proj_transform function and some related checks * Improvements to proj_transform etc. based on suggestions from Even Rouault * Reducing the libc include footprint of proj.h - again based on suggestions from Even Rouault * A few minor corrections * Eliminate a MSVC warning about non-initialized usage. Not an actual issue, as another check has locked the path, but at least this should calm down MSVC * Improved support for the errno reset/restore paradigm * Introduced the internal header proj_internal.h; Moved most non-API stuff from pj_obs_api.c to pj_internal.c * Adding proj_internal.h to HEADERS_LIBPROJ to solve build problems * Correcting a few pj...proj blunders in PJ_pipeline.c * Correcting a few additional blunders in PJ_pipeline.c * Changed angle-brackets to quotation marks in includes of proj_internal.h * Some minor build system repairs * Some PJ_CONTEXT usage simplifications following suggestions by Kristian Evers @kbevers * Added version numbering to proj.h - Fixes #529 * remove proj_errno_restore macro, provide function implementation * Add proj_get_definition. Fixes #538 * Added library specific deallocator proj_buffer_free, eliminating a potential cross heap issues on Windows. Thx to Even Rouault for spotting this * Got rid of a meaningless cast in proj_buffer_free * Added some missing functions to proj.def (again spotted by @rouault); removed some not-yet-implemented material from proj.h * Renamed proj_get_definition/proj_buffer_free to proj_definition_create/proj_definition_destroy, for symmetry and clarity * Renaming the definition handlers to proj_definition_retrieve / proj_free * Renaming proj_free to proj_release --- src/PJ_horner.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src/PJ_horner.c') diff --git a/src/PJ_horner.c b/src/PJ_horner.c index 1b055a4e..56980f72 100644 --- a/src/PJ_horner.c +++ b/src/PJ_horner.c @@ -1,5 +1,5 @@ #define PJ_LIB__ -#include +#include "proj_internal.h" #include #include #include @@ -94,7 +94,7 @@ PROJ_HEAD(horner, "Horner polynomial evaluation"); struct horner; typedef struct horner HORNER; -static UV horner (const HORNER *transformation, enum pj_direction, UV position); +static UV horner (const HORNER *transformation, enum proj_direction, UV position); static HORNER *horner_alloc (size_t order, int complex_polynomia); static void horner_free (HORNER *h); @@ -176,7 +176,7 @@ static HORNER *horner_alloc (size_t order, int complex_polynomia) { /**********************************************************************/ -static UV horner (const HORNER *transformation, enum pj_direction direction, UV position) { +static UV horner (const HORNER *transformation, enum proj_direction direction, UV position) { /*********************************************************************** A reimplementation of the classic Engsager/Poder 2D Horner polynomial @@ -301,7 +301,7 @@ static PJ_OBS horner_reverse_obs (PJ_OBS point, PJ *P) { /**********************************************************************/ -static UV complex_horner (const HORNER *transformation, enum pj_direction direction, UV position) { +static UV complex_horner (const HORNER *transformation, enum proj_direction direction, UV position) { /*********************************************************************** A reimplementation of a classic Engsager/Poder Horner complex @@ -401,7 +401,7 @@ static int parse_coefs (PJ *P, double *coefs, char *param, int ncoefs) { buf = pj_calloc (strlen (param) + 2, sizeof(char)); if (0==buf) { - pj_log_error (P, "Horner: Out of core"); + proj_log_error (P, "Horner: Out of core"); return 0; } @@ -415,7 +415,7 @@ static int parse_coefs (PJ *P, double *coefs, char *param, int ncoefs) { for (i = 0; i < ncoefs; i++) { if (i > 0) { if ( next == 0 || ','!=*next) { - pj_log_error (P, "Horner: Malformed polynomium set %s. need %d coefs", param, ncoefs); + proj_log_error (P, "Horner: Malformed polynomium set %s. need %d coefs", param, ncoefs); return 0; } init = ++next; @@ -443,7 +443,7 @@ PJ *PROJECTION(horner) { if (pj_param (P->ctx, P->params, "tdeg").i) /* degree specified? */ degree = pj_param(P->ctx, P->params, "ideg").i; else { - pj_log_debug (P, "Horner: Must specify polynomial degree, (+deg=n)"); + proj_log_debug (P, "Horner: Must specify polynomial degree, (+deg=n)"); return horner_freeup (P); } @@ -525,48 +525,49 @@ int pj_horner_selftest (void) { double dist; /* Real polynonia relating the technical coordinate system TC32 to "System 45 Bornholm" */ - P = pj_create (tc32_utm32); + P = proj_create (0, tc32_utm32); if (0==P) return 10; - a = b = pj_obs_null; + a = b = proj_obs_null; a.coo.uv.v = 6125305.4245; a.coo.uv.u = 878354.8539; /* Check roundtrip precision for 1 iteration each way, starting in forward direction */ - dist = pj_roundtrip (P, PJ_FWD, 1, a); + dist = proj_roundtrip (P, PJ_FWD, 1, a); if (dist > 0.01) return 1; /* The complex polynomial transformation between the "System Storebaelt" and utm32/ed50 */ - P = pj_create (sb_utm32); + P = proj_create (0, sb_utm32); if (0==P) return 11; /* Test value: utm32_ed50(620000, 6130000) = sb_ed50(495136.8544, 6130821.2945) */ - a = b = c = pj_obs_null; + a = b = c = proj_obs_null; a.coo.uv.v = 6130821.2945; a.coo.uv.u = 495136.8544; c.coo.uv.v = 6130000.0000; c.coo.uv.u = 620000.0000; /* Forward projection */ - b = pj_trans (P, PJ_FWD, a); - dist = pj_xy_dist (b.coo.xy, c.coo.xy); + b = proj_trans_obs (P, PJ_FWD, a); + dist = proj_xy_dist (b.coo.xy, c.coo.xy); if (dist > 0.001) return 2; /* Inverse projection */ - b = pj_trans (P, PJ_INV, c); - dist = pj_xy_dist (b.coo.xy, a.coo.xy); + b = proj_trans_obs (P, PJ_INV, c); + dist = proj_xy_dist (b.coo.xy, a.coo.xy); if (dist > 0.001) return 3; /* Check roundtrip precision for 1 iteration each way */ - dist = pj_roundtrip (P, PJ_FWD, 1, a); + dist = proj_roundtrip (P, PJ_FWD, 1, a); if (dist > 0.01) return 4; + proj_destroy(P); return 0; } #endif -- cgit v1.2.3