Skip to content

Commit

Permalink
Add mapserver config for testing.
Browse files Browse the repository at this point in the history
Added a minimal mapserver config "coastline.map" and a script "render_image.sh"
that uses mapservers shp2img program to render the polygons.
  • Loading branch information
joto committed Apr 20, 2012
1 parent 3d5241f commit 16829cc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
24 changes: 24 additions & 0 deletions coastline.map
@@ -0,0 +1,24 @@
#
# Mapserver configuration
#
# For rendering using this file see render_image.sh.
#
MAP
NAME coastline
IMAGECOLOR 255 255 255

LAYER
NAME polygons
TYPE POLYGON
STATUS ON
CONNECTIONTYPE OGR
CONNECTION "coastline-mapserver.db"
DATA "polygons"
CLASS
STYLE
COLOR 0 0 0
END
END
END

END
34 changes: 34 additions & 0 deletions render_image.sh
@@ -0,0 +1,34 @@
#!/bin/sh
#
# render_image.sh [DBFILE]
#
# Render polygons in DBFILE using shp2img program from mapserver.
# Automatically detects SRID and renders accordingly.
# If no DBFILE is given, testdata.db is used.
#

WIDTH=2048

if [ "x$1" = "x" ]; then
DBFILE=testdata.db
else
DBFILE=$1
fi

SRID=`sqlite3 $DBFILE "SELECT srid FROM geometry_columns WHERE f_table_name='polygons'"`

if [ "$SRID" = "4326" ]; then
# If SRID is WGS84 the image height is half its width
HEIGHT=`expr $WIDTH / 2`
EXTENT="-180 -90 180 90"
else
# If SRID is 3857 (Mercator) the image height is the same as its width
HEIGHT=$WIDTH
EXTENT="-20037508.342789244 -20037508.342789244 20037508.342789244 20037508.342789244"
fi

rm -f coastline-mapserver.db
ln -s $DBFILE coastline-mapserver.db
shp2img -m coastline.map -l polygons -i PNG -o polygons.png -s $WIDTH $HEIGHT -e $EXTENT
rm -f coastline-mapserver.db

0 comments on commit 16829cc

Please sign in to comment.