[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-469-gc6241f8c0

git at osgeo.org git at osgeo.org
Wed Feb 2 16:20:25 PST 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  c6241f8c0ab54b4018d4d285a2c44b24608af891 (commit)
      from  9ee87862195400f8483127cdd6ed7bac8322e247 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c6241f8c0ab54b4018d4d285a2c44b24608af891
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Wed Feb 2 16:20:21 2022 -0800

    Add doc image generator verbose flag

diff --git a/doc/html/image_src/generator.c b/doc/html/image_src/generator.c
index 6e8d6ebf1..9679809d8 100644
--- a/doc/html/image_src/generator.c
+++ b/doc/html/image_src/generator.c
@@ -4,6 +4,7 @@
  * http://postgis.net
  *
  * Copyright (C) 2022 Sandro Santilli <strk at kbt.io>
+ * Copyright (C) 2022 Martin Davis
  * Copyright 2008 Kevin Neufeld
  *
  * This is free software; you can redistribute and/or modify it under
@@ -12,8 +13,9 @@
  * This program will generate a .png image for every .wkt file specified
  * in this directory's Makefile.  Every .wkt file may contain several
  * entries of geometries represented as WKT strings.  Every line in
- * a wkt file is stylized using a predetermined style (line thinkness,
- * fill color, etc) currently hard coded in this programs main function.
+ * a wkt file is stylized using a predetermined style (line thickness,
+ * fill color, etc).
+ * The styles are specified in the adjacent styles.conf file.
  *
  * In order to generate a png file, ImageMagicK must be installed in the
  * user's path as system calls are invoked to "convert".  In this manner,
@@ -28,6 +30,14 @@
  * rendered outside of the generated image's extents, or may be rendered too
  * small to be recognizable as anything other than a single point.
  *
+ * Usage:
+ *  generator [-v] <source_wktfile> [<output_pngfile>]
+ *
+ * -v - show generated Imagemagick commands
+ *
+ * If <output_pngfile> is omitted the output image PNG file has the
+ * same name as the source file
+ *
  **********************************************************************/
 
 #include <stdio.h>
@@ -35,6 +45,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <sys/wait.h> /* for WEXITSTATUS */
+#include <stdbool.h>
 
 #include "liblwgeom_internal.h"
 #include "lwgeom_log.h"
@@ -44,6 +55,8 @@
 #define MAX_DOUBLE_PRECISION 15
 #define MAX_DIGS_DOUBLE (SHOW_DIGS_DOUBLE + 2) /* +2 for dot and sign */
 
+bool optionVerbose = false;
+
 // Some global styling variables
 char *imageSize = "200x200";
 
@@ -356,10 +369,22 @@ getStyleName(char **styleName, char* line)
 	}
 }
 
+int parseOptions(int argc, const char* argv[] )
+{
+	if (argc <= 1) return 1;
+
+	int argPos = 1;
+	while (strncmp(argv[argPos], "-", 1) == 0) {
+		if (strncmp(argv[argPos], "-v", 2) == 0) {
+			optionVerbose = true;
+		}
+		argPos++;
+	}
+	return argPos;
+}
 
 /**
- * Main Application.  Currently, drawing styles are hardcoded in this method.
- * Future work may entail reading the styles from a .properties file.
+ * Main Application.
  */
 int main( int argc, const char* argv[] )
 {
@@ -374,13 +399,14 @@ int main( int argc, const char* argv[] )
 	char *ptr;
 	const char *stylefilename = "styles.conf";
 
-	if ( argc < 2 || strlen(argv[1]) < 3)
+	int filePos = parseOptions(argc, argv);
+	if ( filePos >= argc || strlen(argv[filePos]) < 3)
 	{
-		lwerror("Usage: %s <source_wktfile> [<output_pngfile>]", argv[0]);
+		lwerror("Usage: %s [-v] <source_wktfile> [<output_pngfile>]", argv[0]);
 		return -1;
 	}
 
-	image_src = argv[1];
+	image_src = argv[filePos];
 
 	if ( (pfile = fopen(image_src, "r")) == NULL)
 	{
@@ -406,9 +432,9 @@ int main( int argc, const char* argv[] )
 	getStyles(stylefile_path, &styles);
 	free(stylefile_path);
 
-	if ( argc > 2 )
+	if ( argc - filePos >= 2 )
 	{
-		filename = strdup(argv[2]);
+		filename = strdup(argv[filePos + 1]);
 	}
 	else
 	{
@@ -454,7 +480,9 @@ int main( int argc, const char* argv[] )
 		lwgeom_free( lwgeom );
 
 		LWDEBUGF( 4, "%s", output );
-		//puts(output);
+		if (optionVerbose) {
+			puts(output);
+		}
 		checked_system(output);
 
 		//-- (MD) disable highlighting since it doesn't work well with opacity
diff --git a/doc/html/image_src/styles.c b/doc/html/image_src/styles.c
index 587afb1ed..0a6fd1acf 100644
--- a/doc/html/image_src/styles.c
+++ b/doc/html/image_src/styles.c
@@ -2,13 +2,13 @@
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.net
+ *
+ * Copyright (C) 2022 Martin Davis
  * Copyright 2008 Kevin Neufeld
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU General Public Licence. See the COPYING file.
  *
- * TODO: fix segfault bug caused by a referenced style that doesn't exist in
- *          the .conf file
  **********************************************************************/
 
 #include <stdio.h>

-----------------------------------------------------------------------

Summary of changes:
 doc/html/image_src/generator.c | 48 +++++++++++++++++++++++++++++++++---------
 doc/html/image_src/styles.c    |  4 ++--
 2 files changed, 40 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list