wrong img extent coordinates after draw() method (mapscript)

Christian Sengstock sengc at WEB.DE
Tue Dec 28 07:33:39 EST 2004


Hi!
Ive got a problem with the image extent of my mapscript map object. It is
changed during the method "mapobject->draw()" and i cant see why!
The class "mymap" is initialized with a map filename and the four image
extent coordinates and should draw the mapimage with the methods ...

- (Constructor)
 $mapobject = new mymap($mapfilename, -100, -50, 0, 50);

- (mapobject extent is set to the image extent coordinates)
 $mapobject->setext();

- (get image handle and image url)
 $mapobject->drawmap();

- (write html img link to html page)
 $mapobject->htmloutput();



That´s my source ...
<?
dl("php_mapscript_42.dll");
$mapfilename = "./sam.map";
?>

<html>
<head>
<title>Test2</title>
</head>
<body>

<?
class mymap {
 var $pageMap;
 var $ExtRect;
 var $imgUrl;

 function mymap ($filename, $minx, $miny, $maxx, $maxy) {
  $this->pageMap = ms_newMapObj($filename);

  $this->extoutp($this->pageMap->extent, "pageMap");

  $this->ExtRect = ms_newRectObj();
  $this->ExtRect->setextent($minx, $miny, $maxx, $maxy);

  $this->extoutp($this->ExtRect, "ExtRect");
 }

 function setext () {
  $this->pageMap->extent = $this->ExtRect;

  $this->extoutp($this->pageMap->extent, "PageMap after setext");
 }

 function drawmap() {
  $this->extoutp($this->pageMap->extent, "PageMap before drawmap");

  $image=$this->pageMap->draw();
  $this->imgUrl = $image->saveWebImage();

  $this->extoutp($this->pageMap->extent, "PageMap after drawmap");
 }

 function htmloutput () {
  echo "<img src=\"$this->imgUrl\">";
 }

 function extoutp($rectangle, $str) {
  $mix = $rectangle->minx;
  $miy = $rectangle->miny;
  $max = $rectangle->maxx;
  $may = $rectangle->maxy;
  echo "<p>$str data: $mix, $miy, $max, $may</p>";
 }
}

$mA = new mymap($mapfilename, -100, -50, 0, 50);
$mA->setext();
$mA->drawmap();
$mA->htmloutput();

?>

</body>
</html>


and that´s my output ...

pageMap data: -180, -90, 180, 90  /* init ext from mapfile *(
ExtRect data: -100, -50, 0, 50    /* generated rectangle from given coord */
PageMap after setext data: -100, -50, 0, 50        /* set mapobject OK */
PageMap before drawmap data: -100, -50, 0, 50      /* OK before draw */
PageMap after drawmap data: -180, -144, 180, 144   /* <-- weird transform */


Thanks for any help, Chris



More information about the mapserver-users mailing list