[mapserver-users] reference box in reference map

Rodrigo Becke Cabral cabral at yadata.net
Thu Nov 8 09:09:45 PST 2001


Here is how you can calculate the reference map extents, so when you first
open the "map-page" the reference map should appear with the red border
fully visible. Don't know if there's a simple way to do that. This works for
latest version 3.5 (I had to change the formulas some time ago because of
some changes in mapserver):

1) Your reference image must have the same aspect ratio of your map initial
extents. So, lets say in your .map file you have: extent [minx] [miny]
[maxx] [maxy]. Then you calculate:

aspect = (maxy - miny) / (maxx - minx)
width = 120 # you can put any value you want
height = round( width * aspect )

2) Now, you must calculate the 'extent' you put in the 'reference' section
of your mapfile (it's not the same!). I took a peek in the way mapserver
maps logical (map) to physical (img) units, and the following formula is
working with me:

cellsize = max( (maxx-minx)/width, (maxy-miny)/height )
reference.extent.minx = minx
reference.extent.maxy = maxy
reference.extent.maxx = minx + cellsize*(width+1)
reference.extent.miny = maxy - cellsize*(height+1)

You should use the original map extent to generate the reference image with
your calculated "width" and "height". For those who use mapscript, attached
is a reference map generator. you should access it as:
mapref.php?map=<my_map_file>&width=<my_width>. The width argument is
optional.

Hope it works for you.
Rod.

----- Original Message -----
From: "Maul, Andreas-Alexander" <Andreas.Maul at bgr.de>
To: <    >
Sent: Thursday, November 08, 2001 10:41 AM
Subject: [mapserver-users] reference box in reference map


Hi list,
why does mapserver draw initially the reference box in the reference map
only partially? In example 3 of the tutorial  the first call of the
reference map shows only the right side of the red rectangle. The whole
rectangle is drawn only after zooming in. I get the same behaviour in my
application. Is there a trick to render the complete rectangle before
zooming in?
Andreas Maul

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapref.php
Type: application/octet-stream
Size: 1359 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20011108/7d95d63e/attachment.obj>


More information about the MapServer-users mailing list