gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.main / src / test / java / org / gvsig / fmap / dal / coverage / util / TestIntersectExtent.java @ 2443
History | View | Annotate | Download (2.97 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 |
/**
|
34 |
* Comprueba la llamada de RasterUtilities intersects con un raster rotado. Esta llamada comprueba
|
35 |
* si dos extents intersectan.
|
36 |
*
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
38 |
*
|
39 |
*/
|
40 |
public class TestIntersectExtent extends BaseTestCase { |
41 |
|
42 |
public void start() throws Exception { |
43 |
this.setUp();
|
44 |
this.testStack();
|
45 |
} |
46 |
|
47 |
protected void doSetUp() throws Exception { |
48 |
System.err.println("TestIntersectsExtent running..."); |
49 |
} |
50 |
|
51 |
public void testStack(){ |
52 |
AffineTransform at = new AffineTransform(2.0707369692354263, -1.2132800188916328, -1.2132800188916328, -2.0707369692354263, 645519.8062266004, 4925635.747389836); |
53 |
Point2D ul = new Point2D.Double(645519.8062266004, 4925635.747389836); |
54 |
Point2D ll = new Point2D.Double(644464.2526101647, 4923834.206226601); |
55 |
Point2D ur = new Point2D.Double(647321.3473898353, 4924580.193773401); |
56 |
Point2D lr = new Point2D.Double(646265.7937733995, 4922778.652610166); |
57 |
|
58 |
Point2D ulA = new Point2D.Double(645021.0, 4925601.0); |
59 |
Point2D lrA = new Point2D.Double(645973.0, 4924920.0); |
60 |
|
61 |
Point2D ulB = new Point2D.Double(646008.0, 4923286.0); |
62 |
Point2D lrB = new Point2D.Double(646614.0, 4922830.0); |
63 |
|
64 |
Point2D ulC = new Point2D.Double(646475.0, 4925468.0); |
65 |
Point2D lrC = new Point2D.Double(646822.0, 4925156.0); |
66 |
|
67 |
Extent e1 = new ExtentImpl(ul, lr, ur, ll);
|
68 |
Extent e2 = new ExtentImpl(ulA, lrA);
|
69 |
Extent e3 = new ExtentImpl(ulB, lrB);
|
70 |
Extent e4 = new ExtentImpl(ulC, lrC);
|
71 |
|
72 |
try {
|
73 |
RasterUtils util = RasterLocator.getManager().getRasterUtils(); |
74 |
assertEquals(util.intersects(e1, e2, at), true);
|
75 |
assertEquals(util.intersects(e1, e3, at), true);
|
76 |
assertEquals(util.intersects(e1, e4, at), false);
|
77 |
} catch (NoninvertibleTransformException e) { |
78 |
e.printStackTrace(); |
79 |
} |
80 |
} |
81 |
|
82 |
} |