MapServer / MapServer-import

3 stars 2 forks source link

PHP MapScript - ZoomScale() error #46

Closed tbonfort closed 12 years ago

tbonfort commented 12 years ago

Reporter: dmorissette Date: 2001/09/20 - 16:31

Subject:        [mapserver-users] strange behaviour of zoomscale() in 
phpmapscript
   Date:        Sat, 15 Sep 2001 13:24:53 +0200
   From:        "Claude Philipona" <claude.philipona@camptocamp.com>
     To:        <mapserver-users@lists.gis.umn.edu>

Hello,
We have observed a strange behaviour with the zoomscale method in PHPMpscript
3.5.
If we set the zoomscale with a given scale, we get in return a scale that is not
set equal to what we gave as parameter. There is always a shift, which appears,
for a given width and height, to be a constant percentage of the scale. This
appears anywhere on the map, even very far from the maximum mapextent.

Is it a bug or a wrong use of the fonction? Actually, we need for our 
application
to be able to zoom with a precise scale, to get one to one pixel representation
of our raster image

Here is an example of the problem

we use:
MapScript Version (Aug 29, 2001)
MapServer version 3.5 (pre-alpha) OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
SUPPORTS=PROJ SUPPORTS=TTF SUPPORTS=WMS INPUT=EPPL7 INPUT=JPEG INPUT=OGR
INPUT=GDAL INPUT=SHAPEFILE

if we do:
$Map->zoomscale($scale, $pixelpos,
                    $width_pix, $height_pix,
                    $georefext, $georefmaxext);

with the following values (part of var_dump($Map->scale):
$scale:
int(28347)

$pixelpos:
["x"]=> float(281) ["y"]=> float(277)

$width:
int(400)

$height:
int(400)

$georefext:
["minx"]=> float(556933.36088877) ["miny"]=> float(111233.13134228) ["maxx"]=>
float(562918.54274843) ["maxy"]=> float(117218.31320194)

$georefmaxext:
["minx"]=> float(479231.75) ["miny"]=> float(65964.67) ["maxx"]=>
float(847736.75) ["maxy"]=> float(320184.67)

just after $Map->zoomscale() we get

$new_scale: 28276.1325

$new_extent (bbox): 559142.913985  111078.53760395  563132.98830536
115068.61192431

we have a difference between what we asked and what we get of :
28347 - 28276.1325 = 70.8675 which is 0.25% (this factor is constant for 400x400
map at any scale, but it chages with different scale).

This behaviour doesn't  depend on the initial scale prior to the call of
zoomscale (in this example, the initial scale was 42414)

Any idea on what is happening?

Claude Philipona
tbonfort commented 12 years ago

Author: assefa Date: 2001/09/24 - 18:03

Correct in function GetDeltaExtentsUsingScale in php_mapscript.c (was not in 
sync with msCalculateScale (mapscale.c) ).

Claude, could you please give it a try with the new version. Thanks,
tbonfort commented 12 years ago

Author: claude.philipona@camptocamp.com Date: 2001/09/24 - 20:04

The bug seems to be solved. It returns the same scale that we are asking, no 
error. Thanks for the quick fix.