[Mapserver-users] recalculate scale with mapscript

Sean Gillies sgillies at frii.com
Tue Dec 2 06:58:49 PST 2003


On Tuesday, December 2, 2003, at 06:54  AM, Michael Schulz wrote:

> Hi,
>
> how can i trigger the recalculation of the current scale for a 
> mapscript mapObj if i don't want to draw/prepareImage my map before?
>
> In this special case, i want to change the mapsize and then reassign 
> the scale the mapObj had before and then draw the image (so in my 
> application, when changing the mapsize the scale stays the same but 
> the extent changes).
>
> Cheers, Michael
>
> -- 
> -----------------------------------------------------------
> Michael Schulz                                in medias res
> Dipl.-Geologe                              Gesellschaft für
>                                 Informationstechnologie mbH
>                                      In den Weihermatten 66
> 		                             79108 Freiburg
>                                      0761 55695-95 (Fax 96)
> mschulz at webgis.de              www.webgis.de/www.zopecms.de
>
>

Michael,

There's a setExtent extension to mapObj in the 4.1 (CVS) MapServer.  
Since
we had frozen the features of 4.0, I did not commit it to that source 
branch.
You are welcome to paste it into your mapscript.i and re-build, it 
doesn't
depend on any other code in 4.1.

cheers,
Sean

   // Modeled after PHP-Mapscript method
   //
   // Adjusts map extents and sets map scale
   //
   // Difference from PHP-Mapscript is the rectObj arg is optional, 
default
   // value is NULL, in which case the current extent values will be
   // used, making this function useful to set the scale of a new mapObj.

   void setExtent(rectObj *rect=NULL) {
       if (rect == NULL) {
           // Leave the current extents alone
       }
       else {
           self->extent.minx = rect->minx;
           self->extent.miny = rect->miny;
           self->extent.maxx = rect->maxx;
           self->extent.maxy = rect->maxy;
       }
       self->cellsize = msAdjustExtent(&(self->extent), self->width,
                                       self->height);
       msCalculateScale(self->extent, self->units, self->width, 
self->height,
                        self->resolution, &(self->scale));
   }

--
Sean Gillies
sgillies at frii dot com
http://www.frii.com/~sgillies




More information about the MapServer-users mailing list