[Mapserver-users] Map Extent

Ed McNierney ed at topozone.com
Mon Feb 3 15:13:21 EST 2003


Eric -

You will get predictable but unexpected results if your map image size and your map extents are not proportional.  In your case, you're using a "geographic" projection, so latitude and longitude are treated as planar X/Y coordinates.

You're asking for an image that's 15 degrees wide (X dimension) and 8 degrees high (Y dimension) - so the X extent of the image is about 1.5 times the height.  But you're asking for an image that's 400 pixels wide by 300 pixels high, or about 1.3 times as wide as it is high.  The shapes of the two rectangles are not the same.

Since MapServer does not produce distorted maps, it will adjust the requested X and Y extents of the map in order to be proportional to the size of the requested output image.  Unless you make the same adjustment, your output X and Y extents won't be what you expect.

The easiest fix is to simply change the EXTENTS of the map so the ratio (delta longitude) / (delta latitude) = 400 / 300 in your case.

Once you get that fixed, we'll start working on why you're mapping lobsters in Michigan....

	- Ed

Ed McNierney
President and Chief Mapmaker
TopoZone.com / Maps a la carte, Inc.
73 Princeton Street, Suite 305
North Chelmsford, MA  01863
ed at topozone.com
(978) 251-4242 

-----Original Message-----
From: Eric Bridger [mailto:eric at gomoos.org]
Sent: Monday, February 03, 2003 8:46 AM
To: mapserver-users at lists.gis.umn.edu
Subject: [Mapserver-users] Map Extent




Hi all.  I am a new mapserver, mapscript user, about 2 weeks now.  So
first my thanks to all involved in developing a truly excellent
application.  We are using Mapserver 3.6.4 and mapscript to develop an
Linux Apache/mod-perl oceanographic application.

I am having trouble mapping the users map image mouse click to map
coordinates with precision.  At first I thought it might be the
registration of the map datasets we were using (shape files) with one
shaded relief jpg, so I switched to using the states_ugl data and the
s1ex1.map from the 3.6 tutorial in a simple mapscript test and noticed
the same issues.

When adding a point symbol to the map at the location clicked, the
symbol appears near where I expected but not exactly where I expected. 
The closer I click to the center of the map the closer the symbol
registers.  It appears to me that the y-coordinate is always on target,
but that the x corrdinate is off. The closer to the edges of the map,
the further off the x coordinate is.

Perhaps this has to do with the fact that the map created 400x300 goes
all the way from y=0 to y=400, but not from x=0 to x=300?

The mapextent is gotten from the map object created from the map file.

I calculate the map coordinates with code adapted from the mapquakes.pl
example: 
if($q->param('img.x') && $q->param('imgext')) { # Make sure we got a
click
    @imgext = split(' ', $q->param('imgext'));
    $x = $q->param('img.x');
    $y = $q->param('img.y');

    $cx = ($imgext[2]-$imgext[0])/($map->{width}-1);  
    $cy = ($imgext[3]-$imgext[1])/($map->{height}-1);

    $x = $imgext[0] + $cx*$x;
    $y = $imgext[3] - $cy*$y;
}

Create a point object and add it to the map and display it.


Par of the map file:
MAP
EXTENT -97.238976 41.619778 -82.122902 49.38562
SIZE 400 300
SHAPEPATH "/home/eric/work/htdocs/mapserver/tutorial35/data"
# Added by EB
IMAGETYPE PNG
UNITS DD

LAYER # States
  NAME "lobster_zones"
  DATA states_ugl
  STATUS DEFAULT
  TYPE POLYGON
  CLASSITEM "STATE"
  CLASS
    NAME "Michigan"
    COLOR 255 255 128
    OUTLINECOLOR 0 0 0
  END # end of class object
END # end of layer object

....

Thanks.

Eric Bridger
eric at gomoos.org
Gulf of Maine Ocean Observing System www.gomoos.org


_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list