Revision 38288

View differences:

tags/v2_0_0_Build_2047/libraries/libFMap_geometries/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
6

  
7
	<modelVersion>4.0.0</modelVersion>
8
	<artifactId>org.gvsig.fmap.geometry</artifactId>
9
	<packaging>jar</packaging>
10
	<version>2.0-SNAPSHOT</version>
11
	<name>libFMap_geometries</name>
12
	<parent>
13
		<groupId>org.gvsig</groupId>
14
		<artifactId>gvsig-base-library-pom</artifactId>
15
		<version>2.0-SNAPSHOT</version>
16
	</parent>	
17
	<dependencies>
18
		<dependency>
19
			<groupId>org.gvsig</groupId>
20
			<artifactId>org.gvsig.tools.lib</artifactId>
21
            <scope>compile</scope>
22
		</dependency>			
23
		<dependency>
24
			<groupId>com.vividsolutions</groupId>
25
			<artifactId>jts</artifactId>
26
            <scope>compile</scope>
27
		</dependency>
28
		<dependency>
29
			<groupId>org.gvsig</groupId>
30
			<artifactId>org.gvsig.tools.lib</artifactId>
31
			<type>test-jar</type>
32
            <scope>test</scope>
33
		</dependency>		
34
        <dependency>
35
            <groupId>org.gvsig</groupId>
36
            <artifactId>org.gvsig.projection</artifactId>
37
            <scope>compile</scope>
38
        </dependency>   
39
		<dependency>
40
			<groupId>org.gvsig</groupId>
41
			<artifactId>org.gvsig.projection</artifactId>
42
			<classifier>cresques-impl</classifier>
43
			<scope>test</scope>
44
		</dependency>
45
        <dependency>
46
            <groupId>org.slf4j</groupId>
47
            <artifactId>slf4j-api</artifactId>
48
            <scope>compile</scope>
49
        </dependency>
50
		<dependency>
51
			<groupId>org.opengis</groupId>
52
			<artifactId>geoapi</artifactId>			
53
			<scope>test</scope>
54
		</dependency>
55
		<dependency>
56
			<groupId>org.geotools</groupId>
57
			<artifactId>gt2-legacy</artifactId>			
58
			<scope>test</scope>
59
		</dependency>
60
		<dependency>
61
			<groupId>org.geotools</groupId>
62
			<artifactId>gt2-main</artifactId>
63
			<scope>test</scope>
64
		</dependency>
65
		<dependency>
66
			<groupId>geojava</groupId>
67
			<artifactId>geojava</artifactId>
68
			<scope>test</scope>
69
		</dependency>
70
		<dependency>
71
			<groupId>javax.media</groupId>
72
			<artifactId>jai_core</artifactId>
73
			<scope>test</scope>
74
		</dependency>
75
		<dependency>
76
			<groupId>javax.media</groupId>
77
			<artifactId>jai_codec</artifactId>
78
			<scope>test</scope>
79
		</dependency>
80
	</dependencies>
81

  
82
	<properties>
83
		<build-dir>${basedir}/../build</build-dir>
84
        <eclipse.project.name>libFMap_geometries</eclipse.project.name>
85
	</properties>
86

  
87
	<build>
88
		<sourceDirectory>src</sourceDirectory>
89
		<testSourceDirectory>src-test</testSourceDirectory>
90
        <plugins>
91
            <plugin>
92
                <groupId>org.apache.maven.plugins</groupId>
93
                <artifactId>maven-compiler-plugin</artifactId>
94
                <configuration>
95
                    <source>1.4</source>
96
                    <target>1.4</target>
97
                </configuration>
98
            </plugin>        
99
        </plugins>
100
	</build>
101

  
102
	<profiles>
103
		<profile>
104
			<id>se</id>
105
			<activation>
106
				<activeByDefault>true</activeByDefault>
107
			</activation>
108
			<dependencies>
109
				<dependency>
110
					<groupId>org.gvsig</groupId>
111
					<artifactId>org.gvsig.jdk.v1_6</artifactId>
112
					<version>1.0.0-SNAPSHOT</version>
113
				</dependency>
114
			</dependencies>
115
			<build>
116
				<plugins>
117
					<plugin>
118
						<groupId>org.apache.maven.plugins</groupId>
119
						<artifactId>maven-jar-plugin</artifactId>
120
						<configuration>
121
							<excludes>
122
								<exclude>**/operation/*/*</exclude>
123
								<exclude>**/impl/**</exclude>
124
							</excludes>
125
						</configuration>
126
						<executions>
127
							<!--
128
								Generates a jar file only with the geometries API TODO: make a good
129
								configuration of excludes and includes, when the api and implementation
130
								of the geometries library would be performed. <execution> <id>api</id>
131
								<phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration>
132
								<classifier>api</classifier> <excludes>
133
								<exclude>**/operation/*/*</exclude> </excludes> </configuration>
134
								</execution>
135
							-->
136
							<!--
137
								Generates a jar file only with the geometries implementation
138
							-->
139
							<execution>
140
								<id>impl</id>
141
								<phase>package</phase>
142
								<goals>
143
									<goal>jar</goal>
144
								</goals>
145
								<configuration>
146
									<classifier>impl</classifier>
147
									<excludes>
148
										<exclude>**/operation/impl/**</exclude>
149
									</excludes>
150
									<includes>
151
										<include>**/impl/**</include>
152
									</includes>
153
								</configuration>
154
							</execution>
155
							<!--
156
								Generates a jar file only with the geometries operations
157
							-->
158
							<execution>
159
								<id>operation</id>
160
								<phase>package</phase>
161
								<goals>
162
									<goal>jar</goal>
163
								</goals>
164
								<configuration>
165
									<classifier>operation</classifier>
166
									<excludes>
167
										<exclude>NONE</exclude>
168
									</excludes>
169
									<includes>
170
										<include>**/operation/*/*</include>
171
									</includes>
172
								</configuration>
173
							</execution>
174
						</executions>
175
					</plugin>
176
					<plugin>
177
						<artifactId>maven-antrun-plugin</artifactId>
178
						<executions>
179
							<execution>
180
								<id>services</id>
181
								<phase>package</phase>
182
								<goals>
183
									<goal>run</goal>
184
								</goals>
185
								<configuration>
186
									<tasks>
187
										<jar destfile="${project.build.directory}/${project.build.finalName}.jar"
188
											update="true">
189
											<fileset dir="${basedir}/resources/api" />
190
										</jar>
191
										<jar destfile="${project.build.directory}/${project.build.finalName}-impl.jar"
192
											update="true">
193
											<fileset dir="${basedir}/resources/impl" />
194
										</jar>
195
										<jar destfile="${project.build.directory}/${project.build.finalName}-operation.jar"
196
											update="true">
197
											<fileset dir="${basedir}/resources/operation" />
198
										</jar>
199
									</tasks>
200
								</configuration>
201
							</execution>
202
						</executions>
203
					</plugin>
204
					<plugin>
205
						<groupId>org.apache.maven.plugins</groupId>
206
						<artifactId>maven-surefire-plugin</artifactId>
207
						<configuration>
208
							<additionalClasspathElements>
209
								<additionalClasspathElement>${basedir}/resources/api</additionalClasspathElement>
210
								<additionalClasspathElement>${basedir}/resources/impl</additionalClasspathElement>
211
								<additionalClasspathElement>${basedir}/resources/operation</additionalClasspathElement>
212
							</additionalClasspathElements>
213
						</configuration>
214
					</plugin>
215

  
216
				</plugins>
217
			</build>
218
		</profile>
219

  
220
		<profile>
221
			<id>cdc</id>
222
			<activation>
223
				<activeByDefault>false</activeByDefault>
224
			</activation>
225
			<dependencies>
226
				<dependency>
227
					<groupId>org.gvsig</groupId>
228
					<artifactId>org.gvsig.jdk.v1_4</artifactId>
229
					<version>1.0.0-SNAPSHOT</version>
230
				</dependency>
231
			</dependencies>
232
			<build>
233
				<plugins>
234
					<plugin>
235
						<groupId>org.apache.maven.plugins</groupId>
236
						<artifactId>maven-compiler-plugin</artifactId>
237
						<configuration>
238
							<excludes>
239
								<exclude>**/operation/fromwkb/*</exclude>
240
								<exclude>**/operation/towkb/*</exclude>
241
								<exclude>**/operation/impl/*</exclude>
242
							</excludes>
243

  
244
							<testExcludes>
245
								<exclude>**/fmap/geom/*</exclude>
246
								<exclude>**/geom/operation/**</exclude>
247
							</testExcludes>
248

  
249
						</configuration>
250
					</plugin>
251
					<plugin>
252
						<groupId>org.apache.maven.plugins</groupId>
253
						<artifactId>maven-javadoc-plugin</artifactId>
254
					</plugin>
255
					<plugin>
256
						<groupId>org.apache.maven.plugins</groupId>
257
						<artifactId>maven-jar-plugin</artifactId>
258
						<configuration>
259

  
260
							<includes>
261
								<include>**/**</include>
262
							</includes>
263
							<excludes>
264
								<exclude>**/operation/fromwkb/*</exclude>
265
								<exclude>**/operation/towkb/*</exclude>
266
								<exclude>**/operation/impl/*</exclude>
267
							</excludes>
268
						</configuration>
269
						<executions>
270
							<execution>
271
								<id>impl</id>
272
								<phase>package</phase>
273
								<goals>
274
									<goal>jar</goal>
275
								</goals>
276
								<configuration>
277
									<classifier>impl</classifier>
278
									<includes>
279
										<include>**/impl/**</include>
280
									</includes>
281
									<excludes>
282
										<exclude>**/operation/impl/**</exclude>
283
									</excludes>
284
								</configuration>
285
							</execution>
286

  
287
							<execution>
288
								<id>operation</id>
289
								<phase>package</phase>
290
								<goals>
291
									<goal>jar</goal>
292
								</goals>
293
								<configuration>
294
									<classifier>operation</classifier>
295
									<includes>
296
										<include>**/operation/*/*</include>
297
									</includes>
298
									<excludes>
299
										<exclude>**/operation/fromwkb/*</exclude>
300
										<exclude>**/operation/towkb/*</exclude>
301
									</excludes>
302
								</configuration>
303
							</execution>
304

  
305
						</executions>
306
					</plugin>
307
					
308
					<plugin>
309
						<artifactId>maven-antrun-plugin</artifactId>
310
						<executions>
311
							<execution>
312
								<id>services</id>
313
								<phase>package</phase>
314
								<goals>
315
									<goal>run</goal>
316
								</goals>
317
								<configuration>
318
									<tasks>
319
										<jar destfile="${project.build.directory}/${project.build.finalName}.jar"
320
											update="true">
321
											<fileset dir="${basedir}/resources/api" />
322
										</jar>
323
										<jar destfile="${project.build.directory}/${project.build.finalName}-impl.jar"
324
											update="true">
325
											<fileset dir="${basedir}/resources/impl" />
326
										</jar>
327
									</tasks>
328
								</configuration>
329
							</execution>
330
						</executions>
331
					</plugin>
332
					<plugin>
333
						<groupId>org.apache.maven.plugins</groupId>
334
						<artifactId>maven-surefire-plugin</artifactId>
335
						<configuration>
336
							<additionalClasspathElements>
337
								<additionalClasspathElement>${basedir}/resources/api</additionalClasspathElement>
338
								<additionalClasspathElement>${basedir}/resources/impl</additionalClasspathElement>
339
							</additionalClasspathElements>
340
						</configuration>
341
					</plugin>
342
					
343
				</plugins>
344
			</build>
345
		</profile>
346
		<profile>
347
			<id>eclipse-project</id>
348
			<build>
349
				<defaultGoal>antrun:run</defaultGoal>
350
				<plugins>
351
					<plugin>
352
						<artifactId>maven-antrun-plugin</artifactId>
353
						<configuration>
354
							<tasks>
355
								<ant antfile="${build-dir}/ant-tasks/eclipse-tasks.xml"
356
									target="eclipse.all"/>
357
							</tasks>
358
						</configuration>
359
					</plugin>
360
				</plugins>
361
			</build>				
362
		</profile>		
363
	</profiles>
364
	<reporting>
365
		<plugins>
366
			<plugin>
367
				<groupId>org.apache.maven.plugins</groupId>
368
				<artifactId>maven-javadoc-plugin</artifactId>
369
				<reportSets>
370
					<reportSet>
371
						<id>api</id>
372
						<configuration>
373
							<subpackages>org.gvsig.fmap.geom</subpackages>
374
							<excludePackageNames>org.gvsig.fmap.geom.operation:org.gvsig.fmap.geom.impl:org.gvsig.fmap.geom.aggregate.impl:org.gvsig.fmap.geom.primitive.impl:org.gvsig.fmap.geom.type.impl</excludePackageNames>
375
							<name>JavaDoc - API</name>
376
							<destDir>api</destDir>
377
						</configuration>
378
						<reports>
379
							<report>javadoc</report>
380
						</reports>
381
					</reportSet>
382
					<reportSet>
383
						<id>operation</id>
384
						<configuration>
385
							<subpackages>org.gvsig.fmap.geom.operation</subpackages>
386
							<name>JavaDoc - Geometry operations</name>
387
							<destDir>operation</destDir>
388
						</configuration>
389
						<reports>
390
							<report>javadoc</report>
391
						</reports>
392
					</reportSet>
393
					<reportSet>
394
						<id>impl</id>
395
						<configuration>
396
							<subpackages>org.gvsig.fmap.geom.impl:org.gvsig.fmap.geom.aggregate.impl:org.gvsig.fmap.geom.primitive.impl:org.gvsig.fmap.geom.type.impl</subpackages>
397
							<name>JavaDoc - Default implementation</name>
398
							<destDir>impl</destDir>
399
						</configuration>
400
						<reports>
401
							<report>javadoc</report>
402
						</reports>
403
					</reportSet>
404
				</reportSets>
405
			</plugin>
406
		</plugins>
407
	</reporting>
408
</project>
tags/v2_0_0_Build_2047/libraries/libFMap_geometries/resources/operation/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.geom.operation.impl.DefaultGeometryOperationLibrary
tags/v2_0_0_Build_2047/libraries/libFMap_geometries/resources/impl/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.geom.impl.DefaultGeometryLibrary
tags/v2_0_0_Build_2047/libraries/libFMap_geometries/resources/api/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.geom.GeometryLibrary
tags/v2_0_0_Build_2047/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/DummyPoint2D.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
* 2008 {{Company}}   {{Task}}
26
*/
27
 
28
package org.gvsig.fmap.geom;
29

  
30
import org.gvsig.fmap.geom.primitive.Point;
31
import org.gvsig.fmap.geom.primitive.impl.Point2D;
32
import org.gvsig.fmap.geom.type.GeometryType;
33

  
34

  
35
public class DummyPoint2D extends Point2D implements Point {
36

  
37
	/**
38
	 * @param geometryType
39
	 */
40
	public DummyPoint2D(GeometryType geometryType) {
41
		super(geometryType);
42
		// TODO Auto-generated constructor stub
43
	}
44

  
45
	private static final long serialVersionUID = 4449552637882072964L;
46

  
47
	
48

  
49
}
tags/v2_0_0_Build_2047/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_2047/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_2047/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_2047/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_2047/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_2047/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_2047/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
		}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff