Mapscript extent prediction
Johan Van de Wauw
johan.vandewauw at GMAIL.COM
Wed May 23 12:52:18 PDT 2007
Even though I found a workaround that works for my application (generating
the image first and later the accompying html page), the original problem
still persists.
Just a short example of code (where the width and height are based on the
extent, like in my application) and it's output. My hypothesis is that maybe
the longitude/latitude values are the problem?
dl('php_mapscript.so');
$oMap = ms_newMapObj('/home/johan/rwanda/start-print.map');
$mapExtent = $oMap->extent;
$oMap->setExtent($aExtent[0],$aExtent[1],$aExtent[2],$aExtent[3]);
$tot = $oMap->numlayers;
$pw = 600;
$gw =$aExtent[2] - $aExtent[0];
$gh = $aExtent[3] - $aExtent[1];
$ph = ceil($pw*$gh/$gw);
$oMap->set('width', $pw);
$oMap->set('height', $ph);
$oMap->selectOutputFormat('PNG');
var_dump($oMap->extent);
$oImg = $oMap->draw();
var_dump($oMap->extent);
die;
gives the following output:
object(ms_rect_obj)#2 (5) {
["_handle_"]=>
resource(3) of type (Unknown)
["minx"]=>
float(29.7975484895)
["miny"]=>
float(-1.93103563105)
["maxx"]=>
float(29.9594623555)
["maxy"]=>
float(-1.80965089289)
}
(and after the draw method is called:)
object(ms_rect_obj)#2 (5) {
["_handle_"]=>
resource(3) of type (Unknown)
["minx"]=>
float(29.7596991183)
["miny"]=>
float(-1.93103563105)
["maxx"]=>
float(29.9973117267)
["maxy"]=>
float(-1.80965089289)
}
>
>
> 2007/5/23, Johan Van de Wauw <johan.vandewauw at gmail.com>:
> > Hello everyone,
> >
> > When generating a map using mapscript, I notice that the extent changes
> > (slightly) after calling the "draw" operation.
> > I don't seem to be the only one with this problem as eg the ka-map wiki
> > says:
> >
> > Print output is related to viewport but image extent correspondence in
> not
> > yet perfect.
> >
> > Is there a way to make this correspondence better, or is there a way to
> > get/predict the actual extent used in the image before (or without)
> calling
> > the "draw" method?
> >
> > Johan
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20070523/20f3ea57/attachment.htm>
More information about the MapServer-users
mailing list