PERL/Mapscript postGIS examples?
Simpson
asimpson at I-55.COM
Fri Mar 17 05:12:03 PST 2006
Stephen,
You might try checking the Postgresql logs to see if Mapserver is connecting
and requesting data. Turn on statement logging in Postgresql config to get
details of exactly what is being sent. You can then run the statement from
psql to see if it is returning what you expect.
Drew.
-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]On
Behalf Of Stephen Davies
Sent: Friday, March 17, 2006 12:48 AM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: [UMN_MAPSERVER-USERS] PERL/Mapscript postGIS examples?
Could somebody please send me or point me at an example of a
PERL/Mapscript script that displays layers populated from a postGIS
database and/or raster layers?
The following PERL/Mapscript and map file generates an image containing
only the copyright layer.
Exactly the same map file with mapserver invoked as CGI generates all
layers.
(In both cases the extent is provided as args.
eg ./genpics q 1 jpg 139.5143351 -34.7459112 139.5278707 -34.7207064)
Cheers and thanks,
Stephen Davies
#! /usr/bin/perl
#
# args are UID (for mapfile), pic sequence #, image type (extension),
extent
#
use strict;
#use CGI;
use mapscript;
my $uno = $ARGV[0];
my $seq = $ARGV[1];
my $ext = $ARGV[2];
my $minx = $ARGV[3];
my $miny = $ARGV[4];
my $maxx = $ARGV[5];
my $maxy = $ARGV[6];
#
# if sequence = 1, create/empty directory (ignoring errors)
#
if ($seq == 1){
mkdir("/var/www/html/status_images/$uno",0777);
unlink </var/www/html/status_images/$uno/*>;
}
#
my $mapfile = "/tmp/$uno.map";
my $map = mapscript::mapObj->new($mapfile);
my $i=$map->setExtent($minx,$miny,$maxx,$maxy);
#
#my $img = $map->prepareImage();
my $img = $map->draw();
my $fname = "/var/www/html/status_images/$uno/$seq.$ext";
$img->save($fname);
===================================================
MAP
NAME perltest
PROJECTION
"proj=eqc"
"lon_0=139.521e"
END
SIZE 600 600
FONTSET "/var/www/html/benparts/fonts.list"
SYMBOLSET "/var/www/html/benparts/symbols"
UNITS METERS
IMAGETYPE jpeg
OUTPUTFORMAT
NAME jpeg
DRIVER "GD/JPEG"
MIMETYPE "image/jpeg"
IMAGEMODE RGB
EXTENSION "jpg"
FORMATOPTION "QUALITY=75"
END
IMAGECOLOR 255 255 255
WEB
template /var/www/html/benparts/templates/test1.html
imagepath "/var/www/html/tmp/"
imageurl "/tmp/"
END
LAYER
TYPE RASTER
NAME "bkgrnd"
STATUS DEFAULT
PROJECTION
"init=epsg:28354"
END
DATA "/var/www/html/benparts/rasters/walker.ecw"
# OFFSITE 0 0 0
PROCESSING "DITHER=YES"
END
LAYER
CONNECTIONTYPE postgis
NAME "probe"
DATA "geom from probe"
CONNECTION "user=scldad dbname=benparts"
STATUS DEFAULT
TYPE POINT
# FILTER "id in (0)"
PROJECTION
"init=epsg:4284"
END
MAXSCALE 5000000
LABELITEM "location"
CLASS
NAME "Probe (Right Click to select)"
STYLE
COLOR 0 214 0
SYMBOL 'circle'
SIZE 7
END
LABEL
MINDISTANCE 15
POSITION CR
SIZE SMALL
COLOR 0 0 0
FORCE TRUE
END
END
END
LAYER
NAME 'copyright'
TYPE ANNOTATION
STATUS DEFAULT
TRANSFORM FALSE # coordinates are in pixels
FEATURE
POINTS 10 595 END
END
CLASS
LABEL
TYPE TRUETYPE
FONT arial
SIZE 8
COLOR 255 0 0
POSITION CR
END
TEXT 'Photography supplied by MAPLAND, Environment Information,
Dept Environment & Heritage'
END
END
END
--
=======================================================================
This email is for the person(s) identified above, and is confidential to
the sender and the person(s). No one else is authorised to use or
disseminate this email or its contents.
Stephen Davies Consulting Voice: 08-8177 1595
Adelaide, South Australia. Fax: 08-8177 0133
Computing & Network solutions. Mobile:0403 0405 83
More information about the MapServer-users
mailing list