[mapserver-users] Scale calculation

Richard Greenwood Rich at GreenwoodMap.com
Wed Jul 11 14:44:41 EDT 2001


Your math makes sense to me. Are your units set to meters in your map file?

This is the code that calculates the scale:

     md = (width-1)/(MS_PPI*inchesPerUnit[units]);
     gd = extent.maxx - extent.minx;
     scale = gd/md;

where:
      width is your map width in screen pixels
      MS_PPI = 72
      inchesPerUnit[units] = 39.3701 (assuming you are using meters)
      gd is the width of the map in real world units


At 10:51 AM 7/11/2001 +0200, you wrote:
>I don't quite understand how scale are calculated. I know that mapserver 
>uses 72
>pixel per inch to calculate the scale.
>
>I've a tif raster map where 1 pixel = 2.5 meter. Here is the tfw file:
>2.500
>0.
>0.
>-2.500
>558751.250
>121998.750
>
>I want to calculate the right scale to render 1 pixel in the original tif file
>will give 1 pixel in the mpaserver map (no resizing)
>
>-> size of 1 pixel on screen = 1/72 inch =  2.54/72 cm = 0.0352777777 cm 
>(based
>on constant used by mapserver, I don't care about the real size on the screen)
>
>-> size of 1 pixel on tif raster map = 2.5 m = 250 cm
>
>-> scale calculation to render one pixel from the raster map to one pixel to
>mapservermap:
>0.035277777 : 250 -> 1:7086.6
>
>If I used this setting MINSACLE 7086 in .map file, I don't get the one to one
>pixel ratio and the original map is resized by mapserver.
>
>I've tried to empiracally set the scale and I found a scale of about 5300, 
>which
>would mean that the constant used by Mapserver is about 53.85 pixel per inch.
>
>Even the behaviour of this scale factor is strange, the scalebar is perfectly
>rendered (size of the scalebar corresponds to the size of the features on the
>map)
>
>What is wrong? Do you have any idea?
>
>Claude Philipona


Richard W. Greenwood, PLS
Greenwood Mapping, Inc.
Rich at GreenwoodMap.com
(307) 733-0203
http://www.GreenwoodMap.com




More information about the mapserver-users mailing list