[postgis-tickets] [SCM] PostGIS branch out-of-build-docs updated. 3.2.0-380-gbb827330e

git at osgeo.org git at osgeo.org
Thu Jan 27 08:51:16 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, out-of-build-docs has been updated
       via  bb827330ed16bdf88dbe793b67beaa2b0e9de81d (commit)
      from  99809f9f1a0391b2dc44b4eaff94a2bbf3cf2852 (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 bb827330ed16bdf88dbe793b67beaa2b0e9de81d
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Jan 27 17:50:32 2022 +0100

    [generator] look for styles.conf in the dir containing image source

diff --git a/doc/html/image_src/generator.c b/doc/html/image_src/generator.c
index 0732acb99..d53d9cd30 100644
--- a/doc/html/image_src/generator.c
+++ b/doc/html/image_src/generator.c
@@ -336,7 +336,10 @@ int main( int argc, const char* argv[] )
 	char *filename;
 	int layerCount;
 	LAYERSTYLE *styles;
+	char *stylefile_path;
 	const char *image_src;
+	char *ptr;
+	const char *stylefilename = "styles.conf";
 
 	if ( argc < 2 || strlen(argv[1]) < 3)
 	{
@@ -352,7 +355,23 @@ int main( int argc, const char* argv[] )
 		return -1;
 	}
 
-	getStyles(&styles);
+	/* Get style */
+	ptr = rindex( image_src, '/' );
+	if ( ptr ) /* source image file has a slash */
+	{
+		size_t dirname_len = (ptr - image_src);
+		stylefile_path = malloc( strlen(stylefilename) + dirname_len + 2);
+		/* copy the directory name */
+		memcpy(stylefile_path, image_src, dirname_len);
+		sprintf(stylefile_path + dirname_len, "/%s", stylefilename);
+	}
+	else /* source image file has no slash, use CWD */
+	{
+		stylefile_path = strdup(stylefilename);
+	}
+	printf("reading styles from %s\n", stylefile_path);
+	getStyles(stylefile_path, &styles);
+	free(stylefile_path);
 
 	if ( argc > 2 )
 	{
diff --git a/doc/html/image_src/styles.c b/doc/html/image_src/styles.c
index 35fdfb676..d22c0ae12 100644
--- a/doc/html/image_src/styles.c
+++ b/doc/html/image_src/styles.c
@@ -20,7 +20,7 @@
 
 
 void
-getStyles( LAYERSTYLE **headRef )
+getStyles( const char *filename, LAYERSTYLE **headRef )
 {
 	char line [128];
 	FILE* pFile;
@@ -28,9 +28,9 @@ getStyles( LAYERSTYLE **headRef )
 
 	*headRef = NULL;
 
-	if ((pFile = fopen("styles.conf", "r")) == NULL)
+	if ((pFile = fopen(filename, "r")) == NULL)
 	{
-		perror ( "styles.conf: No such file or directory" );
+		perror ( filename );
 		return;
 	}
 
diff --git a/doc/html/image_src/styles.h b/doc/html/image_src/styles.h
index 04c4fc260..78144e5d8 100644
--- a/doc/html/image_src/styles.h
+++ b/doc/html/image_src/styles.h
@@ -33,7 +33,7 @@ struct layerStyle
 	LAYERSTYLE *next;
 };
 
-void getStyles( LAYERSTYLE **headRef );
+void getStyles( const char *filename, LAYERSTYLE **headRef );
 void freeStyles( LAYERSTYLE **headRef );
 void addStyle( LAYERSTYLE **headRef, char* styleName, int pointSize, char* pointColor, int lineWidth, char* lineColor, char* polygonFillColor, char* polygonStrokeColor, int polygonStrokeWidth );
 

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

Summary of changes:
 doc/html/image_src/generator.c | 21 ++++++++++++++++++++-
 doc/html/image_src/styles.c    |  6 +++---
 doc/html/image_src/styles.h    |  2 +-
 3 files changed, 24 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list