From 3913cfa1776f3fe00ebc4bf56575371f23566948 Mon Sep 17 00:00:00 2001 From: Frank Warmerdam Date: Tue, 11 Jun 2002 18:08:25 +0000 Subject: Added the pj_get_def() function git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@1017 4e78687f-474d-0410-85f9-8d5e500ac6b2 --- src/pj_pr_list.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/pj_pr_list.c') diff --git a/src/pj_pr_list.c b/src/pj_pr_list.c index e4feeda6..f7a62344 100644 --- a/src/pj_pr_list.c +++ b/src/pj_pr_list.c @@ -46,3 +46,43 @@ pj_pr_list(PJ *P) { (void)pr_list(P, 1); } } + +/************************************************************************/ +/* pj_get_def() */ +/* */ +/* Returns the PROJ.4 command string that would produce this */ +/* definition expanded as much as possible. For instance, */ +/* +init= calls and +datum= defintions would be expanded. */ +/************************************************************************/ + +char *pj_get_def( PJ *P, int options ) + +{ + paralist *t; + int l; + char *definition; + int def_max = 10; + + definition = (char *) pj_malloc(def_max); + definition[0] = '\0'; + + for (t = P->params; t; t = t->next) + { + l = strlen(t->param) + 1; + if( strlen(definition) + l + 5 > def_max ) + { + char *def2; + + def_max = def_max * 2 + l + 5; + def2 = (char *) pj_malloc(def_max); + strcpy( def2, definition ); + pj_dalloc( definition ); + definition = def2; + } + + strcat( definition, " +" ); + strcat( definition, t->param ); + } + + return definition; +} -- cgit v1.2.3