Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my $map = new mapscript::mapObj();
- warn "New mapObj() error: $mapscript::ms_error->{message}\n" unless $map;
- $map->{status} = $mapscript::MS_ON; # STATUS ON
- $map->{units} = $mapscript::MS_DD; # UNITS DD
- $map->setImageType('png'); # IMAGETYPE PNG
- $map->{imagecolor} = new mapscript::colorObj(255, 255, 255); # IMAGECOLOR 255 255 255
- $map->setSize(1000, 600); # SIZE 1000 600
- $map->setExtent( -180, -90, 180, 90 ); # EXTENT -180 -90 180 90
- $map->selectOutputFormat( 'png' ); # Choose active output format
- $map->setProjection( "proj=latlong" ); # PROJECTION
- # "proj=latlong"
- # END
- my $outputFormatObj = new mapscript::outputFormatObj('GD/PNG'); # DRIVER "GD/PNG"
- $outputFormatObj->setExtension('png'); # EXTENSION "png"
- $outputFormatObj->setMimetype('image/png'); # MIMETYPE "image/png"
- $outputFormatObj->{imagemode} = $mapscript::MS_IMAGEMODE_RGB; # IMAGEMODE RGB | PC256
- $map->setOutputFormat( $outputFormatObj );
- my $layerObj = new mapscript::layerObj($map);
- $layerObj->setConnectionType($mapscript::MS_POSTGIS, '');
- $layerObj->{connection} = "host=127.0.0.1 port=5432 dbname=$db user=$dbuser password=$pwd";
- $layerObj->{data} = 'the_geom FROM table USING UNIQUE gid';
- my $classObj = new mapscript::classObj($layerObj);
- $classObj->{name} = 'foo';
- my $styleObj = new mapscript::styleObj($classObj);
- $styleObj->{color} = new mapscript::colorObj( 132, 132, 132);
- $styleObj->{outlinecolor} = new mapscript::colorObj(0, 0, 0);
- # create an image for drawing.
- my $img = $map->draw();
- warn "prepareImage() error: $mapscript::ms_error->{message}\n" unless $img;
- $img->save("$tmp_dir/$image_name");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement