From e6bcf568fa75e326da450f2ead8fdc152252b1e0 Mon Sep 17 00:00:00 2001 From: Frank Warmerdam Date: Thu, 5 Apr 2001 04:22:39 +0000 Subject: added pj_init_plus() git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@926 4e78687f-474d-0410-85f9-8d5e500ac6b2 --- src/pj_init.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'src') diff --git a/src/pj_init.c b/src/pj_init.c index 993d2ff9..6ec87bf4 100644 --- a/src/pj_init.c +++ b/src/pj_init.c @@ -72,6 +72,63 @@ get_init(paralist *next, char *name) { return next; } +/************************************************************************/ +/* pj_init_plus() */ +/* */ +/* Same as pj_init() except it takes one argument string with */ +/* individual arguments preceeded by '+', such as "+proj=utm */ +/* +zone=11 +ellps=WGS84". */ +/************************************************************************/ + +PJ * +pj_init_plus( const char *definition ) + +{ +#define MAX_ARG 200 + char *argv[MAX_ARG]; + char *defn_copy; + int argc = 0, i; + PJ *result; + + /* make a copy that we can manipulate */ + defn_copy = pj_malloc( strlen(definition)+1 ); + strcpy( defn_copy, definition ); + + /* split into arguments based on '+' and trim white space */ + + for( i = 0; defn_copy[i] != '\0'; i++ ) + { + switch( defn_copy[i] ) + { + case '+': + if( argc+1 == MAX_ARG ) + { + pj_errno = -44; + return NULL; + } + + argv[argc++] = defn_copy + i + 1; + break; + + case ' ': + case '\t': + case '\n': + defn_copy[i] = '\0'; + break; + + default: + /* do nothing */ + } + } + + /* perform actual initialization */ + result = pj_init( argc, argv ); + + pj_dalloc( defn_copy ); + + return result; +} + /************************************************************************/ /* pj_init() */ /* */ -- cgit v1.2.3