Revision 39246
tags/v2_0_0_Build_2058/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/operation/tojts/toJTSTest.java | ||
---|---|---|
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.operation.tojts; |
|
29 |
|
|
30 |
import org.slf4j.Logger; |
|
31 |
import org.slf4j.LoggerFactory; |
|
32 |
|
|
33 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
34 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
35 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
36 |
import org.gvsig.fmap.geom.GeometryManager; |
|
37 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
|
38 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
39 |
import org.gvsig.fmap.geom.aggregate.MultiSurface; |
|
40 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
41 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
42 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
43 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
44 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
45 |
import org.gvsig.fmap.geom.primitive.Point; |
|
46 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
47 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
48 |
|
|
49 |
/** |
|
50 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
51 |
*/ |
|
52 |
public class toJTSTest extends AbstractLibraryAutoInitTestCase { |
|
53 |
final static private Logger logger = LoggerFactory.getLogger("org.gvsig"); |
|
54 |
private GeometryManager manager; |
|
55 |
|
|
56 |
protected void doSetUp() throws Exception { |
|
57 |
manager = GeometryLocator.getGeometryManager(); |
|
58 |
manager.registerGeometryOperation(ToJTS.NAME, new Point2DToJTS(), TYPES.POINT, SUBTYPES.GEOM2D); |
|
59 |
manager.registerGeometryOperation(ToJTS.NAME, new Curve2DToJTS(), TYPES.CURVE, SUBTYPES.GEOM2D); |
|
60 |
manager.registerGeometryOperation(ToJTS.NAME, new Curve2DToJTS(), TYPES.ARC, SUBTYPES.GEOM2D); |
|
61 |
|
|
62 |
manager.registerGeometryOperation(ToJTS.NAME, new Surface2DToJTS(), TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
63 |
manager.registerGeometryOperation(ToJTS.NAME, new Surface2DToJTS(), TYPES.CIRCLE, SUBTYPES.GEOM2D); |
|
64 |
manager.registerGeometryOperation(ToJTS.NAME, new Surface2DToJTS(), TYPES.ELLIPSE, SUBTYPES.GEOM2D); |
|
65 |
|
|
66 |
manager.registerGeometryOperation(ToJTS.NAME, new MultiPointToJTS(), TYPES.MULTIPOINT, SUBTYPES.GEOM2D); |
|
67 |
|
|
68 |
manager.registerGeometryOperation(ToJTS.NAME, new MultiCurveToJTS(), TYPES.MULTICURVE, SUBTYPES.GEOM2D); |
|
69 |
|
|
70 |
manager.registerGeometryOperation(ToJTS.NAME, new MultiSurfaceToJTS(), TYPES.MULTISURFACE, SUBTYPES.GEOM2D); |
|
71 |
} |
|
72 |
|
|
73 |
public void testPoint() throws CreateGeometryException, GeometryOperationNotSupportedException, GeometryOperationException{ |
|
74 |
Point point = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
|
75 |
point.setCoordinateAt(0, 1.0); |
|
76 |
point.setCoordinateAt(1, 2.0); |
|
77 |
|
|
78 |
JTSGeometryOperationContext ctx = new JTSGeometryOperationContext(-1); |
|
79 |
|
|
80 |
Object obj = point.invokeOperation(ToJTS.CODE, ctx); |
|
81 |
assertNotNull(obj); |
|
82 |
assertTrue(obj instanceof com.vividsolutions.jts.geom.Point); |
|
83 |
assertEquals(1.0, ((com.vividsolutions.jts.geom.Point)obj).getX(), 0.0); |
|
84 |
assertEquals(2.0, ((com.vividsolutions.jts.geom.Point)obj).getY(), 0.0); |
|
85 |
} |
|
86 |
|
|
87 |
public void testMultiPoint() throws GeometryOperationNotSupportedException, GeometryOperationException, CreateGeometryException{ |
|
88 |
Point point1 = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM3D); |
|
89 |
point1.setCoordinateAt(0, 1.0); |
|
90 |
point1.setCoordinateAt(1, 2.0); |
|
91 |
point1.setCoordinateAt(2, 3.0); |
|
92 |
|
|
93 |
Point point2 = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM3D); |
|
94 |
point2.setCoordinateAt(0, 4.0); |
|
95 |
point2.setCoordinateAt(1, 5.0); |
|
96 |
point2.setCoordinateAt(2, 6.0); |
|
97 |
|
|
98 |
MultiPoint multiPoint = (MultiPoint)manager.create(TYPES.MULTIPOINT, SUBTYPES.GEOM2D); |
|
99 |
multiPoint.addPoint(point1); |
|
100 |
multiPoint.addPoint(point2); |
|
101 |
|
|
102 |
JTSGeometryOperationContext ctx = new JTSGeometryOperationContext(-1); |
|
103 |
|
|
104 |
Object obj = multiPoint.invokeOperation(ToJTS.CODE, ctx); |
|
105 |
assertNotNull(obj); |
|
106 |
assertTrue(obj instanceof com.vividsolutions.jts.geom.MultiPoint); |
|
107 |
com.vividsolutions.jts.geom.MultiPoint gtMultiPoint = (com.vividsolutions.jts.geom.MultiPoint)obj; |
|
108 |
assertEquals(2, (int)gtMultiPoint.getNumGeometries()); |
|
109 |
} |
|
110 |
|
|
111 |
public void testLineString() throws GeometryOperationNotSupportedException, GeometryOperationException, CreateGeometryException{ |
|
112 |
Curve lineString = (Curve)manager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
|
113 |
GeneralPathX generalPathX = new GeneralPathX(); |
|
114 |
generalPathX.moveTo(0, 0); |
|
115 |
generalPathX.lineTo(1, 1); |
|
116 |
generalPathX.lineTo(2, 1); |
|
117 |
lineString.setGeneralPath(generalPathX); |
|
118 |
|
|
119 |
JTSGeometryOperationContext ctx = new JTSGeometryOperationContext(-1); |
|
120 |
|
|
121 |
Object obj = lineString.invokeOperation(ToJTS.CODE, ctx); |
|
122 |
assertNotNull(obj); |
|
123 |
assertTrue(obj instanceof com.vividsolutions.jts.geom.LineString); |
|
124 |
com.vividsolutions.jts.geom.LineString gtLineString = (com.vividsolutions.jts.geom.LineString)obj; |
|
125 |
assertEquals(0, gtLineString.getCoordinates()[0].x, 0.0); |
|
126 |
assertEquals(0, gtLineString.getCoordinates()[0].y, 0.0); |
|
127 |
assertEquals(0, gtLineString.getCoordinates()[1].x, 1.0); |
|
128 |
assertEquals(0, gtLineString.getCoordinates()[1].y, 1.0); |
|
129 |
assertEquals(0, gtLineString.getCoordinates()[2].x, 2.0); |
|
130 |
assertEquals(0, gtLineString.getCoordinates()[2].y, 2.0); |
|
131 |
} |
|
132 |
|
|
133 |
public void testPolygon() throws CreateGeometryException, GeometryOperationNotSupportedException, GeometryOperationException{ |
|
134 |
Surface polygon = (Surface)manager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
135 |
GeneralPathX generalPathX = new GeneralPathX(); |
|
136 |
generalPathX.moveTo(0, 0); |
|
137 |
generalPathX.lineTo(1, 1); |
|
138 |
generalPathX.lineTo(2, 1); |
|
139 |
polygon.setGeneralPath(generalPathX); |
|
140 |
|
|
141 |
JTSGeometryOperationContext ctx = new JTSGeometryOperationContext(-1); |
|
142 |
|
|
143 |
Object obj = polygon.invokeOperation(ToJTS.CODE, ctx); |
|
144 |
assertNotNull(obj); |
|
145 |
assertTrue(obj instanceof com.vividsolutions.jts.geom.Polygon); |
|
146 |
com.vividsolutions.jts.geom.Polygon gtPolygon = (com.vividsolutions.jts.geom.Polygon)obj; |
|
147 |
assertEquals(0, gtPolygon.getCoordinates()[0].x, 0.0); |
|
148 |
assertEquals(0, gtPolygon.getCoordinates()[0].y, 0.0); |
|
149 |
assertEquals(0, gtPolygon.getCoordinates()[1].x, 1.0); |
|
150 |
assertEquals(0, gtPolygon.getCoordinates()[1].y, 1.0); |
|
151 |
assertEquals(0, gtPolygon.getCoordinates()[2].x, 2.0); |
|
152 |
assertEquals(0, gtPolygon.getCoordinates()[2].y, 2.0); |
|
153 |
} |
|
154 |
|
|
155 |
public void testMultiLineString() throws CreateGeometryException, GeometryOperationNotSupportedException, GeometryOperationException{ |
|
156 |
Curve curve1 = (Curve)manager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
|
157 |
GeneralPathX generalPathX1 = new GeneralPathX(); |
|
158 |
generalPathX1.moveTo(0, 0); |
|
159 |
generalPathX1.lineTo(1, 1); |
|
160 |
generalPathX1.lineTo(2, 1); |
|
161 |
curve1.setGeneralPath(generalPathX1); |
|
162 |
|
|
163 |
Curve curve2 = (Curve)manager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
|
164 |
GeneralPathX generalPathX2 = new GeneralPathX(); |
|
165 |
generalPathX2.moveTo(0, 0); |
|
166 |
generalPathX2.lineTo(1, 1); |
|
167 |
generalPathX2.lineTo(2, 1); |
|
168 |
curve2.setGeneralPath(generalPathX2); |
|
169 |
|
|
170 |
MultiCurve multiCurve = (MultiCurve)manager.create(TYPES.MULTICURVE, SUBTYPES.GEOM2D); |
|
171 |
multiCurve.addCurve(curve1); |
|
172 |
multiCurve.addCurve(curve2); |
|
173 |
|
|
174 |
JTSGeometryOperationContext ctx = new JTSGeometryOperationContext(-1); |
|
175 |
|
|
176 |
Object obj = multiCurve.invokeOperation(ToJTS.CODE, ctx); |
|
177 |
assertNotNull(obj); |
|
178 |
assertTrue(obj instanceof com.vividsolutions.jts.geom.MultiLineString); |
|
179 |
com.vividsolutions.jts.geom.MultiLineString gtMultiLineString = (com.vividsolutions.jts.geom.MultiLineString)obj; |
|
180 |
assertEquals(2, (int)gtMultiLineString.getNumGeometries()); |
|
181 |
} |
|
182 |
|
|
183 |
public void testMultiPlygon() throws CreateGeometryException, GeometryOperationNotSupportedException, GeometryOperationException{ |
|
184 |
Surface surface1 = (Surface)manager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
185 |
GeneralPathX generalPathX1 = new GeneralPathX(); |
|
186 |
generalPathX1.moveTo(0, 0); |
|
187 |
generalPathX1.lineTo(1, 1); |
|
188 |
generalPathX1.lineTo(2, 1); |
|
189 |
surface1.setGeneralPath(generalPathX1); |
|
190 |
|
|
191 |
Surface surface2 = (Surface)manager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
192 |
GeneralPathX generalPathX2 = new GeneralPathX(); |
|
193 |
generalPathX2.moveTo(0, 0); |
|
194 |
generalPathX2.lineTo(1, 1); |
|
195 |
generalPathX2.lineTo(2, 1); |
|
196 |
surface2.setGeneralPath(generalPathX2); |
|
197 |
|
|
198 |
MultiSurface multiPolygon = (MultiSurface)manager.create(TYPES.MULTISURFACE, SUBTYPES.GEOM2D); |
|
199 |
multiPolygon.addSurface(surface1); |
|
200 |
multiPolygon.addSurface(surface2); |
|
201 |
|
|
202 |
JTSGeometryOperationContext ctx = new JTSGeometryOperationContext(-1); |
|
203 |
|
|
204 |
Object obj = multiPolygon.invokeOperation(ToJTS.CODE, ctx); |
|
205 |
assertNotNull(obj); |
|
206 |
assertTrue(obj instanceof com.vividsolutions.jts.geom.MultiPolygon); |
|
207 |
com.vividsolutions.jts.geom.MultiPolygon gtMultiPolygon = (com.vividsolutions.jts.geom.MultiPolygon)obj; |
|
208 |
assertEquals(2, (int)gtMultiPolygon.getNumGeometries()); |
|
209 |
assertEquals(0, gtMultiPolygon.getCoordinates()[0].x, 0.0); |
|
210 |
assertEquals(0, gtMultiPolygon.getCoordinates()[0].x, 0.0); |
|
211 |
} |
|
212 |
|
|
213 |
} |
|
214 |
|
|
0 | 215 |
tags/v2_0_0_Build_2058/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/operation/println/PrintPoint.java | ||
---|---|---|
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.operation.println; |
|
29 |
|
|
30 |
import org.gvsig.fmap.geom.Geometry; |
|
31 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
32 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
33 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
34 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
|
35 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
36 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
37 |
import org.gvsig.fmap.geom.primitive.Point; |
|
38 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
|
39 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
|
40 |
import org.gvsig.tools.locator.LocatorException; |
|
41 |
|
|
42 |
/** |
|
43 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
44 |
*/ |
|
45 |
public class PrintPoint extends GeometryOperation { |
|
46 |
|
|
47 |
|
|
48 |
/* (non-Javadoc) |
|
49 |
* @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex() |
|
50 |
*/ |
|
51 |
public int getOperationIndex() { |
|
52 |
try { |
|
53 |
return GeometryLocator.getGeometryManager() |
|
54 |
.registerGeometryOperation("println", new PrintPoint(), TYPES.POINT, SUBTYPES.GEOM2D); |
|
55 |
} catch (LocatorException e) { |
|
56 |
// TODO Auto-generated catch block |
|
57 |
e.printStackTrace(); |
|
58 |
} catch (GeometryTypeNotSupportedException e) { |
|
59 |
// TODO Auto-generated catch block |
|
60 |
e.printStackTrace(); |
|
61 |
} catch (GeometryTypeNotValidException e) { |
|
62 |
// TODO Auto-generated catch block |
|
63 |
e.printStackTrace(); |
|
64 |
} |
|
65 |
return -1; |
|
66 |
} |
|
67 |
|
|
68 |
/* (non-Javadoc) |
|
69 |
* @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext) |
|
70 |
*/ |
|
71 |
public Object invoke(Geometry geom, GeometryOperationContext ctx) |
|
72 |
throws GeometryOperationException { |
|
73 |
Point point = (Point)geom; |
|
74 |
System.out.println("Point, X=" + point.getX() + " Y=" + point.getY()); |
|
75 |
return "println-point"; |
|
76 |
} |
|
77 |
|
|
78 |
} |
|
79 |
|
|
0 | 80 |
tags/v2_0_0_Build_2058/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/operation/println/PrintlnOperationTest.java | ||
---|---|---|
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.operation.println; |
|
29 |
|
|
30 |
import org.slf4j.Logger; |
|
31 |
import org.slf4j.LoggerFactory; |
|
32 |
|
|
33 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
34 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
35 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
36 |
import org.gvsig.fmap.geom.GeometryManager; |
|
37 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
38 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
39 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
40 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
41 |
import org.gvsig.fmap.geom.primitive.Point; |
|
42 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
43 |
|
|
44 |
/** |
|
45 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
46 |
*/ |
|
47 |
public class PrintlnOperationTest extends AbstractLibraryAutoInitTestCase { |
|
48 |
final static private Logger logger = LoggerFactory.getLogger("org.gvsig"); |
|
49 |
private GeometryManager manager; |
|
50 |
|
|
51 |
protected void doSetUp() throws Exception { |
|
52 |
manager = GeometryLocator.getGeometryManager(); |
|
53 |
manager.registerGeometryOperation("println", new PrintPoint(), TYPES.POINT, SUBTYPES.GEOM2D); |
|
54 |
manager.registerGeometryOperation("println", new PrintMultiPoint(), TYPES.MULTIPOINT, SUBTYPES.GEOM2D); |
|
55 |
} |
|
56 |
|
|
57 |
public void testPoint() throws InstantiationException, IllegalAccessException, GeometryOperationNotSupportedException, GeometryOperationException, CreateGeometryException{ |
|
58 |
Point point = (Point) manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
|
59 |
assertEquals((String)manager.invokeOperation("println", point, null), "println-point"); |
|
60 |
} |
|
61 |
|
|
62 |
public void testMultiPoint() throws InstantiationException, IllegalAccessException, GeometryOperationNotSupportedException, GeometryOperationException, CreateGeometryException{ |
|
63 |
Point point1 = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
|
64 |
point1.setCoordinateAt(0, 1.0); |
|
65 |
point1.setCoordinateAt(1, 2.0); |
|
66 |
|
|
67 |
Point point2 = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
|
68 |
point2.setCoordinateAt(0, 4.0); |
|
69 |
point2.setCoordinateAt(1, 5.0); |
|
70 |
|
|
71 |
MultiPoint multiPoint = (MultiPoint)manager.create(TYPES.MULTIPOINT, SUBTYPES.GEOM2D); |
|
72 |
multiPoint.addPoint(point1); |
|
73 |
multiPoint.addPoint(point2); |
|
74 |
|
|
75 |
assertEquals((String)manager.invokeOperation("println", multiPoint, null), "println-multipoint"); |
|
76 |
assertEquals((String)manager.invokeOperation("println", point1, null), "println-point"); |
|
77 |
assertEquals((String)manager.invokeOperation("println", point2, null), "println-point"); |
|
78 |
|
|
79 |
assertEquals((String)point1.invokeOperation("println", null), "println-point"); |
|
80 |
|
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
|
|
85 |
|
|
0 | 86 |
tags/v2_0_0_Build_2058/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/operation/println/PrintMultiPoint.java | ||
---|---|---|
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.operation.println; |
|
29 |
|
|
30 |
import org.gvsig.fmap.geom.Geometry; |
|
31 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
32 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
33 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
34 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
35 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
|
36 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
37 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
38 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
39 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
|
40 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
|
41 |
import org.gvsig.tools.locator.LocatorException; |
|
42 |
|
|
43 |
/** |
|
44 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
45 |
*/ |
|
46 |
public class PrintMultiPoint extends GeometryOperation { |
|
47 |
|
|
48 |
public PrintMultiPoint() { |
|
49 |
super(); |
|
50 |
// TODO Auto-generated constructor stub |
|
51 |
} |
|
52 |
|
|
53 |
/* (non-Javadoc) |
|
54 |
* @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex() |
|
55 |
*/ |
|
56 |
public int getOperationIndex() { |
|
57 |
try { |
|
58 |
return GeometryLocator.getGeometryManager() |
|
59 |
.registerGeometryOperation("println", new PrintPoint(), TYPES.MULTIPOINT, SUBTYPES.GEOM2D); |
|
60 |
} catch (LocatorException e) { |
|
61 |
// TODO Auto-generated catch block |
|
62 |
e.printStackTrace(); |
|
63 |
} catch (GeometryTypeNotSupportedException e) { |
|
64 |
// TODO Auto-generated catch block |
|
65 |
e.printStackTrace(); |
|
66 |
} catch (GeometryTypeNotValidException e) { |
|
67 |
// TODO Auto-generated catch block |
|
68 |
e.printStackTrace(); |
|
69 |
} |
|
70 |
return -1; |
|
71 |
} |
|
72 |
|
|
73 |
/* (non-Javadoc) |
|
74 |
* @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext) |
|
75 |
*/ |
|
76 |
public Object invoke(Geometry geom, GeometryOperationContext ctx) |
|
77 |
throws GeometryOperationException { |
|
78 |
MultiPoint multiPoint = (MultiPoint)geom; |
|
79 |
System.out.println("MultiPoint"); |
|
80 |
for (int i=0 ; i<multiPoint.getPrimitivesNumber() ; i++){ |
|
81 |
try { |
|
82 |
System.out.print(" - "); |
|
83 |
multiPoint.getPointAt(i).invokeOperation(getOperationIndex(), ctx); |
|
84 |
} catch (GeometryOperationNotSupportedException e) { |
|
85 |
// TODO Auto-generated catch block |
|
86 |
e.printStackTrace(); |
|
87 |
} |
|
88 |
} |
|
89 |
return "println-multipoint"; |
|
90 |
} |
|
91 |
|
|
92 |
|
|
93 |
} |
|
94 |
|
|
95 |
|
|
96 |
|
|
0 | 97 |
tags/v2_0_0_Build_2058/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/operation/towkb/WKBNativeTest.java | ||
---|---|---|
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.operation.towkb; |
|
29 |
|
|
30 |
import org.gvsig.fmap.geom.Geometry; |
|
31 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
32 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
33 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
34 |
import org.gvsig.fmap.geom.GeometryManager; |
|
35 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
|
36 |
import org.gvsig.fmap.geom.operation.fromwkb.FromWKB; |
|
37 |
import org.gvsig.fmap.geom.operation.fromwkb.FromWKBGeometryOperationContext; |
|
38 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
39 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
40 |
import org.gvsig.fmap.geom.primitive.Point; |
|
41 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
42 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
43 |
|
|
44 |
/** |
|
45 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
46 |
*/ |
|
47 |
public class WKBNativeTest extends AbstractLibraryAutoInitTestCase { |
|
48 |
private GeometryManager manager; |
|
49 |
private GeometryOperation toWkb2d; |
|
50 |
private GeometryOperation fromWkb2d; |
|
51 |
private FromWKBGeometryOperationContext fromWkbContext; |
|
52 |
|
|
53 |
protected void doSetUp() throws Exception { |
|
54 |
manager = GeometryLocator.getGeometryManager(); |
|
55 |
fromWkbContext = new FromWKBGeometryOperationContext(); |
|
56 |
} |
|
57 |
|
|
58 |
public void testPoint() throws Exception{ |
|
59 |
Point point = (Point) manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
|
60 |
point.setX(1); |
|
61 |
point.setY(2); |
|
62 |
toWkb2d = |
|
63 |
manager.getGeometryOperation(ToWKBNative.CODE, |
|
64 |
Geometry.TYPES.POINT, Geometry.SUBTYPES.GEOM2D); |
|
65 |
fromWkb2d = |
|
66 |
manager.getGeometryOperation(FromWKB.CODE, Geometry.TYPES.POINT, |
|
67 |
Geometry.SUBTYPES.GEOM2D); |
|
68 |
byte[] wkb = (byte[]) toWkb2d.invoke(point, |
|
69 |
null); |
|
70 |
fromWkbContext.setData(wkb); |
|
71 |
Geometry geom = (Geometry) fromWkb2d.invoke(null, |
|
72 |
fromWkbContext); |
|
73 |
|
|
74 |
assertEquals(point, geom); |
|
75 |
} |
|
76 |
|
|
77 |
public void testCurve() throws Exception { |
|
78 |
|
|
79 |
GeneralPathX gp = new GeneralPathX(); |
|
80 |
|
|
81 |
gp.moveTo(0.0, 0.0); |
|
82 |
gp.lineTo(1.0, 1.0); |
|
83 |
gp.lineTo(2.0, 2.0); |
|
84 |
gp.lineTo(3.0, 3.0); |
|
85 |
toWkb2d = |
|
86 |
manager.getGeometryOperation(ToWKBNative.CODE, |
|
87 |
Geometry.TYPES.CURVE, Geometry.SUBTYPES.GEOM2D); |
|
88 |
fromWkb2d = |
|
89 |
manager.getGeometryOperation(FromWKB.CODE, Geometry.TYPES.CURVE, |
|
90 |
Geometry.SUBTYPES.GEOM2D); |
|
91 |
Curve curve = (Curve) manager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
|
92 |
curve.setGeneralPath(gp); |
|
93 |
byte[] wkb = (byte[]) toWkb2d.invoke(curve, |
|
94 |
null); |
|
95 |
fromWkbContext.setData(wkb); |
|
96 |
Geometry geom = (Geometry) fromWkb2d.invoke(null, |
|
97 |
fromWkbContext); |
|
98 |
assertTrue(curve.equals(geom)); |
|
99 |
} |
|
100 |
|
|
101 |
public void testPolygon() throws Exception { |
|
102 |
GeneralPathX gp = new GeneralPathX(); |
|
103 |
gp.moveTo(1.0, 1.0); |
|
104 |
gp.lineTo(2.0, 2.0); |
|
105 |
gp.lineTo(3.0, 3.0); |
|
106 |
gp.lineTo(4.0, 4.0); |
|
107 |
gp.lineTo(5.0, 5.0); |
|
108 |
gp.closePath(); |
|
109 |
|
|
110 |
toWkb2d = |
|
111 |
manager.getGeometryOperation(ToWKBNative.CODE, |
|
112 |
Geometry.TYPES.SURFACE, Geometry.SUBTYPES.GEOM2D); |
|
113 |
fromWkb2d = |
|
114 |
manager.getGeometryOperation(FromWKB.CODE, Geometry.TYPES.SURFACE, |
|
115 |
Geometry.SUBTYPES.GEOM2D); |
|
116 |
|
|
117 |
Surface surface = manager.createSurface(gp, SUBTYPES.GEOM2D); |
|
118 |
|
|
119 |
byte[] wkb = (byte[]) toWkb2d.invoke(surface, null); |
|
120 |
fromWkbContext.setData(wkb); |
|
121 |
Geometry geom = (Geometry) fromWkb2d.invoke(null, fromWkbContext); |
|
122 |
assertTrue(surface.equals(geom)); |
|
123 |
} |
|
124 |
|
|
125 |
// public void testPolygonWithZ() throws Exception { |
|
126 |
// Surface surface = (Surface)manager.create(TYPES.SURFACE, SUBTYPES.GEOM3D); |
|
127 |
// |
|
128 |
// Point point = manager.createPoint(1, 1, SUBTYPES.GEOM3D); |
|
129 |
// point.setCoordinateAt(DIMENSIONS.Z, 1); |
|
130 |
// surface.addMoveToVertex(point); |
|
131 |
// |
|
132 |
// point = manager.createPoint(2, 2, SUBTYPES.GEOM3D); |
|
133 |
// point.setCoordinateAt(DIMENSIONS.Z, 2); |
|
134 |
// surface.addVertex(point); |
|
135 |
// |
|
136 |
// point = manager.createPoint(3, 3, SUBTYPES.GEOM3D); |
|
137 |
// point.setCoordinateAt(DIMENSIONS.Z, 3); |
|
138 |
// surface.addVertex(point); |
|
139 |
// |
|
140 |
// point = manager.createPoint(4, 4, SUBTYPES.GEOM3D); |
|
141 |
// point.setCoordinateAt(DIMENSIONS.Z, 4); |
|
142 |
// surface.addVertex(point); |
|
143 |
// |
|
144 |
// point = manager.createPoint(5, 5, SUBTYPES.GEOM3D); |
|
145 |
// point.setCoordinateAt(DIMENSIONS.Z, 5); |
|
146 |
// surface.addVertex(point); |
|
147 |
// |
|
148 |
// surface.closePrimitive(); |
|
149 |
// |
|
150 |
// byte[] wkb = (byte[]) toWkb2d.invoke(surface, null); |
|
151 |
// fromWkbContext.setData(wkb); |
|
152 |
// Geometry geom = (Geometry) fromWkb2d.invoke(null, fromWkbContext); |
|
153 |
// assertTrue(surface.equals(geom)); |
|
154 |
// } |
|
155 |
} |
|
156 |
|
|
0 | 157 |
tags/v2_0_0_Build_2058/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/operation/towkb/WKBTest.java | ||
---|---|---|
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.operation.towkb; |
|
29 |
|
|
30 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
31 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
32 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
33 |
import org.gvsig.fmap.geom.GeometryManager; |
|
34 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
35 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
36 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
37 |
import org.gvsig.fmap.geom.primitive.Point; |
|
38 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
39 |
|
|
40 |
/** |
|
41 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
42 |
*/ |
|
43 |
public class WKBTest extends AbstractLibraryAutoInitTestCase { |
|
44 |
private GeometryManager manager; |
|
45 |
|
|
46 |
protected void doSetUp() throws Exception { |
|
47 |
manager = GeometryLocator.getGeometryManager(); |
|
48 |
} |
|
49 |
|
|
50 |
public void testPoint() throws InstantiationException, IllegalAccessException, GeometryOperationNotSupportedException, GeometryOperationException, CreateGeometryException{ |
|
51 |
Point point = (Point) manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
|
52 |
manager.invokeOperation("toWKB", point, null); |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
0 | 56 |
tags/v2_0_0_Build_2058/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/impl/DefaultGeometryManagerTest.java | ||
---|---|---|
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 {} {{Task}} |
|
26 |
*/ |
|
27 |
package org.gvsig.fmap.geom.impl; |
|
28 |
|
|
29 |
import java.awt.Rectangle; |
|
30 |
import java.awt.Shape; |
|
31 |
import java.awt.geom.AffineTransform; |
|
32 |
import java.awt.geom.PathIterator; |
|
33 |
import java.awt.geom.Point2D; |
|
34 |
import java.awt.geom.Rectangle2D; |
|
35 |
|
|
36 |
import junit.framework.TestCase; |
|
37 |
|
|
38 |
import org.cresques.cts.ICoordTrans; |
|
39 |
|
|
40 |
import org.gvsig.fmap.geom.Geometry; |
|
41 |
import org.gvsig.fmap.geom.handler.Handler; |
|
42 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
43 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
44 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
45 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
46 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
47 |
import org.gvsig.fmap.geom.primitive.Point; |
|
48 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
49 |
|
|
50 |
/** |
|
51 |
* Unit tests for the class {@link DefaultGeometryManager}. |
|
52 |
* |
|
53 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team |
|
54 |
*/ |
|
55 |
public class DefaultGeometryManagerTest extends TestCase { |
|
56 |
|
|
57 |
private DefaultGeometryManager manager; |
|
58 |
|
|
59 |
protected void setUp() throws Exception { |
|
60 |
super.setUp(); |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* Test method for |
|
65 |
* {@link org.gvsig.fmap.geom.impl.DefaultGeometryManager#registerGeometryType(int, int)} |
|
66 |
* and |
|
67 |
* {@link org.gvsig.fmap.geom.impl.DefaultGeometryManager#getGeometryType(int, int) |
|
68 |
* . |
|
69 |
*/ |
|
70 |
public void testRegisterGetGeometryType() throws Exception { |
|
71 |
manager = new DefaultGeometryManager(1, 1); |
|
72 |
manager.registerGeometryType(TestGeometry.class, |
|
73 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D); |
|
74 |
manager.registerGeometryType(TestGeometry.class, |
|
75 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM3D); |
|
76 |
manager.registerGeometryType(TestGeometry.class, |
|
77 |
Geometry.TYPES.MULTISOLID, Geometry.SUBTYPES.GEOM2D); |
|
78 |
manager.registerGeometryType(TestGeometry.class, Geometry.TYPES.ARC, |
|
79 |
Geometry.SUBTYPES.GEOM3DM); |
|
80 |
|
|
81 |
assertNotNull(manager.getGeometryType(Geometry.TYPES.GEOMETRY, |
|
82 |
Geometry.SUBTYPES.GEOM2D)); |
|
83 |
|
|
84 |
assertNotNull(manager.getGeometryType(Geometry.TYPES.GEOMETRY, |
|
85 |
Geometry.SUBTYPES.GEOM3D)); |
|
86 |
|
|
87 |
assertNotNull(manager.getGeometryType(Geometry.TYPES.MULTISOLID, |
|
88 |
Geometry.SUBTYPES.GEOM2D)); |
|
89 |
|
|
90 |
assertNotNull(manager.getGeometryType(Geometry.TYPES.ARC, |
|
91 |
Geometry.SUBTYPES.GEOM3DM)); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Test method for |
|
96 |
* {@link org.gvsig.fmap.geom.impl.DefaultGeometryManager#create(int, int)}. |
|
97 |
*/ |
|
98 |
public void testCreateIntInt() throws Exception { |
|
99 |
manager = new DefaultGeometryManager(); |
|
100 |
manager.registerGeometryType(TestGeometry.class, |
|
101 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D); |
|
102 |
manager.registerGeometryType(TestGeometry.class, |
|
103 |
Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM3D); |
|
104 |
manager.registerGeometryType(TestGeometry.class, |
|
105 |
Geometry.TYPES.MULTISOLID, Geometry.SUBTYPES.GEOM2D); |
|
106 |
manager.registerGeometryType(TestGeometry.class, Geometry.TYPES.ARC, |
|
107 |
Geometry.SUBTYPES.GEOM3DM); |
|
108 |
|
|
109 |
assertGeometry(manager.create(Geometry.TYPES.GEOMETRY, |
|
110 |
Geometry.SUBTYPES.GEOM2D)); |
|
111 |
|
|
112 |
assertGeometry(manager.create(Geometry.TYPES.GEOMETRY, |
|
113 |
Geometry.SUBTYPES.GEOM3D)); |
|
114 |
|
|
115 |
assertGeometry(manager.create(Geometry.TYPES.MULTISOLID, |
|
116 |
Geometry.SUBTYPES.GEOM2D)); |
|
117 |
|
|
118 |
assertGeometry(manager.create(Geometry.TYPES.ARC, |
|
119 |
Geometry.SUBTYPES.GEOM3DM)); |
|
120 |
} |
|
121 |
|
|
122 |
private void assertGeometry(Geometry geom) { |
|
123 |
assertNotNull(geom); |
|
124 |
assertEquals(TestGeometry.class, geom.getClass()); |
|
125 |
} |
|
126 |
|
|
127 |
public static class TestGeometry implements Geometry { |
|
128 |
|
|
129 |
private final GeometryType geometryType; |
|
130 |
|
|
131 |
public TestGeometry(GeometryType geometryType) { |
|
132 |
this.geometryType = geometryType; |
|
133 |
} |
|
134 |
|
|
135 |
public Geometry cloneGeometry() { |
|
136 |
// TODO Auto-generated method stub |
|
137 |
return null; |
|
138 |
} |
|
139 |
|
|
140 |
public boolean fastIntersects(double x, double y, double w, double h) { |
|
141 |
// TODO Auto-generated method stub |
|
142 |
return false; |
|
143 |
} |
|
144 |
|
|
145 |
public Rectangle2D getBounds2D() { |
|
146 |
// TODO Auto-generated method stub |
|
147 |
return null; |
|
148 |
} |
|
149 |
|
|
150 |
public int getDimension() { |
|
151 |
// TODO Auto-generated method stub |
|
152 |
return 0; |
|
153 |
} |
|
154 |
|
|
155 |
public Envelope getEnvelope() { |
|
156 |
// TODO Auto-generated method stub |
|
157 |
return null; |
|
158 |
} |
|
159 |
|
|
160 |
public GeneralPathX getGeneralPath() { |
|
161 |
// TODO Auto-generated method stub |
|
162 |
return null; |
|
163 |
} |
|
164 |
|
|
165 |
public GeometryType getGeometryType() { |
|
166 |
return geometryType; |
|
167 |
} |
|
168 |
|
|
169 |
public Handler[] getHandlers(int type) { |
|
170 |
// TODO Auto-generated method stub |
|
171 |
return null; |
|
172 |
} |
|
173 |
|
|
174 |
public Shape getInternalShape() { |
|
175 |
// TODO Auto-generated method stub |
|
176 |
return null; |
|
177 |
} |
|
178 |
|
|
179 |
public PathIterator getPathIterator(AffineTransform at) { |
|
180 |
// TODO Auto-generated method stub |
|
181 |
return null; |
|
182 |
} |
|
183 |
|
|
184 |
public PathIterator getPathIterator(AffineTransform at, double flatness) { |
|
185 |
// TODO Auto-generated method stub |
|
186 |
return null; |
|
187 |
} |
|
188 |
|
|
189 |
public int getType() { |
|
190 |
return 0; |
|
191 |
} |
|
192 |
|
|
193 |
public boolean intersects(Rectangle2D r) { |
|
194 |
// TODO Auto-generated method stub |
|
195 |
return false; |
|
196 |
} |
|
197 |
|
|
198 |
public Object invokeOperation(int index, GeometryOperationContext ctx) |
|
199 |
throws GeometryOperationNotSupportedException, |
|
200 |
GeometryOperationException { |
|
201 |
// TODO Auto-generated method stub |
|
202 |
return null; |
|
203 |
} |
|
204 |
|
|
205 |
public Object invokeOperation(String opName, |
|
206 |
GeometryOperationContext ctx) |
|
207 |
throws GeometryOperationNotSupportedException, |
|
208 |
GeometryOperationException { |
|
209 |
// TODO Auto-generated method stub |
|
210 |
return null; |
|
211 |
} |
|
212 |
|
|
213 |
public boolean isSimple() { |
|
214 |
// TODO Auto-generated method stub |
|
215 |
return false; |
|
216 |
} |
|
217 |
|
|
218 |
public void reProject(ICoordTrans ct) { |
|
219 |
// TODO Auto-generated method stub |
|
220 |
|
|
221 |
} |
|
222 |
|
|
223 |
public void transform(AffineTransform at) { |
|
224 |
// TODO Auto-generated method stub |
|
225 |
|
|
226 |
} |
|
227 |
|
|
228 |
public boolean contains(Point2D p) { |
|
229 |
// TODO Auto-generated method stub |
|
230 |
return false; |
|
231 |
} |
|
232 |
|
|
233 |
public boolean contains(Rectangle2D r) { |
|
234 |
// TODO Auto-generated method stub |
|
235 |
return false; |
|
236 |
} |
|
237 |
|
|
238 |
public boolean contains(double x, double y) { |
|
239 |
// TODO Auto-generated method stub |
|
240 |
return false; |
|
241 |
} |
|
242 |
|
|
243 |
public boolean contains(double x, double y, double w, double h) { |
|
244 |
// TODO Auto-generated method stub |
|
245 |
return false; |
|
246 |
} |
|
247 |
|
|
248 |
public Rectangle getBounds() { |
|
249 |
// TODO Auto-generated method stub |
|
250 |
return null; |
|
251 |
} |
|
252 |
|
|
253 |
public boolean intersects(double x, double y, double w, double h) { |
|
254 |
// TODO Auto-generated method stub |
|
255 |
return false; |
|
256 |
} |
|
257 |
|
|
258 |
public int compareTo(Object arg0) { |
|
259 |
// TODO Auto-generated method stub |
|
260 |
return 0; |
|
261 |
} |
|
262 |
|
|
263 |
public Geometry buffer(double distance) |
|
264 |
throws GeometryOperationNotSupportedException, |
|
265 |
GeometryOperationException { |
|
266 |
// TODO Auto-generated method stub |
|
267 |
return null; |
|
268 |
} |
|
269 |
|
|
270 |
public boolean contains(Geometry geometry) |
|
271 |
throws GeometryOperationNotSupportedException, |
|
272 |
GeometryOperationException { |
|
273 |
// TODO Auto-generated method stub |
|
274 |
return false; |
|
275 |
} |
|
276 |
|
|
277 |
public byte[] convertToWKB() |
|
278 |
throws GeometryOperationNotSupportedException, |
|
279 |
GeometryOperationException { |
|
280 |
// TODO Auto-generated method stub |
|
281 |
return null; |
|
282 |
} |
|
283 |
|
|
284 |
public String convertToWKT() |
|
285 |
throws GeometryOperationNotSupportedException, |
|
286 |
GeometryOperationException { |
|
287 |
// TODO Auto-generated method stub |
|
288 |
return null; |
|
289 |
} |
|
290 |
|
|
291 |
public Geometry convexHull() |
|
292 |
throws GeometryOperationNotSupportedException, |
|
293 |
GeometryOperationException { |
|
294 |
// TODO Auto-generated method stub |
|
295 |
return null; |
|
296 |
} |
|
297 |
|
|
298 |
public boolean coveredBy(Geometry geometry) |
|
299 |
throws GeometryOperationNotSupportedException, |
|
300 |
GeometryOperationException { |
|
301 |
// TODO Auto-generated method stub |
|
302 |
return false; |
|
303 |
} |
|
304 |
|
|
305 |
public boolean crosses(Geometry geometry) |
|
306 |
throws GeometryOperationNotSupportedException, |
|
307 |
GeometryOperationException { |
|
308 |
// TODO Auto-generated method stub |
|
309 |
return false; |
|
310 |
} |
|
311 |
|
|
312 |
public Geometry difference(Geometry other) |
|
313 |
throws GeometryOperationNotSupportedException, |
|
314 |
GeometryOperationException { |
|
315 |
// TODO Auto-generated method stub |
|
316 |
return null; |
|
317 |
} |
|
318 |
|
|
319 |
public boolean disjoint(Geometry geometry) |
|
320 |
throws GeometryOperationNotSupportedException, |
|
321 |
GeometryOperationException { |
|
322 |
// TODO Auto-generated method stub |
|
323 |
return false; |
|
324 |
} |
|
325 |
|
|
326 |
public double distance(Geometry geometry) |
|
327 |
throws GeometryOperationNotSupportedException, |
|
328 |
GeometryOperationException { |
|
329 |
// TODO Auto-generated method stub |
|
330 |
return 0; |
|
331 |
} |
|
332 |
|
|
333 |
public Geometry intersection(Geometry other) |
|
334 |
throws GeometryOperationNotSupportedException, |
|
335 |
GeometryOperationException { |
|
336 |
// TODO Auto-generated method stub |
|
337 |
return null; |
|
338 |
} |
|
339 |
|
|
340 |
public boolean intersects(Geometry geometry) |
|
341 |
throws GeometryOperationNotSupportedException, |
|
342 |
GeometryOperationException { |
|
343 |
// TODO Auto-generated method stub |
|
344 |
return false; |
|
345 |
} |
|
346 |
|
|
347 |
public boolean overlaps(Geometry geometry) |
|
348 |
throws GeometryOperationNotSupportedException, |
|
349 |
GeometryOperationException { |
|
350 |
// TODO Auto-generated method stub |
|
351 |
return false; |
|
352 |
} |
|
353 |
|
|
354 |
public boolean touches(Geometry geometry) |
|
355 |
throws GeometryOperationNotSupportedException, |
|
356 |
GeometryOperationException { |
|
357 |
// TODO Auto-generated method stub |
|
358 |
return false; |
|
359 |
} |
|
360 |
|
|
361 |
public Geometry union(Geometry other) |
|
362 |
throws GeometryOperationNotSupportedException, |
|
363 |
GeometryOperationException { |
|
364 |
// TODO Auto-generated method stub |
|
365 |
return null; |
|
366 |
} |
|
367 |
|
|
368 |
public boolean within(Geometry geometry) |
|
369 |
throws GeometryOperationNotSupportedException, |
|
370 |
GeometryOperationException { |
|
371 |
// TODO Auto-generated method stub |
|
372 |
return false; |
|
373 |
} |
|
374 |
|
|
375 |
public Point centroid() throws GeometryOperationNotSupportedException, |
|
376 |
GeometryOperationException { |
|
377 |
// TODO Auto-generated method stub |
|
378 |
return null; |
|
379 |
} |
|
380 |
|
|
381 |
public double area() throws GeometryOperationNotSupportedException, |
|
382 |
GeometryOperationException { |
|
383 |
// TODO Auto-generated method stub |
|
384 |
return 0; |
|
385 |
} |
|
386 |
|
|
387 |
public double perimeter() |
|
388 |
throws GeometryOperationNotSupportedException, |
|
389 |
GeometryOperationException { |
|
390 |
// TODO Auto-generated method stub |
|
391 |
return 0; |
|
392 |
} |
|
393 |
|
|
394 |
public Shape getShape() { |
|
395 |
// TODO Auto-generated method stub |
|
396 |
return null; |
|
397 |
} |
|
398 |
|
|
399 |
public Shape getShape(AffineTransform affineTransform) { |
|
400 |
// TODO Auto-generated method stub |
|
401 |
return null; |
|
402 |
} |
|
403 |
|
|
404 |
/* (non-Javadoc) |
|
405 |
* @see org.gvsig.fmap.geom.Geometry#getInteriorPoint() |
|
406 |
*/ |
|
407 |
public Point getInteriorPoint() |
|
408 |
throws GeometryOperationNotSupportedException, |
|
409 |
GeometryOperationException { |
|
410 |
// TODO Auto-generated method stub |
|
411 |
return null; |
|
412 |
} |
|
413 |
|
|
414 |
/* (non-Javadoc) |
|
415 |
* @see org.gvsig.fmap.geom.Geometry#rotate(double, double, double) |
|
416 |
*/ |
|
417 |
public void rotate(double radAngle, double basex, double basey) { |
|
418 |
// TODO Auto-generated method stub |
|
419 |
|
|
420 |
} |
|
421 |
|
|
422 |
/* (non-Javadoc) |
|
423 |
* @see org.gvsig.fmap.geom.Geometry#move(double, double) |
|
424 |
*/ |
|
425 |
public void move(double dx, double dy) { |
|
426 |
// TODO Auto-generated method stub |
|
427 |
|
|
428 |
} |
|
429 |
|
|
430 |
/* (non-Javadoc) |
|
431 |
* @see org.gvsig.fmap.geom.Geometry#scale(org.gvsig.fmap.geom.primitive.Point, double, double) |
|
432 |
*/ |
|
433 |
public void scale(Point basePoint, double sx, double sy) { |
|
434 |
// TODO Auto-generated method stub |
|
435 |
|
|
436 |
} |
|
437 |
|
|
438 |
/* (non-Javadoc) |
|
439 |
* @see org.gvsig.fmap.geom.Geometry#closestPoints(org.gvsig.fmap.geom.Geometry) |
|
440 |
*/ |
|
441 |
public Geometry[] closestPoints(Geometry other) |
|
442 |
throws GeometryOperationNotSupportedException, |
|
443 |
GeometryOperationException { |
|
444 |
// TODO Auto-generated method stub |
|
445 |
return null; |
|
446 |
} |
|
447 |
|
|
448 |
/* (non-Javadoc) |
|
449 |
* @see org.gvsig.fmap.geom.Geometry#isWithinDistance(org.gvsig.fmap.geom.Geometry, double) |
|
450 |
*/ |
|
451 |
public boolean isWithinDistance(Geometry other, double distance) |
|
452 |
throws GeometryOperationNotSupportedException, |
|
453 |
GeometryOperationException { |
|
454 |
// TODO Auto-generated method stub |
|
455 |
return false; |
|
456 |
} |
|
457 |
|
|
458 |
/* (non-Javadoc) |
|
459 |
* @see org.gvsig.fmap.geom.Geometry#snapTo(org.gvsig.fmap.geom.Geometry, double) |
|
460 |
*/ |
|
461 |
public Geometry snapTo(Geometry other, double snapTolerance) |
|
462 |
throws GeometryOperationNotSupportedException, |
|
463 |
GeometryOperationException { |
|
464 |
// TODO Auto-generated method stub |
|
465 |
return null; |
|
466 |
} |
|
467 |
|
|
468 |
} |
|
469 |
} |
tags/v2_0_0_Build_2058/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/wktparser/WKTParserTest.java | ||
---|---|---|
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.wktparser; |
|
29 |
|
|
30 |
import java.awt.geom.PathIterator; |
|
31 |
|
|
32 |
import com.vividsolutions.jts.io.ParseException; |
|
33 |
|
|
34 |
import junit.framework.Assert; |
|
35 |
|
|
36 |
import org.gvsig.fmap.geom.Geometry; |
|
37 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
38 |
import org.gvsig.fmap.geom.GeometryManager; |
|
39 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
40 |
import org.gvsig.fmap.geom.operation.fromwkt.WKTParser; |
|
41 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
42 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
43 |
import org.slf4j.Logger; |
|
44 |
import org.slf4j.LoggerFactory; |
|
45 |
|
|
46 |
/** |
|
47 |
* @author jldominguez |
|
48 |
*/ |
|
49 |
public class WKTParserTest extends AbstractLibraryAutoInitTestCase { |
|
50 |
private GeometryManager manager; |
|
51 |
|
|
52 |
final static private Logger logger = LoggerFactory.getLogger("org.gvsig"); |
|
53 |
|
|
54 |
protected void doSetUp() throws Exception { |
|
55 |
manager = GeometryLocator.getGeometryManager(); |
|
56 |
} |
|
57 |
|
|
58 |
public void testParseWKT() throws InstantiationException, IllegalAccessException, CreateGeometryException{ |
|
59 |
|
|
60 |
|
|
61 |
WKTParser wp = new WKTParser(); |
|
62 |
try { |
|
63 |
Geometry geom = wp.read("LINESTRING(0 0, 1 1, 2 1)"); |
|
64 |
|
|
65 |
Assert.assertTrue(geom instanceof Curve); |
|
66 |
PathIterator piter = geom.getPathIterator(null); |
|
67 |
|
|
68 |
double[] curr = new double[6]; |
|
69 |
int type = 0; |
|
70 |
|
|
71 |
type = piter.currentSegment(curr); |
|
72 |
Assert.assertEquals(PathIterator.SEG_MOVETO, type); |
|
73 |
Assert.assertEquals(0, curr[0], 0.0000000001); |
|
74 |
Assert.assertEquals(0, curr[1], 0.0000000001); |
|
75 |
piter.next(); |
|
76 |
|
|
77 |
type = piter.currentSegment(curr); |
|
78 |
Assert.assertEquals(PathIterator.SEG_LINETO, type); |
|
79 |
Assert.assertEquals(1, curr[0], 0.0000000001); |
|
80 |
Assert.assertEquals(1, curr[1], 0.0000000001); |
|
81 |
piter.next(); |
|
82 |
|
|
83 |
type = piter.currentSegment(curr); |
|
84 |
Assert.assertEquals(PathIterator.SEG_LINETO, type); |
|
85 |
Assert.assertEquals(2, curr[0], 0.0000000001); |
|
86 |
Assert.assertEquals(1, curr[1], 0.0000000001); |
|
87 |
|
|
88 |
piter.next(); |
|
89 |
Assert.assertTrue(piter.isDone()); |
|
90 |
|
|
91 |
} catch (ParseException e) { |
|
92 |
logger.info("Error while checking line string from WKT.", e); |
|
93 |
Assert.assertTrue(e == null); |
|
94 |
} |
|
95 |
|
|
96 |
} |
|
97 |
} |
|
98 |
|
tags/v2_0_0_Build_2058/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/GeometryAPITest.java | ||
---|---|---|
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; |
|
29 |
|
|
30 |
import java.awt.geom.Rectangle2D; |
|
31 |
|
|
32 |
import junit.framework.Assert; |
|
33 |
|
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
38 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
39 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
40 |
import org.gvsig.fmap.geom.primitive.Point; |
|
41 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
42 |
|
|
43 |
/** |
|
44 |
* Tests some methods in geometry API with various instances. |
|
45 |
* |
|
46 |
* @author jldominguez |
|
47 |
* |
|
48 |
*/ |
|
49 |
public class GeometryAPITest extends AbstractLibraryAutoInitTestCase { |
|
50 |
private GeometryManager manager; |
|
51 |
|
|
52 |
final static private Logger logger = LoggerFactory.getLogger("org.gvsig"); |
|
53 |
|
|
54 |
protected void doSetUp() throws Exception { |
|
55 |
manager = GeometryLocator.getGeometryManager(); |
|
56 |
} |
|
57 |
|
|
58 |
public void testMethods() throws InstantiationException, IllegalAccessException, CreateGeometryException{ |
|
59 |
|
|
60 |
try { |
|
61 |
Envelope env0 = manager.createEnvelope(0,0,1,1, SUBTYPES.GEOM2D); |
|
62 |
Envelope env1 = manager.createEnvelope(2,0,3,1, SUBTYPES.GEOM2D); |
|
63 |
Geometry g0 = env0.getGeometry(); |
|
64 |
Geometry g1 = env1.getGeometry(); |
|
65 |
Geometry gm = g0.union(g1); |
|
66 |
|
|
67 |
gm.move(-2,2); |
|
68 |
|
|
69 |
double cxy = gm.getBounds2D().getCenterX() |
|
70 |
*gm.getBounds2D().getCenterY(); |
|
71 |
// test move ============================ |
|
72 |
Assert.assertEquals(-1.25, cxy, 0.0000000001); |
|
73 |
// ========================================== |
|
74 |
|
|
75 |
gm.move(2,-2); |
|
76 |
gm.rotate(30.0*Math.PI/180.0, 0,1); |
|
77 |
|
|
78 |
double maxy = 1 + 3 * Math.sin(30.0*Math.PI/180.0); |
|
79 |
// test rotation ============================ |
|
80 |
Assert.assertEquals(maxy, gm.getBounds2D().getMaxY(), 0.0000000001); |
|
81 |
// ========================================== |
|
82 |
|
|
83 |
|
|
84 |
gm.rotate(-30.0*Math.PI/180.0, 0,1); |
|
85 |
Point p = manager.createPoint(1.5, 0.5, SUBTYPES.GEOM2D); |
|
86 |
gm.scale(p, 0.5, 1.5); |
|
87 |
|
|
88 |
Rectangle2D bb = gm.getBounds2D(); |
|
89 |
// test scale ============================ |
|
90 |
Assert.assertEquals(0.75, bb.getMinX(), 0.0000000001); |
|
91 |
Assert.assertEquals(-0.25, bb.getMinY(), 0.0000000001); |
|
92 |
Assert.assertEquals(2.25, bb.getMaxX(), 0.0000000001); |
|
93 |
Assert.assertEquals(1.25, bb.getMaxY(), 0.0000000001); |
|
94 |
// ======================================= |
|
95 |
|
|
96 |
} catch (Exception e) { |
|
97 |
logger.info("Error while checking Geometry API.", e); |
|
98 |
Assert.assertTrue(e == null); |
|
99 |
} |
|
100 |
|
|
101 |
} |
|
102 |
} |
|
103 |
|
tags/v2_0_0_Build_2058/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/GeometryManagerTest.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom; |
|
2 |
|
|
3 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
4 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
5 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
6 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
|
7 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
8 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
9 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
10 |
import org.gvsig.fmap.geom.operation.ensureOrientation.EnsureOrientation; |
|
11 |
import org.gvsig.fmap.geom.operation.flip.Flip; |
|
12 |
import org.gvsig.fmap.geom.operation.isCCW.IsCCW; |
|
13 |
import org.gvsig.fmap.geom.operation.tojts.ToJTS; |
|
14 |
import org.gvsig.fmap.geom.operation.towkb.ToWKB; |
|
15 |
import org.gvsig.fmap.geom.primitive.Arc; |
|
16 |
import org.gvsig.fmap.geom.primitive.Point; |
|
17 |
import org.gvsig.fmap.geom.primitive.impl.Arc2D; |
|
18 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
19 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
|
20 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
|
21 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
22 |
import org.slf4j.Logger; |
|
23 |
import org.slf4j.LoggerFactory; |
|
24 |
|
|
25 |
public class GeometryManagerTest extends AbstractLibraryAutoInitTestCase { |
|
26 |
|
|
27 |
final static private Logger logger = LoggerFactory.getLogger("org.gvsig"); |
|
28 |
|
|
29 |
private GeometryManager manager; |
|
30 |
|
|
31 |
protected void doSetUp() throws Exception { |
|
32 |
manager = GeometryLocator.getGeometryManager(); |
|
33 |
} |
|
34 |
|
|
35 |
public void testRegister() throws Exception { |
|
36 |
logger.debug("--------- testRegister() START ----------"); |
|
37 |
|
|
38 |
Point p2d = (Point) manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
|
39 |
assertNotNull(p2d); |
|
40 |
p2d.setCoordinateAt(0, 0); |
|
41 |
p2d.setCoordinateAt(1, 0); |
|
42 |
|
|
43 |
java.awt.geom.Point2D pt1 = new java.awt.geom.Point2D.Float(0,1); |
|
44 |
java.awt.geom.Point2D pt2 = new java.awt.geom.Point2D.Float(1,1); |
|
45 |
java.awt.geom.Point2D pt3 = new java.awt.geom.Point2D.Float(1,0); |
|
46 |
Arc2D c2d = (Arc2D) manager.create(TYPES.ARC, SUBTYPES.GEOM2D); |
|
47 |
assertNotNull(c2d); |
|
48 |
|
|
49 |
GeometryType geomType1 = manager.getGeometryType(TYPES.POINT, SUBTYPES.GEOM2D); |
|
50 |
GeometryType geomType2 = manager.getGeometryType(TYPES.ARC, SUBTYPES.GEOM2D); |
|
51 |
|
|
52 |
assertEquals(p2d.getGeometryType(), geomType1); |
|
53 |
assertEquals(c2d.getGeometryType(), geomType2); |
|
54 |
|
|
55 |
// int op1 = manager.registerGeometryOperation("toJTS", new ToJTS(), geomType1); |
|
56 |
// logger.debug("op1=" + op1); |
|
57 |
// |
|
58 |
// int op2 = -1; |
|
59 |
// try { |
Also available in: Unified diff