gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.main / src / test / java / org / gvsig / fmap / dal / coverage / util / TestAdjustExtentToRotateRaster.java @ 2443
History | View | Annotate | Download (3.07 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.fmap.dal.coverage.util; |
23 |
|
24 |
import java.awt.geom.AffineTransform; |
25 |
import java.awt.geom.NoninvertibleTransformException; |
26 |
import java.awt.geom.Point2D; |
27 |
|
28 |
import org.gvsig.fmap.dal.coverage.BaseTestCase; |
29 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
30 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
31 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
32 |
/**
|
33 |
* Comprueba la llamada de RasterUtilities calculateAdjustedView con un raster
|
34 |
* rotado. Le pasar? un extent y este tiene que ser devuelto ajustado a la
|
35 |
* transformaci?n indicada. Como comprobaci?n se convertir? el resultado a
|
36 |
* valores pixel y se mirar? que esten entre el rango 0-width, 0-height
|
37 |
*
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
39 |
*/
|
40 |
public class TestAdjustExtentToRotateRaster extends BaseTestCase { |
41 |
private int w = 870, h = 870; |
42 |
|
43 |
public void start() throws Exception { |
44 |
this.setUp();
|
45 |
this.testStack();
|
46 |
} |
47 |
|
48 |
protected void doSetUp() throws Exception { |
49 |
System.err.println("TestAdjustExtentToRotateRaster running..."); |
50 |
|
51 |
try {
|
52 |
super.doSetUp();
|
53 |
} catch (Exception e) { |
54 |
e.printStackTrace(); |
55 |
} |
56 |
} |
57 |
|
58 |
public void testStack() { |
59 |
AffineTransform at = new AffineTransform(2.4, 0.2, 0.2, -2.4, 644850.0, 4925250.0); |
60 |
Extent ext = new ExtentImpl(644823.3, 4925240.5, 644930.5, 4925123.6); |
61 |
Extent e = RasterLocator.getManager().getRasterUtils().calculateAdjustedView(ext, at, w, h); |
62 |
// System.out.println("-UL=" + e.minX() + " " + e.maxY());
|
63 |
// System.out.println("-LR=" + e.maxX() + " " + e.minY());
|
64 |
|
65 |
Point2D ul = new Point2D.Double(e.minX(), e.maxY()); |
66 |
Point2D lr = new Point2D.Double(e.maxX(), e.minY()); |
67 |
|
68 |
try {
|
69 |
at.inverseTransform(ul, ul); |
70 |
at.inverseTransform(lr, lr); |
71 |
} catch (NoninvertibleTransformException exc) { |
72 |
exc.printStackTrace(); |
73 |
} |
74 |
|
75 |
// System.out.println("*UL=" + ul.getX() + " " + ul.getY());
|
76 |
// System.out.println("*LR=" + lr.getX() + " " + lr.getY());
|
77 |
|
78 |
if (ul.getX() < 0 || ul.getY() < 0 || lr.getX() < 0 || lr.getY() < 0) |
79 |
assertEquals(0, 1); |
80 |
|
81 |
if (ul.getX() >= w || ul.getY() >= h || lr.getX() >= w || lr.getY() >= h)
|
82 |
assertEquals(0, 1); |
83 |
|
84 |
// System.out.println("-UL=" + e.minX() + " " + e.maxY());
|
85 |
// System.out.println("-LR=" + e.maxX() + " " + e.minY());
|
86 |
} |
87 |
} |