]> granicus.if.org Git - postgis/commitdiff
added styles to the generated documentation images
authorKevin Neufeld <kneufeld.ca@gmail.com>
Thu, 14 May 2009 23:42:02 +0000 (23:42 +0000)
committerKevin Neufeld <kneufeld.ca@gmail.com>
Thu, 14 May 2009 23:42:02 +0000 (23:42 +0000)
added ImageMagick as a dependency

git-svn-id: http://svn.osgeo.org/postgis/trunk@4081 b70326c6-7e19-0410-871a-916f4a2858ee

37 files changed:
configure.ac
doc/Makefile.in
doc/html/image_src/Makefile.in
doc/html/image_src/generator.c
doc/html/image_src/st_centroid01.wkt
doc/html/image_src/st_centroid02.wkt
doc/html/image_src/st_centroid03.wkt
doc/html/image_src/st_centroid04.wkt
doc/html/image_src/st_crosses01.wkt
doc/html/image_src/st_crosses02.wkt
doc/html/image_src/st_crosses03.wkt
doc/html/image_src/st_crosses04.wkt
doc/html/image_src/st_issimple01.wkt
doc/html/image_src/st_issimple02.wkt
doc/html/image_src/st_issimple03.wkt
doc/html/image_src/st_issimple04.wkt
doc/html/image_src/st_issimple05.wkt
doc/html/image_src/st_issimple06.wkt
doc/html/image_src/st_issimple07.wkt
doc/html/image_src/st_isvalid01.wkt
doc/html/image_src/st_isvalid02.wkt
doc/html/image_src/st_isvalid03.wkt
doc/html/image_src/st_isvalid04.wkt
doc/html/image_src/st_isvalid05.wkt
doc/html/image_src/st_isvalid06.wkt [new file with mode: 0644]
doc/html/image_src/st_isvalid07.wkt [new file with mode: 0644]
doc/html/image_src/st_isvalid08.wkt [new file with mode: 0644]
doc/html/image_src/st_touches01.wkt [new file with mode: 0644]
doc/html/image_src/st_touches02.wkt [new file with mode: 0644]
doc/html/image_src/st_touches03.wkt [new file with mode: 0644]
doc/html/image_src/st_touches04.wkt [new file with mode: 0644]
doc/html/image_src/st_touches05.wkt [new file with mode: 0644]
doc/html/image_src/st_touches06.wkt [new file with mode: 0644]
doc/html/image_src/styles.c [new file with mode: 0644]
doc/html/image_src/styles.conf [new file with mode: 0644]
doc/html/image_src/styles.h [new file with mode: 0644]
doc/reference.xml

index 3f2ad0c0f162a5df9b7a3a9cc0ebdac648100670..c95cad9fec082164b887efd6fc3731b1fd7daf36 100644 (file)
@@ -85,6 +85,11 @@ dnl
 dnl Search for xsltproc which is required for building documentation
 dnl
 
+AC_PATH_PROG([IMAGEMAGICK], [convert], [])
+if test "x$IMAGEMAGICK" = "x"; then
+       AC_MSG_WARN([ImageMagick does not seem to be installed. Documentation cannot be built])
+fi
+
 AC_PATH_PROG([XSLTPROC], [xsltproc], [])
 if test "x$XSLTPROC" = "x"; then
        AC_MSG_WARN([xsltproc is not installed so documentation cannot be built])
index 30f06fbfb07e3a19ca9670666e547d9a1b792b89..4200ecfb9d80ccbf4add8d3e316bfaf5e2b60e73 100644 (file)
@@ -49,9 +49,13 @@ else
 ifeq ($(XSLBASE),)
 all: requirements_not_met_xslbase
 else
+ifeq ($(IMAGEMAGICK),)
+all: requirements_not_met_imagemagick
+else
 all: html/postgis.html ../postgis_comments.sql
 endif
 endif
+endif
 
 postgis_aggs_mm.xml: ./xsl/postgis_aggs_mm.xml.xsl reference.xml
        $(XSLTPROC) ./xsl/postgis_aggs_mm.xml.xsl reference.xml > $@
@@ -107,7 +111,7 @@ doxygen: doxygen.cfg
        doxygen $<
 
 images: 
-       make -C html/image_src
+       make -C html/image_src images
        
 clean:
        make -C html/image_src clean
@@ -149,5 +153,14 @@ requirements_not_met_xslbase:
        @echo "  http://postgis.refractions.net/docs"
        @echo
 
+requirements_not_met_imagemagick:
+       @echo 
+       @echo "configure was unable to find the ImageMagick's 'convert' utility program."
+       @echo "To build the documentation, install ImageMagick and then re-run configure. Alternatively "
+       @echo "refer to online manual:"
+       @echo
+       @echo "  http://postgis.refractions.net/docs"
+       @echo 
+       
 .PHONY: html
 
index 0ab59911f2a494afcb6fede2a8ec05877d9e179d..51da89d1ca5121835b8402055eea383e6797dbdc 100644 (file)
@@ -36,22 +36,34 @@ IMAGES= \
        ../images/st_isvalid02.png \
        ../images/st_isvalid03.png \
        ../images/st_isvalid04.png \
-       ../images/st_isvalid05.png 
+       ../images/st_isvalid05.png \
+       ../images/st_isvalid06.png \
+       ../images/st_isvalid07.png \
+       ../images/st_isvalid08.png \
+       ../images/st_touches01.png \
+       ../images/st_touches02.png \
+       ../images/st_touches03.png \
+       ../images/st_touches04.png \
+       ../images/st_touches05.png \
+       ../images/st_touches06.png 
        
-OBJS=generator.o
+OBJS=styles.o generator.o
 
 # Build the generator
-all: $(IMAGES)
+all: generator
+
+# generate the images
+images: $(IMAGES)
 
 # Command to build each of the .o files
 $(OBJS): %.o: %.c
        $(CC) $(CFLAGS) $(CUNIT_CPPFLAGS) -c -o $@ $<
        
 # Command to build each of the .wkt files
-$(IMAGES): ../images/%.png: %.wkt generator
+$(IMAGES): ../images/%.png: %.wkt generator styles.conf
        @./generator $<
 
-# Build the main unit test executable
+# Build the main executable
 generator: ../../../liblwgeom/liblwgeom.a $(OBJS)
        $(CC) -o $@ $(OBJS) ../../../liblwgeom/liblwgeom.a -lm $(CUNIT_LDFLAGS)
 
index 3d0e34180ace7ac5a16140de9ebae428d7452bf4..5614ce1357627c4e1a9623cc7a27991aed44d982 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 #include "CUnit/Basic.h"
 
 #include "lwalgorithm.h"
+#include "styles.h"
 
 #define SHOW_DIGS_DOUBLE 15
 #define MAX_DOUBLE_PRECISION 15
 // Some global styling variables
 char *imageSize = "200x200";
 
-typedef struct {       
-       int       pointSize;
-       char *pointColor;
-       
-       int   lineWidth;
-       char *lineColor;
-       
-       char *polygonFillColor;
-       char *polygonStrokeColor;
-       int   polygonStrokeWidth;
-} LAYERSTYLE;
 
+int getStyleName(char **styleName, char* line);
 
 /**
  * Set up liblwgeom to run in stand-alone mode using the 
  * usual system memory handling functions.
  */
 void lwgeom_init_allocators(void) {
-               /* liblwgeom callback - install default handlers */
-               lwgeom_install_default_allocators();
+       /* liblwgeom callback - install default handlers */
+       lwgeom_install_default_allocators();
 }
 
 /**
@@ -103,9 +95,7 @@ pointarrayToString(char *output, POINTARRAY *pa) {
  * @return the numbers of character written to *output
  */
 static size_t
-drawPoint(char *output, LWPOINT *lwp, LAYERSTYLE style) {
-       LWDEBUGF( 4, "%s", "enter drawPoint" );
-       
+drawPoint(char *output, LWPOINT *lwp, LAYERSTYLE *styles) {    
        char x[MAX_DIGS_DOUBLE+MAX_DOUBLE_PRECISION+1];
        char y1[MAX_DIGS_DOUBLE+MAX_DOUBLE_PRECISION+1];
        char y2[MAX_DIGS_DOUBLE+MAX_DOUBLE_PRECISION+1];
@@ -118,10 +108,10 @@ drawPoint(char *output, LWPOINT *lwp, LAYERSTYLE style) {
        trim_trailing_zeros(x);
        sprintf(y1, "%f", p.y);
        trim_trailing_zeros(y1);
-       sprintf(y2, "%f", p.y + style.pointSize);
+       sprintf(y2, "%f", p.y + styles->pointSize);
        trim_trailing_zeros(y2);
                
-       ptr += sprintf(ptr, "-fill %s -strokewidth 5 ", style.pointColor);
+       ptr += sprintf(ptr, "-fill %s -strokewidth 0 ", styles->pointColor);
        ptr += sprintf(ptr, "-draw \"circle %s,%s %s,%s", x, y1, x, y2);
        ptr += sprintf(ptr, "'\" ");
        
@@ -138,11 +128,10 @@ drawPoint(char *output, LWPOINT *lwp, LAYERSTYLE style) {
  * @return the numbers of character written to *output
  */
 static size_t
-drawLineString(char *output, LWLINE *lwl, LAYERSTYLE style) {
-       LWDEBUGF( 4, "%s", "enter drawLineString" );
+drawLineString(char *output, LWLINE *lwl, LAYERSTYLE *style) {
        char *ptr = output;
 
-       ptr += sprintf(ptr, "-fill none -stroke %s -strokewidth %d ", style.lineColor, style.lineWidth);
+       ptr += sprintf(ptr, "-fill none -stroke %s -strokewidth %d ", style->lineColor, style->lineWidth);
        ptr += sprintf(ptr, "-draw \"stroke-linecap round stroke-linejoin round path 'M ");
        ptr += pointarrayToString(ptr, lwl->points );
        ptr += sprintf(ptr, "'\" ");
@@ -160,13 +149,11 @@ drawLineString(char *output, LWLINE *lwl, LAYERSTYLE style) {
  * @return the numbers of character written to *output
  */
 static size_t
-drawPolygon(char *output, LWPOLY *lwp, LAYERSTYLE style) {
-       LWDEBUGF( 4, "%s", "enter drawPolygon" );
-       
+drawPolygon(char *output, LWPOLY *lwp, LAYERSTYLE *style) {    
        char *ptr = output;
        int i;
 
-       ptr += sprintf(ptr, "-fill %s -stroke %s -strokewidth %d ", style.polygonFillColor, style.polygonStrokeColor, style.polygonStrokeWidth );
+       ptr += sprintf(ptr, "-fill %s -stroke %s -strokewidth %d ", style->polygonFillColor, style->polygonStrokeColor, style->polygonStrokeWidth );
        ptr += sprintf(ptr, "-draw \"path '");
        for (i=0; i<lwp->nrings; i++) {
                ptr += sprintf(ptr, "M ");
@@ -188,29 +175,27 @@ drawPolygon(char *output, LWPOLY *lwp, LAYERSTYLE style) {
  * @return the numbers of character written to *output
  */
 static size_t
-drawGeometry(char *output, LWGEOM *lwgeom, LAYERSTYLE style ) {
-       LWDEBUGF( 4, "%s", "enter drawGeometry" );
+drawGeometry(char *output, LWGEOM *lwgeom, LAYERSTYLE *styles ) {
        char *ptr = output;
        int i;
        int type = lwgeom_getType(lwgeom->type);        
                                
-       LWDEBUGF( 4, "switching on %d", type );
        switch(type) {
                case POINTTYPE:
-                       ptr += drawPoint(ptr, (LWPOINT*)lwgeom, style );
+                       ptr += drawPoint(ptr, (LWPOINT*)lwgeom, styles );
                        break;
                case LINETYPE:
-                       ptr += drawLineString(ptr, (LWLINE*)lwgeom, style );
+                       ptr += drawLineString(ptr, (LWLINE*)lwgeom, styles );
                        break;
                case POLYGONTYPE:
-                       ptr += drawPolygon(ptr, (LWPOLY*)lwgeom, style );
+                       ptr += drawPolygon(ptr, (LWPOLY*)lwgeom, styles );
                        break;
                case MULTIPOINTTYPE:
                case MULTILINETYPE:
                case MULTIPOLYGONTYPE:
                case COLLECTIONTYPE:
                        for (i=0; i<((LWCOLLECTION*)lwgeom)->ngeoms; i++) {
-                               ptr += drawGeometry( ptr, lwcollection_getsubgeom ((LWCOLLECTION*)lwgeom, i), style );
+                               ptr += drawGeometry( ptr, lwcollection_getsubgeom ((LWCOLLECTION*)lwgeom, i), styles );
                        }
                        break;
         }
@@ -226,12 +211,14 @@ drawGeometry(char *output, LWGEOM *lwgeom, LAYERSTYLE style ) {
  */
 static void
 addDropShadow(int layerNumber) {
-       char str[129];
+       // TODO: change to properly sized string
+       char str[512];
        sprintf(
                str, 
                "convert tmp%d.png -gravity center \\( +clone -background navy -shadow 100x3+4+4 \\) +swap -background none -flatten tmp%d.png", 
                layerNumber, layerNumber);
        system(str);
+       LWDEBUGF(4, "%s", str);
 }
 
 /**
@@ -242,12 +229,30 @@ addDropShadow(int layerNumber) {
  */
 static void
 addHighlight(int layerNumber) {
-       char str[129];
+       // TODO: change to properly sized string
+       char str[512];
        sprintf(
                str, 
-               "convert tmp%d.png  -fx A +matte -blur 1x1  -shade 120x45  -normalize tmp%d.png  -compose Overlay -composite tmp%d.png  -matte  -compose Dst_In  -composite tmp%d.png", 
-               layerNumber, layerNumber, layerNumber, layerNumber);
+               "convert tmp%d.png \\( +clone -channel A -separate +channel -negate -background black -virtual-pixel background -blur 0x3 -shade 120x55 -contrast-stretch 0%% +sigmoidal-contrast 7x50%% -fill grey50 -colorize 10%% +clone +swap -compose overlay -composite \\) -compose In -composite tmp%d.png", 
+               layerNumber, layerNumber);
+       system(str);
+       LWDEBUGF(4, "%s", str);
+}
+
+/**
+ * Invokes a system call to ImageMagick's "convert" command that reduces  
+ * the overall filesize
+ * 
+ * @param filename the current working image.
+ */
+static void
+optimizeImage(char* filename) {
+       char *str;
+       str = malloc( (18 + (2*strlen(filename)) + 1) * sizeof(char) );
+       sprintf(str, "convert %s -depth 8 %s", filename, filename);
        system(str);
+       LWDEBUGF(4, "%s", str);
+       free(str);
 }
 
 /**
@@ -258,12 +263,40 @@ flattenLayers(char* filename) {
        char *str;
        str = malloc( (48 + strlen(filename) + 1) * sizeof(char) );
        sprintf(str, "convert tmp[0-9].png -background none -flatten %s", filename);
+       
+       LWDEBUGF(4, "%s", str);
        system(str);
-       system("rm -f tmp[0-9].png");
+       // TODO: only remove the tmp files if they exist.
+       remove("tmp0.png");
+       remove("tmp1.png");
+       remove("tmp2.png");
+       remove("tmp3.png");
+       remove("tmp4.png");
+       remove("tmp5.png");
        free(str);
 }
 
 
+// TODO: comments
+int
+getStyleName(char **styleName, char* line) {
+       char *ptr = strrchr(line, ';');
+       if (ptr == NULL) {
+               *styleName = malloc( 8 );
+               strncpy(*styleName, "Default", 7);
+               (*styleName)[7] = '\0';
+               return 1;
+       }
+       else {
+               *styleName = malloc( ptr - line + 1);
+               strncpy(*styleName, line, ptr - line);
+               (*styleName)[ptr - line] = '\0';
+               LWDEBUGF( 4, "%s", *styleName );
+               return 0;
+       }
+}
+
+
 /**
  * Main Application.  Currently, drawing styles are hardcoded in this method.
  * Future work may entail reading the styles from a .properties file.
@@ -275,35 +308,12 @@ int main( int argc, const char* argv[] ) {
        char *filename;
        int layerCount;
        int styleNumber;
-       LAYERSTYLE styles[3];
-       
-       styles[0].pointSize = 6;
-       styles[0].pointColor = "Blue";
-       styles[0].lineWidth = 7;
-       styles[0].lineColor = "Blue";
-       styles[0].polygonFillColor = "Blue";
-       styles[0].polygonStrokeColor = "Blue";
-       styles[0].polygonStrokeWidth = 1;
-       
-       styles[1].pointSize = 6;
-       styles[1].pointColor = "Green";
-       styles[1].lineWidth = 7;
-       styles[1].lineColor = "Green";
-       styles[1].polygonFillColor = "Green";
-       styles[1].polygonStrokeColor = "Green";
-       styles[1].polygonStrokeWidth = 1;
-       
-       styles[2].pointSize = 6;
-       styles[2].pointColor = "Red";
-       styles[2].lineWidth = 7;
-       styles[2].lineColor = "Red";
-       styles[2].polygonFillColor = "Red";
-       styles[2].polygonStrokeColor = "Red";
-       styles[2].polygonStrokeWidth = 1;
+       LAYERSTYLE *styles;
        
+       getStyles(&styles);
                
        if ( argc != 2 ) {
-               printf("You must specifiy a wkt filename to convert.\n");
+               lwerror("You must specifiy a wkt filename to convert.\n");
                return -1;
        }
        
@@ -312,27 +322,36 @@ int main( int argc, const char* argv[] ) {
                return -1;
        }
                
-       filename = malloc( (strlen(argv[1])+8) * sizeof(char) );
-       strcpy( filename, "../images/" );
+       filename = malloc( strlen(argv[1])+11 );
+       strncpy( filename, "../images/", 10 );
        strncat( filename, argv[1], strlen(argv[1])-3 );
-       strcat( filename, "png" );
+       strncat( filename, "png", 3 );
        
        printf( "generating %s\n", filename );
        
        layerCount = 0;
-       while ( fgets ( line, sizeof line, pfile ) != NULL ) {          
+       while ( fgets ( line, sizeof line, pfile ) != NULL && !isspace(*line) ) {       
                
-               char output [2048];
+               char output[2048];
                char *ptr = output;
+               char *styleName;
+               int useDefaultStyle;
+               
                ptr += sprintf( ptr, "convert -size %s xc:none ", imageSize );
-       
-               lwgeom = lwgeom_from_ewkt( line, PARSER_CHECK_NONE );
+               
+               useDefaultStyle = getStyleName(&styleName, line);
+               LWDEBUGF( 4, "%s", styleName );
+               
+               if (useDefaultStyle) {
+                       printf("   Warning: using Default style for layer %d\n", layerCount);
+                       lwgeom = lwgeom_from_ewkt( line, PARSER_CHECK_NONE );
+               }
+               else 
+                       lwgeom = lwgeom_from_ewkt( line+strlen(styleName)+1, PARSER_CHECK_NONE );
                LWDEBUGF( 4, "geom = %s", lwgeom_to_ewkt((LWGEOM*)lwgeom,0) );
                
-               styleNumber = layerCount % 3;
-               LWDEBUGF( 4, "using style %d", styleNumber );
-               ptr += drawGeometry( ptr, lwgeom, styles[styleNumber] );
-               LWDEBUGF( 4, "%s", "after drawGeometry" );
+               styleNumber = layerCount % length(styles);
+               ptr += drawGeometry( ptr, lwgeom, getStyle(styles, styleName) );
                
                ptr += sprintf( ptr, "-flip tmp%d.png", layerCount );
                 
@@ -341,15 +360,17 @@ int main( int argc, const char* argv[] ) {
                LWDEBUGF( 4, "%s", output );
                system(output);
                
-               addHighlight( layerCount );
-               addDropShadow( layerCount );
+               addHighlight( layerCount );     
+               addDropShadow( layerCount );    
                layerCount++;
+               free(styleName);
        }
        
-       LWDEBUGF(4, "%s", filename);
        flattenLayers(filename);
+       optimizeImage(filename);
        
        fclose(pfile);
        free(filename);
+       freeStyles(&styles);
        return 0;
 }
index 416decee46f466a00ef2ad501f167e754def5469..f95562f4d7e340cb22432c1891136b4827b30a38 100644 (file)
@@ -1,2 +1,3 @@
-MULTIPOINT ( 8 24, 10 92, 12 154, 17 68, 28 10, 29 52, 29 84, 55 50, 56 24, 131 14, 160 180, 189 180 )\r
-POINT(60.3333333333333 77.6666666666667)
\ No newline at end of file
+Style1;MULTIPOINT ( 8 24, 10 92, 12 154, 17 68, 28 10, 29 52, 29 84, 55 50, 56 24, 131 14, 160 180, 189 180 )
+Style2;POINT(60.3333333333333 77.6666666666667)
+
index 9833dccdf76201d7c0536f4880f9345590b1360a..12b2025b1e4bbbefffdade74bd2e4061cb9fe1e4 100644 (file)
@@ -1,2 +1,3 @@
-LINESTRING ( 190 160, 10 190, 40 90, 20 70, 10 10, 30 40, 30 10, 110 40, 70 10, 110 10, 140 40, 140 10, 160 30, 180 10 )
-POINT(76.1907245453253 79.8755933886095)
\ No newline at end of file
+Style1;LINESTRING ( 190 160, 10 190, 40 90, 20 70, 10 10, 30 40, 30 10, 110 40, 70 10, 110 10, 140 40, 140 10, 160 30, 180 10 )
+Style2;POINT(76.1907245453253 79.8755933886095)
+
index 59b2326c3bd2bb20afed890a81a65707d758eefd..44050206afeb39423543e5d6d371280ba543aa79 100644 (file)
@@ -1,2 +1,3 @@
-POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))
-POINT(80.2508960573477 113.405017921147)
\ No newline at end of file
+Style1;POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))
+Style2;POINT(80.2508960573477 113.405017921147)
+
index f74d61b81921e5d723daa2770870ed12ce1a51fd..54e95e3d830696cd8cb353396d8e076ec91a1395 100644 (file)
@@ -1,2 +1,3 @@
-GEOMETRYCOLLECTION ( POLYGON (( 190 170, 180 100, 80 140, 80 160, 130 160, 110 180, 110 190, 180 180, 190 170 )), LINESTRING ( 80 120, 120 20, 140 70, 150 30, 180 50, 190 10 ), MULTIPOINT ( 19 150, 22 49, 30 13, 32 101, 45 35, 67 88, 75 16 ))
-POINT(143.361344537815 148.263305322129)
\ No newline at end of file
+Style1;GEOMETRYCOLLECTION ( POLYGON (( 190 170, 180 100, 80 140, 80 160, 130 160, 110 180, 110 190, 180 180, 190 170 )), LINESTRING ( 80 120, 120 20, 140 70, 150 30, 180 50, 190 10 ), MULTIPOINT ( 19 150, 22 49, 30 13, 32 101, 45 35, 67 88, 75 16 ))
+Style2;POINT(143.361344537815 148.263305322129)
+
index 4fdc5b8fd11348d50afa85b70f58ac184fcde70f..b97bbe230ebc73487458392929c892874a9bb68d 100644 (file)
@@ -1,2 +1,3 @@
-LINESTRING ( 10 190, 60 80, 130 120, 190 10 )
-MULTIPOINT ( 80 170, 120 13, 130 119, 181 142 )
\ No newline at end of file
+Style1;LINESTRING ( 10 190, 60 80, 130 120, 190 10 )
+Style2;MULTIPOINT ( 80 170, 120 13, 130 119, 181 142 )
+
index 8f0c81be96a95f93b0d9996ccd29fd0f736c8ae1..eeaec912766da2d0bd8bc8466db75bbcbadff5d1 100644 (file)
@@ -1,2 +1,3 @@
-POLYGON (( 10 190, 20 10, 90 20, 110 70, 80 130, 10 190 ))
-MULTIPOINT ( 56 60, 94 172, 128 125, 145 44, 172 173 )
\ No newline at end of file
+Style1;POLYGON (( 30 190, 10 100, 10 10, 90 20, 110 70, 80 130, 30 190 ))
+Style2;MULTIPOINT ( 56 60, 120 13, 130 119, 181 142 )
+
index 6799a5d7dc04e9b03308e24dab5194279b021cf2..3301398516286a5df98228abc819190b6a742814 100644 (file)
@@ -1,2 +1,3 @@
-POLYGON (( 10 190, 20 10, 90 20, 110 70, 80 130, 10 190 ))
-LINESTRING ( 30 40, 70 50, 120 150, 190 190 )
\ No newline at end of file
+Style1;POLYGON (( 30 190, 10 100, 10 10, 90 20, 110 70, 80 130, 30 190 ))
+Style2;LINESTRING ( 30 40, 70 50, 120 150, 190 190 )
+
index 221a798f8a3b8e32b90591695f9fe97f8adb02ee..95953310bdc7075fbe6502bf72bde31203cd86a0 100644 (file)
@@ -1,2 +1,3 @@
-LINESTRING ( 10 190, 60 110, 110 120, 190 10 )
-LINESTRING ( 10 10, 70 30, 110 120, 190 190 )
+Style1;LINESTRING ( 10 190, 60 80, 130 120, 190 10 )
+Style2;LINESTRING ( 10 10, 70 30, 110 120, 190 190 )
+
index 4af1d5a1976eb9312b59716581e1364c8f0ab02f..a1006195b8feb99b2824b43e5c4c2edb99e400b7 100644 (file)
@@ -1 +1 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 10 190, 140 130, 70 80, 190 10 ), POINT(10 190), POINT(190 10) )
+Style1;GEOMETRYCOLLECTION ( LINESTRING ( 10 190, 140 130, 70 80, 190 10 ), POINT(10 190), POINT(190 10) )
index fb68f5966a547d8202f9c915166c12aecfd50dde..72b711772c711422e6ec3cba6c69f55861fe7aa3 100644 (file)
@@ -1 +1,2 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 10 190, 130 40, 170 160, 10 10 ), POINT(10 190), POINT(10 10) )
+Style1;GEOMETRYCOLLECTION ( LINESTRING ( 10 190, 130 40, 170 160, 10 10 ), POINT(10 190), POINT(10 10) )
+
index cdcf5dcc2bdcc73820a2ae571d9c9411aea382f5..5931363f7ce0bea910f33317857edbfd3e12808c 100644 (file)
@@ -1 +1,2 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 90 190, 120 190, 130 140, 190 50, 70 10, 10 70, 10 150, 90 190 ), POINT(90 190) )
+Style1;GEOMETRYCOLLECTION ( LINESTRING ( 90 190, 120 190, 130 140, 190 50, 70 10, 10 70, 10 150, 90 190 ), POINT(90 190) )
+
index 31221f0679fba72a07f6af8e07dd4030b8798399..937d04dfeb0efef9e8c56f7f17369c643c10b412 100644 (file)
@@ -1 +1,2 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 90 190, 120 190, 50 60, 130 10, 190 50, 160 90, 10 150, 90 190 ), POINT(90 190) )
+Style1;GEOMETRYCOLLECTION ( LINESTRING ( 90 190, 120 190, 50 60, 130 10, 190 50, 160 90, 10 150, 90 190 ), POINT(90 190) )
+
index 296f3e66506e3e53d8d2e6c08323bd1bbef83202..aa870d0ccb17feb7734ea9aab7070d0bb5d36185 100644 (file)
@@ -1 +1,2 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 30 190, 60 60, 170 10 ), LINESTRING ( 100 190, 180 150, 160 70 ), MULTIPOINT ( 30 190, 170 10, 100 190, 160 70 ) )
+Style1;GEOMETRYCOLLECTION ( LINESTRING ( 30 190, 60 60, 170 10 ), LINESTRING ( 100 190, 180 150, 160 70 ), MULTIPOINT ( 30 190, 170 10, 100 190, 160 70 ) )
+
index 31f3a8e6d6c3a5eac09829f1b23a3b862e13aaa0..6ae475b0b83af06b538bd9bc6764c5ffe1982d76 100644 (file)
@@ -1 +1,2 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 30 190, 60 60, 170 10 ), LINESTRING ( 30 190, 180 150, 160 70 ), MULTIPOINT( 170 10, 30 190, 170 10 ) )
+Style1;GEOMETRYCOLLECTION ( LINESTRING ( 30 190, 60 60, 170 10 ), LINESTRING ( 30 190, 180 150, 160 70 ), MULTIPOINT( 170 10, 30 190, 170 10, 160 70 ) )
+
index 684e6fbe8e58ff4e5cb346f0b333124d9a31f942..70d751c637337fc98c255a282f1da5ff4e5d9306 100644 (file)
@@ -1 +1,2 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 30 190, 60 60, 170 10 ), LINESTRING (100 190, 180 150, 80 10), MULTIPOINT( 30 190, 170 10, 100 190, 80 10 ) )
+Style1;GEOMETRYCOLLECTION ( LINESTRING ( 30 190, 60 60, 170 10 ), LINESTRING (100 190, 180 150, 80 10), MULTIPOINT( 30 190, 170 10, 100 190, 80 10 ) )
+
index 99d45f12c77323ad66da4a7cdf0e2b0f42a65bb9..fe8eba6254fd7fd1a68a3a4dc752cc96d5fd2e46 100644 (file)
@@ -1 +1,2 @@
-POLYGON ((10 140, 90 190, 130 170, 190 60, 160 10, 50 20, 10 140), (50 100, 70 80, 110 100, 110 140, 50 100))
+Style1;POLYGON ((10 140, 90 190, 130 170, 190 60, 160 10, 50 20, 10 140), (50 100, 70 80, 110 100, 110 140, 50 100))
+
index ab279131d157955d39bc1086e55f1af27b5120c5..b77609a6ad4e1e0ff3cba63b50727b1fcf29005f 100644 (file)
@@ -1 +1,2 @@
-POLYGON ((10 140, 90 190, 130 170, 190 60, 160 10, 50 20, 10 140), (190 60, 140 40, 110 60, 120 90, 190 60))
+Style1;POLYGON ((10 140, 90 190, 130 170, 190 60, 160 10, 50 20, 10 140), (190 60, 140 40, 110 60, 120 90, 190 60))
+
index 451a350be3d886728600cbabff71d38e1e4daebb..07f9393db65763c6c5109b14ac392f6eefa53907 100644 (file)
@@ -1 +1,2 @@
-POLYGON ((10 140, 90 190, 130 170, 190 60, 160 10, 50 20, 10 140), (130 170, 10 140, 50 120, 110 110, 130 170))
+Style1;POLYGON ((10 140, 90 190, 130 170, 190 60, 160 10, 50 20, 10 140), (130 170, 10 140, 50 120, 110 110, 130 170))
+
index 2cfe45b4e7d6732d7582958f11ee57284396e9f4..fb162135fd98cc48a5cd5c579de902c20767c501 100644 (file)
@@ -1 +1,2 @@
-POLYGON ((10 140, 90 190, 130 170, 190 60, 160 10, 50 20, 10 140), (90 189, 10 139, 80 110, 110 130, 90 189))
+Style1;POLYGON ((10 140, 90 190, 130 170, 190 60, 160 10, 50 20, 10 140), (90 189, 10 139, 80 110, 110 130, 90 189))
+
index 9e6bf315209509c30dc92aac502a170504d95f92..1c99d080803d62f16ba00fc04534001c6bc9ab0b 100644 (file)
@@ -1 +1,2 @@
-POLYGON (( 10 100, 60 140, 60 190, 62 190, 62 157, 130 170, 190 60, 160 10, 50 20, 10 100 ))
+Style1;POLYGON (( 10 100, 60 140, 60 190, 61 190, 61 157, 130 170, 190 60, 160 10, 50 20, 10 100 ))
+
diff --git a/doc/html/image_src/st_isvalid06.wkt b/doc/html/image_src/st_isvalid06.wkt
new file mode 100644 (file)
index 0000000..4a6b4a6
--- /dev/null
@@ -0,0 +1,2 @@
+Style1-thinline;GEOMETRYCOLLECTION (POLYGON (( 10 40, 10 100, 130 130, 190 80, 140 20, 50 10, 10 40 )), LINESTRING ( 81 143, 103 143, 112 162, 107 175, 89 183, 71 169, 81 143 ))
+
diff --git a/doc/html/image_src/st_isvalid07.wkt b/doc/html/image_src/st_isvalid07.wkt
new file mode 100644 (file)
index 0000000..cbcb298
--- /dev/null
@@ -0,0 +1,2 @@
+Style1;GEOMETRYCOLLECTION (POLYGON (( 10 40, 29 118, 120 118, 180 88, 140 30, 70 10, 10 40 )), POLYGON (( 50 170, 100 190, 160 180, 180 140, 180 90, 120 120, 30 120, 50 170 )))
+
diff --git a/doc/html/image_src/st_isvalid08.wkt b/doc/html/image_src/st_isvalid08.wkt
new file mode 100644 (file)
index 0000000..30306da
--- /dev/null
@@ -0,0 +1,2 @@
+Style1-thinline;GEOMETRYCOLLECTION (POLYGON (( 10 40, 42 93, 113 105, 180 86, 140 30, 70 10, 10 40 )), POLYGON (( 50 170, 100 190, 138 182, 149 156, 146 137, 113 129, 58 140, 50 170 )), LINESTRING ( 113 105, 113 129 ))
+
diff --git a/doc/html/image_src/st_touches01.wkt b/doc/html/image_src/st_touches01.wkt
new file mode 100644 (file)
index 0000000..382f31e
--- /dev/null
@@ -0,0 +1,2 @@
+Style1;POLYGON (( 10 190, 10 70, 80 70, 80 130, 50 160, 120 160, 120 190, 10 190 ))
+Style2;POLYGON (( 81 110, 140 140, 190 110, 180 40, 140 10, 81 50, 81 70, 81 110 ))
diff --git a/doc/html/image_src/st_touches02.wkt b/doc/html/image_src/st_touches02.wkt
new file mode 100644 (file)
index 0000000..0b209a8
--- /dev/null
@@ -0,0 +1,2 @@
+Style1;POLYGON (( 10 190, 10 70, 80 70, 80 130, 50 160, 120 160, 120 190, 10 190 ))
+Style2;POLYGON (( 140 140, 190 110, 180 40, 140 10, 80 70, 140 140 ))
diff --git a/doc/html/image_src/st_touches03.wkt b/doc/html/image_src/st_touches03.wkt
new file mode 100644 (file)
index 0000000..f568fcf
--- /dev/null
@@ -0,0 +1,2 @@
+Style1;POLYGON ((80 10, 50 40, 50 90, 80 130, 140 120, 160 70, 140 30, 80 10))
+Style2;LINESTRING (30 190, 180 150, 160 70)
\ No newline at end of file
diff --git a/doc/html/image_src/st_touches04.wkt b/doc/html/image_src/st_touches04.wkt
new file mode 100644 (file)
index 0000000..02df54d
--- /dev/null
@@ -0,0 +1,2 @@
+Style1;LINESTRING ( 10 10, 60 140, 140 190 )
+Style2;LINESTRING ( 140 190, 190 10 )
diff --git a/doc/html/image_src/st_touches05.wkt b/doc/html/image_src/st_touches05.wkt
new file mode 100644 (file)
index 0000000..c52982d
--- /dev/null
@@ -0,0 +1,2 @@
+Style1;LINESTRING ( 10 10, 60 140, 140 190 )
+Style2;LINESTRING ( 60 140, 190 10 )
diff --git a/doc/html/image_src/st_touches06.wkt b/doc/html/image_src/st_touches06.wkt
new file mode 100644 (file)
index 0000000..b871749
--- /dev/null
@@ -0,0 +1,2 @@
+Style1;POLYGON (( 30 30, 10 110, 40 190, 120 170, 180 180, 170 100, 130 10, 30 30 ))
+Style2;POINT ( 170 100 )
diff --git a/doc/html/image_src/styles.c b/doc/html/image_src/styles.c
new file mode 100644 (file)
index 0000000..84a9095
--- /dev/null
@@ -0,0 +1,175 @@
+/**********************************************************************
+ * $Id: generator.c 3967 2009-05-04 16:48:11Z kneufeld $
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * 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>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "styles.h"
+
+
+void
+getStyles( LAYERSTYLE **headRef ) {
+       char line [128];
+       FILE* pFile;
+       char *getResults;
+
+       *headRef = NULL;
+       
+       if ((pFile = fopen("styles.conf", "r")) == NULL) {
+               perror ( "styles.properties: No such file or directory" );
+               return;
+       }       
+
+       getResults = fgets ( line, sizeof line, pFile );
+       while ( getResults != NULL ) {
+               
+               // process defined styles
+               while ( (getResults != NULL) && strncmp(line, "[Style]", 7) == 0)  {
+                       char *styleName = "DefaultStyle";
+                       int pointSize = 5;
+                       char *pointColor = "Grey";
+                       int lineWidth = 5;
+                       char *lineColor = "Grey";
+                       char *polygonFillColor = "Grey";
+                       char *polygonStrokeColor = "Grey";
+                       int polygonStrokeWidth = 0;
+                       
+                       getResults = fgets ( line, sizeof line, pFile );
+                       while ( (getResults != NULL) && (strncmp(line, "[Style]", 7) != 0) ) {
+                               char *ptr;
+                               
+                               // loop over all lines until [Style] is reached again   
+                               if ( (*line != '#') && (ptr = strchr(line, '=')) ) {
+                                       ptr = trim((++ptr));
+                                       
+                                       if (strncmp(line, "styleName", 9) == 0) 
+                                               styleName = ptr;
+                                       else if (strncmp(line, "pointSize", 9) == 0) {
+                                               pointSize = atoi(ptr);
+                                               free(ptr);
+                                       }
+                                       else if (strncmp(line, "pointColor", 10) == 0) 
+                                               pointColor = ptr;
+                                       else if (strncmp(line, "lineWidth", 9) == 0) {
+                                               lineWidth = atoi(ptr);
+                                               free(ptr);
+                                       }
+                                       else if (strncmp(line, "lineColor", 9) == 0) 
+                                               lineColor = ptr;
+                                       else if (strncmp(line, "polygonFillColor", 16) == 0) 
+                                               polygonFillColor = ptr;
+                                       else if (strncmp(line, "polygonStrokeColor", 18) == 0) 
+                                               polygonStrokeColor = ptr;
+                                       else if (strncmp(line, "polygonStrokeWidth", 18) == 0) {
+                                               polygonStrokeWidth = atoi(ptr);
+                                               free(ptr);
+                                       }
+                                       
+                               }       
+                               getResults = fgets ( line, sizeof line, pFile );
+                       }
+                       
+                       addStyle(headRef, styleName, pointSize, pointColor, lineWidth, lineColor, polygonFillColor, polygonStrokeColor, polygonStrokeWidth);
+               }
+               
+               getResults = fgets ( line, sizeof line, pFile );
+       }
+               
+       fclose( pFile );
+}
+
+
+void 
+freeStyles( LAYERSTYLE **headRef ) {
+       LAYERSTYLE *curr = *headRef;
+       LAYERSTYLE *next;
+       
+       while (curr != NULL) {
+               next = curr->next;
+               free(curr->styleName);
+               free(curr->pointColor);
+               free(curr->lineColor);
+               free(curr->polygonFillColor);
+               free(curr->polygonStrokeColor);
+               free(curr);
+               curr = next;
+       }
+       
+       *headRef = NULL;
+}
+
+
+void 
+addStyle(
+               LAYERSTYLE **headRef, 
+               char* styleName, 
+               int pointSize, char* pointColor, 
+               int lineWidth, char* lineColor, 
+               char* polygonFillColor, char* polygonStrokeColor, int polygonStrokeWidth) {
+       LAYERSTYLE *style = malloc( sizeof(LAYERSTYLE) );
+       
+       style->styleName = styleName;
+       style->pointSize = pointSize;
+       style->pointColor = pointColor;
+       style->lineWidth = lineWidth;
+       style->lineColor = lineColor;
+       style->polygonFillColor = polygonFillColor;
+       style->polygonStrokeColor = polygonStrokeColor;
+       style->polygonStrokeWidth = polygonStrokeWidth;
+       style->next = *headRef;
+       *headRef = style;
+}
+
+
+int 
+length( LAYERSTYLE *head ) {
+       int count = 0;
+       LAYERSTYLE *curr = head;
+       
+       while (curr != NULL) {
+               count++;
+               curr = curr->next;
+       }
+       
+       return (count);
+}
+
+
+LAYERSTYLE* 
+getStyle( LAYERSTYLE *headRef, char* styleName ) {
+       LAYERSTYLE *curr = headRef;
+       
+       while (curr != NULL && (strcmp(curr->styleName, styleName) != 0)) 
+               curr = curr->next;
+       
+       return (curr);
+}
+
+
+char*
+trim(char* str) {
+       int len;
+       char* result;
+       char* start = str;
+       char* end = strchr(start, '\0');
+       while (start<end && isspace(*start)) start++;
+       while (start<end && isspace(*(end-1))) end--;
+       len = end-start;
+       result = malloc( len+1 );
+       strncpy(result, start, len);
+       result[len] = '\0';
+       return result;
+}
diff --git a/doc/html/image_src/styles.conf b/doc/html/image_src/styles.conf
new file mode 100644 (file)
index 0000000..423bd54
--- /dev/null
@@ -0,0 +1,53 @@
+# This file describes the styles used to render the png images
+# The styleName attribute for every style should be unique.
+#
+# To use a style, prefix the wkt string with the styleName;  i.e. 
+#    Style1;POINT(50 50)
+#
+#    convert -list color
+
+[Style]
+# The default style if no style is specified.
+styleName = Default
+pointSize = 6
+pointColor = Grey
+lineWidth = 7
+lineColor = Grey
+polygonFillColor = Grey
+polygonStrokeColor = Grey
+polygonStrokeWidth = 0
+
+[Style]
+# The bottom layer in the rendered WKT image
+styleName = Style1
+pointSize = 6
+pointColor = '#00bfff'
+lineWidth = 7
+lineColor = '#00bfff'
+polygonFillColor = '#00bfff'
+polygonStrokeColor = '#00bfff'
+polygonStrokeWidth = 0
+
+[Style]
+# The bottom layer in the rendered WKT image
+styleName = Style1-thinline
+pointSize = 6
+pointColor = '#00bfff'
+lineWidth = 3
+lineColor = '#00bfff'
+polygonFillColor = '#00bfff'
+polygonStrokeColor = '#00bfff'
+polygonStrokeWidth = 0
+
+
+[Style]
+# The second layer in the rendered WKT image
+styleName = Style2
+pointSize = 6
+pointColor = DarkSeaGreen4
+lineWidth = 7
+lineColor = DarkSeaGreen4
+polygonFillColor = DarkSeaGreen4
+polygonStrokeColor = DarkGreen
+polygonStrokeWidth = 0
+
diff --git a/doc/html/image_src/styles.h b/doc/html/image_src/styles.h
new file mode 100644 (file)
index 0000000..ab3f4b7
--- /dev/null
@@ -0,0 +1,42 @@
+/**********************************************************************
+ * $Id: generator.c 3967 2009-05-04 16:48:11Z kneufeld $
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * 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: add descriptions
+ **********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct layerStyle LAYERSTYLE;
+
+struct layerStyle {    
+       char *styleName; // A unique name 
+       
+       int       pointSize;
+       char *pointColor;
+       
+       int   lineWidth;
+       char *lineColor;
+       
+       char *polygonFillColor;
+       char *polygonStrokeColor;
+       int   polygonStrokeWidth;
+       
+       LAYERSTYLE *next;
+};
+
+void getStyles( 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 );
+
+int length( LAYERSTYLE *headRef );
+LAYERSTYLE* getStyle( LAYERSTYLE *headRef, char* styleName );
+char* trim(char* str);
index fc1a695b0047eb4a1df91d5f354d925b007f4394..c8e73a87dd8da8e18781a1f91ba9b8957938eb83 100644 (file)
@@ -9433,7 +9433,7 @@ FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
                          <entry><para><informalfigure>
                                  <mediaobject>
                                        <imageobject>
-                                         <imagedata fileref="images/st_crosses01.gif" />
+                                         <imagedata fileref="images/st_crosses01.png" />
                                        </imageobject>
 
                                        <caption><para><varname>MULTIPOINT</varname> / <varname>LINESTRING</varname></para></caption>
@@ -9443,7 +9443,7 @@ FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
                          <entry><para><informalfigure>
                                  <mediaobject>
                                        <imageobject>
-                                         <imagedata fileref="images/st_crosses02.gif" />
+                                         <imagedata fileref="images/st_crosses02.png" />
                                        </imageobject>
 
                                        <caption><para><varname>MULTIPOINT</varname> / <varname>POLYGON</varname></para></caption>
@@ -9455,7 +9455,7 @@ FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
                          <entry><para><informalfigure>
                                  <mediaobject>
                                        <imageobject>
-                                         <imagedata fileref="images/st_crosses03.gif" />
+                                         <imagedata fileref="images/st_crosses03.png" />
                                        </imageobject>
 
                                        <caption><para><varname>LINESTRING</varname> / <varname>POLYGON</varname></para></caption>
@@ -9465,7 +9465,7 @@ FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
                          <entry><para><informalfigure>
                                  <mediaobject>
                                        <imageobject>
-                                         <imagedata fileref="images/st_crosses04.gif" />
+                                         <imagedata fileref="images/st_crosses04.png" />
                                        </imageobject>
 
                                        <caption><para><varname>LINESTRING</varname> / <varname>LINESTRING</varname></para></caption>