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])
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 > $@
doxygen $<
images:
- make -C html/image_src
+ make -C html/image_src images
clean:
make -C html/image_src clean
@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
../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)
#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();
}
/**
* @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];
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, "'\" ");
* @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, "'\" ");
* @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 ");
* @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;
}
*/
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);
}
/**
*/
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);
}
/**
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.
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;
}
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 );
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;
}
-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)
+
-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)
+
-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)
+
-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)
+
-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 )
+
-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 )
+
-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 )
+
-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 )
+
-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) )
-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) )
+
-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) )
+
-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) )
+
-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 ) )
+
-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 ) )
+
-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 ) )
+
-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))
+
-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))
+
-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))
+
-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))
+
-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 ))
+
--- /dev/null
+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 ))
+
--- /dev/null
+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 )))
+
--- /dev/null
+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 ))
+
--- /dev/null
+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 ))
--- /dev/null
+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 ))
--- /dev/null
+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
--- /dev/null
+Style1;LINESTRING ( 10 10, 60 140, 140 190 )
+Style2;LINESTRING ( 140 190, 190 10 )
--- /dev/null
+Style1;LINESTRING ( 10 10, 60 140, 140 190 )
+Style2;LINESTRING ( 60 140, 190 10 )
--- /dev/null
+Style1;POLYGON (( 30 30, 10 110, 40 190, 120 170, 180 180, 170 100, 130 10, 30 30 ))
+Style2;POINT ( 170 100 )
--- /dev/null
+/**********************************************************************
+ * $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;
+}
--- /dev/null
+# 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
+
--- /dev/null
+/**********************************************************************
+ * $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);
<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>
<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>
<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>
<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>