Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_geometries / src-test / org / gvsig / fmap / geom / aggregate / MultiPointTest.java @ 34899

History | View | Annotate | Download (2.9 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

    
32
import org.gvsig.fmap.geom.GeometryLocator;
33
import org.gvsig.fmap.geom.GeometryManager;
34
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
35
import org.gvsig.fmap.geom.Geometry.TYPES;
36
import org.gvsig.fmap.geom.exception.CreateGeometryException;
37
import org.gvsig.fmap.geom.primitive.Point;
38
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
39
import org.slf4j.Logger;
40
import org.slf4j.LoggerFactory;
41

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

    
50
        protected void doSetUp() throws Exception {
51
                manager = GeometryLocator.getGeometryManager();                
52
        }
53
        
54
        public void testCreateMultiPoint2D() throws InstantiationException, IllegalAccessException, CreateGeometryException{
55
                Point point1 = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM3D);
56
                point1.setCoordinateAt(0, 1.0);
57
                point1.setCoordinateAt(1, 2.0);
58
                point1.setCoordinateAt(2, 3.0);
59
                
60
                Point point2 = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM3D);
61
                point2.setCoordinateAt(0, 4.0);
62
                point2.setCoordinateAt(1, 5.0);
63
                point2.setCoordinateAt(2, 6.0);
64
                
65
                MultiPoint multiPoint = (MultiPoint)manager.create(TYPES.MULTIPOINT, SUBTYPES.GEOM2D);
66
                multiPoint.addPoint(point1);
67
                multiPoint.addPoint(point2);
68
                
69
                Assert.assertEquals(2, multiPoint.getPrimitivesNumber());
70
                Assert.assertEquals(1.0, ((Point)multiPoint.getPrimitiveAt(0)).getX(), 0);
71
                Assert.assertEquals(2.0, ((Point)multiPoint.getPrimitiveAt(0)).getY(), 0);
72
                Assert.assertEquals(3.0, ((Point)multiPoint.getPrimitiveAt(0)).getCoordinateAt(2), 0);
73
                Assert.assertEquals(4.0, ((Point)multiPoint.getPrimitiveAt(1)).getX(), 0);
74
                Assert.assertEquals(5.0, ((Point)multiPoint.getPrimitiveAt(1)).getY(), 0);
75
                Assert.assertEquals(6.0, ((Point)multiPoint.getPrimitiveAt(1)).getCoordinateAt(2), 0);
76
                
77
        }
78
        
79
}
80