Opened 17 years ago
Closed 13 years ago
#518 closed defect (fixed)
Zoom Rectangle calculation assumes lower-left to upper-right dragging in AJAX Viewer
Reported by: | nclayton | Owned by: | |
---|---|---|---|
Priority: | medium | Milestone: | 2.4 |
Component: | AJAX Viewer | Version: | 2.1.0 |
Severity: | minor | Keywords: | Zoom Rectangle |
Cc: | External ID: |
Description
In ajaxmappage.templ, the code assumes that users will always go lower-left to upper-right when drawing the Zoom Rectangle box.
pt1 = ScreenToMapUnits(x1, y1); pt2 = ScreenToMapUnits(x2, y2); mcsW = pt2.X - pt1.X; mcsH = pt2.Y - pt1.Y;
If a user (like myself) drags from upper-right to lower-left, mcsW and/or mcsH will be a negative value which will throw off the zoom operation.
By checking for a negative value then multiplying by -1 after the assignment will give accurate width and height values for the drawn box:
if(mcsW < 0){ mcsW = mcsW * -1; } if(mcsH < 0){ mcsH = mcsH * -1; }
Once these values are corrected, you'll need to find the lower X,Y values:
var lowX = (pt1.X < pt2.X? pt1.X: pt2.X); var lowY = (pt1.Y < pt2.Y? pt1.Y: pt2.Y);
Then calculate the view by adding the width/2 and height/2 values to the lowX and lowY values:
GotoView(lowX + mcsW/2, lowY + mcsH/2, scale, true, false);
I have set the Severity to minor, but for myself this was a major issue and I resolved it in my file.
I have not ran across it, but there may be other areas where drag direction is assumed and could sometimes be inaccurate.
Change History (4)
comment:1 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 15 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Version: | 2.0.0 → 2.1.0 |
This was still an issue in 2.1.0
The code in question is in the ExecuteRectangleTool function in ajaxmappane.templ The issue can be seen by zooming into an area and performing a zoom rectangle across an area. The returned image will be of a smaller portion of the area than selected. In some cases, this may be acceptable but others, but for others this isn't good. The changes stated above make the zoom rectangle accurate.
comment:3 by , 13 years ago
Milestone: | → 2.4 |
---|
comment:4 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
The code in ajaxmappane.templ has changed since then
mcsW and mcsH go through Math.abs() making negative values impossible
I guess this got fixed somewhere along the way, because I cannot reproduce on the trunk version.