[Mapserver-users] Perl Mapscript Dynamic Layer Rendering in 4 .01

Simpson, Andrew Andrew.Simpson at ssc.nasa.gov
Wed Mar 10 13:13:55 EST 2004


No messages in the MS_ERRORFILE.

-----Original Message-----
From: Lowell Filak [mailto:lfilak at medinaco.org] 
Sent: Wednesday, March 10, 2004 11:13 AM
To: Simpson, Andrew; 'mapserver-users at lists.gis.umn.edu'
Subject: Re: [Mapserver-users] Perl Mapscript Dynamic Layer Rendering in
4.01

Does turning on debugging help narrow the search?
$ENV{MS_ERRORFILE} = "/var/log/mapserver.log"; # map engine error log 

Lowell

The following message was sent by "Simpson, Andrew"
<Andrew.Simpson at ssc.nasa.gov> on Wed, 10 Mar 2004 09:29:17 -0600.

> Greetings,
> 
>  
> 
> We are migrating from MS  3.6.5 to MS 4.01 on a Linux Redhat server.
> 
>  
> 
> Using the migration guide, updated the code where necessary (mainly the
> styles object changes).
> 
>  
> 
> Does anyone have any ideas why the DrawPolygon() function below renders
> fine, but the DrawLine() function does not?
> 
>  
> 
> The image is rendered with a scalebar, but vector missing.
> 
>  
> 
> I also tried a DrawPoint with no success.
> 
>  
> 
> Please put me out of my misery!
> 
>  
> 
> Thanks,
> 
> Drew.
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> =================  start script ======================
> 
>  
> 
> #!/usr/bin/perl
> 
>  
> 
> use mapscript;
> 
>  
> 
> $map = new mapscript::mapObj("test_map.map") || die "Couldn't instantiate
> map object:$!<br>\n";
> 
>  
> 
> $img = $map->prepareImage();
> 
>  
> 
> #DrawPolygon();
> 
>  
> 
> DrawLine();
> 
>  
> 
> $map->draw();
> 
>  
> 
> $map->drawLabelCache($img);
> 
>  
> 
> $outfile = 'mapgen.'.time.'.png';
> 
> $img->save($outfile);
> 
>  
> 
> exit;
> 
>  
> 
> sub DrawLine
> 
> {
> 
>     $layer = new mapscript::layerObj($map);
> 
>     $layer->{name} = $name;
> 
>     $layer->{type} = $mapscript::MS_LAYER_LINE;
> 
>     $layer->{symbolscale}   = 1000; # The scale at which symbols
and/or text
> appear full size.
> 
>     $layer->{minscale}      = 1;
> 
>     $layer->{labelcache}    = $mapscript::MS_ON;
> 
>     $layer->{labelmaxscale} = 50000;
> 
>  
> 
>     $class = new mapscript::classObj($layer);        
> 
>     $class->{numstyles} = 1;
> 
>  
> 
>     $class->{styles}->{minsize} = 40; 
> 
>     $class->{styles}->{maxsize} = 40; 
> 
>     $class->{styles}->{size}    = 40; 
> 
>     $class->{styles}->{symbol}  = 7;
> 
>  
> 
>     $class->{styles}->{color}->{red} = 255;
> 
>     $class->{styles}->{color}->{green} = 255;
> 
>     $class->{styles}->{color}->{blue} = 255;
> 
>  
> 
>     $class->{styles}->{outlinecolor}->{red} = 255;
> 
>     $class->{styles}->{outlinecolor}->{green} = 0;
> 
>     $class->{styles}->{outlinecolor}->{blue} = 0;
> 
>  
> 
>     $class->{label}->{color}->{red} = 0;
> 
>     $class->{label}->{color}->{green} = 255;
> 
>     $class->{label}->{color}->{blue} = 255;
> 
>     $class->{label}->{font} = 'arialbd';
> 
>     $class->{label}->{type} = $mapscript::MS_TRUETYPE;
> 
>     $class->{label}->{size} = 7;
> 
>     $class->{label}->{minsize} = 7;
> 
>  
> 
>     $shape = new mapscript::shapeObj($mapscript::MS_SHAPE_LINE );
> 
>  
> 
>     $line = new mapscript::lineObj();
> 
>         
> 
>     $point = new mapscript::pointObj();
> 
>  
> 
>     #EXTENT 388553.951505 3166053.063199 914513.202293 3691701.38882
> 
>  
> 
>     $point->{x} = 400000.000000;
> 
>     $point->{y} = 3200000.000000;
> 
>     $line->add($point);
> 
>     
> 
>     $point->{x} = 900000.000000;
> 
>     $point->{y} = 3600000.000000;
> 
>     $line->add($point);
> 
>         
> 
>     $shape->add($line);
> 
>  
> 
>     $shape->{text} = "TEST";
> 
>  
> 
>     $shape->draw($map,$layer,$img);
> 
>  
> 
>     $layer->draw($map, $img);
> 
>  
> 
>     undef $layer;
> 
>  
> 
> }
> 
>  
> 
>  
> 
> sub DrawPolygon
> 
> {
> 
>     $layer = new mapscript::layerObj($map);
> 
>     $layer->{name} = $name;
> 
>     $layer->{type} = $mapscript::MS_LAYER_POLYGON;
> 
>     $layer->{symbolscale}   = 1000; # The scale at which symbols
and/or text
> appear full size.
> 
>     $layer->{minscale}      = 1;
> 
>     $layer->{labelcache}    = $mapscript::MS_ON;
> 
>     $layer->{labelmaxscale} = 50000;
> 
>  
> 
>     $class = new mapscript::classObj($layer);        
> 
>     $class->{numstyles} = 1;
> 
>  
> 
>     $class->{styles}->{minsize} = 4; 
> 
>     $class->{styles}->{maxsize} = 4; 
> 
>     $class->{styles}->{size}    = 4; 
> 
>     $class->{styles}->{symbol}  = 7;
> 
>  
> 
>     $class->{styles}->{color}->{red} = 255;
> 
>     $class->{styles}->{color}->{green} = 255;
> 
>     $class->{styles}->{color}->{blue} = 255;
> 
>  
> 
>     $class->{styles}->{outlinecolor}->{red} = 255;
> 
>     $class->{styles}->{outlinecolor}->{green} = 0;
> 
>     $class->{styles}->{outlinecolor}->{blue} = 0;
> 
>  
> 
>     $class->{label}->{color}->{red} = 0;
> 
>     $class->{label}->{color}->{green} = 255;
> 
>     $class->{label}->{color}->{blue} = 255;
> 
>     $class->{label}->{font} = 'arialbd';
> 
>     $class->{label}->{type} = $mapscript::MS_TRUETYPE;
> 
>     $class->{label}->{size} = 7;
> 
>     $class->{label}->{minsize} = 7;
> 
>  
> 
>     $shape = new mapscript::shapeObj($mapscript::MS_SHAPE_POLYGON );
> 
>  
> 
>     $line = new mapscript::lineObj();
> 
>         
> 
>     $point = new mapscript::pointObj();
> 
>  
> 
>     #EXTENT 388553.951505 3166053.063199 914513.202293 3691701.38882
> 
>  
> 
>     $point->{x} = 400000.000000;
> 
>     $point->{y} = 3200000.000000;
> 
>     $line->add($point);
> 
>     $point->{x} = 900000.000000;
> 
>     $point->{y} = 3200000.000000;
> 
>     $line->add($point);
> 
>     $point->{x} = 900000.000000;
> 
>     $point->{y} = 3600000.000000;
> 
>     $line->add($point);
> 
>     $point->{x} = 400000.000000;
> 
>     $point->{y} = 3600000.000000;
> 
>     $line->add($point);
> 
>     $point->{x} = 400000.000000;
> 
>     $point->{y} = 3200000.000000;
> 
>     $line->add($point);
> 
>         
> 
>     $shape->add($line);
> 
>  
> 
>     $shape->{text} = "TEST";
> 
>  
> 
>     $shape->draw($map,$layer,$img);
> 
>  
> 
>     $layer->draw($map, $img);
> 
>  
> 
>     undef $layer;
> 
>  
> 
> }
> 
>  
> 
>  
> 
> ======================  end script ======================================
> 
>  
> 
>  
> 
>  
> 
> ====================== start map =======================================
> 
>  
> 
> # Start of map file
> 
> #
> 
> NAME DYN_TEST
> 
> STATUS ON
> 
> SIZE 600 600
> 
> FONTSET /var/fonts/font_sets
> 
> SYMBOLSET /var/symbols/symbolset.sym
> 
> EXTENT 388553.951505 3166053.063199 914513.202293 3691701.38882
> 
> UNITS meters
> 
> SHAPEPATH "shapes"
> 
> IMAGECOLOR 0 0 0
> 
>  
> 
> PROJECTION
> 
>   "proj=utm"
> 
>   "zone=15"
> 
>   "ellps=GRS80"
> 
>   "datum=NAD83"
> 
>   "units=m"
> 
> END
> 
>  
> 
> #
> 
> # Start of web interface definition
> 
> #
> 
> WEB
> 
>   HEADER dipx_header.html
> 
>   TEMPLATE dipx.html
> 
>   MINSCALE 1000
> 
>   MAXSCALE 100000000
> 
>   IMAGEPATH "/var/www/html/scratch/"
> 
>   IMAGEURL "/scratch/"
> 
>   LOG "/var/log/mapserver/mapserv.log"
> 
> END
> 
>  
> 
> #
> 
> # Start of reference map
> 
> #
> 
> REFERENCE
> 
>   IMAGE ref_base_zone_15.png
> 
>   EXTENT 388553.951505 3166053.063199 914513.202293 3691701.38882
> 
>   SIZE 120 120
> 
>   STATUS ON
> 
>   COLOR 255 255 255
> 
>   OUTLINECOLOR 255 0 0
> 
> END
> 
>  
> 
> #
> 
> # Start of legend
> 
> #
> 
> LEGEND
> 
>   KEYSIZE 18 12
> 
>   LABEL
> 
>     TYPE BITMAP
> 
>     SIZE MEDIUM
> 
>     COLOR 0 0 89
> 
>   END
> 
>   STATUS ON
> 
> END
> 
>  
> 
> #
> 
> # Start of scalebar
> 
> #
> 
> SCALEBAR
> 
>   IMAGECOLOR 255 255 255
> 
>   LABEL
> 
>     COLOR 0 0 0
> 
>     SIZE SMALL
> 
>   END
> 
>   SIZE 350 5
> 
>   COLOR 255 255 255
> 
>   BACKGROUNDCOLOR 0 0 0
> 
>   OUTLINECOLOR 0 0 0
> 
>   UNITS MILES
> 
>   INTERVALS 5
> 
>   STATUS EMBED
> 
> END
> 
>  
> 
> #
> 
> # Start of layer definitions
> 
> #
> 
>  
> 
>  
> 
> END # Map File
> 
> #
> 
>  
> 
>  
> 
> =======================  end map =========================
> 
> 





More information about the mapserver-users mailing list