Opened 14 years ago

Closed 13 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

Description

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 14 years ago.
zoom_rectangle.patch (796 bytes ) - added by wuma 14 years ago.

Download all attachments as: .zip

Change History (6)

by wuma, 14 years ago

Attachment: zoom_to_rectangle.jpg added

comment:1 by wuma, 14 years ago

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))
            return;

        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);
        HideMapImage();
        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.

by wuma, 14 years ago

Attachment: zoom_rectangle.patch added

comment:2 by wuma, 14 years ago

External ID: 1380783

comment:3 by wuma, 13 years ago

Milestone: 2.22.3
Version: 2.2.0

comment:4 by wuma, 13 years ago

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