[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-506-g41b5824da

git at osgeo.org git at osgeo.org
Mon Feb 7 12:13:35 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  41b5824dabca28364a4e822c42123042a9329edb (commit)
      from  981fb9390891328a9d82f2731ef81101826a73b5 (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 41b5824dabca28364a4e822c42123042a9329edb
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Mon Feb 7 12:13:31 2022 -0800

    Add doc image generator arrow style

diff --git a/doc/html/image_src/generator.c b/doc/html/image_src/generator.c
index 97b325667..6ad1b04b8 100644
--- a/doc/html/image_src/generator.c
+++ b/doc/html/image_src/generator.c
@@ -135,6 +135,61 @@ drawPointSymbol(char *output, POINTARRAY *pa, unsigned int index, int size, char
 	return (ptr - output);
 }
 
+/**
+ * Draws a point in a POINTARRAY to a char* using ImageMagick SVG for styling.
+
+ * @param output a char reference to write the LWPOINT to
+ * @param lwp a reference to a LWPOINT
+ * @return the numbers of character written to *output
+ */
+static size_t
+drawLineArrow(char *output, POINTARRAY *pa, int size, int strokeWidth, char* color)
+{
+	// short-circuit no-op
+	if (size <= 0) return 0;
+	if (pa->npoints <= 1) return 0;
+
+	char s0x[OUT_DOUBLE_BUFFER_SIZE];
+	char s0y[OUT_DOUBLE_BUFFER_SIZE];
+	char s1x[OUT_DOUBLE_BUFFER_SIZE];
+	char s1y[OUT_DOUBLE_BUFFER_SIZE];
+	char s2x[OUT_DOUBLE_BUFFER_SIZE];
+	char s2y[OUT_DOUBLE_BUFFER_SIZE];
+
+	POINT2D pn;
+	getPoint2d_p(pa, pa->npoints-1, &pn);
+	POINT2D pn1;
+	getPoint2d_p(pa, pa->npoints-2, &pn1);
+
+	double dx = pn1.x - pn.x;
+	double dy = pn1.y - pn.y;
+	double len = sqrt(dx*dx + dy*dy);
+	//-- abort if final line segment has length 0
+	if (len <= 0) return 0;
+
+	double offx = -0.5 * size * dy/len;
+	double offy =  0.5 * size * dx/len;
+
+
+	double p1x = pn.x + size * dx / len + offx;
+	double p1y = pn.y + size * dy / len + offy;
+	double p2x = pn.x + size * dx / len - offx;
+	double p2y = pn.y + size * dy / len - offy;
+
+	lwprint_double(pn.x, 10, s0x);
+	lwprint_double(pn.y, 10, s0y);
+	lwprint_double(p1x,  10, s1x);
+	lwprint_double(p1y,  10, s1y);
+	lwprint_double(p2x,  10, s2x);
+	lwprint_double(p2y,  10, s2y);
+
+	char *ptr = output;
+	ptr += sprintf(ptr, "-fill %s -strokewidth %d ", color, 2);
+	ptr += sprintf(ptr, "-draw \"path 'M %s,%s %s,%s %s,%s %s,%s'\" ", s0x, s0y, s1x, s1y, s2x, s2y, s0x, s0y);
+
+	return (ptr - output);
+}
+
 /**
  * Serializes a LWPOINT to a char*.  This is a helper function that partially
  * writes the appropriate draw and fill commands used to generate an SVG image
@@ -193,6 +248,7 @@ drawLineString(char *output, LWLINE *lwl, LAYERSTYLE *style)
 
 	ptr += drawPointSymbol(ptr, lwl->points, 0, style->lineStartSize, style->lineColor);
 	ptr += drawPointSymbol(ptr, lwl->points, lwl->points->npoints-1, style->lineEndSize, style->lineColor);
+	ptr += drawLineArrow(ptr, lwl->points, style->lineArrowSize, style->lineWidth, style->lineColor);
 
 	return (ptr - output);
 }
diff --git a/doc/html/image_src/st_linecrossingdirection01.wkt b/doc/html/image_src/st_linecrossingdirection01.wkt
index 64b080b24..d188a59b9 100644
--- a/doc/html/image_src/st_linecrossingdirection01.wkt
+++ b/doc/html/image_src/st_linecrossingdirection01.wkt
@@ -1,2 +1,2 @@
-ArgA;GEOMETRYCOLLECTION(LINESTRING(25 169,89 114,40 70,86 43), POINT(25 169),POLYGON((78.26 40.98,83.98 50.74,86 43,78.26 40.98)) )
-ArgB;GEOMETRYCOLLECTION(LINESTRING(171 154,20 140,71 74,161 53),POINT(171 154),POLYGON((153.15 48.12,156.12 60.85,161 53,153.15 48.12)) )
+ArgA-arrow;LINESTRING(25 169,89 114,40 70,86 43)
+ArgB-arrow;LINESTRING(171 154,20 140,71 74,161 53)
diff --git a/doc/html/image_src/st_linecrossingdirection02.wkt b/doc/html/image_src/st_linecrossingdirection02.wkt
index f26dcf2f5..a9b31dffd 100644
--- a/doc/html/image_src/st_linecrossingdirection02.wkt
+++ b/doc/html/image_src/st_linecrossingdirection02.wkt
@@ -1,2 +1,2 @@
-ArgA;GEOMETRYCOLLECTION(LINESTRING(25 169,89 114,40 70,86 43), POINT(25 169), POLYGON((80.84 41.66,84.66 48.16,86 43,80.84 41.66)) )
-ArgB;GEOMETRYCOLLECTION(LINESTRING(171 154, 20 140, 71 74, 2.99 90.16),POINT(171 154),POLYGON((6.66 84.21,2.99 90.16,8.94 93.83,6.66 84.21)) )
+ArgA-arrow;LINESTRING(25 169,89 114,40 70, 86 43)
+ArgB-arrow;LINESTRING(171 154, 20 140, 71 74, 2.99 90)
diff --git a/doc/html/image_src/st_linecrossingdirection03.wkt b/doc/html/image_src/st_linecrossingdirection03.wkt
index 072ce4dc3..9987afd2b 100644
--- a/doc/html/image_src/st_linecrossingdirection03.wkt
+++ b/doc/html/image_src/st_linecrossingdirection03.wkt
@@ -1,2 +1,2 @@
-ArgA;GEOMETRYCOLLECTION(LINESTRING(25 169,89 114,40 70,86 43), POINT(25 169), POLYGON((78.26 40.98,83.98 50.74,86 43,78.26 40.98)) )
-ArgB;GEOMETRYCOLLECTION(LINESTRING (20 140, 71 74, 161 53), POINT(20 140), POLYGON ((153.15 48.12, 156.12 60.85, 161 53, 153.15 48.12)))
+ArgA-arrow;LINESTRING(25 169,89 114,40 70,86 43)
+ArgB-arrow;LINESTRING (20 140, 71 74, 161 53)
diff --git a/doc/html/image_src/st_linecrossingdirection04.wkt b/doc/html/image_src/st_linecrossingdirection04.wkt
index b46305346..cbd0ac7ac 100644
--- a/doc/html/image_src/st_linecrossingdirection04.wkt
+++ b/doc/html/image_src/st_linecrossingdirection04.wkt
@@ -1,2 +1,2 @@
-ArgA;GEOMETRYCOLLECTION(LINESTRING(25 169,89 114,40 70,86 43), POINT(25 169), POLYGON((80.84 41.66,84.66 48.16,86 43,80.84 41.66)) )
-ArgB;GEOMETRYCOLLECTION(LINESTRING(5 90,71 74,20 140,171 154),POINT(5 90),POLYGON((159.33 163.69,171 154,161.31 142.33,159.33 163.69)) )
+ArgA-arrow;LINESTRING(25 169,89 114,40 70,86 43)
+ArgB-arrow;LINESTRING(5 90,71 74,20 140,171 154)
diff --git a/doc/html/image_src/styles.c b/doc/html/image_src/styles.c
index 0a6fd1acf..ae07860d7 100644
--- a/doc/html/image_src/styles.c
+++ b/doc/html/image_src/styles.c
@@ -48,6 +48,7 @@ getStyles( const char *filename, LAYERSTYLE **headRef )
 			char *lineColor = "Grey";
 			int lineStartSize = 0;
 			int lineEndSize = 0;
+			int lineArrowSize = 0;
 			char *polygonFillColor = "Grey";
 			char *polygonStrokeColor = "Grey";
 			int polygonStrokeWidth = 0;
@@ -93,6 +94,11 @@ getStyles( const char *filename, LAYERSTYLE **headRef )
 						lineEndSize = atoi(ptr);
 						free(ptr);
 					}
+					else if (strncmp(line, "lineArrowSize", 3) == 0)
+					{
+						lineArrowSize = atoi(ptr);
+						free(ptr);
+					}
 					else if (strncmp(line, "polygonFillColor", 16) == 0)
 						polygonFillColor = ptr;
 					else if (strncmp(line, "polygonStrokeColor", 18) == 0)
@@ -106,7 +112,7 @@ getStyles( const char *filename, LAYERSTYLE **headRef )
 				getResults = fgets ( line, sizeof line, pFile );
 			}
 			addStyle(headRef, styleName, pointSize, pointColor,
-				lineWidth, lineColor, lineStartSize, lineEndSize,
+				lineWidth, lineColor, lineStartSize, lineEndSize, lineArrowSize,
 				polygonFillColor, polygonStrokeColor, polygonStrokeWidth);
 		}
 		getResults = fgets ( line, sizeof line, pFile );
@@ -143,7 +149,7 @@ addStyle(
     char* styleName,
     int pointSize, char* pointColor,
     int lineWidth, char* lineColor,
-	int lineStartSize, int lineEndSize,
+	int lineStartSize, int lineEndSize, int lineArrowSize,
     char* polygonFillColor, char* polygonStrokeColor, int polygonStrokeWidth)
 {
 	LAYERSTYLE *style = malloc( sizeof(LAYERSTYLE) );
@@ -155,6 +161,7 @@ addStyle(
 	style->lineColor = lineColor;
 	style->lineStartSize = lineStartSize;
 	style->lineEndSize = lineEndSize;
+	style->lineArrowSize = lineArrowSize;
 	style->polygonFillColor = polygonFillColor;
 	style->polygonStrokeColor = polygonStrokeColor;
 	style->polygonStrokeWidth = polygonStrokeWidth;
diff --git a/doc/html/image_src/styles.conf b/doc/html/image_src/styles.conf
index e7e7d0875..20df8d2e8 100644
--- a/doc/html/image_src/styles.conf
+++ b/doc/html/image_src/styles.conf
@@ -64,6 +64,18 @@ polygonFillColor = "#C0D0F080"
 polygonStrokeColor = "#6495ED"
 polygonStrokeWidth = 2
 
+[Style]
+styleName = ArgA-arrow
+pointSize = 5
+pointColor = "#6495ED"
+lineWidth = 4
+lineColor = "#6495ED"
+lineStartSize = 5
+lineArrowSize = 10
+polygonFillColor = "#C0D0F080"
+polygonStrokeColor = "#6495ED"
+polygonStrokeWidth = 2
+
 [Style]
 # Argument B
 styleName = ArgB
@@ -99,6 +111,18 @@ polygonFillColor = "#00ffa040"
 polygonStrokeColor = "#7ACAC4"
 polygonStrokeWidth = 2
 
+[Style]
+styleName = ArgB-arrow
+pointSize = 5
+pointColor = "#7ACAC4"
+lineWidth = 4
+lineColor = "#7ACAC4"
+lineStartSize = 5
+lineArrowSize = 10
+polygonFillColor = "#00ffa040"
+polygonStrokeColor = "#7ACAC4"
+polygonStrokeWidth = 2
+
 [Style]
 # Result
 styleName = Result
diff --git a/doc/html/image_src/styles.h b/doc/html/image_src/styles.h
index cf1688d35..fff87ad1e 100644
--- a/doc/html/image_src/styles.h
+++ b/doc/html/image_src/styles.h
@@ -28,6 +28,7 @@ struct layerStyle
 
 	int   lineStartSize;
 	int   lineEndSize;
+	int   lineArrowSize;
 
 	char *polygonFillColor;
 	char *polygonStrokeColor;
@@ -38,7 +39,9 @@ struct layerStyle
 
 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, int lineStartSize, int lineEndSize, char* polygonFillColor, char* polygonStrokeColor, int polygonStrokeWidth );
+void addStyle( LAYERSTYLE **headRef, char* styleName, int pointSize, char* pointColor,
+	int lineWidth, char* lineColor, int lineStartSize, int lineEndSize, int lineArrowSize,
+	char* polygonFillColor, char* polygonStrokeColor, int polygonStrokeWidth );
 
 int length( LAYERSTYLE *headRef );
 LAYERSTYLE* getStyle( LAYERSTYLE *headRef, char* styleName );

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

Summary of changes:
 doc/html/image_src/generator.c                    | 56 +++++++++++++++++++++++
 doc/html/image_src/st_linecrossingdirection01.wkt |  4 +-
 doc/html/image_src/st_linecrossingdirection02.wkt |  4 +-
 doc/html/image_src/st_linecrossingdirection03.wkt |  4 +-
 doc/html/image_src/st_linecrossingdirection04.wkt |  4 +-
 doc/html/image_src/styles.c                       | 11 ++++-
 doc/html/image_src/styles.conf                    | 24 ++++++++++
 doc/html/image_src/styles.h                       |  5 +-
 8 files changed, 101 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list