svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src-test / org / gvsig / fmap / geom / aggregate / MultiCurveTest.java @ 26866
History | View | Annotate | Download (3.91 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.GeometryLibrary; |
34 |
import org.gvsig.fmap.geom.GeometryLocator; |
35 |
import org.gvsig.fmap.geom.GeometryManager; |
36 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
37 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
38 |
import org.gvsig.fmap.geom.primitive.Curve; |
39 |
import org.gvsig.fmap.geom.primitive.Curve2D; |
40 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
41 |
import org.slf4j.Logger; |
42 |
import org.slf4j.LoggerFactory; |
43 |
|
44 |
/**
|
45 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
46 |
*/
|
47 |
public class MultiCurveTest extends TestCase { |
48 |
private GeometryManager manager;
|
49 |
|
50 |
final static private Logger logger = LoggerFactory.getLogger("org.gvsig"); |
51 |
|
52 |
static {
|
53 |
//logger.addAppender(new ConsoleAppender(new SimpleLayout()));
|
54 |
} |
55 |
|
56 |
public void setUp() throws Exception { |
57 |
super.setUp();
|
58 |
|
59 |
GeometryLibrary lib = new GeometryLibrary();
|
60 |
lib.initialize(); |
61 |
lib.postInitialize(); |
62 |
|
63 |
manager = GeometryLocator.getGeometryManager(); |
64 |
} |
65 |
|
66 |
public void testCreateMultiCurve2D() throws InstantiationException, IllegalAccessException{ |
67 |
Curve curve1 = (Curve)manager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
68 |
GeneralPathX generalPathX1 = new GeneralPathX();
|
69 |
generalPathX1.moveTo(0, 0); |
70 |
generalPathX1.lineTo(1, 1); |
71 |
generalPathX1.lineTo(2, 1); |
72 |
curve1.setGeneralPath(generalPathX1); |
73 |
|
74 |
Curve curve2 = (Curve)manager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
75 |
GeneralPathX generalPathX2 = new GeneralPathX();
|
76 |
generalPathX2.moveTo(0, 0); |
77 |
generalPathX2.lineTo(1, 1); |
78 |
generalPathX2.lineTo(2, 1); |
79 |
curve2.setGeneralPath(generalPathX2); |
80 |
|
81 |
MultiCurve multiCurve = (MultiCurve)manager.create(TYPES.MULTICURVE, SUBTYPES.GEOM2D); |
82 |
multiCurve.addCurve(curve1); |
83 |
multiCurve.addCurve(curve2); |
84 |
|
85 |
Assert.assertEquals(2, multiCurve.getPrimitivesNumber());
|
86 |
Assert.assertEquals(0.0, ((Curve)multiCurve.getPrimitiveAt(0)).getCoordinateAt(0, 0), 0); |
87 |
Assert.assertEquals(0.0, ((Curve)multiCurve.getPrimitiveAt(0)).getCoordinateAt(0, 1), 0); |
88 |
Assert.assertEquals(1.0, ((Curve)multiCurve.getPrimitiveAt(0)).getCoordinateAt(1, 0), 1); |
89 |
Assert.assertEquals(1.0, ((Curve)multiCurve.getPrimitiveAt(0)).getCoordinateAt(1, 1), 1); |
90 |
Assert.assertEquals(2.0, ((Curve)multiCurve.getPrimitiveAt(0)).getCoordinateAt(2, 0), 2); |
91 |
Assert.assertEquals(1.0, ((Curve)multiCurve.getPrimitiveAt(0)).getCoordinateAt(2, 1), 1); |
92 |
|
93 |
Assert.assertEquals(2, multiCurve.getPrimitivesNumber());
|
94 |
Assert.assertEquals(0.0, ((Curve)multiCurve.getPrimitiveAt(1)).getCoordinateAt(0, 0), 0); |
95 |
Assert.assertEquals(0.0, ((Curve)multiCurve.getPrimitiveAt(1)).getCoordinateAt(0, 1), 0); |
96 |
Assert.assertEquals(1.0, ((Curve)multiCurve.getPrimitiveAt(1)).getCoordinateAt(1, 0), 1); |
97 |
Assert.assertEquals(1.0, ((Curve)multiCurve.getPrimitiveAt(1)).getCoordinateAt(1, 1), 1); |
98 |
Assert.assertEquals(2.0, ((Curve)multiCurve.getPrimitiveAt(1)).getCoordinateAt(2, 0), 2); |
99 |
Assert.assertEquals(1.0, ((Curve)multiCurve.getPrimitiveAt(1)).getCoordinateAt(2, 1), 1); |
100 |
} |
101 |
} |
102 |
|