aboutsummaryrefslogtreecommitdiff
path: root/src/pr_list.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-19 13:00:37 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-26 10:08:55 +0100
commitdf574ae332d57f556fd56314883b3354cab1d0ff (patch)
tree63a68d40d7ed7932d6329d9c7baa340bb6294f7f /src/pr_list.cpp
parente6de172371ea203f6393d745641d66c82b5b13e2 (diff)
downloadPROJ-df574ae332d57f556fd56314883b3354cab1d0ff.tar.gz
PROJ-df574ae332d57f556fd56314883b3354cab1d0ff.zip
cpp conversion: remove useless pj_, PJ_ and proj_ filename prefixes
Diffstat (limited to 'src/pr_list.cpp')
-rw-r--r--src/pr_list.cpp104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/pr_list.cpp b/src/pr_list.cpp
new file mode 100644
index 00000000..b8ad2c04
--- /dev/null
+++ b/src/pr_list.cpp
@@ -0,0 +1,104 @@
+/* print projection's list of parameters */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "projects.h"
+
+#define LINE_LEN 72
+ static int
+pr_list(PJ *P, int not_used) {
+ paralist *t;
+ int l, n = 1, flag = 0;
+
+ (void)putchar('#');
+ for (t = P->params; t; t = t->next)
+ if ((!not_used && t->used) || (not_used && !t->used)) {
+ l = (int)strlen(t->param) + 1;
+ if (n + l > LINE_LEN) {
+ (void)fputs("\n#", stdout);
+ n = 2;
+ }
+ (void)putchar(' ');
+ if (*(t->param) != '+')
+ (void)putchar('+');
+ (void)fputs(t->param, stdout);
+ n += l;
+ } else
+ flag = 1;
+ if (n > 1)
+ (void)putchar('\n');
+ return flag;
+}
+ void /* print link list of projection parameters */
+pj_pr_list(PJ *P) {
+ char const *s;
+
+ (void)putchar('#');
+ for (s = P->descr; *s ; ++s) {
+ (void)putchar(*s);
+ if (*s == '\n')
+ (void)putchar('#');
+ }
+ (void)putchar('\n');
+ if (pr_list(P, 0)) {
+ (void)fputs("#--- following specified but NOT used\n", stdout);
+ (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= definitions would be expanded. */
+/************************************************************************/
+
+char *pj_get_def( PJ *P, int options )
+
+{
+ paralist *t;
+ int l;
+ char *definition;
+ size_t def_max = 10;
+ (void) options;
+
+ definition = (char *) pj_malloc(def_max);
+ if (!definition)
+ return nullptr;
+ definition[0] = '\0';
+
+ for (t = P->params; t; t = t->next)
+ {
+ /* skip unused parameters ... mostly appended defaults and stuff */
+ if (!t->used)
+ continue;
+
+ /* grow the resulting string if needed */
+ l = (int)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);
+ if (def2) {
+ strcpy( def2, definition );
+ pj_dalloc( definition );
+ definition = def2;
+ }
+ else {
+ pj_dalloc( definition );
+ return nullptr;
+ }
+ }
+
+ /* append this parameter */
+ strcat( definition, " +" );
+ strcat( definition, t->param );
+ }
+
+ return definition;
+}