[Mapserver-users] MapScript, help starting?

Lowell Filak lfilak at medinaco.org
Fri Feb 28 16:26:57 EST 2003


There could be a few things causing that.
To turn on debugging see:
http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PerlMapScriptDebugging
To find the "EXTENT" of "parcel" to make sure the data matches the mapfile try:
<mapserver_unpack&compile_dir>/mapscript/perl/examples/shpinfo.pl 
-file=parcel
For examples see:
http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PerlMapScriptExamples35
But then replying to a "Junkmail Box" may not be a good decision on my part.
HTH
Lowell F.

The following message was sent by Junkmail Box <junkmail at deathkeep.com> on Thu, 27 Feb 2003 08:33:35 -0800 (PST).

> 
> 
> I'm having trouble getting started using Perl MapScript. The doc at
> http://mapserver.gis.umn.edu/doc36/perlmapscript-reference.html doesn't
> give a lot for examples of getting started. They do give this, though:
> 
> #!/usr/bin/perl
> use mapscript;
> my $map = new mapObj('arcata.map') or die('Unable to open mapfile.');
> my $img = $map->draw() or die('Unable to draw map');
> my $void = $img->saveImage('example.png', $mapscript::MS_PNG, $map->{transparent}, $map->{interlace}, 0);
> 
> However, when I run it, example.png is an empty file.
> 
> Any ideas on what the problem could be?
> Are there any tutorials on getting started using MapScript?
> 
> arcata.map is a map file, and works with the mapserv CGI binary just fine.
> And $map->{numlayers} properly says there are 3 layers in the map. So I
> know mapscript is seeing the arcata.map file, and that arcata.map is
> valid. The arcata.map file is as follows:
> 
> 
> #
> # map file - Arcata demo
> #
> NAME ARCATADEMO
> STATUS ON
> SIZE 504 504
> EXTENT 407375  4522866  410627 4526910
> UNITS METERS
> SHAPEPATH "/usr/local/mapserv/htdocs/arcata"
> IMAGECOLOR 255 255 255
> IMAGETYPE JPEG
> 
> # web interface definition
> WEB
>   # the template for browsing mode
>   TEMPLATE arcata.html
>   MINSCALE 1000
>   MAXSCALE 1550000
>   IMAGEPATH "/usr/local/mapserv/tmp/"
>   IMAGEURL "/tmp/"
> END
> 
> # reference (thumbnail) map
> REFERENCE
>   IMAGE arcata_thumbnail.jpg
>   EXTENT 404958.660383 4520848.011905 413035.327051 4528936.011905
>   SIZE 216 216
>   STATUS ON
>   COLOR -1 -1 -1
>   OUTLINECOLOR 255 0 0
> END
> 
> ## legend - automatically generated from any classes that have a NAME
> attribute
> #LEGEND
> #  KEYSIZE 18 12
> #  LABEL
> #    TYPE BITMAP
> #    SIZE MEDIUM
> #    COLOR 0 0 89
> #  END
> #  STATUS ON
> #END
> 
> # scalebar
> SCALEBAR
>   IMAGECOLOR 0 0 0
>   LABEL
>     COLOR 255 255 255
>     SIZE medium
>   END
>   STYLE 1
>   SIZE 288 6
>   COLOR 255 255 255
>   UNITS MILES
>   INTERVALS 4
>   TRANSPARENT TRUE
>   STATUS ON
> END
> 
> 
> 
> ### LAYER DEFINITIONS
> 
> 
> ### parcel divisions
> LAYER
>   NAME parcels
>   TYPE POLYGON
>   DATA parcels
>   STATUS OFF
> 
>   # what template to use for displaying a query about a parcel
>   TEMPLATE /usr/local/mapserv/htdocs/arcata/parcel_query_template.html
> 
>   # when labeling parcels, the owner's name is the label to use
>   LABELITEM OWNER_NAME
> 
>   # color-code certain parcels, depending on the owner
>   CLASSITEM OWNER_ADD
>   CLASS
>     #EXPRESSION "ARCATA PLAZA"
>     EXPRESSION /ARCATA*/
>     COLOR 128 255 255
>     OUTLINECOLOR 0 255 0
>     LABEL
>       COLOR 0 0 0
>     END
>   END
>   CLASS
>     EXPRESSION /CALIFORNIA*/
>     COLOR 200 200 200
>     OUTLINECOLOR 0 255 0
>     LABEL
>       COLOR 0 0 0
>     END
>   END
>   # default parcel coloration
>   CLASS
>     NAME "Parcel"
>     OUTLINECOLOR 255 0 0
>     COLOR 255 120 120
>     LABEL
>       COLOR 255 255 255
>     END
>   END
> 
> END
> 
> 
> ### creeks
> LAYER
>   NAME creeks
>   STATUS OFF
>   DATA creeks
>   TYPE LINE
> 
>   CLASS
>     NAME "Creek"
>     COLOR 0 0 255
>   END
> 
>   # template to use if someone queries a creek
>   TEMPLATE creeks_query_template.html
> END
> 
> 
> ### roads
> LAYER
>   NAME roads
>   STATUS ON
>   DATA roads
>   TYPE LINE
> 
>   CLASS
>     NAME "Road"
>     COLOR 0 0 0
>     LABEL
>       COLOR 128 128 128
>     END
>   END
> 
>   # label roads, and allow a user to query a road
>   LABELITEM FNAME
>   TEMPLATE roads_query_template.html
> END
> 
> ### END OF LAYER DEFINITIONS
> END # end of map file
> 
> 
> 
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list