Opened 11 years ago

Closed 11 years ago

#1585 closed defect (fixed)

Zoom Rectange doesn't work properly in Ajax viewer

Reported by: wuma Owned by: Mars Wu
Priority: low Milestone: 2.3
Component: AJAX Viewer Version:
Severity: trivial Keywords:
Cc: External ID: 1380783


With "Zoom Rectangle" command active, if I digitize a rectangle on screen which has a ratio of (width / height) < ratio of (map width / map height) The map will zoom to a wrong scale. (see attached screen shot) The zoomed map should contain all features in the zoom rectangle.

Attachments (2)

zoom_to_rectangle.jpg (31.8 KB) - added by wuma 11 years ago.
zoom_rectangle.patch (796 bytes) - added by wuma 11 years ago.

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by wuma

Attachment: zoom_to_rectangle.jpg added

comment:1 Changed 11 years ago by wuma

The reason is: in function ExecuteRectangleTool?, the scale calculation and zoom is done this way:

    if(tool == 3)
        if((x2 - x1 <= 2) && (y2 - y1 <= 2))

        pt1 = ScreenToMapUnits(x1, y1);
        pt2 = ScreenToMapUnits(x2, y2);

        mcsW = pt2.X - pt1.X;
        mcsH = pt2.Y - pt1.Y;
        scale = CalculateScale1(mcsW, mcsH, mapDevW, mapDevH);
        scale = finscale? GetNearestFiniteScale(scale): NormalizeScale(scale);
        GotoView(pt1.X + mcsW/2, pt1.Y + mcsH/2, scale, true, false);

In screen space, coordinates increase from top-left corner to bottom-right corner, while in map CS space, the coordinates increase from bottom-left corner to top-right corner. As a result, mcsH will be a negative number. While in above function, it is used as a positive number. Then the calculated scale is wrong.

Changed 11 years ago by wuma

Attachment: zoom_rectangle.patch added

comment:2 Changed 11 years ago by wuma

External ID: 1380783

comment:3 Changed 11 years ago by wuma

Milestone: 2.22.3
Version: 2.2.0

comment:4 Changed 11 years ago by wuma

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.