<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Here is an extraction of some of my code. I get PDF maps to an
accurate scale when printed.<br>
<br>
All steps are necessary and must be in the order described.<br>
<br>
<tt> $map = new mapObj($mapfile);</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> $map->selectOutputFormat('PDF'); // defined in
mapfile</tt><tt><br>
</tt><tt><br>
</tt><tt> // set mapsize using pdfMapDef paper sizes</tt><tt><br>
</tt><tt> // $map->resolution defaults to 72 pixels/inch</tt><tt><br>
</tt><tt> $w = $width_inches * $map->resolution;</tt><tt><br>
</tt><tt> $h = $height_inches * $map->resolution;</tt><tt><br>
</tt><tt> $map->setSize($w, $h); //in pixels</tt><tt><br>
</tt><tt><br>
</tt><tt> // set to actual sizes set by 'setSize'</tt><tt><br>
</tt><tt> $w = $map->width;</tt><tt><br>
</tt><tt> $h = $map->height;</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> $map->setExtent($bounds[0], $bounds[1], $bounds[2],
$bounds[3]);</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> // calculate center point in pixels</tt><tt><br>
</tt><tt> // this center will not be very accurate as it is a
pixel value?? </tt><tt><br>
</tt><tt> $x = $w * ($center->x - $map->extent->minx) /
($map->extent->maxx - $map->extent->minx);</tt><tt><br>
</tt><tt> $y = $h - ($h * ($center->y -
$map->extent->miny) / ($map->extent->maxy -
$map->extent->miny));</tt><tt><br>
</tt><tt><br>
</tt><tt> $center_pixel = new pointObj();</tt><tt><br>
</tt><tt> $center_pixel->setXY($x, $y);</tt><tt><br>
</tt><tt><br>
</tt><tt> // this zooms the map to scale given in $scaleDemon</tt><tt><br>
</tt><tt> // but the center value is not accurate enough for
small scale maps</tt><tt><br>
</tt><tt> $scaleDenom = 4000;</tt><tt><br>
</tt><tt> $success = $map->zoomScale($scaleDenom,
$center_pixel, $w, $h, $map->extent);</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> if ($success == MS_FAILURE) echo "\n FAILURE OF
zoomScale";</tt><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt><tt> // set the desired center in map units to get a better
map</tt><tt><br>
</tt><tt> $x_mapunits = <your value here>;</tt><tt><br>
</tt><tt> $y_mapunits = <your value here>;</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> // here setCenter will set the center point of the map
based upon</tt><tt><br>
</tt><tt> // the center value in map units not pixels</tt><tt><br>
</tt><tt> $center_mapunits = new pointObj();</tt><tt><br>
</tt><tt> $center_mapunits->setXY($x_mapunits, $y_mapunits);</tt><tt><br>
</tt><tt> $success = $map->setCenter($center_mapunits);</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> if ($success == MS_FAILURE) echo "\n FAILURE OF
setCenter";</tt><tt><br>
</tt><tt><br>
</tt><tt> // ** turn on desired layers here **</tt><tt><br>
</tt><tt> </tt><tt><br>
</tt><tt> $img = $map->draw();</tt><tt><br>
</tt><tt> $outfile = $img->saveWebimage();</tt><tt><br>
</tt><br>
<br>
<br>
<div class="moz-signature"><b>Worth Lutz</b><br>
<br>
<br>
</div>
<div class="moz-cite-prefix">On 05/18/2016 07:10 AM, ankur
chitranshi wrote:<br>
</div>
<blockquote
cite="mid:CA+Pqw-50XMnPjvT6bakHubjtsSyqqPQ+kZ+sVB9OVVBOa=nu1A@mail.gmail.com"
type="cite">
<div dir="ltr">
<div style="font-size:12.8px">hello all, <br>
<br>
</div>
<span style="font-size:12.8px"> can any body help me out in how
touser-define map scale manually in mapserver(ms4w) map script
mode </span><br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature">thanks & regards<br>
Ankur Chitranshi<br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
mapserver-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapserver-users">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a></pre>
</blockquote>
<br>
</body>
</html>