Advertisement
Guest User

baby_mapscript

a guest
Aug 27th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.99 KB | None | 0 0
  1. my $map = new mapscript::mapObj();
  2. warn "New mapObj() error: $mapscript::ms_error->{message}\n" unless $map;
  3.  
  4. $map->{status} = $mapscript::MS_ON;                             # STATUS ON
  5. $map->{units} = $mapscript::MS_DD;                              # UNITS DD
  6. $map->setImageType('png');                                      # IMAGETYPE PNG
  7. $map->{imagecolor} = new mapscript::colorObj(255, 255, 255);    # IMAGECOLOR 255 255 255
  8. $map->setSize(1000, 600);                                       # SIZE 1000 600
  9. $map->setExtent( -180, -90, 180, 90 );                          # EXTENT -180 -90 180 90
  10. $map->selectOutputFormat( 'png' );                              # Choose active output format
  11. $map->setProjection( "proj=latlong" );                          # PROJECTION
  12.                                                                 #   "proj=latlong"
  13.                                                                 # END
  14.  
  15. my $outputFormatObj = new mapscript::outputFormatObj('GD/PNG'); # DRIVER "GD/PNG"
  16. $outputFormatObj->setExtension('png');                          # EXTENSION "png"
  17. $outputFormatObj->setMimetype('image/png');                     # MIMETYPE "image/png"
  18. $outputFormatObj->{imagemode} = $mapscript::MS_IMAGEMODE_RGB;   # IMAGEMODE RGB | PC256
  19.  
  20. $map->setOutputFormat( $outputFormatObj );
  21.  
  22. my $layerObj = new mapscript::layerObj($map);
  23. $layerObj->setConnectionType($mapscript::MS_POSTGIS, '');
  24. $layerObj->{connection} = "host=127.0.0.1 port=5432 dbname=$db user=$dbuser password=$pwd";
  25. $layerObj->{data} = 'the_geom FROM table USING UNIQUE gid';
  26.    
  27. my $classObj = new mapscript::classObj($layerObj);
  28. $classObj->{name} = 'foo';
  29.  
  30. my $styleObj = new mapscript::styleObj($classObj);        
  31. $styleObj->{color} = new mapscript::colorObj( 132, 132, 132);
  32. $styleObj->{outlinecolor} = new mapscript::colorObj(0, 0, 0);
  33.  
  34. # create an image for drawing.
  35. my $img = $map->draw();
  36. warn "prepareImage() error: $mapscript::ms_error->{message}\n" unless $img;
  37.  
  38. $img->save("$tmp_dir/$image_name");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement