<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2627" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2>Nick -</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2>I'm not sure what your "unit" is supposed to mean, but I 
can describe the process for taking the pixel size and finding the right 
MINSCALE/MAXSCALE values.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2>The MINSCALE and MAXSCALE values are the denominators of 
scale ratios, like 1:10,000 scale.&nbsp; MINSCALE 10000 means "a minimum scale 
of 1:10,000", where one meter on the map equals 10,000 meters on the 
ground.&nbsp; The problem becomes, "what's one meter on the 
map"?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2>The RESOLUTION statement answers that question.&nbsp; The 
default value is 72, meaning that 72 pixels in a MapServer output image are 
presumed to occupy one inch on the screen.&nbsp; This is actually unlikely to be 
an accurate value unless you're running a 20-year-old Macintosh, but it often 
doesn't matter&nbsp;- it's mostly used for internal 
calculations.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2>So, if 72 pixels are presumed to cover one inch on the 
screen, and your image has a source resolution of 1.26956817 meters per pixel, 
then one inch on the screen will show 72 * 1.26956817 meters or 91.40890824 
meters of image.&nbsp; Since 91.40890824 meters equals 3598.7687 inches, this 
means one inch on the screen shows 3598.7687 inches on the ground - a scale 
ratio of 1:3598.7687</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=500564301-25042005><FONT face=Arial 
color=#0000ff size=2>If you displayed that image at the "scale" of 3598.7687 you 
should get a pixel-for-pixel replica of your source image.&nbsp; If you use a 
different RESOLUTION statement, you need to adjust 
accordingly.</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=500564301-25042005></SPAN><FONT face=Arial><FONT 
color=#0000ff><FONT size=2>F<SPAN class=500564301-25042005>or calculating the 
IMGEXT values, you simply need to make the X extent and Y extent equal the 
number of (X or Y) pixels in the image times 
1.26956817.</SPAN></FONT></FONT></FONT><BR></DIV>
<DIV><SPAN class=500564301-25042005><FONT face=Arial color=#0000ff size=2>Yes, 
there are better-quality ways of resampling images, but - as you saw in Preview 
- they're slow.&nbsp; MapServer doesn't use them, but you can use various tools 
(including gdalwarp, from the GDAL distribution) to resample images offline and 
create "pyramids" of varying resolutions.&nbsp; This will improve the display 
quality of your images while keeping the performance fast - at the expense of 
extra disk space and preprocessing work.</FONT></SPAN></DIV>
<DIV><SPAN class=500564301-25042005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=500564301-25042005>&nbsp;&nbsp;&nbsp; <FONT face=Arial 
color=#0000ff size=2>- Ed</FONT></SPAN></DIV>
<DIV><SPAN class=500564301-25042005><!-- Converted from text/plain format -->
<P><FONT size=2>Ed McNierney<BR>President and Chief Mapmaker<BR>TopoZone.com / 
Maps a la carte, Inc.<BR>73 Princeton Street, Suite 305<BR>North Chelmsford, 
MA&nbsp; 01863<BR>Phone: +1 (978) 251-4242<BR>Fax: +1 (978) 
251-1396<BR>ed@topozone.com</FONT> </P></SPAN></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> UMN MapServer Users List 
[mailto:MAPSERVER-USERS@LISTS.UMN.EDU] <B>On Behalf Of </B>Nick 
Dabner<BR><B>Sent:</B> Sunday, April 24, 2005 7:17 PM<BR><B>To:</B> 
MAPSERVER-USERS@LISTS.UMN.EDU<BR><B>Subject:</B> Re: [UMN_MAPSERVER-USERS] 
Zooming to match a raster scale<BR></FONT><BR></DIV>
<DIV></DIV><!-- Converted from text/enriched format -->
<DIV>Got it. - Thanks Bart. My extents were wrong as IMGEXT do not match the 
gdalinfo info fo upper-left, lower-right style when applied to Australia. Seems 
I have to switch the latitude. </DIV><BR>
<DIV>Ok, so just to finish up this thread, found a solution by taking a point 
using Mapxy and then applying a scale or buffer. The rasters I am using have a 
pixel size of (1.26956817,-1.26956817) and a unit of 0.0174532925199433. By 
matching the scale as returned in the template/html file, as close as possible 
to this pixel size shown by gdalinfo, the maps start looking pretty good as they 
have little or no scaling. </DIV><BR>
<DIV>First question: With a given pixel size and unit (metres) above, what is 
the formula to work out the scale to input? In the example above, I found a 
value of .31267 would give me a matching output scale to pixel size to 4 decimal 
places. </DIV><BR>
<DIV>Second question: Loading the TIF file up in Apple Preview, it looks jagged 
for a moment, until it anti-aliases the file. Once anti-aliased, the legibility 
improves noticeably. I take it mapserver cannot perform any anti-aliasing when 
scaling rasters. I suspect even nearest neighbour would be a great improvement. 
Any plans for this? I guess it would require JPEG or PNG24 to provide enough 
colours. Is it possible for a browser or client app to do this work? </DIV><BR>
<DIV>regards, </DIV><BR>
<DIV>Nick </DIV><BR><BR>
<DIV>On 25/04/2005, at 7:45 AM, Nick Dabner wrote: </DIV><BR>
<BLOCKQUOTE>
  <DIV>Thanks Bart, </DIV><BR>
  <DIV>So I take it that scale and mapxy are mutually exclusive with mapext? 
  Removing mapext always results in the error: </DIV><BR>
  <DIV><FONT face=Times><BIG><BIG>msDrawMap(): Image handling error. Unable to 
  initialize image. </DIV>
  <DIV>msCalculateScale(): General error message. Invalid image extent, 
  minx=-1.000000, miny=-1.000000, maxx=-1.000000, maxy=-1.000000 </DIV>
  <DIV></BIG></BIG></FONT></DIV>
  <DIV>Any idea what I am doing wrong? Also I found out my scale is current 3.15 
  on the output map and needs to be 2.59, hence the poor output. Would a 
  resolution tag in the mapfile help? </DIV><BR>
  <DIV>ND </DIV><BR>
  <DIV>On 24/04/2005, at 10:45 PM, Bart van den Eijnden wrote: </DIV><BR>
  <BLOCKQUOTE>
    <DIV>Hi Nick, </DIV><BR>
    <DIV>you can probably use a combination of mapxy and scale. </DIV><BR>
    <DIV>See Mapserver CGI reference: </DIV>
    <DIV>http://mapserver.gis.umn.edu/doc44/cgi-reference.html </DIV><BR>
    <DIV>Best regards, </DIV>
    <DIV>Bart </DIV><BR>
    <DIV>On Sun, 24 Apr 2005 22:38:34 +1000, Nick Dabner 
    &lt;dabner@OPTUSNET.COM.AU&gt; </DIV>
    <DIV>wrote: </DIV><BR>
    <BLOCKQUOTE>
      <DIV>Hello list, </DIV><BR>
      <DIV>I have a set of raster geotiffs tiled and working on mapserver 4.2 on 
      </DIV>
      <DIV>osx (thanks to william k). </DIV><BR>
      <DIV>When viewing the rasters in mapserver, I find they suffer from some 
      </DIV>
      <DIV>slight scaling and never look anywhere near as good as the original 
      </DIV>
      <DIV>files. I have given dithering and PNG24 a go, but see that I probably 
      </DIV>
      <DIV>need to match my mapserver session's scale as close as possible to 
      the </DIV>
      <DIV>source data scale. Does this sound right? </DIV><BR>
      <DIV>Using CGI mapserver, how can I specify an exact viewing area (to 
      match </DIV>
      <DIV>my calculations)? What argument would I choose. </DIV><BR>
      <DIV>Attemping to pass IMGEXT=2482199.076569 4407814.492404 
      2484230.3854232 </DIV>
      <DIV>4406291.0107634 just returns an extent error. Oh, I am in Melb Aust, 
      so </DIV>
      <DIV>these are real coords. </DIV><BR>
      <DIV>Any other ideas? The next step would probably be fixed zoom levels 
      for </DIV>
      <DIV>street, area, suburb, municipality and city or similar, with </DIV>
      <DIV>preprocessed rasters for each level. </DIV><BR>
      <DIV>regards, </DIV><BR>
      <DIV>Nick </DIV><BR></BLOCKQUOTE><BR><BR><BR>
    <DIV>-- </DIV>
    <DIV>Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ 
    </DIV><BR></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>