Revision 39608

View differences:

branches/v2_0_0_prep/libraries/libProjection/src/org/cresques/impl/cts/gt2/CoordTrans.java
165 165
     * @see org.cresques.cts.ICoordTrans#convert(java.awt.geom.Rectangle2D)
166 166
     */
167 167
    public Rectangle2D convert(Rectangle2D rect) {
168
        
168 169
        Point2D pt1 = new Point2D.Double(rect.getMinX(), rect.getMinY());
169 170
        Point2D pt2 = new Point2D.Double(rect.getMaxX(), rect.getMaxY());
170
        pt1 = convert(pt1, null);
171
        pt2 = convert(pt2, null);
172
        rect = new Rectangle2D.Double();
173
        rect.setFrameFromDiagonal(pt1, pt2);
171
        Point2D pt3 = new Point2D.Double(rect.getMinX(), rect.getMaxY());
172
        Point2D pt4 = new Point2D.Double(rect.getMaxX(), rect.getMinY());
173
        
174
        convert(pt1, pt1);
175
        convert(pt2, pt2);
176
        convert(pt3, pt3);
177
        convert(pt4, pt4);
174 178

  
175
        return rect;
179
        double min_x = Math.min(
180
            Math.min(pt1.getX(), pt2.getX()),
181
            Math.min(pt3.getX(), pt4.getX()));
182
        double min_y = Math.min(
183
            Math.min(pt1.getY(), pt2.getY()),
184
            Math.min(pt3.getY(), pt4.getY()));
185
        double max_x = Math.max(
186
            Math.max(pt1.getX(), pt2.getX()),
187
            Math.max(pt3.getX(), pt4.getX()));
188
        double max_y = Math.max(
189
            Math.max(pt1.getY(), pt2.getY()),
190
            Math.max(pt3.getY(), pt4.getY()));
191
        
192
        return new Rectangle2D.Double(
193
            min_x, min_y, max_x - min_x, max_y - min_y);
194
        
176 195
    }
177 196
}
branches/v2_0_0_prep/libraries/libProjection/src/org/cresques/impl/geo/ReProjection.java
97 97
     * @see org.cresques.cts.ICoordTrans#convert(java.awt.geom.Rectangle2D)
98 98
     */
99 99
    public Rectangle2D convert(Rectangle2D rect) {
100

  
100 101
        Point2D pt1 = new Point2D.Double(rect.getMinX(), rect.getMinY());
101 102
        Point2D pt2 = new Point2D.Double(rect.getMaxX(), rect.getMaxY());
102
        pt1 = convert(pt1, null);
103
        pt2 = convert(pt2, null);
104
        rect = new Rectangle2D.Double();
105
        rect.setFrameFromDiagonal(pt1, pt2);
103
        Point2D pt3 = new Point2D.Double(rect.getMinX(), rect.getMaxY());
104
        Point2D pt4 = new Point2D.Double(rect.getMaxX(), rect.getMinY());
105
        
106
        convert(pt1, pt1);
107
        convert(pt2, pt2);
108
        convert(pt3, pt3);
109
        convert(pt4, pt4);
106 110

  
107
        return rect;
111
        double min_x = Math.min(
112
            Math.min(pt1.getX(), pt2.getX()),
113
            Math.min(pt3.getX(), pt4.getX()));
114
        double min_y = Math.min(
115
            Math.min(pt1.getY(), pt2.getY()),
116
            Math.min(pt3.getY(), pt4.getY()));
117
        double max_x = Math.max(
118
            Math.max(pt1.getX(), pt2.getX()),
119
            Math.max(pt3.getX(), pt4.getX()));
120
        double max_y = Math.max(
121
            Math.max(pt1.getY(), pt2.getY()),
122
            Math.max(pt3.getY(), pt4.getY()));
123
        
124
        return new Rectangle2D.Double(
125
            min_x, min_y, max_x - min_x, max_y - min_y);
108 126
    }
109 127
}
branches/v2_0_0_prep/libraries/libProjection/src/org/cresques/cts/ICoordTrans.java
37 37

  
38 38
    public Point2D convert(Point2D ptOrig, Point2D ptDest);
39 39

  
40
    /**
41
     * Reprojects the input rectangle and returns the minimum rectangle
42
     * containing the result of that reprojection (which was not
43
     * necessarily a rectangle).
44
     * 
45
     * Reprojecting the diagonal an assuming that
46
     * the result is the diagonal of the rectangle to be returned is wrong
47
     * 
48
     * Reprojecting the four corners and searching for min and max
49
     * to create the resulting rectangle is not completely accurate
50
     * but provides an acceptable approximation 
51
     * 
52
     * @param rect
53
     * @return
54
     */
40 55
    public Rectangle2D convert(Rectangle2D rect);
41 56

  
42 57
    public ICoordTrans getInverted();

Also available in: Unified diff