root / trunk / libraries / libRaster / src-test / org / gvsig / raster / util / TestIsInsideRaster.java @ 13393
History | View | Annotate | Download (2.32 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.raster.util; |
20 |
|
21 |
import java.awt.geom.AffineTransform; |
22 |
import java.awt.geom.Point2D; |
23 |
|
24 |
import junit.framework.TestCase; |
25 |
|
26 |
import org.gvsig.raster.RasterLibrary; |
27 |
import org.gvsig.raster.datastruct.Extent; |
28 |
|
29 |
/**
|
30 |
* Comprueba la llamada de RasterUtilities isInside con un raster rotado. Esta llamada cmprueba
|
31 |
* si un punto se encuentra dentro de un Extent o fuera. Para esto convierte ambos a coordenadas
|
32 |
* pixel y comprueba si el punto est? entre 0 y maxX y 0 y maxY.
|
33 |
*
|
34 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
35 |
*
|
36 |
*/
|
37 |
public class TestIsInsideRaster extends TestCase { |
38 |
|
39 |
static {
|
40 |
RasterLibrary.wakeUp(); |
41 |
} |
42 |
|
43 |
public void start() { |
44 |
this.setUp();
|
45 |
this.testStack();
|
46 |
} |
47 |
|
48 |
public void setUp() { |
49 |
System.err.println("TestIsInsideRaster running..."); |
50 |
|
51 |
} |
52 |
|
53 |
public void testStack(){ |
54 |
AffineTransform at = new AffineTransform(2.0707369692354263, -1.2132800188916328, -1.2132800188916328, -2.0707369692354263, 645519.8062266004, 4925635.747389836); |
55 |
Point2D ul = new Point2D.Double(645519.8062266004, 4925635.747389836); |
56 |
Point2D ll = new Point2D.Double(644464.2526101647, 4923834.206226601); |
57 |
Point2D ur = new Point2D.Double(647321.3473898353, 4924580.193773401); |
58 |
Point2D lr = new Point2D.Double(646265.7937733995, 4922778.652610166); |
59 |
Extent e = new Extent(ul, lr, ur, ll);
|
60 |
|
61 |
assertEquals(RasterUtilities.isInside(new Point2D.Double(645915.55, 4924461.97), e, at), true); |
62 |
assertEquals(RasterUtilities.isInside(new Point2D.Double(646161.22, 4925326.38), e, at), false); |
63 |
} |
64 |
|
65 |
} |