[MAPSERVER-USERS] Problems calculating MAXSCALES

Rob gis at vanbooth.com
Mon Sep 1 06:24:38 EDT 2008


Many thanks for the reply Steve.

I'm trying to modify the mapserver code to compute the cellsize based
on my original extent calculations, and not the extent calculations
that Mapserver now uses.

Based on the following links
http://mapserver.gis.umn.edu/development/rfc/ms-rfc-25/
http://trac.osgeo.org/mapserver/ticket/2015
http://trac.osgeo.org/mapserver/changeset/6529
http://trac.osgeo.org/mapserver/changeset/5895

I have modified the folllowing :

maputil.c - msAdjustExtent
ox = MS_MAX(((width) - (rect->maxx - rect->minx)/cellsize)/2,0);
oy = MS_MAX(((height) - (rect->maxy - rect->miny)/cellsize)/2,0);

mapscale.c - msCalculateScale
    md = (width)/(resolution*msInchesPerUnit(units, center_y));

maptemplate.c  - setExtent
    case FROMSCALE:
     cellsize =
(msObj->Scale/msObj->Map->resolution)/msInchesPerUnit(msObj->Map->units,0);
// user supplied a point and a scale
     msObj->Map->extent.minx = msObj->MapPnt.x - cellsize*msObj->Map->width/2.0;
     msObj->Map->extent.miny = msObj->MapPnt.y -
cellsize*msObj->Map->height/2.0;
     msObj->Map->extent.maxx = msObj->MapPnt.x + cellsize*msObj->Map->width/2.0;
     msObj->Map->extent.maxy = msObj->MapPnt.y +
cellsize*msObj->Map->height/2.0;

mapserver.h
#define MS_CELLSIZE(min,max,d)    ((max - min)/d)

I'm still getting figures that are ever so slightly out (1:1,999,995
instead of 1:2m), but these margins still vary depending on image
size, so I still can't just modify my MAXSCALEDENOM values to
compensate for any potential rounding errors that may be causing the
discrepancies.

I'm not up to speed on what all the components of the code do - should
I also be modifying some of the width-1 calculations that are in
mapprimitive.c (msOffsetPointRelativeTo) ?

Is there anything else I have missed?

Thanks

Rob

2008/8/14 Steve Lime <Steve.Lime at dnr.state.mn.us>:
> Your assuming that an extent in ESRI represents the same thing MapServer. It doesn't assuming an ESRI extent is UL corner of UL pixel and the LR corner of the LR pixel for the rendered map. MapServer would use the centers of each pixel. You need to account for those differences when comparing the two. (MapServer has roots with ERDAS Imagine and that was the model it used at the time.) Compute cellsize from the ESRI extent (maxx-minx)/width and then offset the extent by 1/2 cellsize (UL + cellsize, LR - cellsize) to get the MapServer equivalent. If you do that then the scales will match.
>
> Perhaps this will change at some point and lead to even more confusion.
>
> Steve
>


More information about the mapserver-users mailing list