Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|