Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.main / src / test / java / org / gvsig / fmap / dal / coverage / util / TestIsInsideRaster.java @ 2443

History | View | Annotate | Download (2.6 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.Point2D;
26

    
27
import org.gvsig.fmap.dal.coverage.BaseTestCase;
28
import org.gvsig.fmap.dal.coverage.RasterLocator;
29
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
30
import org.gvsig.raster.impl.datastruct.ExtentImpl;
31

    
32
/**
33
 * Comprueba la llamada de RasterUtilities isInside con un raster rotado. Esta llamada cmprueba
34
 * si un punto se encuentra dentro de un Extent o fuera. Para esto convierte ambos a coordenadas
35
 * pixel y comprueba si el punto est? entre 0 y maxX y 0 y maxY. 
36
 * 
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 *
39
 */
40
public class TestIsInsideRaster 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("TestIsInsideRaster running...");
49
                
50
                try {
51
                        super.doSetUp();
52
                } catch (Exception e) {
53
                        e.printStackTrace();
54
                }
55
        }
56
        
57
        public void testStack(){
58
                AffineTransform at = new AffineTransform(2.0707369692354263, -1.2132800188916328, -1.2132800188916328, -2.0707369692354263, 645519.8062266004, 4925635.747389836);
59
                Point2D ul = new Point2D.Double(645519.8062266004, 4925635.747389836);
60
                Point2D ll = new Point2D.Double(644464.2526101647, 4923834.206226601);
61
                Point2D ur = new Point2D.Double(647321.3473898353, 4924580.193773401);
62
                Point2D lr = new Point2D.Double(646265.7937733995, 4922778.652610166);
63
                Extent e = new ExtentImpl(ul, lr, ur, ll);
64
                
65
                assertEquals(RasterLocator.getManager().getRasterUtils().isInside(new Point2D.Double(645915.55, 4924461.97), e, at), true);
66
                assertEquals(RasterLocator.getManager().getRasterUtils().isInside(new Point2D.Double(646161.22, 4925326.38), e, at), false);
67
        }
68

    
69
}