don't understand scale

Douglass Davis douglass_davis at EARTHLINK.NET
Wed Aug 3 21:30:41 PDT 2005


Ok, thanks for all the help everyone.  I guess mapObj->{scale}was the 
magic number I was looking for.

Just wanted to point out though that oddly enough PHP/Mapscript you will 
get -1 for scale, until you set the extent (or call another method on 
the mapObj apparently).

here's the code:

$map = ms_newMapObj($map_file);

echo "<br>scale1= ".$map->scale;  // prints -1

// just setting to what it is already.
$map->setExtent(
    $map->extent->minx,
    $map->extent->miny,
    $map->extent->maxx,
    $map->extent->maxy);

echo "<br>scale2= ".$map->scale;  // prints real scale value

I thought this was strange... But, in case anyone is interested, this is 
what I had to do to make it work.

--
http://www.douglassdavis.com

Stephen Woodbridge wrote:

> Douglass,
>
> Scale is the ratio of the real world extents of an image of your data 
> compared to the physical rendered image of that data.
>
> SO say for example lets say you display 10 miles of real world data 
> onto an image that is ten inches wide. Then you scale is 1 in : 1 mile 
> or 1:63360 because 1 mi = 5280 * 12 inches
>
> For displaying on the screen we figure 72 dot per inch. If you are 
> trying to figure out how to set minscale and maxscale values, most of 
> us  add
>
>   <p>Scale 1:[scale]</p>
>
> to our templates or get the scale directly from the mapObj->{scale} 
> and print it on out web pages. Then as we zoom in/out if always shows 
> the scale.
>
> HTH,
>   -Steve W.
>
> Douglass Davis wrote:
>
>> Ok, so the scale is relative to the units used in the mapfile.  I 
>> still don't quite understand.  This example would help me a lot if 
>> any one could explain it.
>>
>> let's say I have a map with (fictitional units)
>>
>> EXTENT 100 100 200 300
>>
>> Now...  For example, what scale number will I have to use in 
>> zoomScale to get a map scaled to exactly 100%.  Meaning, exactly the 
>> same map I would get without scaling.  From that number I can get the 
>> other scales.
>>
>> And can any one explain how they got this mathematically?
>>
>> ---
>> http://www.douglassdavis.com
>>
>>
>> Douglass Davis wrote:
>>
>>> I am using php mapscript, and i want to zoom in to a point.  I have 
>>> two options:
>>>
>>> zoomPoint and zoomScale...  I understand zoomPoint, because it just 
>>> zooms by a percentage.  But, zoomScale, I am not understanding.  It 
>>> zooms to a certain scale, which is a double.  What does that scale 
>>> represent? What is the scale relative to?  The docs don't really 
>>> explain this well.
>>>
>>> The reason I wanted to do this, is because instead of  zooming in 
>>> and out relative to the previous map's extent, it would be better if 
>>> I had about 9 zoom levels, kind of like mapquest.  level 1 would 
>>> show the states, level 9 would be a close up of the street.   But 
>>> each of the 9 levels would be a fixed zoom amount, relative to the 
>>> size of the original extent in the mapfile possibly.   Is this 
>>> difficult to do?
>>>
>>> -- 
>>> http://www.douglassdavis.com
>>>
>>
>
>



More information about the MapServer-users mailing list