svn-gvsig-desktop / trunk / libraries / libGeometries / src-test / org / gvsig / geometries / MultiGeometry2DTest.java @ 20086
History | View | Annotate | Download (3.56 KB)
1 |
package org.gvsig.geometries; |
---|---|
2 |
|
3 |
import org.gvsig.exceptions.BaseException; |
4 |
import org.gvsig.geometries.operation.GeometryOperation; |
5 |
|
6 |
import com.iver.cit.gvsig.fmap.core.FGeometry; |
7 |
import com.iver.cit.gvsig.fmap.core.FGeometryCollection; |
8 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
9 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
10 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
11 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
12 |
import com.iver.cit.gvsig.fmap.core.Handler; |
13 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
14 |
|
15 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
16 |
*
|
17 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
18 |
*
|
19 |
* This program is free software; you can redistribute it and/or
|
20 |
* modify it under the terms of the GNU General Public License
|
21 |
* as published by the Free Software Foundation; either version 2
|
22 |
* of the License, or (at your option) any later version.
|
23 |
*
|
24 |
* This program is distributed in the hope that it will be useful,
|
25 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27 |
* GNU General Public License for more details.
|
28 |
*
|
29 |
* You should have received a copy of the GNU General Public License
|
30 |
* along with this program; if not, write to the Free Software
|
31 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
32 |
*
|
33 |
* For more information, contact:
|
34 |
*
|
35 |
* Generalitat Valenciana
|
36 |
* Conselleria d'Infraestructures i Transport
|
37 |
* Av. Blasco Ib??ez, 50
|
38 |
* 46010 VALENCIA
|
39 |
* SPAIN
|
40 |
*
|
41 |
* +34 963862235
|
42 |
* gvsig@gva.es
|
43 |
* www.gvsig.gva.es
|
44 |
*
|
45 |
* or
|
46 |
*
|
47 |
* IVER T.I. S.A
|
48 |
* Salamanca 50
|
49 |
* 46005 Valencia
|
50 |
* Spain
|
51 |
*
|
52 |
* +34 963163400
|
53 |
* dac@iver.es
|
54 |
*/
|
55 |
/* CVS MESSAGES:
|
56 |
*
|
57 |
* $Id: MultiGeometry2DTest.java,v 1.2 2008/03/25 08:47:41 cvs Exp $
|
58 |
* $Log: MultiGeometry2DTest.java,v $
|
59 |
* Revision 1.2 2008/03/25 08:47:41 cvs
|
60 |
* Visitors removed
|
61 |
*
|
62 |
* Revision 1.1 2008/03/12 08:46:20 cvs
|
63 |
* *** empty log message ***
|
64 |
*
|
65 |
*
|
66 |
*/
|
67 |
/**
|
68 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es)
|
69 |
*/
|
70 |
public class MultiGeometry2DTest extends AbstractGeometriesTest{ |
71 |
|
72 |
public void testMultiPointPoint1() throws BaseException{ |
73 |
FGeometry[] geometries = new FGeometry[3]; |
74 |
//Add a point
|
75 |
geometries[0] = (FPoint2D)ShapeFactory.createPoint2D(1,1); |
76 |
|
77 |
//Add a line
|
78 |
GeneralPathX gp = new GeneralPathX();
|
79 |
gp.moveTo(1, 1); |
80 |
gp.lineTo(2, 2); |
81 |
gp.lineTo(3, 3); |
82 |
geometries[1] = (FPolyline2D)ShapeFactory.createPolyline2D(gp);
|
83 |
|
84 |
//Add a polygon
|
85 |
GeneralPathX gp2 = new GeneralPathX();
|
86 |
gp2.moveTo(4, 4); |
87 |
gp2.lineTo(5, 5); |
88 |
gp2.lineTo(6, 6); |
89 |
geometries[2] = (FPolygon2D)ShapeFactory.createPolygon2D(gp2);
|
90 |
|
91 |
FGeometryCollection multiGeometry = (FGeometryCollection)ShapeFactory.createMultiGeometry(geometries); |
92 |
multiGeometry.doOperation(GeometryOperation.PRINTLN_OPERATION); |
93 |
assertEquals(multiGeometry.getCoordinateDimension(), 2);
|
94 |
assertEquals(multiGeometry.isSimple(), false);
|
95 |
assertEquals(multiGeometry.getPrimitivesNumber(), 3);
|
96 |
|
97 |
//Asserts for the first geometry
|
98 |
FPoint2D point1 = (FPoint2D)multiGeometry.getPrimitiveAt(0);
|
99 |
assertEquals(point1.getX(),1.0);
|
100 |
assertEquals(point1.getY(),1.0);
|
101 |
|
102 |
//Asserts for the last geometry
|
103 |
FPolygon2D line2 = (FPolygon2D)multiGeometry.getPrimitiveAt(multiGeometry.getPrimitivesNumber()-1);
|
104 |
Handler[] handlers2 = line2.getSelectHandlers(); |
105 |
assertEquals(handlers2[0].getPoint().getX(),4.0); |
106 |
assertEquals(handlers2[0].getPoint().getY(),4.0); |
107 |
assertEquals(handlers2[handlers2.length-1].getPoint().getX(),6.0); |
108 |
assertEquals(handlers2[handlers2.length-1].getPoint().getY(),6.0); |
109 |
} |
110 |
} |
111 |
|