[mapserver-users] More about SCALE calculations

Jeff Hoffmann jeff at propertykey.com
Fri Nov 29 09:49:01 EST 2002


Lars V. Nielsen wrote:
> Hi List,
> 
> Just wanted to share my latest findings on the SCALE issue.
> After testing various combinations of extent (zoom), width and scales I've
> discovered a constant !
> 
> It seems these formulas will work (scale_number is > 1, i.e. scale =
> 1:scale_number) :
> 
> Constant = (field width in meters) / ( (scale_number) * (pixel width) ) =
> 0.000352777... = 1 / 2834.6472..
> I.e.
> Scale_number = (field width in meters) / ( (pixel width) * 0.000352777.. )
> 
> It's workable for now, but I'd still like to know what this constant
> represents (if anything) ??
> 'cause I'm not sure whether more parameters should go into the equations,
> e.g. (server) screen size and resolution ???

I'm not an expert, but my understanding of how this works is as follows:

Mapserver assumes an on-screen resolution of 72 pixels/inch -- so a map 
that is, say, 360 pixels wide on screen would be assumed by mapserver to 
be 5 inches wide.  The scale factor would be the the number of inches 
wide your map is divided by the (assumed) 5 inch wide map.  A map that 
is 1 mile (5280 ft.) wide would have a scale of:

(5280 ft * 12 in/ft * 72 pixels/inch)/360 pixels = 12672 (scale).

That's for us Americans.  As for the rest of the world, the resolution 
would be :

72 pixels/inch / 2.54 cm/inch = 28.3464 pixels/cm or 2834.64 pixels/m.

That should explain the number you're using.  It's not magic, but it 
seemed like it to me for a while.  I'm fairly new to mapserver and had 
to struggle with it for a while to figure it out. You can change the 
screen resolution in the configuration file if you want, but it's a fake 
number anyway unless you know the actual screen resolution of the 
end-user's display device, so I can't see the point.  The parameter 
you're looking for is RESOLUTION in the MAP object.

-- 

Jeff Hoffmann
PropertyKey.com




More information about the mapserver-users mailing list