[mapserver-users] Recalculating CELLSIZE

Rob gis at vanbooth.com
Tue Sep 2 06:03:02 EDT 2008


Many, many apologies if this is a repost(?), but I couldn't see my
reply in the Nabble thread list.

Following on from my previous posts about problems with MAXSCALE, it
looks like I've made some basic assumptions regarding scale and
extents based on how MapServer 4.8.3 worked, but that have since been
changed as part of RFC-25.  What I think I need to do is modify the
code so that those basic assumptions hold true once more.

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?

Many thanks in advance

Rob


More information about the mapserver-users mailing list