]> granicus.if.org Git - postgis/commitdiff
removed horrible dos carriage returns
authorKevin Neufeld <kneufeld.ca@gmail.com>
Wed, 6 May 2009 23:32:51 +0000 (23:32 +0000)
committerKevin Neufeld <kneufeld.ca@gmail.com>
Wed, 6 May 2009 23:32:51 +0000 (23:32 +0000)
- convert to unix

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

20 files changed:
doc/html/image_src/generator.c
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

index 188db0ccf7c5a69a16d947db0af5b44974d1de44..3d0e34180ace7ac5a16140de9ebae428d7452bf4 100644 (file)
-/**********************************************************************\r
- * $Id: generator.c 3967 2009-05-04 16:48:11Z kneufeld $\r
- *\r
- * PostGIS - Spatial Types for PostgreSQL\r
- * http://postgis.refractions.net\r
- * Copyright 2008 Kevin Neufeld\r
- *\r
- * This is free software; you can redistribute and/or modify it under\r
- * the terms of the GNU General Public Licence. See the COPYING file.\r
- *\r
- * This program will generate a .png image for every .wkt file specified \r
- * in this directory's Makefile.  Every .wkt file may contain several \r
- * entries of geometries represented as WKT strings.  Every line in \r
- * a wkt file is stylized using a predetermined style (line thinkness, \r
- * fill color, etc) currently hard coded in this programs main function.\r
- *\r
- * In order to generate a png file, ImageMagicK must be installed in the\r
- * user's path as system calls are invoked to "convert".  In this manner,\r
- * WKT files are converted into SVG syntax and rasterized as png.  (PostGIS's\r
- * internal SVG methods could not be used dues to syntax issues with ImageMagick)\r
- *\r
- * The goal of this application is to dynamically generate all the spatial\r
- * pictures used in PostGIS's documentation pages.\r
- *\r
- * Note: the coordinates of the supplied geometries should be within the x-y range \r
- * of 200, otherwise they will appear outside of the generated image.\r
- * \r
- **********************************************************************/\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include "CUnit/Basic.h"\r
-\r
-#include "lwalgorithm.h"\r
-\r
-#define SHOW_DIGS_DOUBLE 15\r
-#define MAX_DOUBLE_PRECISION 15\r
-#define MAX_DIGS_DOUBLE (SHOW_DIGS_DOUBLE + 2) /* +2 for dot and sign */\r
-\r
-// Some global styling variables\r
-char *imageSize = "200x200";\r
-\r
-typedef struct {       \r
-       int       pointSize;\r
-       char *pointColor;\r
-       \r
-       int   lineWidth;\r
-       char *lineColor;\r
-       \r
-       char *polygonFillColor;\r
-       char *polygonStrokeColor;\r
-       int   polygonStrokeWidth;\r
-} LAYERSTYLE;\r
-\r
-\r
-/**\r
- * Set up liblwgeom to run in stand-alone mode using the \r
- * usual system memory handling functions.\r
- */\r
-void lwgeom_init_allocators(void) {\r
-               /* liblwgeom callback - install default handlers */\r
-               lwgeom_install_default_allocators();\r
-}\r
-\r
-/**\r
- * Writes the coordinates of a POINTARRAY to a char* where ordinates are \r
- * separated by a comma and coordinates by a space so that the coordinate\r
- * pairs can be interpreted by ImageMagick's SVG draw command.\r
- *\r
- * @param output a reference to write the POINTARRAY to\r
- * @param pa a reference to a POINTARRAY\r
- * @return the numbers of character written to *output\r
- */\r
-static size_t \r
-pointarrayToString(char *output, POINTARRAY *pa) {\r
-       char x[MAX_DIGS_DOUBLE+MAX_DOUBLE_PRECISION+1];\r
-       char y[MAX_DIGS_DOUBLE+MAX_DOUBLE_PRECISION+1];\r
-       int i;\r
-       char *ptr = output;\r
-       \r
-       for ( i=0; i < pa->npoints; i++ ) {\r
-               POINT2D pt;\r
-               getPoint2d_p(pa, i, &pt);\r
-               sprintf(x, "%f", pt.x);\r
-               trim_trailing_zeros(x);\r
-               sprintf(y, "%f", pt.y);\r
-               trim_trailing_zeros(y);\r
-               if ( i ) ptr += sprintf(ptr, " ");\r
-               ptr += sprintf(ptr, "%s,%s", x, y);\r
-       }\r
-       \r
-       return (ptr - output);\r
-}\r
-\r
-/**\r
- * Serializes a LWPOINT to a char*.  This is a helper function that partially\r
- * writes the appropriate draw and fill commands used to generate an SVG image\r
- * using ImageMagick's "convert" command.\r
\r
- * @param output a char reference to write the LWPOINT to\r
- * @param lwp a reference to a LWPOINT\r
- * @return the numbers of character written to *output\r
- */\r
-static size_t\r
-drawPoint(char *output, LWPOINT *lwp, LAYERSTYLE style) {\r
-       LWDEBUGF( 4, "%s", "enter drawPoint" );\r
-       \r
-       char x[MAX_DIGS_DOUBLE+MAX_DOUBLE_PRECISION+1];\r
-       char y1[MAX_DIGS_DOUBLE+MAX_DOUBLE_PRECISION+1];\r
-       char y2[MAX_DIGS_DOUBLE+MAX_DOUBLE_PRECISION+1];\r
-       char *ptr = output;\r
-       POINTARRAY *pa = lwp->point;\r
-       POINT2D p;\r
-       getPoint2d_p(pa, 0, &p);\r
-       \r
-       sprintf(x, "%f", p.x);\r
-       trim_trailing_zeros(x);\r
-       sprintf(y1, "%f", p.y);\r
-       trim_trailing_zeros(y1);\r
-       sprintf(y2, "%f", p.y + style.pointSize);\r
-       trim_trailing_zeros(y2);\r
-               \r
-       ptr += sprintf(ptr, "-fill %s -strokewidth 5 ", style.pointColor);\r
-       ptr += sprintf(ptr, "-draw \"circle %s,%s %s,%s", x, y1, x, y2);\r
-       ptr += sprintf(ptr, "'\" ");\r
-       \r
-       return (ptr - output);\r
-}\r
-\r
-/**\r
- * Serializes a LWLINE to a char*.  This is a helper function that partially\r
- * writes the appropriate draw and stroke commands used to generate an SVG image\r
- * using ImageMagick's "convert" command.\r
\r
- * @param output a char reference to write the LWLINE to\r
- * @param lwl a reference to a LWLINE\r
- * @return the numbers of character written to *output\r
- */\r
-static size_t\r
-drawLineString(char *output, LWLINE *lwl, LAYERSTYLE style) {\r
-       LWDEBUGF( 4, "%s", "enter drawLineString" );\r
-       char *ptr = output;\r
-\r
-       ptr += sprintf(ptr, "-fill none -stroke %s -strokewidth %d ", style.lineColor, style.lineWidth);\r
-       ptr += sprintf(ptr, "-draw \"stroke-linecap round stroke-linejoin round path 'M ");\r
-       ptr += pointarrayToString(ptr, lwl->points );\r
-       ptr += sprintf(ptr, "'\" ");\r
-       \r
-       return (ptr - output);\r
-}\r
-\r
-/**\r
- * Serializes a LWPOLY to a char*.  This is a helper function that partially\r
- * writes the appropriate draw and fill commands used to generate an SVG image\r
- * using ImageMagick's "convert" command.\r
\r
- * @param output a char reference to write the LWPOLY to\r
- * @param lwp a reference to a LWPOLY\r
- * @return the numbers of character written to *output\r
- */\r
-static size_t\r
-drawPolygon(char *output, LWPOLY *lwp, LAYERSTYLE style) {\r
-       LWDEBUGF( 4, "%s", "enter drawPolygon" );\r
-       \r
-       char *ptr = output;\r
-       int i;\r
-\r
-       ptr += sprintf(ptr, "-fill %s -stroke %s -strokewidth %d ", style.polygonFillColor, style.polygonStrokeColor, style.polygonStrokeWidth );\r
-       ptr += sprintf(ptr, "-draw \"path '");\r
-       for (i=0; i<lwp->nrings; i++) {\r
-               ptr += sprintf(ptr, "M ");\r
-               ptr += pointarrayToString(ptr, lwp->rings[i] );\r
-               ptr += sprintf(ptr, " ");\r
-       }\r
-       ptr += sprintf(ptr, "'\" ");\r
-       \r
-       return (ptr - output);\r
-}\r
-\r
-/**\r
- * Serializes a LWGEOM to a char*.  This is a helper function that partially\r
- * writes the appropriate draw, stroke, and fill commands used to generate an \r
- * SVG image using ImageMagick's "convert" command.\r
\r
- * @param output a char reference to write the LWGEOM to\r
- * @param lwgeom a reference to a LWGEOM\r
- * @return the numbers of character written to *output\r
- */\r
-static size_t\r
-drawGeometry(char *output, LWGEOM *lwgeom, LAYERSTYLE style ) {\r
-       LWDEBUGF( 4, "%s", "enter drawGeometry" );\r
-       char *ptr = output;\r
-       int i;\r
-       int type = lwgeom_getType(lwgeom->type);        \r
-                               \r
-       LWDEBUGF( 4, "switching on %d", type );\r
-       switch(type) {\r
-               case POINTTYPE:\r
-                       ptr += drawPoint(ptr, (LWPOINT*)lwgeom, style );\r
-                       break;\r
-               case LINETYPE:\r
-                       ptr += drawLineString(ptr, (LWLINE*)lwgeom, style );\r
-                       break;\r
-               case POLYGONTYPE:\r
-                       ptr += drawPolygon(ptr, (LWPOLY*)lwgeom, style );\r
-                       break;\r
-               case MULTIPOINTTYPE:\r
-               case MULTILINETYPE:\r
-               case MULTIPOLYGONTYPE:\r
-               case COLLECTIONTYPE:\r
-                       for (i=0; i<((LWCOLLECTION*)lwgeom)->ngeoms; i++) {\r
-                               ptr += drawGeometry( ptr, lwcollection_getsubgeom ((LWCOLLECTION*)lwgeom, i), style );\r
-                       }\r
-                       break;\r
-        }\r
-        \r
-       return (ptr - output);\r
-}\r
-\r
-/**\r
- * Invokes a system call to ImageMagick's "convert" command that adds a drop \r
- * shadow to the current layer image.\r
- * \r
- * @param layerNumber the current working layer number.\r
- */\r
-static void\r
-addDropShadow(int layerNumber) {\r
-       char str[129];\r
-       sprintf(\r
-               str, \r
-               "convert tmp%d.png -gravity center \\( +clone -background navy -shadow 100x3+4+4 \\) +swap -background none -flatten tmp%d.png", \r
-               layerNumber, layerNumber);\r
-       system(str);\r
-}\r
-\r
-/**\r
- * Invokes a system call to ImageMagick's "convert" command that adds a  \r
- * highlight to the current layer image.\r
- * \r
- * @param layerNumber the current working layer number.\r
- */\r
-static void\r
-addHighlight(int layerNumber) {\r
-       char str[129];\r
-       sprintf(\r
-               str, \r
-               "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", \r
-               layerNumber, layerNumber, layerNumber, layerNumber);\r
-       system(str);\r
-}\r
-\r
-/**\r
- * Flattens all the temporary processing png files into a single image\r
- */\r
-static void\r
-flattenLayers(char* filename) {\r
-       char *str;\r
-       str = malloc( (48 + strlen(filename) + 1) * sizeof(char) );\r
-       sprintf(str, "convert tmp[0-9].png -background none -flatten %s", filename);\r
-       system(str);\r
-       system("rm -f tmp[0-9].png");\r
-       free(str);\r
-}\r
-\r
-\r
-/**\r
- * Main Application.  Currently, drawing styles are hardcoded in this method.\r
- * Future work may entail reading the styles from a .properties file.\r
- */\r
-int main( int argc, const char* argv[] ) {\r
-       FILE *pfile;\r
-       LWGEOM *lwgeom;\r
-       char line [2048];\r
-       char *filename;\r
-       int layerCount;\r
-       int styleNumber;\r
-       LAYERSTYLE styles[3];\r
-       \r
-       styles[0].pointSize = 6;\r
-       styles[0].pointColor = "Blue";\r
-       styles[0].lineWidth = 7;\r
-       styles[0].lineColor = "Blue";\r
-       styles[0].polygonFillColor = "Blue";\r
-       styles[0].polygonStrokeColor = "Blue";\r
-       styles[0].polygonStrokeWidth = 1;\r
-       \r
-       styles[1].pointSize = 6;\r
-       styles[1].pointColor = "Green";\r
-       styles[1].lineWidth = 7;\r
-       styles[1].lineColor = "Green";\r
-       styles[1].polygonFillColor = "Green";\r
-       styles[1].polygonStrokeColor = "Green";\r
-       styles[1].polygonStrokeWidth = 1;\r
-       \r
-       styles[2].pointSize = 6;\r
-       styles[2].pointColor = "Red";\r
-       styles[2].lineWidth = 7;\r
-       styles[2].lineColor = "Red";\r
-       styles[2].polygonFillColor = "Red";\r
-       styles[2].polygonStrokeColor = "Red";\r
-       styles[2].polygonStrokeWidth = 1;\r
-       \r
-               \r
-       if ( argc != 2 ) {\r
-               printf("You must specifiy a wkt filename to convert.\n");\r
-               return -1;\r
-       }\r
-       \r
-       if( (pfile = fopen(argv[1], "r")) == NULL){\r
-               perror ( argv[1] );\r
-               return -1;\r
-       }\r
-               \r
-       filename = malloc( (strlen(argv[1])+8) * sizeof(char) );\r
-       strcpy( filename, "../images/" );\r
-       strncat( filename, argv[1], strlen(argv[1])-3 );\r
-       strcat( filename, "png" );\r
-       \r
-       printf( "generating %s\n", filename );\r
-       \r
-       layerCount = 0;\r
-       while ( fgets ( line, sizeof line, pfile ) != NULL ) {          \r
-               \r
-               char output [2048];\r
-               char *ptr = output;\r
-               ptr += sprintf( ptr, "convert -size %s xc:none ", imageSize );\r
-       \r
-               lwgeom = lwgeom_from_ewkt( line, PARSER_CHECK_NONE );\r
-               LWDEBUGF( 4, "geom = %s", lwgeom_to_ewkt((LWGEOM*)lwgeom,0) );\r
-               \r
-               styleNumber = layerCount % 3;\r
-               LWDEBUGF( 4, "using style %d", styleNumber );\r
-               ptr += drawGeometry( ptr, lwgeom, styles[styleNumber] );\r
-               LWDEBUGF( 4, "%s", "after drawGeometry" );\r
-               \r
-               ptr += sprintf( ptr, "-flip tmp%d.png", layerCount );\r
-                \r
-               lwfree( lwgeom );       \r
-               \r
-               LWDEBUGF( 4, "%s", output );\r
-               system(output);\r
-               \r
-               addHighlight( layerCount );\r
-               addDropShadow( layerCount );\r
-               layerCount++;\r
-       }\r
-       \r
-       LWDEBUGF(4, "%s", filename);\r
-       flattenLayers(filename);\r
-       \r
-       fclose(pfile);\r
-       free(filename);\r
-       return 0;\r
-}\r
+/**********************************************************************
+ * $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.
+ *
+ * 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.
+ *
+ * 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,
+ * WKT files are converted into SVG syntax and rasterized as png.  (PostGIS's
+ * internal SVG methods could not be used dues to syntax issues with ImageMagick)
+ *
+ * The goal of this application is to dynamically generate all the spatial
+ * pictures used in PostGIS's documentation pages.
+ *
+ * Note: the coordinates of the supplied geometries should be within the x-y range 
+ * of 200, otherwise they will appear outside of the generated image.
+ * 
+ **********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
+
+#include "lwalgorithm.h"
+
+#define SHOW_DIGS_DOUBLE 15
+#define MAX_DOUBLE_PRECISION 15
+#define MAX_DIGS_DOUBLE (SHOW_DIGS_DOUBLE + 2) /* +2 for dot and sign */
+
+// Some global styling variables
+char *imageSize = "200x200";
+
+typedef struct {       
+       int       pointSize;
+       char *pointColor;
+       
+       int   lineWidth;
+       char *lineColor;
+       
+       char *polygonFillColor;
+       char *polygonStrokeColor;
+       int   polygonStrokeWidth;
+} LAYERSTYLE;
+
+
+/**
+ * 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();
+}
+
+/**
+ * Writes the coordinates of a POINTARRAY to a char* where ordinates are 
+ * separated by a comma and coordinates by a space so that the coordinate
+ * pairs can be interpreted by ImageMagick's SVG draw command.
+ *
+ * @param output a reference to write the POINTARRAY to
+ * @param pa a reference to a POINTARRAY
+ * @return the numbers of character written to *output
+ */
+static size_t 
+pointarrayToString(char *output, POINTARRAY *pa) {
+       char x[MAX_DIGS_DOUBLE+MAX_DOUBLE_PRECISION+1];
+       char y[MAX_DIGS_DOUBLE+MAX_DOUBLE_PRECISION+1];
+       int i;
+       char *ptr = output;
+       
+       for ( i=0; i < pa->npoints; i++ ) {
+               POINT2D pt;
+               getPoint2d_p(pa, i, &pt);
+               sprintf(x, "%f", pt.x);
+               trim_trailing_zeros(x);
+               sprintf(y, "%f", pt.y);
+               trim_trailing_zeros(y);
+               if ( i ) ptr += sprintf(ptr, " ");
+               ptr += sprintf(ptr, "%s,%s", x, y);
+       }
+       
+       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
+ * using ImageMagick's "convert" command.
+ * @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
+drawPoint(char *output, LWPOINT *lwp, LAYERSTYLE style) {
+       LWDEBUGF( 4, "%s", "enter drawPoint" );
+       
+       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];
+       char *ptr = output;
+       POINTARRAY *pa = lwp->point;
+       POINT2D p;
+       getPoint2d_p(pa, 0, &p);
+       
+       sprintf(x, "%f", p.x);
+       trim_trailing_zeros(x);
+       sprintf(y1, "%f", p.y);
+       trim_trailing_zeros(y1);
+       sprintf(y2, "%f", p.y + style.pointSize);
+       trim_trailing_zeros(y2);
+               
+       ptr += sprintf(ptr, "-fill %s -strokewidth 5 ", style.pointColor);
+       ptr += sprintf(ptr, "-draw \"circle %s,%s %s,%s", x, y1, x, y2);
+       ptr += sprintf(ptr, "'\" ");
+       
+       return (ptr - output);
+}
+
+/**
+ * Serializes a LWLINE to a char*.  This is a helper function that partially
+ * writes the appropriate draw and stroke commands used to generate an SVG image
+ * using ImageMagick's "convert" command.
+ * @param output a char reference to write the LWLINE to
+ * @param lwl a reference to a LWLINE
+ * @return the numbers of character written to *output
+ */
+static size_t
+drawLineString(char *output, LWLINE *lwl, LAYERSTYLE style) {
+       LWDEBUGF( 4, "%s", "enter drawLineString" );
+       char *ptr = output;
+
+       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, "'\" ");
+       
+       return (ptr - output);
+}
+
+/**
+ * Serializes a LWPOLY to a char*.  This is a helper function that partially
+ * writes the appropriate draw and fill commands used to generate an SVG image
+ * using ImageMagick's "convert" command.
+ * @param output a char reference to write the LWPOLY to
+ * @param lwp a reference to a LWPOLY
+ * @return the numbers of character written to *output
+ */
+static size_t
+drawPolygon(char *output, LWPOLY *lwp, LAYERSTYLE style) {
+       LWDEBUGF( 4, "%s", "enter drawPolygon" );
+       
+       char *ptr = output;
+       int i;
+
+       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 ");
+               ptr += pointarrayToString(ptr, lwp->rings[i] );
+               ptr += sprintf(ptr, " ");
+       }
+       ptr += sprintf(ptr, "'\" ");
+       
+       return (ptr - output);
+}
+
+/**
+ * Serializes a LWGEOM to a char*.  This is a helper function that partially
+ * writes the appropriate draw, stroke, and fill commands used to generate an 
+ * SVG image using ImageMagick's "convert" command.
+ * @param output a char reference to write the LWGEOM to
+ * @param lwgeom a reference to a LWGEOM
+ * @return the numbers of character written to *output
+ */
+static size_t
+drawGeometry(char *output, LWGEOM *lwgeom, LAYERSTYLE style ) {
+       LWDEBUGF( 4, "%s", "enter drawGeometry" );
+       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 );
+                       break;
+               case LINETYPE:
+                       ptr += drawLineString(ptr, (LWLINE*)lwgeom, style );
+                       break;
+               case POLYGONTYPE:
+                       ptr += drawPolygon(ptr, (LWPOLY*)lwgeom, style );
+                       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 );
+                       }
+                       break;
+        }
+        
+       return (ptr - output);
+}
+
+/**
+ * Invokes a system call to ImageMagick's "convert" command that adds a drop 
+ * shadow to the current layer image.
+ * 
+ * @param layerNumber the current working layer number.
+ */
+static void
+addDropShadow(int layerNumber) {
+       char str[129];
+       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);
+}
+
+/**
+ * Invokes a system call to ImageMagick's "convert" command that adds a  
+ * highlight to the current layer image.
+ * 
+ * @param layerNumber the current working layer number.
+ */
+static void
+addHighlight(int layerNumber) {
+       char str[129];
+       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);
+       system(str);
+}
+
+/**
+ * Flattens all the temporary processing png files into a single image
+ */
+static void
+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);
+       system(str);
+       system("rm -f tmp[0-9].png");
+       free(str);
+}
+
+
+/**
+ * Main Application.  Currently, drawing styles are hardcoded in this method.
+ * Future work may entail reading the styles from a .properties file.
+ */
+int main( int argc, const char* argv[] ) {
+       FILE *pfile;
+       LWGEOM *lwgeom;
+       char line [2048];
+       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;
+       
+               
+       if ( argc != 2 ) {
+               printf("You must specifiy a wkt filename to convert.\n");
+               return -1;
+       }
+       
+       if( (pfile = fopen(argv[1], "r")) == NULL){
+               perror ( argv[1] );
+               return -1;
+       }
+               
+       filename = malloc( (strlen(argv[1])+8) * sizeof(char) );
+       strcpy( filename, "../images/" );
+       strncat( filename, argv[1], strlen(argv[1])-3 );
+       strcat( filename, "png" );
+       
+       printf( "generating %s\n", filename );
+       
+       layerCount = 0;
+       while ( fgets ( line, sizeof line, pfile ) != NULL ) {          
+               
+               char output [2048];
+               char *ptr = output;
+               ptr += sprintf( ptr, "convert -size %s xc:none ", imageSize );
+       
+               lwgeom = lwgeom_from_ewkt( line, 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" );
+               
+               ptr += sprintf( ptr, "-flip tmp%d.png", layerCount );
+                
+               lwfree( lwgeom );       
+               
+               LWDEBUGF( 4, "%s", output );
+               system(output);
+               
+               addHighlight( layerCount );
+               addDropShadow( layerCount );
+               layerCount++;
+       }
+       
+       LWDEBUGF(4, "%s", filename);
+       flattenLayers(filename);
+       
+       fclose(pfile);
+       free(filename);
+       return 0;
+}
index 223f072be4ed47be2d0408658405c9f0e372f1cb..9833dccdf76201d7c0536f4880f9345590b1360a 100644 (file)
@@ -1,2 +1,2 @@
-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 )\r
+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
index 86117c2105abe229bda77273e1bdfa303679c10f..59b2326c3bd2bb20afed890a81a65707d758eefd 100644 (file)
@@ -1,2 +1,2 @@
-POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))\r
+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
index f324d5d57f90e7cd6fc7bd7999fa1d6331d3f5af..f74d61b81921e5d723daa2770870ed12ce1a51fd 100644 (file)
@@ -1,2 +1,2 @@
-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 ))\r
+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
index 915598ba232b1c074058979215402009ab9b93d2..4fdc5b8fd11348d50afa85b70f58ac184fcde70f 100644 (file)
@@ -1,2 +1,2 @@
-LINESTRING ( 10 190, 60 80, 130 120, 190 10 )\r
+LINESTRING ( 10 190, 60 80, 130 120, 190 10 )
 MULTIPOINT ( 80 170, 120 13, 130 119, 181 142 )
\ No newline at end of file
index 148e3634c858bf484bc3407ee18092f3bc05fcf7..8f0c81be96a95f93b0d9996ccd29fd0f736c8ae1 100644 (file)
@@ -1,2 +1,2 @@
-POLYGON (( 10 190, 20 10, 90 20, 110 70, 80 130, 10 190 ))\r
+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
index 69a8c1865712c16681f14f2511e7a9b47a715cd3..6799a5d7dc04e9b03308e24dab5194279b021cf2 100644 (file)
@@ -1,2 +1,2 @@
-POLYGON (( 10 190, 20 10, 90 20, 110 70, 80 130, 10 190 ))\r
+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
index ef22ee14bfc2b0d05c6e4d7b2dc857acd959b585..221a798f8a3b8e32b90591695f9fe97f8adb02ee 100644 (file)
@@ -1,2 +1,2 @@
-LINESTRING ( 10 190, 60 110, 110 120, 190 10 )\r
-LINESTRING ( 10 10, 70 30, 110 120, 190 190 )\r
+LINESTRING ( 10 190, 60 110, 110 120, 190 10 )
+LINESTRING ( 10 10, 70 30, 110 120, 190 190 )
index ba1976025cfa1f1b480ac9eb82ff4f433fc957dc..4af1d5a1976eb9312b59716581e1364c8f0ab02f 100644 (file)
@@ -1 +1 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 10 190, 140 130, 70 80, 190 10 ), POINT(10 190), POINT(190 10) )\r
+GEOMETRYCOLLECTION ( LINESTRING ( 10 190, 140 130, 70 80, 190 10 ), POINT(10 190), POINT(190 10) )
index b9d6e28c6653dfcc62f01ca277f5f4e7e05a0b38..fb68f5966a547d8202f9c915166c12aecfd50dde 100644 (file)
@@ -1 +1 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 10 190, 130 40, 170 160, 10 10 ), POINT(10 190), POINT(10 10) )\r
+GEOMETRYCOLLECTION ( LINESTRING ( 10 190, 130 40, 170 160, 10 10 ), POINT(10 190), POINT(10 10) )
index d6b1be7e341afc6c96ed3605a2da1dcd6ce12db1..cdcf5dcc2bdcc73820a2ae571d9c9411aea382f5 100644 (file)
@@ -1 +1 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 90 190, 120 190, 130 140, 190 50, 70 10, 10 70, 10 150, 90 190 ), POINT(90 190) )\r
+GEOMETRYCOLLECTION ( LINESTRING ( 90 190, 120 190, 130 140, 190 50, 70 10, 10 70, 10 150, 90 190 ), POINT(90 190) )
index 00b8169f76bab7580d462c1b67446816ffc3c67b..31221f0679fba72a07f6af8e07dd4030b8798399 100644 (file)
@@ -1 +1 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 90 190, 120 190, 50 60, 130 10, 190 50, 160 90, 10 150, 90 190 ), POINT(90 190) )\r
+GEOMETRYCOLLECTION ( LINESTRING ( 90 190, 120 190, 50 60, 130 10, 190 50, 160 90, 10 150, 90 190 ), POINT(90 190) )
index 8d68b5d4400d15c31d844085c5c14b2251ff2cf8..296f3e66506e3e53d8d2e6c08323bd1bbef83202 100644 (file)
@@ -1 +1 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 30 190, 60 60, 170 10 ), LINESTRING ( 100 190, 180 150, 160 70 ), MULTIPOINT ( 30 190, 170 10, 100 190, 160 70 ) )\r
+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 bf63e2d8e0056ec74345a58f5e6aabdafcee05db..31f3a8e6d6c3a5eac09829f1b23a3b862e13aaa0 100644 (file)
@@ -1 +1 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 30 190, 60 60, 170 10 ), LINESTRING ( 30 190, 180 150, 160 70 ), MULTIPOINT( 170 10, 30 190, 170 10 ) )\r
+GEOMETRYCOLLECTION ( LINESTRING ( 30 190, 60 60, 170 10 ), LINESTRING ( 30 190, 180 150, 160 70 ), MULTIPOINT( 170 10, 30 190, 170 10 ) )
index 2316ab8d77d732df95cbdc39d4beb6e05ee4e2f3..684e6fbe8e58ff4e5cb346f0b333124d9a31f942 100644 (file)
@@ -1 +1 @@
-GEOMETRYCOLLECTION ( LINESTRING ( 30 190, 60 60, 170 10 ), LINESTRING (100 190, 180 150, 80 10), MULTIPOINT( 30 190, 170 10, 100 190, 80 10 ) )\r
+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 d1a414e38bd4cf2e8b2d3af98676f0e1afcdbe58..99d45f12c77323ad66da4a7cdf0e2b0f42a65bb9 100644 (file)
@@ -1 +1 @@
-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))\r
+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 349ebadd853599e12c6555afcfa2567bf93f56f7..ab279131d157955d39bc1086e55f1af27b5120c5 100644 (file)
@@ -1 +1 @@
-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))\r
+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 8616141903b59084472bcd40fc859f30d3eb6fd2..451a350be3d886728600cbabff71d38e1e4daebb 100644 (file)
@@ -1 +1 @@
-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))\r
+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 f6ae8a7b7ac39ba3c4bff6d4c23013ab5726c98d..2cfe45b4e7d6732d7582958f11ee57284396e9f4 100644 (file)
@@ -1 +1 @@
-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))\r
+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 80b93df9b916bc4d2b0f0d22496a16852b15c1c9..9e6bf315209509c30dc92aac502a170504d95f92 100644 (file)
@@ -1 +1 @@
-POLYGON (( 10 100, 60 140, 60 190, 62 190, 62 157, 130 170, 190 60, 160 10, 50 20, 10 100 ))\r
+POLYGON (( 10 100, 60 140, 60 190, 62 190, 62 157, 130 170, 190 60, 160 10, 50 20, 10 100 ))