Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src-test / org / gvsig / fmap / geom / aggregate / MultiPointTest.java @ 27042

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

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.fmap.geom.aggregate;
29

    
30
import junit.framework.Assert;
31
import junit.framework.TestCase;
32

    
33
import org.gvsig.fmap.geom.GeometryLocator;
34
import org.gvsig.fmap.geom.GeometryManager;
35
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
36
import org.gvsig.fmap.geom.Geometry.TYPES;
37
import org.gvsig.fmap.geom.impl.DefaultGeometryLibrary;
38
import org.gvsig.fmap.geom.primitive.Point;
39
import org.gvsig.fmap.geom.primitive.impl.Point2DZ;
40
import org.slf4j.Logger;
41
import org.slf4j.LoggerFactory;
42

    
43
/**
44
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
45
 */
46
public class MultiPointTest extends TestCase {
47
        private GeometryManager manager;
48
        
49
        final static private Logger logger = LoggerFactory.getLogger("org.gvsig");
50

    
51
        static {
52
                //logger.addAppender(new ConsoleAppender(new SimpleLayout()));
53
        }
54

    
55
        public void setUp() throws Exception {
56
                super.setUp();
57

    
58
                DefaultGeometryLibrary lib = new DefaultGeometryLibrary();                
59
                lib.initialize();
60
                lib.postInitialize();
61
                
62
                manager = GeometryLocator.getGeometryManager();
63
        }
64
        
65
        public void testCreateMultiPoint2D() throws InstantiationException, IllegalAccessException{
66
                Point point1 = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2DZ);
67
                point1.setCoordinateAt(0, 1.0);
68
                point1.setCoordinateAt(1, 2.0);
69
                point1.setCoordinateAt(2, 3.0);
70
                
71
                Point point2 = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2DZ);
72
                point2.setCoordinateAt(0, 4.0);
73
                point2.setCoordinateAt(1, 5.0);
74
                point2.setCoordinateAt(2, 6.0);
75
                
76
                MultiPoint multiPoint = (MultiPoint)manager.create(TYPES.MULTIPOINT, SUBTYPES.GEOM2D);
77
                multiPoint.addPoint(point1);
78
                multiPoint.addPoint(point2);
79
                
80
                Assert.assertEquals(2, multiPoint.getPrimitivesNumber());
81
                Assert.assertEquals(1.0, ((Point)multiPoint.getPrimitiveAt(0)).getX(), 0);
82
                Assert.assertEquals(2.0, ((Point)multiPoint.getPrimitiveAt(0)).getY(), 0);
83
                Assert.assertEquals(3.0, ((Point)multiPoint.getPrimitiveAt(0)).getCoordinateAt(2), 0);
84
                Assert.assertEquals(4.0, ((Point)multiPoint.getPrimitiveAt(1)).getX(), 0);
85
                Assert.assertEquals(5.0, ((Point)multiPoint.getPrimitiveAt(1)).getY(), 0);
86
                Assert.assertEquals(6.0, ((Point)multiPoint.getPrimitiveAt(1)).getCoordinateAt(2), 0);
87
                
88
        }
89
        
90
}
91