aboutsummaryrefslogtreecommitdiff
path: root/src/pj_apply_gridshift.c
diff options
context:
space:
mode:
authorFrank Warmerdam <warmerdam@pobox.com>2010-06-11 01:51:24 +0000
committerFrank Warmerdam <warmerdam@pobox.com>2010-06-11 01:51:24 +0000
commitec678c07c2acb83da8a2187c541b8a2e452dec4b (patch)
treea4c004a6e88d7330fe9d1c6ed793129831b5bdca /src/pj_apply_gridshift.c
parenta7290836114dc82b35eceb1efcb5ecdf605d335f (diff)
downloadPROJ-ec678c07c2acb83da8a2187c541b8a2e452dec4b.tar.gz
PROJ-ec678c07c2acb83da8a2187c541b8a2e452dec4b.zip
preliminary implementation of projCtx API
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@1854 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src/pj_apply_gridshift.c')
-rw-r--r--src/pj_apply_gridshift.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/src/pj_apply_gridshift.c b/src/pj_apply_gridshift.c
index 50ff6e6a..9ce9c02c 100644
--- a/src/pj_apply_gridshift.c
+++ b/src/pj_apply_gridshift.c
@@ -45,7 +45,7 @@
/* it to honour our public api. */
/************************************************************************/
-int pj_apply_gridshift( const char *nadgrids, int inverse,
+int pj_apply_gridshift( projCtx ctx, const char *nadgrids, int inverse,
long point_count, int point_offset,
double *x, double *y, double *z )
@@ -54,12 +54,12 @@ int pj_apply_gridshift( const char *nadgrids, int inverse,
int grid_count;
int ret;
- gridlist = pj_gridlist_from_nadgrids( nadgrids, &grid_count );
+ gridlist = pj_gridlist_from_nadgrids( ctx, nadgrids, &grid_count );
if( gridlist == NULL || grid_count == 0 )
- return pj_errno;
+ return ctx->last_errno;
- ret = pj_apply_gridshift_3( gridlist, grid_count, inverse,
+ ret = pj_apply_gridshift_3( ctx, gridlist, grid_count, inverse,
point_count, point_offset, x, y, z );
/*
@@ -88,14 +88,16 @@ int pj_apply_gridshift_2( PJ *defn, int inverse,
if( defn->gridlist == NULL )
{
defn->gridlist =
- pj_gridlist_from_nadgrids( pj_param(defn->params,"snadgrids").s,
+ pj_gridlist_from_nadgrids( pj_get_ctx( defn ),
+ pj_param(defn->params,"snadgrids").s,
&(defn->gridlist_count) );
if( defn->gridlist == NULL || defn->gridlist_count == 0 )
- return pj_errno;
+ return defn->ctx->last_errno;
}
- return pj_apply_gridshift_3( defn->gridlist, defn->gridlist_count, inverse,
+ return pj_apply_gridshift_3( pj_get_ctx( defn ),
+ defn->gridlist, defn->gridlist_count, inverse,
point_count, point_offset, x, y, z );
}
@@ -106,22 +108,21 @@ int pj_apply_gridshift_2( PJ *defn, int inverse,
/* This is the real workhorse, given a gridlist. */
/************************************************************************/
-int pj_apply_gridshift_3( PJ_GRIDINFO **tables, int grid_count,
+int pj_apply_gridshift_3( projCtx ctx, PJ_GRIDINFO **tables, int grid_count,
int inverse, long point_count, int point_offset,
double *x, double *y, double *z )
{
int i;
- int debug_flag = getenv( "PROJ_DEBUG" ) != NULL;
static int debug_count = 0;
if( tables == NULL || grid_count == 0 )
{
- pj_errno = -38;
+ pj_ctx_set_errno( ctx, -38);
return -38;
}
- pj_errno = 0;
+ ctx->last_errno = 0;
for( i = 0; i < point_count; i++ )
{
@@ -172,44 +173,44 @@ int pj_apply_gridshift_3( PJ_GRIDINFO **tables, int grid_count,
}
/* load the grid shift info if we don't have it. */
- if( ct->cvs == NULL && !pj_gridinfo_load( gi ) )
+ if( ct->cvs == NULL && !pj_gridinfo_load( ctx, gi ) )
{
- pj_errno = -38;
+ pj_ctx_set_errno( ctx, -38 );
return -38;
}
output = nad_cvt( input, inverse, ct );
if( output.lam != HUGE_VAL )
{
- if( debug_flag && debug_count++ < 20 )
- fprintf( stderr,
- "pj_apply_gridshift(): used %s\n",
- ct->id );
+ if( debug_count++ < 20 )
+ pj_log( ctx, PJ_LOG_DEBUG_MINOR,
+ "pj_apply_gridshift(): used %s", ct->id );
break;
}
}
if( output.lam == HUGE_VAL )
{
- if( debug_flag )
+ if( ctx->debug_level >= PJ_LOG_DEBUG_MAJOR )
{
- fprintf( stderr,
- "pj_apply_gridshift(): failed to find a grid shift table for\n"
- " location (%.7fdW,%.7fdN)\n",
- x[io] * RAD_TO_DEG,
- y[io] * RAD_TO_DEG );
+ pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
+ "pj_apply_gridshift(): failed to find a grid shift table for\n"
+ " location (%.7fdW,%.7fdN)",
+ x[io] * RAD_TO_DEG,
+ y[io] * RAD_TO_DEG );
for( itable = 0; itable < grid_count; itable++ )
{
PJ_GRIDINFO *gi = tables[itable];
if( itable == 0 )
- fprintf( stderr, " tried: %s", gi->gridname );
+ pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
+ " tried: %s", gi->gridname );
else
- fprintf( stderr, ",%s", gi->gridname );
+ pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
+ ",%s", gi->gridname );
}
- fprintf( stderr, "\n" );
}
- pj_errno = PJD_ERR_GRID_AREA;
+ pj_ctx_set_errno( ctx, PJD_ERR_GRID_AREA );
return PJD_ERR_GRID_AREA;
}
else