Opened 15 years ago
Closed 15 years ago
#3131 closed defect (fixed)
Bug with mapObj.zoomScale() does not set the scale to the desired value.
Reported by: | kfaschoway | Owned by: | aboudreault |
---|---|---|---|
Priority: | normal | Milestone: | 5.6 release |
Component: | MapScript-PHP | Version: | 5.4 |
Severity: | normal | Keywords: | |
Cc: | aboudreault, dmorissette, assefa |
Description
The function mapObj.zoomScale(...) does not set the scale to the desired value. If the desired scale is 20,000,000 then the function would set the scale to something slightly different like 20,000,063 after the function call.
Attachments (2)
Change History (21)
comment:1 by , 15 years ago
Component: | MapServer C Library → MapScript-PHP |
---|---|
Owner: | changed from | to
comment:2 by , 15 years ago
Cc: | added |
---|---|
Milestone: | → 5.6 release |
Can you please provide a test case to reproduce? A small mapfile + PHP script should be enough in this case.
BTW, you marked this ticket as version 5.2. Is this really the version you are using? Would it be possible for you to retest this with a more recent version?
comment:3 by , 15 years ago
Version: | 5.2 → 5.4 |
---|
We retested with version 5.4.2 and got the same result. We are in the process of creating a suitable test case.
comment:4 by , 15 years ago
kfaschoway, I would like to check that ticket. Is your test case ready? Thanks!
by , 15 years ago
Attachment: | zoomScaleTestData.zip added |
---|
comment:5 by , 15 years ago
aboudreault, I have attached test data. Let me know if you need anything else.
comment:6 by , 15 years ago
Cc: | added |
---|---|
Owner: | changed from | to
comment:7 by , 15 years ago
Is my test script is ok? Is it supposed to fail?
$szMapFile = "./test.map"; $oMap = ms_newMapObj($szMapFile); $oMap->draw(); echo "Current Scale: ".$oMap->scaledenom."<br/>"; $p1 = ms_newPointObj(); $p1->setXY(100,50); $r = ms_newRectObj(); $r->setextent(-1541932.35654056,-1756849.79208326,2966774.81854162, 3051857.38299892); $oMap->zoomScale(20000000, $p1, 500,700, $r); $oMap->draw(); echo "Modified Scale: ".$oMap->scaledenom;
output
Current Scale: 28452741.021 Modified Scale: 20000000
by , 15 years ago
Attachment: | MapServerTest.zip added |
---|
comment:8 by , 15 years ago
I have attached a VS2005 C# app that does similar to your php code but for some reason the scaledenom does not get set to the desired value of 20,000,000. It returns as 20,040,080.1603206.
comment:9 by , 15 years ago
comment:10 by , 15 years ago
May I also ask why this was filed as a PHP MapScript ticket if it happens with C#?
comment:13 by , 15 years ago
I confirm that the problem is related to the swig related bindings. Here's the python output:
Current Scale: 28452741.020975 Modified scale: 20040080.160321
comment:14 by , 15 years ago
The swig stuff was a straight port of the PHP functions by Sean way back. Does PHP not return the same values as the swig bindings?
Steve
comment:15 by , 15 years ago
Steve, swig and PHP do not return the same values. The problem is that the dfDeltaExt is not calculated as it is in PHP. In PHP (PHP uses its own function to calculate the delta extents using scale: I modified the code below to easily compare it to swig):
dfDeltaExt=scale*((nTmp-1)/(self->resolution*msInchesPerUnit(self->units,dfGeoPosY)));
in the swig function:
dfDeltaExt=scale*nTmp/(self->resolution*msInchesPerUnit(self->units,0));
Is it ok to change the zoomScale function (and all other functions in mapzoom.i: zoomRectangle, etc.) to do the same calcul as PHP does (which I assume the right result) ?
comment:16 by , 15 years ago
FYI, I've already done the test and doing that change make the proper scaledenom after the function call. (Tested in Python).
comment:17 by , 15 years ago
Keeping zoomScale consistent across the board is important so your change makes perfect sense to me. We should note the need to change those functions in both places somehow. Perhaps comments in both environments?
Steve
comment:18 by , 15 years ago
The Delta Extents is now calculated the same way as php does. I've also fixed the zoomRectangle function, which had the same bug and also an error check mistake.
Fixed and committed in r9444.
comment:19 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Assuming this is in PHP/MapScript. Those functions all originated there... I would think this is rounding error related. Given that MapServer requires square pixels it may not be possible to achieve a scale exactly with a given aspect ratio.
Steve