aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Warmerdam <warmerdam@pobox.com>2014-02-07 19:35:56 +0000
committerFrank Warmerdam <warmerdam@pobox.com>2014-02-07 19:35:56 +0000
commitf9c3e66e6e27022f8e3547b15a873061c36d6e39 (patch)
treed40e069f37773af31db86af342759c24b62405a5
parentbf5009fb800262ec36c2d61e847b05faded6c2c9 (diff)
downloadPROJ-f9c3e66e6e27022f8e3547b15a873061c36d6e39.tar.gz
PROJ-f9c3e66e6e27022f8e3547b15a873061c36d6e39.zip
avoid mistaken error about missing init file entry (#229)
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@2418 4e78687f-474d-0410-85f9-8d5e500ac6b2
-rwxr-xr-xnad/testvarious9
-rw-r--r--nad/tv_out.dist3
-rw-r--r--src/pj_init.c23
3 files changed, 28 insertions, 7 deletions
diff --git a/nad/testvarious b/nad/testvarious
index 88964dd7..b39e670d 100755
--- a/nad/testvarious
+++ b/nad/testvarious
@@ -580,6 +580,15 @@ $EXE -f '%.13f' \
-E >>${OUT} <<EOF
2073986.94908809568733 -1680858.27222427958623
EOF
+echo "##############################################################" >> ${OUT}
+echo "Test bug 229" >> ${OUT}
+#
+$EXE -f '%.13f' \
+ +init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0 \
+ +to +proj=latlong +datum=WGS84 +no_defs \
+ -E >>${OUT} <<EOF
+13 -10
+EOF
##############################################################################
# Done!
# do 'diff' with distribution results
diff --git a/nad/tv_out.dist b/nad/tv_out.dist
index c8607372..122657bf 100644
--- a/nad/tv_out.dist
+++ b/nad/tv_out.dist
@@ -271,3 +271,6 @@ Test omerc differences between poles (#190)
Test qsc
13 -10 2073986.9490880956873 -1680858.2722242795862 0.0000000000000
2073986.94908809568733 -1680858.27222427958623 13.0000000000000 -10.0000000000000 0.0000000000000
+##############################################################
+Test bug 229
+13 -10 13.0000000000000 -10.0000000000000 0.0000000000000
diff --git a/src/pj_init.c b/src/pj_init.c
index fcd57bb8..b51c5278 100644
--- a/src/pj_init.c
+++ b/src/pj_init.c
@@ -97,7 +97,8 @@ static const char *fill_buffer(pj_read_state *state, const char *last_char)
/* get_opt() */
/************************************************************************/
static paralist *
-get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next) {
+get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next,
+ int *found_def) {
pj_read_state *state = (pj_read_state*) calloc(1,sizeof(pj_read_state));
char sword[302];
int len;
@@ -107,6 +108,8 @@ get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next) {
state->fid = fid;
state->ctx = ctx;
next_char = fill_buffer(state, NULL);
+ if(found_def)
+ *found_def = 0;
len = strlen(name);
*sword = 't';
@@ -150,6 +153,8 @@ get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next) {
/* skip past target word */
next_char += len + 1;
in_target = 1;
+ if(found_def)
+ *found_def = 1;
}
else
{
@@ -221,9 +226,9 @@ get_defaults(projCtx ctx, paralist **start, paralist *next, char *name) {
PAFile fid;
if ( (fid = pj_open_lib(ctx,"proj_def.dat", "rt")) != NULL) {
- next = get_opt(ctx, start, fid, "general", next);
+ next = get_opt(ctx, start, fid, "general", next, NULL);
pj_ctx_fseek(ctx, fid, 0, SEEK_SET);
- next = get_opt(ctx, start, fid, name, next);
+ next = get_opt(ctx, start, fid, name, next, NULL);
pj_ctx_fclose(ctx, fid);
}
if (errno)
@@ -237,7 +242,8 @@ get_defaults(projCtx ctx, paralist **start, paralist *next, char *name) {
/* get_init() */
/************************************************************************/
static paralist *
-get_init(projCtx ctx, paralist **start, paralist *next, char *name) {
+get_init(projCtx ctx, paralist **start, paralist *next, char *name,
+ int *found_def) {
char fname[MAX_PATH_FILENAME+ID_TAG_MAX+3], *opt;
PAFile fid;
paralist *init_items = NULL;
@@ -266,7 +272,7 @@ get_init(projCtx ctx, paralist **start, paralist *next, char *name) {
else { pj_ctx_set_errno(ctx,-3); return NULL; }
if ( (fid = pj_open_lib(ctx,fname, "rt")) != NULL)
- next = get_opt(ctx, start, fid, opt, next);
+ next = get_opt(ctx, start, fid, opt, next, found_def);
else
return NULL;
pj_ctx_fclose(ctx, fid);
@@ -416,10 +422,13 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
/* check if +init present */
if (pj_param(ctx, start, "tinit").i) {
paralist *last = curr;
+ int found_def = 0;
- if (!(curr = get_init(ctx,&start, curr, pj_param(ctx, start, "sinit").s)))
+ if (!(curr = get_init(ctx,&start, curr,
+ pj_param(ctx, start, "sinit").s,
+ &found_def)))
goto bum_call;
- if (curr == last) { pj_ctx_set_errno( ctx, -2); goto bum_call; }
+ if (!found_def) { pj_ctx_set_errno( ctx, -2); goto bum_call; }
}
/* find projection selection */