Revision 30285
tags/tmp_build/libraries/libFMap_geometries/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|
2 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<groupId>org.gvsig</groupId> |
|
6 |
<artifactId>libFMap_Geometries</artifactId> |
|
7 |
<packaging>jar</packaging> |
|
8 |
<version>1.0-SNAPSHOT</version> |
|
9 |
<name>libFMap_Geometries</name> |
|
10 |
<url>http://gvsig.org</url> |
|
11 |
<!-- |
|
12 |
<distributionManagement> |
|
13 |
<repository> |
|
14 |
<id>gvsig-ftp-repository</id> |
|
15 |
<name>gvSIG maven FTP repository</name> |
|
16 |
<url>ftp://downloads.gvsig.org:20001/user/maven</url> |
|
17 |
</repository> |
|
18 |
</distributionManagement> |
|
19 |
--> |
|
20 |
<parent> |
|
21 |
<groupId>org.gvsig</groupId> |
|
22 |
<artifactId>gvsig-library-base-pom</artifactId> |
|
23 |
<version>1.0-SNAPSHOT</version> |
|
24 |
</parent> |
|
25 |
<dependencies> |
|
26 |
<dependency> |
|
27 |
<groupId>log4j</groupId> |
|
28 |
<artifactId>log4j</artifactId> |
|
29 |
<version>1.2.8</version> |
|
30 |
</dependency> |
|
31 |
<dependency> |
|
32 |
<groupId>org.gvsig</groupId> |
|
33 |
<artifactId>libExceptions</artifactId> |
|
34 |
<version>1.0-SNAPSHOT</version> |
|
35 |
</dependency> |
|
36 |
<dependency> |
|
37 |
<groupId>org.gvsig</groupId> |
|
38 |
<artifactId>libProjection</artifactId> |
|
39 |
<version>1.0-SNAPSHOT</version> |
|
40 |
</dependency> |
|
41 |
<dependency> |
|
42 |
<groupId>org.geotools</groupId> |
|
43 |
<artifactId>gt2-postgis</artifactId> |
|
44 |
<version>2.2.0</version> |
|
45 |
</dependency> |
|
46 |
<dependency> |
|
47 |
<groupId>com.vividsolutions</groupId> |
|
48 |
<artifactId>jts</artifactId> |
|
49 |
<version>1.8</version> |
|
50 |
</dependency> |
|
51 |
</dependencies> |
|
52 |
<build> |
|
53 |
<sourceDirectory>src</sourceDirectory> |
|
54 |
<testSourceDirectory>src-test</testSourceDirectory> |
|
55 |
</build> |
|
56 |
</project> |
tags/tmp_build/libraries/libFMap_geometries/.settings/org.eclipse.jdt.ui.prefs | ||
---|---|---|
1 |
#Mon May 19 12:46:14 CEST 2008 |
|
2 |
eclipse.preferences.version=1 |
|
3 |
internal.default.compliance=user |
|
0 | 4 |
tags/tmp_build/libraries/libFMap_geometries/build.xml | ||
---|---|---|
1 |
<project name="libFMap-Geometries" default="dist" basedir="."> |
|
2 |
<description> |
|
3 |
FMap Geometries |
|
4 |
</description> |
|
5 |
<property name="build" location="bin"/> |
|
6 |
<property name="src" location="src"/> |
|
7 |
<property name="dist" location="dist"/> |
|
8 |
<property name="jarName" value="org.gvsig.fmap.geom"/> |
|
9 |
<property name="targetDir" location="../libFMap/lib" /> |
|
10 |
|
|
11 |
<target name="dist" description="generate the distribution" > |
|
12 |
<!-- Create the distribution directory --> |
|
13 |
<mkdir dir="${dist}" /> |
|
14 |
|
|
15 |
<jar jarfile="${dist}/${jarName}.jar" basedir="${build}" /> |
|
16 |
<move todir="${targetDir}" overwrite="true"> |
|
17 |
<fileset dir="${dist}" includes="**/**"/> |
|
18 |
</move> |
|
19 |
</target> |
|
20 |
|
|
21 |
</project> |
|
0 | 22 |
tags/tmp_build/libraries/libFMap_geometries/.classpath | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="src" path="src-test"/> |
|
5 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
6 |
<classpathentry sourcepath="/extJCRS/src/org/gvsig/crs" kind="lib" path="/libFMap/lib/org.cresques.cts.jar"/> |
|
7 |
<classpathentry kind="lib" path="/libFMap/lib/jts-1.8.jar"/> |
|
8 |
<classpathentry kind="lib" path="/libFMap/lib/gt2-postgis.jar"/> |
|
9 |
<classpathentry kind="lib" path="/_fwAndami/lib/org.gvsig.exceptions.jar"/> |
|
10 |
<classpathentry sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.1.1/src/org.junit_3.8.1/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/> |
|
11 |
<classpathentry kind="lib" path="/_fwAndami/lib/log4j-1.2.8.jar"/> |
|
12 |
<classpathentry kind="output" path="bin"/> |
|
13 |
</classpath> |
|
0 | 14 |
tags/tmp_build/libraries/libFMap_geometries/.project | ||
---|---|---|
1 |
<projectDescription> |
|
2 |
<name>libFMap_Geometries</name> |
|
3 |
<comment>Base POM for all GvSIG libraries projects. This pom knows how to |
|
4 |
build and made an libraries for GvSIG. The property |
|
5 |
"gvsig-path" must be set up correctly.</comment> |
|
6 |
<projects/> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
</buildCommand> |
|
11 |
</buildSpec> |
|
12 |
<natures> |
|
13 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
14 |
</natures> |
|
15 |
</projectDescription> |
|
0 | 16 |
tags/tmp_build/libraries/libFMap_geometries/src-test/org/gvsig/fmap/geom/GeometryManagerTest.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom; |
|
2 |
|
|
3 |
|
|
4 |
import junit.framework.TestCase; |
|
5 |
|
|
6 |
import org.apache.log4j.Appender; |
|
7 |
import org.apache.log4j.ConsoleAppender; |
|
8 |
import org.apache.log4j.FileAppender; |
|
9 |
import org.apache.log4j.Layout; |
|
10 |
import org.apache.log4j.Logger; |
|
11 |
import org.apache.log4j.SimpleLayout; |
|
12 |
import org.gvsig.fmap.geom.GeometryManager; |
|
13 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
14 |
import org.gvsig.fmap.geom.operation.println.PrintlnPoint2D; |
|
15 |
import org.gvsig.fmap.geom.primitive.Point; |
|
16 |
import org.gvsig.fmap.geom.primitive.Point2D; |
|
17 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
18 |
|
|
19 |
|
|
20 |
public class GeometryManagerTest extends TestCase { |
|
21 |
|
|
22 |
private static Logger logger = Logger.getLogger(GeometryManagerTest.class.getName()); |
|
23 |
|
|
24 |
static { |
|
25 |
|
|
26 |
logger.addAppender(new ConsoleAppender(new SimpleLayout())); |
|
27 |
|
|
28 |
} |
|
29 |
|
|
30 |
private GeometryManager gm; |
|
31 |
|
|
32 |
protected void setUp() throws Exception { |
|
33 |
super.setUp(); |
|
34 |
|
|
35 |
gm = GeometryManager.getInstance(); |
|
36 |
} |
|
37 |
|
|
38 |
public void testRegister() { |
|
39 |
|
|
40 |
logger.debug("--------- testRegister() START ----------"); |
|
41 |
|
|
42 |
GeometryType geomType1 = gm.registerGeometryType(Point2D.class); |
|
43 |
GeometryType geomType2 = gm.registerGeometryType(Point2D.class); |
|
44 |
|
|
45 |
|
|
46 |
int println = gm.registerGeometryOperation("println2D", new PrintlnPoint2D(), geomType1); |
|
47 |
logger.debug("println="+println); |
|
48 |
|
|
49 |
int println2 = -1; |
|
50 |
try { |
|
51 |
println2 = gm.registerGeometryOperation("println2D", PrintlnPoint2D.class, geomType1); |
|
52 |
logger.debug("println2="+println2); |
|
53 |
} catch (Exception e) { |
|
54 |
logger.error("Error registrando operación: ", e); |
|
55 |
} |
|
56 |
|
|
57 |
int draw3D = gm.registerGeometryOperation("draw3D", new PrintlnPoint2D(), geomType1); |
|
58 |
|
|
59 |
int println3 = gm.registerGeometryOperation("println2D", new PrintlnPoint2D(), geomType2); |
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
logger.debug("draw3D="+draw3D); |
|
64 |
|
|
65 |
assertTrue("FALLO: println != println2", println == println2); |
|
66 |
assertTrue("FALLO: println != println3", println == println3); |
|
67 |
assertFalse("FALLO: draw3D == println", draw3D == println); |
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
Point p = (Point) GeometryFactory.createPoint2D(1, 2); |
|
72 |
|
|
73 |
|
|
74 |
GeometryOperationContext ctx = new GeometryOperationContext(); |
|
75 |
ctx.setAttribute("dummy", "DummyValue"); |
|
76 |
|
|
77 |
try { |
|
78 |
p.invokeOperation(PrintlnPoint2D.OPERATION_PRINTLN, ctx); |
|
79 |
} catch (Exception e) { |
|
80 |
logger.error("Error, ", e); |
|
81 |
} |
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
logger.debug("--------- testRegister() END ----------"); |
|
86 |
} |
|
87 |
|
|
88 |
} |
tags/tmp_build/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/GeometryFactory.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.fmap.geom; |
|
42 |
|
|
43 |
import java.awt.geom.AffineTransform; |
|
44 |
import java.awt.geom.Arc2D; |
|
45 |
import java.awt.geom.Point2D; |
|
46 |
|
|
47 |
import org.gvsig.fmap.geom.aggregate.MultiPoint2D; |
|
48 |
import org.gvsig.fmap.geom.aggregate.MultiSurface2D; |
|
49 |
import org.gvsig.fmap.geom.aggregate.MultiCurve2D; |
|
50 |
import org.gvsig.fmap.geom.aggregate.BaseMultiPrimitive; |
|
51 |
import org.gvsig.fmap.geom.aggregate.MultiPoint3D; |
|
52 |
import org.gvsig.fmap.geom.primitive.Circle2D; |
|
53 |
import org.gvsig.fmap.geom.primitive.Curve2D; |
|
54 |
import org.gvsig.fmap.geom.primitive.Curve3D; |
|
55 |
import org.gvsig.fmap.geom.primitive.Ellipse2D; |
|
56 |
import org.gvsig.fmap.geom.primitive.FShape; |
|
57 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
58 |
import org.gvsig.fmap.geom.primitive.Point3D; |
|
59 |
import org.gvsig.fmap.geom.primitive.Spline2D; |
|
60 |
import org.gvsig.fmap.geom.primitive.Surface2D; |
|
61 |
import org.gvsig.fmap.geom.primitive.Surface3D; |
|
62 |
import org.gvsig.fmap.geom.util.UtilFunctions; |
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
/** |
|
68 |
* Clase que crea las geometr�as, contendra un m�todo create por cada tipo de |
|
69 |
* geometria que soporte gvSIG |
|
70 |
*/ |
|
71 |
public class GeometryFactory { |
|
72 |
|
|
73 |
/** |
|
74 |
* Crea una geometr�a que contiene como shape un punto 2D. |
|
75 |
* |
|
76 |
* @param x Coordenada x. |
|
77 |
* @param y Coordenada y. |
|
78 |
* |
|
79 |
* @return Geometr�a. |
|
80 |
*/ |
|
81 |
public static Geometry createPoint2D(double x, double y) { |
|
82 |
return new org.gvsig.fmap.geom.primitive.Point2D(null, null, x, y); |
|
83 |
} |
|
84 |
|
|
85 |
public static Geometry createPoint2D(org.gvsig.fmap.geom.primitive.Point2D p) { |
|
86 |
return p; |
|
87 |
} |
|
88 |
|
|
89 |
|
|
90 |
/** |
|
91 |
* Crea una geometr�a que contiene como shape un Multipunto 2D. |
|
92 |
* |
|
93 |
* @param x Coordenada x. |
|
94 |
* @param y Coordenada y. |
|
95 |
* |
|
96 |
* @return Geometr�a. |
|
97 |
*/ |
|
98 |
public static Geometry createMultipoint2D(double[] x, double[] y) { |
|
99 |
return new MultiPoint2D(null, null, x, y); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Crea una geometr�a que contiene como shape un punto 3D. |
|
104 |
* |
|
105 |
* @param x Coordenada x. |
|
106 |
* @param y Coordenada y. |
|
107 |
* @param z Coordenada z. |
|
108 |
* |
|
109 |
* @return Geometr�a. |
|
110 |
*/ |
|
111 |
public static Geometry createPoint3D(double x, double y, double z) { |
|
112 |
return new Point3D(null, null, x, y, z); |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Crea una geometr�a que contiene como shape un Multipunto 3D. |
|
117 |
* |
|
118 |
* @param x Coordenada x. |
|
119 |
* @param y Coordenada y. |
|
120 |
* @param z Coordenada z. |
|
121 |
* |
|
122 |
* @return Geometr�a. |
|
123 |
*/ |
|
124 |
public static Geometry createMultipoint3D(double[] x, double[] y, |
|
125 |
double[] z) { |
|
126 |
return new MultiPoint3D(null, null, x, y, z); |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* Crea una geometr�a que contiene como shape un Polil�nea 2D. |
|
131 |
* |
|
132 |
* @param shape GeneralPathX. |
|
133 |
* |
|
134 |
* @return Geometr�a. |
|
135 |
*/ |
|
136 |
public static Geometry createPolyline2D(GeneralPathX shape) { |
|
137 |
return new Curve2D(null, null, shape); |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* Crea una geometr�a que contiene como shape un Polil�nea 3D. |
|
142 |
* |
|
143 |
* @param shape GeneralPathX. |
|
144 |
* @param pZ Vector de Z. |
|
145 |
* |
|
146 |
* @return Geometr�a. |
|
147 |
*/ |
|
148 |
public static Geometry createPolyline3D(GeneralPathX shape, double[] pZ) { |
|
149 |
return new Curve3D(null, null, shape, pZ); |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* Creates a multiline form a set of lines |
|
154 |
* @param polylines |
|
155 |
* The lines |
|
156 |
* @return |
|
157 |
* A multiline |
|
158 |
*/ |
|
159 |
public static Geometry createMultiPolyline(Curve2D[] polylines) { |
|
160 |
return new MultiCurve2D(null, null, polylines); |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* Creates a multiline form a set of lines |
|
165 |
* @param polylines |
|
166 |
* The lines |
|
167 |
* @return |
|
168 |
* A multiline |
|
169 |
*/ |
|
170 |
public static Geometry createMultiPolygon(Surface2D[] polygons) { |
|
171 |
return new MultiSurface2D(null, null, polygons); |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Creates a multigeometry form a set of geometries |
|
176 |
* @param geometries |
|
177 |
* The geometries |
|
178 |
* @return |
|
179 |
* A multigeometry |
|
180 |
*/ |
|
181 |
public static Geometry createMultiGeometry(Geometry[] geometries) { |
|
182 |
return new BaseMultiPrimitive(null, null, geometries); |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* Crea una geometr�a que contiene como shape un Pol�gono 3D. |
|
187 |
* |
|
188 |
* @param shape GeneralPathX. |
|
189 |
* @param pZ Vector de Z. |
|
190 |
* |
|
191 |
* @return Geometr�a. |
|
192 |
*/ |
|
193 |
public static Geometry createPolygon3D(GeneralPathX shape, double[] pZ) { |
|
194 |
return new Surface3D(null, null, shape, pZ); |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* Crea una geometr�a que contiene como shape un Pol�gono 2D. |
|
199 |
* |
|
200 |
* @param shape GeneralPathX. |
|
201 |
* |
|
202 |
* @return Geometr�a. |
|
203 |
*/ |
|
204 |
public static Geometry createPolygon2D(GeneralPathX shape) { |
|
205 |
return new Surface2D(null, null, shape); |
|
206 |
} |
|
207 |
|
|
208 |
/** |
|
209 |
* Crea una geometr�a que contiene como shape un Pol�gono 2D. |
|
210 |
* |
|
211 |
* @param shape FPolyline2D closed (you must be sure it is really closed). |
|
212 |
* |
|
213 |
* @return Geometr�a. |
|
214 |
*/ |
|
215 |
public static Geometry createPolygon2D(Curve2D shape) { |
|
216 |
return new Surface2D(null, null, shape.getGeneralPathX()); |
|
217 |
} |
|
218 |
|
|
219 |
/** |
|
220 |
* Crea a partir de un FShape una geometr�a. |
|
221 |
* |
|
222 |
* @param shp FShape. |
|
223 |
* |
|
224 |
* @return Geometr�a. |
|
225 |
*/ |
|
226 |
public static Geometry createGeometry(FShape shp) { |
|
227 |
return (Geometry) shp; |
|
228 |
} |
|
229 |
|
|
230 |
public static Geometry createCircle(java.awt.geom.Point2D center, java.awt.geom.Point2D r){ |
|
231 |
double radio = center.distance(r); |
|
232 |
return createCircle(center, radio); |
|
233 |
} |
|
234 |
|
|
235 |
public static Geometry createCircle(Point2D center, double radio){ |
|
236 |
Arc2D.Double arc = new Arc2D.Double(center.getX()-radio, center.getY() - radio, |
|
237 |
2 * radio, 2 * radio, 0, 360, Arc2D.OPEN); |
|
238 |
|
|
239 |
return new Circle2D(null, null, new GeneralPathX(arc),center,radio); |
|
240 |
} |
|
241 |
public static Geometry createCircle(Point2D p1, Point2D p2, Point2D p3){ |
|
242 |
Point2D center = UtilFunctions.getCenter(p1, p2, p3); |
|
243 |
if (center!=null) |
|
244 |
return createCircle(center,p1); |
|
245 |
return null; |
|
246 |
} |
|
247 |
|
|
248 |
public static Geometry createArc(Point2D p1, Point2D p2, Point2D p3){ |
|
249 |
Arc2D arco = UtilFunctions.createArc(p1, p2, p3); |
|
250 |
if (arco == null) return null; |
|
251 |
return new org.gvsig.fmap.geom.primitive.Arc2D(null, null, new GeneralPathX(arco),p1,p2,p3); |
|
252 |
} |
|
253 |
|
|
254 |
public static Geometry createEllipse(Point2D axis1Start, Point2D axis1End, double axis2Length){ |
|
255 |
double xAxis = axis1Start.distance(axis1End); |
|
256 |
Arc2D.Double arc = new Arc2D.Double(axis1Start.getX(), |
|
257 |
axis1Start.getY() - axis2Length, xAxis, 2 * axis2Length, 0, 360, Arc2D.OPEN); |
|
258 |
// TODO Línea comentada para quitar warning: Point2D rotationPoint = new Point2D.Double(axis1Start.getX() + xAxis /2, axis1Start.getY()); |
|
259 |
double angle = UtilFunctions.getAngle(axis1Start, axis1End); |
|
260 |
AffineTransform mT = AffineTransform.getRotateInstance(angle, axis1Start.getX(), axis1Start.getY()); |
|
261 |
GeneralPathX gp = new GeneralPathX(arc); |
|
262 |
gp.transform(mT); |
|
263 |
|
|
264 |
return new org.gvsig.fmap.geom.primitive.Ellipse2D(null, null, new GeneralPathX(gp),axis1Start,axis1End,axis2Length); |
|
265 |
} |
|
266 |
public static Geometry createSpline2D(Point2D[] points) { |
|
267 |
return new Spline2D(null, null, points); |
|
268 |
} |
|
269 |
} |
|
0 | 270 |
tags/tmp_build/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/GeometryManager.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.fmap.geom; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
import java.util.HashMap; |
|
45 |
import java.util.List; |
|
46 |
import java.util.Map; |
|
47 |
|
|
48 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
|
49 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
50 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
51 |
|
|
52 |
public class GeometryManager { |
|
53 |
|
|
54 |
private static GeometryManager instance; |
|
55 |
|
|
56 |
/** Índice con el nombre único de cada operación */ |
|
57 |
private List geometryOperations = new ArrayList(); |
|
58 |
|
|
59 |
/** Mapa con las instancias de cada tipo de geometría, la clave es el nombre de la clase de geometría. |
|
60 |
* Es decir para "org.gvsig.fmap.geom.Point2D" se obtiene una instancia de GeometryType que contiene las |
|
61 |
* operaciones asociadas a Point2D. |
|
62 |
*/ |
|
63 |
private Map geometryTypes = new HashMap(); |
|
64 |
private int typeIndex = 128; |
|
65 |
|
|
66 |
/** |
|
67 |
* Constructor privado (singleton) |
|
68 |
*/ |
|
69 |
private GeometryManager() { |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* Método para obtener la instancia única (singleton) |
|
74 |
* @return |
|
75 |
*/ |
|
76 |
public static GeometryManager getInstance() { |
|
77 |
if (instance == null) { |
|
78 |
instance = new GeometryManager(); |
|
79 |
} |
|
80 |
return instance; |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* Método para registrar una operación asociada a un tipo de geometría. |
|
85 |
* |
|
86 |
* @param geomOpName Nombre de la operación, este nombre es único |
|
87 |
* @param geomOp Instancia de GeometryOperation que implementa la operación |
|
88 |
* @param geomType Instancia de GeometryType a la que se asocia la operación |
|
89 |
* @return índice asignado a la operación. Este índice se debe usar despues para acceder a la operación |
|
90 |
* |
|
91 |
*/ |
|
92 |
public int registerGeometryOperation(String geomOpName, |
|
93 |
GeometryOperation geomOp, GeometryType geomType) { |
|
94 |
if (geomOpName == null) |
|
95 |
throw new IllegalArgumentException("geomOpName cannot be null."); |
|
96 |
if (geomOp == null) |
|
97 |
throw new IllegalArgumentException("geomOp cannot be null."); |
|
98 |
if (geomType == null) |
|
99 |
throw new IllegalArgumentException("geomType cannot be null."); |
|
100 |
|
|
101 |
int index = geometryOperations.indexOf(geomOpName); |
|
102 |
if (index == -1) { |
|
103 |
geometryOperations.add(geomOpName); |
|
104 |
index = geometryOperations.indexOf(geomOpName); |
|
105 |
} |
|
106 |
|
|
107 |
geomType.setGeometryOperation(index, geomOp); |
|
108 |
|
|
109 |
return index; |
|
110 |
} |
|
111 |
|
|
112 |
public int registerGeometryOperation(String geomOpName, |
|
113 |
GeometryOperation geomOp) { |
|
114 |
// FIXME Registrar operacion para todas las geom |
|
115 |
return -1; |
|
116 |
|
|
117 |
} |
|
118 |
|
|
119 |
public int registerGeometryOperation(String geomOpName, |
|
120 |
GeometryOperation geomOp, Class geomClass) { |
|
121 |
|
|
122 |
GeometryType geomType = getGeometryType(geomClass); |
|
123 |
return registerGeometryOperation(geomOpName, geomOp, geomType); |
|
124 |
} |
|
125 |
|
|
126 |
|
|
127 |
/** |
|
128 |
* |
|
129 |
* @param geomOpName |
|
130 |
* @param geomOpClass |
|
131 |
* @param geomType |
|
132 |
* @return |
|
133 |
* @throws GeometryOperationNotSupportedException |
|
134 |
*/ |
|
135 |
public int registerGeometryOperation(String geomOpName, Class geomOpClass, |
|
136 |
GeometryType geomType) |
|
137 |
throws IllegalAccessException, InstantiationException { |
|
138 |
|
|
139 |
if (geomOpName == null) |
|
140 |
throw new IllegalArgumentException("geomOpName cannot be null."); |
|
141 |
if (geomOpClass == null) |
|
142 |
throw new IllegalArgumentException("geomOpClass cannot be null."); |
|
143 |
if (geomType == null) |
|
144 |
throw new IllegalArgumentException("geomType cannot be null."); |
|
145 |
|
|
146 |
int index = geometryOperations.indexOf(geomOpName); |
|
147 |
if (index == -1) { |
|
148 |
geometryOperations.add(geomOpName); |
|
149 |
index = geometryOperations.indexOf(geomOpName); |
|
150 |
} |
|
151 |
geomType.setGeometryOperation(index, (GeometryOperation) geomOpClass.newInstance()); |
|
152 |
|
|
153 |
return index; |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Registra una clase de geometría y devuelve la instancia GeometryType |
|
158 |
* asociada. Si la clase ya está registrada sólo se devuelve la instancia |
|
159 |
* GeometryType asociada. |
|
160 |
* |
|
161 |
* geomClass no debe ser nulo y debe implementar la interfaz Geometry, en |
|
162 |
* caso contrario se lanza una excepción. |
|
163 |
* |
|
164 |
* @param geomClass |
|
165 |
* Clase de Geometry |
|
166 |
* @return Instancia de GeometryType asociada a la clase de geometría |
|
167 |
* geomClass |
|
168 |
* @throws IllegalArgumentException |
|
169 |
* si geomClass es nulo o no implementa Geometry |
|
170 |
*/ |
|
171 |
public GeometryType registerGeometryType(Class geomClass, String name) { |
|
172 |
|
|
173 |
if (geomClass == null) { |
|
174 |
throw new IllegalArgumentException("geomClass cannot be null."); |
|
175 |
} |
|
176 |
|
|
177 |
if (!Geometry.class.isAssignableFrom(geomClass)) { |
|
178 |
throw new IllegalArgumentException(geomClass.getName() |
|
179 |
+ " must implement the Geometry interface"); |
|
180 |
} |
|
181 |
|
|
182 |
// Comprobar si ya está registrada |
|
183 |
GeometryType geomType = (GeometryType) geometryTypes.get(geomClass |
|
184 |
.getName()); |
|
185 |
|
|
186 |
// Si no está registrada, registrarla |
|
187 |
if (geomType == null) { |
|
188 |
geomType = new GeometryType(geomClass, name, typeIndex++); |
|
189 |
geometryTypes.put(geomClass.getName(), geomType); |
|
190 |
} |
|
191 |
|
|
192 |
return geomType; |
|
193 |
} |
|
194 |
|
|
195 |
public GeometryType registerGeometryType(Class geomClass) { |
|
196 |
// TODO Coger sólo nombre clase sin paquetes |
|
197 |
return registerGeometryType(geomClass, geomClass.getName()); |
|
198 |
} |
|
199 |
/** |
|
200 |
* Devuelve un GeometryType dada la clase que lo implementa |
|
201 |
* |
|
202 |
* @param geomClass |
|
203 |
* @return |
|
204 |
*/ |
|
205 |
public GeometryType getGeometryType(Class geomClass) { |
|
206 |
return (GeometryType) geometryTypes.get(geomClass.getName()); |
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* Devuelve un GeometryType dado el nombre cualificado de la clase de |
|
211 |
* geometría |
|
212 |
* |
|
213 |
* @param className |
|
214 |
* Nombre cualificado de la clase de geometría |
|
215 |
* @return GeometryType asociado |
|
216 |
*/ |
|
217 |
public GeometryType getGeometryType(String className) { |
|
218 |
return (GeometryType) geometryTypes.get(className); |
|
219 |
} |
|
220 |
|
|
221 |
/** |
|
222 |
* Devuelve una operación dada la clase de geometría y el índice de la |
|
223 |
* operación. Este índice se obtiene al registrar la operación. |
|
224 |
* |
|
225 |
* @param geomClass |
|
226 |
* @param index |
|
227 |
* @return |
|
228 |
*/ |
|
229 |
public GeometryOperation getGeometryOperation(Class geomClass, int index) { |
|
230 |
GeometryType geomType = getGeometryType(geomClass); |
|
231 |
if (geomType != null) { |
|
232 |
return geomType.getGeometryOperation(index); |
|
233 |
} |
|
234 |
return null; |
|
235 |
} |
|
236 |
} |
|
0 | 237 |
tags/tmp_build/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/Aggregate.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom.aggregate; |
|
2 |
|
|
3 |
import org.gvsig.fmap.geom.Geometry; |
|
4 |
import org.gvsig.fmap.geom.primitive.Primitive; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
23 |
* |
|
24 |
* For more information, contact: |
|
25 |
* |
|
26 |
* Generalitat Valenciana |
|
27 |
* Conselleria d'Infraestructures i Transport |
|
28 |
* Av. Blasco Ib��ez, 50 |
|
29 |
* 46010 VALENCIA |
|
30 |
* SPAIN |
|
31 |
* |
|
32 |
* +34 963862235 |
|
33 |
* gvsig@gva.es |
|
34 |
* www.gvsig.gva.es |
|
35 |
* |
|
36 |
* or |
|
37 |
* |
|
38 |
* IVER T.I. S.A |
|
39 |
* Salamanca 50 |
|
40 |
* 46005 Valencia |
|
41 |
* Spain |
|
42 |
* |
|
43 |
* +34 963163400 |
|
44 |
* dac@iver.es |
|
45 |
*/ |
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id: MultiGeometry.java,v 1.1 2008/03/12 08:46:20 cvs Exp $ |
|
49 |
* $Log: MultiGeometry.java,v $ |
|
50 |
* Revision 1.1 2008/03/12 08:46:20 cvs |
|
51 |
* *** empty log message *** |
|
52 |
* |
|
53 |
* |
|
54 |
*/ |
|
55 |
/** |
|
56 |
* @author Jorge Piera Llodr� (jorge.piera@iver.es) |
|
57 |
*/ |
|
58 |
public interface Aggregate extends Geometry{ |
|
59 |
|
|
60 |
/** |
|
61 |
* @return the number of GM_Primitives that composes |
|
62 |
* this multi geometry |
|
63 |
*/ |
|
64 |
public int getPrimitivesNumber(); |
|
65 |
|
|
66 |
/** |
|
67 |
* Returns one of the GM_Primitive's that is in |
|
68 |
* a concrete position |
|
69 |
* @param i |
|
70 |
* Geometry position |
|
71 |
* @return |
|
72 |
* A simple geometry |
|
73 |
*/ |
|
74 |
public Primitive getPrimitiveAt(int i); |
|
75 |
} |
|
0 | 76 |
tags/tmp_build/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiSurface2D.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom.aggregate; |
|
2 |
|
|
3 |
import org.cresques.cts.IProjection; |
|
4 |
import org.gvsig.fmap.geom.Geometry; |
|
5 |
import org.gvsig.fmap.geom.primitive.FShape; |
|
6 |
import org.gvsig.fmap.geom.primitive.Surface2D; |
|
7 |
|
|
8 |
import com.vividsolutions.jts.geom.GeometryFactory; |
|
9 |
import com.vividsolutions.jts.geom.Polygon; |
|
10 |
|
|
11 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
12 |
* |
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or |
|
16 |
* modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 |
|
18 |
* of the License, or (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
28 |
* |
|
29 |
* For more information, contact: |
|
30 |
* |
|
31 |
* Generalitat Valenciana |
|
32 |
* Conselleria d'Infraestructures i Transport |
|
33 |
* Av. Blasco Ib��ez, 50 |
|
34 |
* 46010 VALENCIA |
|
35 |
* SPAIN |
|
36 |
* |
|
37 |
* +34 963862235 |
|
38 |
* gvsig@gva.es |
|
39 |
* www.gvsig.gva.es |
|
40 |
* |
|
41 |
* or |
|
42 |
* |
|
43 |
* IVER T.I. S.A |
|
44 |
* Salamanca 50 |
|
45 |
* 46005 Valencia |
|
46 |
* Spain |
|
47 |
* |
|
48 |
* +34 963163400 |
|
49 |
* dac@iver.es |
|
50 |
*/ |
|
51 |
/* CVS MESSAGES: |
|
52 |
* |
|
53 |
* $Id: FMultiPolygon2D.java,v 1.2 2008/03/25 08:47:41 cvs Exp $ |
|
54 |
* $Log: FMultiPolygon2D.java,v $ |
|
55 |
* Revision 1.2 2008/03/25 08:47:41 cvs |
|
56 |
* Visitors removed |
|
57 |
* |
|
58 |
* Revision 1.1 2008/03/12 08:46:20 cvs |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* |
|
62 |
*/ |
|
63 |
/** |
|
64 |
* @author Jorge Piera Llodr� (jorge.piera@iver.es) |
|
65 |
*/ |
|
66 |
public class MultiSurface2D extends BaseMultiPrimitive implements MultiSurface{ |
|
67 |
|
|
68 |
private static final long serialVersionUID = 1L; |
|
69 |
|
|
70 |
public MultiSurface2D(String id, IProjection projection) { |
|
71 |
super(id, projection); |
|
72 |
} |
|
73 |
|
|
74 |
public MultiSurface2D(String id, IProjection projection, Surface2D[] polygons) { |
|
75 |
super(id, projection, polygons); |
|
76 |
} |
|
77 |
|
|
78 |
/* (non-Javadoc) |
|
79 |
* @see com.iver.cit.gvsig.fmap.core.FGeometryCollection#cloneGeometry() |
|
80 |
*/ |
|
81 |
public Geometry cloneGeometry() { |
|
82 |
Surface2D[] aux = new Surface2D[getPrimitivesNumber()]; |
|
83 |
for (int i=0; i < getPrimitivesNumber(); i++){ |
|
84 |
aux[i] = (Surface2D) geometries[i].cloneGeometry(); |
|
85 |
} |
|
86 |
return new MultiSurface2D(id, projection, aux); |
|
87 |
} |
|
88 |
|
|
89 |
/* (non-Javadoc) |
|
90 |
* @see com.iver.cit.gvsig.fmap.core.FGeometryCollection#getGeometryType() |
|
91 |
*/ |
|
92 |
public int getShapeType() { |
|
93 |
return FShape.MULTIPOLYGON; |
|
94 |
} |
|
95 |
|
|
96 |
/* (non-Javadoc) |
|
97 |
* @see com.iver.cit.gvsig.fmap.core.FGeometryCollection#toJTSGeometry() |
|
98 |
*/ |
|
99 |
public com.vividsolutions.jts.geom.Geometry toJTSGeometry() { |
|
100 |
Polygon[] polygons = new Polygon[geometries.length]; |
|
101 |
for (int i = 0; i < polygons.length; i++){ |
|
102 |
polygons[i] = (Polygon)((Surface2D)geometries[i]).toJTSGeometry(); |
|
103 |
} |
|
104 |
return new GeometryFactory().createMultiPolygon(polygons); |
|
105 |
} |
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
} |
|
0 | 111 |
tags/tmp_build/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiPoint2D.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.fmap.geom.aggregate; |
|
42 |
|
|
43 |
import java.awt.Rectangle; |
|
44 |
import java.awt.geom.AffineTransform; |
|
45 |
import java.awt.geom.Rectangle2D; |
|
46 |
import java.io.IOException; |
|
47 |
|
|
48 |
import org.cresques.cts.IProjection; |
|
49 |
import org.geotools.data.postgis.attributeio.WKBEncoder; |
|
50 |
import org.gvsig.fmap.geom.Geometry; |
|
51 |
import org.gvsig.fmap.geom.handler.AbstractHandler; |
|
52 |
import org.gvsig.fmap.geom.primitive.FShape; |
|
53 |
import org.gvsig.fmap.geom.primitive.Point2D; |
|
54 |
|
|
55 |
import com.vividsolutions.jts.geom.Coordinate; |
|
56 |
import com.vividsolutions.jts.geom.GeometryFactory; |
|
57 |
|
|
58 |
/** |
|
59 |
* Multipunto 2D. |
|
60 |
* |
|
61 |
* @author Vicente Caballero Navarro |
|
62 |
*/ |
|
63 |
public class MultiPoint2D extends BaseMultiPrimitive implements MultiPoint { |
|
64 |
|
|
65 |
private static final long serialVersionUID = 1L; |
|
66 |
|
|
67 |
public MultiPoint2D(IProjection projection, Point2D[] points) { |
|
68 |
this(null, projection, points); |
|
69 |
} |
|
70 |
|
|
71 |
public MultiPoint2D(Point2D[] points) { |
|
72 |
this(null, null, points); |
|
73 |
} |
|
74 |
|
|
75 |
public MultiPoint2D(IProjection projection) { |
|
76 |
this(null, projection, null); |
|
77 |
} |
|
78 |
|
|
79 |
public MultiPoint2D(String id, IProjection projection, Point2D[] points) { |
|
80 |
super(id, projection, points); |
|
81 |
} |
|
82 |
|
|
83 |
public MultiPoint2D(String id, IProjection projection) { |
|
84 |
this(id, projection, null); |
|
85 |
} |
|
86 |
|
|
87 |
public MultiPoint2D(double[] x, double[] y) { |
|
88 |
this(null, null, x, y); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Crea un nuevo MultiPoint2D. |
|
93 |
* |
|
94 |
* @param x |
|
95 |
* DOCUMENT ME! |
|
96 |
* @param y |
|
97 |
* DOCUMENT ME! |
|
98 |
*/ |
|
99 |
public MultiPoint2D(String id, IProjection projection, double[] x, |
|
100 |
double[] y) { |
|
101 |
super(id, projection); |
|
102 |
geometries = new Point2D[x.length]; |
|
103 |
for (int i = 0; i < x.length; i++) { |
|
104 |
geometries[i] = new Point2D(id, projection, x[i], y[i]); |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
/* |
|
109 |
* (non-Javadoc) |
|
110 |
* |
|
111 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry() |
|
112 |
*/ |
|
113 |
public Geometry cloneGeometry() { |
|
114 |
Point2D[] aux = new Point2D[getNumgeometries()]; |
|
115 |
for (int i = 0; i < getNumgeometries(); i++) { |
|
116 |
aux[i] = (Point2D) geometries[i].cloneGeometry().getInternalShape(); |
|
117 |
} |
|
118 |
return new MultiPoint2D(id, projection, aux); |
|
119 |
} |
|
120 |
|
|
121 |
/* |
|
122 |
* (non-Javadoc) |
|
123 |
* |
|
124 |
* @see com.iver.cit.gvsig.fmap.core.FGeometryCollection#getBounds() |
|
125 |
*/ |
|
126 |
public Rectangle getBounds() { |
|
127 |
Rectangle r = null; |
|
128 |
if (getNumgeometries() > 0) { |
|
129 |
r = geometries[0].getBounds(); |
|
130 |
} |
|
131 |
for (int i = 1; i < getNumgeometries(); i++) { |
|
132 |
java.awt.geom.Point2D p = geometries[i] |
|
133 |
.getHandlers(Geometry.SELECTHANDLER)[0].getPoint(); |
|
134 |
r.add(p.getX(), p.getY()); |
|
135 |
} |
|
136 |
return r; |
|
137 |
} |
|
138 |
|
|
139 |
/* |
|
140 |
* (non-Javadoc) |
|
141 |
* |
|
142 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D() |
|
143 |
*/ |
|
144 |
public Rectangle2D getBounds2D() { |
|
145 |
Rectangle2D r = null; |
|
146 |
if (getNumgeometries() > 0) { |
|
147 |
java.awt.geom.Point2D p = geometries[0] |
|
148 |
.getHandlers(Geometry.SELECTHANDLER)[0].getPoint(); |
|
149 |
|
|
150 |
r = new Rectangle2D.Double(p.getX(), p.getY(), 0.001, 0.001); |
|
151 |
} |
|
152 |
for (int i = 1; i < getNumgeometries(); i++) { |
|
153 |
java.awt.geom.Point2D p = geometries[i] |
|
154 |
.getHandlers(Geometry.SELECTHANDLER)[0].getPoint(); |
|
155 |
r.add(p.getX(), p.getY()); |
|
156 |
} |
|
157 |
return r; |
|
158 |
} |
|
159 |
|
|
160 |
/* |
|
161 |
* (non-Javadoc) |
|
162 |
* |
|
163 |
* @see com.iver.cit.gvsig.fmap.core.FGeometryCollection#toJTSGeometry() |
|
164 |
*/ |
|
165 |
public com.vividsolutions.jts.geom.Geometry toJTSGeometry() { |
|
166 |
Coordinate[] theGeoms = new Coordinate[geometries.length]; |
|
167 |
for (int i = 0; i < theGeoms.length; i++) { |
|
168 |
java.awt.geom.Point2D p = geometries[i] |
|
169 |
.getHandlers(Geometry.SELECTHANDLER)[0].getPoint(); |
|
170 |
Coordinate c = new Coordinate(p.getX(), p.getY()); |
|
171 |
theGeoms[i] = c; |
|
172 |
} |
|
173 |
com.vividsolutions.jts.geom.MultiPoint geomCol = new GeometryFactory() |
|
174 |
.createMultiPoint(theGeoms); |
|
175 |
return geomCol; |
|
176 |
} |
|
177 |
|
|
178 |
/* |
|
179 |
* (non-Javadoc) |
|
180 |
* |
|
181 |
* @see com.iver.cit.gvsig.fmap.core.FShape#getShapeType() |
|
182 |
*/ |
|
183 |
public int getShapeType() { |
|
184 |
return FShape.MULTIPOINT; |
|
185 |
} |
|
186 |
|
|
187 |
/* |
|
188 |
* (non-Javadoc) |
|
189 |
* |
|
190 |
* @see com.iver.cit.gvsig.fmap.core.FShape#cloneFShape() |
|
191 |
*/ |
|
192 |
public FShape cloneFShape() { |
|
193 |
Point2D[] aux = new Point2D[getNumgeometries()]; |
|
194 |
for (int i = 0; i < getNumgeometries(); i++) { |
|
195 |
aux[i] = (Point2D) geometries[i].cloneGeometry().getInternalShape(); |
|
196 |
} |
|
197 |
return (FShape) new MultiPoint2D(id, projection, aux); |
|
198 |
} |
|
199 |
|
|
200 |
/** |
|
201 |
* @return the numbre of points |
|
202 |
* @deprecated use getPrimitivesNumber |
|
203 |
*/ |
|
204 |
public int getNumgeometries() { |
|
205 |
return getPrimitivesNumber(); |
|
206 |
} |
|
207 |
|
|
208 |
/** |
|
209 |
* @return the numbre of points |
|
210 |
* @deprecated use getPrimitivesNumber |
|
211 |
*/ |
|
212 |
public int getNumPoints() { |
|
213 |
return getPrimitivesNumber(); |
|
214 |
} |
|
215 |
|
|
216 |
public Point2D getPoint(int i) { |
|
217 |
return (Point2D) geometries[i].getInternalShape(); |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* DOCUMENT ME! |
|
222 |
* |
|
223 |
* @author Vicente Caballero Navarro |
|
224 |
*/ |
|
225 |
class PointHandler extends AbstractHandler { |
|
226 |
/** |
|
227 |
* Crea un nuevo PointHandler. |
|
228 |
* |
|
229 |
* @param x |
|
230 |
* DOCUMENT ME! |
|
231 |
* @param y |
|
232 |
* DOCUMENT ME! |
|
233 |
*/ |
|
234 |
public PointHandler(int i, Point2D p) { |
|
235 |
point = new java.awt.geom.Point2D.Double(p.getX(), p.getY()); |
|
236 |
index = i; |
|
237 |
} |
|
238 |
|
|
239 |
/** |
|
240 |
* DOCUMENT ME! |
|
241 |
* |
|
242 |
* @param x |
|
243 |
* DOCUMENT ME! |
|
244 |
* @param y |
|
245 |
* DOCUMENT ME! |
|
246 |
* |
|
247 |
* @return DOCUMENT ME! |
|
248 |
*/ |
|
249 |
public void move(double x, double y) { |
|
250 |
java.awt.geom.Point2D p = geometries[index] |
|
251 |
.getHandlers(Geometry.SELECTHANDLER)[0].getPoint(); |
|
252 |
|
|
253 |
point.setLocation(p.getX() + x, p.getY() + y); |
|
254 |
} |
|
255 |
|
|
256 |
/** |
|
257 |
* @see org.gvsig.fmap.geom.handler.Handler#set(double, double) |
|
258 |
*/ |
|
259 |
public void set(double x, double y) { |
|
260 |
point.setLocation(x, y); |
|
261 |
} |
|
262 |
|
|
263 |
} |
|
264 |
|
|
265 |
public void transform(AffineTransform at) { |
|
266 |
for (int i = 0; i < getNumgeometries(); i++) { |
|
267 |
geometries[i].transform(at); |
|
268 |
} |
|
269 |
|
|
270 |
} |
|
271 |
|
|
272 |
public byte[] toWKB() throws IOException { |
|
273 |
return WKBEncoder.encodeGeometry(toJTSGeometry()); |
|
274 |
} |
|
275 |
} |
|
0 | 276 |
tags/tmp_build/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiPoint3D.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.fmap.geom.aggregate; |
|
42 |
|
|
43 |
import java.awt.geom.Point2D; |
|
44 |
|
|
45 |
import org.cresques.cts.IProjection; |
|
46 |
import org.gvsig.fmap.geom.Geometry; |
|
47 |
import org.gvsig.fmap.geom.GeometryManager; |
|
48 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
49 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
50 |
import org.gvsig.fmap.geom.primitive.FShape; |
|
51 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
52 |
|
|
53 |
/** |
|
54 |
* Multipunto 3D. |
|
55 |
* |
|
56 |
* @author Vicente Caballero Navarro |
|
57 |
*/ |
|
58 |
public class MultiPoint3D extends MultiPoint2D implements MultiPoint { |
|
59 |
|
|
60 |
private static final long serialVersionUID = 1L; |
|
61 |
|
|
62 |
// Registramos el tipo de geometria |
|
63 |
private static GeometryType geomType = GeometryManager.getInstance() |
|
64 |
.registerGeometryType(MultiPoint3D.class); |
|
65 |
|
|
66 |
double[] z = null; |
|
67 |
|
|
68 |
/** |
|
69 |
* Crea un nuevo Multipoint3D. |
|
70 |
* |
|
71 |
* @param x |
|
72 |
* Array de Xs. |
|
73 |
* @param y |
|
74 |
* Array de Ys. |
|
75 |
* @param z |
|
76 |
* Array de Zs. |
|
77 |
*/ |
|
78 |
public MultiPoint3D(String id, IProjection projection, double[] x, |
|
79 |
double[] y, double[] z) { |
|
80 |
super(id, projection, x, y); |
|
81 |
this.z = z; |
|
82 |
} |
|
83 |
|
|
84 |
/* |
|
85 |
* (non-Javadoc) |
|
86 |
* |
|
87 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry() |
|
88 |
*/ |
|
89 |
public Geometry cloneGeometry() { |
|
90 |
double[] x = new double[getPrimitivesNumber()]; |
|
91 |
double[] y = new double[getPrimitivesNumber()]; |
|
92 |
for (int i = 0; i < getPrimitivesNumber(); i++) { |
|
93 |
Point2D p = geometries[i].getHandlers(Geometry.SELECTHANDLER)[0] |
|
94 |
.getPoint(); |
|
95 |
|
|
96 |
x[i] = p.getX(); |
|
97 |
y[i] = p.getY(); |
|
98 |
} |
|
99 |
return new MultiPoint3D(id, projection, x, y, (double[]) z.clone()); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Devuelve un array con todos los valores de Z. |
|
104 |
* |
|
105 |
* @return Array de Zs. |
|
106 |
*/ |
|
107 |
public double[] getZs() { |
|
108 |
return z; |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* @see org.gvsig.fmap.geom.Geometry#getShapeType() |
|
113 |
*/ |
|
114 |
public int getShapeType() { |
|
115 |
return FShape.MULTIPOINT | FShape.Z; |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* @see org.gvsig.fmap.geom.Geometry#invokeOperation() |
|
120 |
*/ |
|
121 |
public Object invokeOperation(int index, GeometryOperationContext ctx) |
|
122 |
throws GeometryOperationException { |
|
123 |
return geomType.getGeometryOperation(index).invoke(this, ctx); |
|
124 |
} |
|
125 |
|
|
126 |
} |
|
0 | 127 |
tags/tmp_build/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiSolid3D.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom.aggregate; |
|
2 |
|
|
3 |
import org.cresques.cts.IProjection; |
|
4 |
import org.gvsig.fmap.geom.primitive.Solid3D; |
|
5 |
|
|
6 |
|
|
7 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
8 |
* |
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
10 |
* |
|
11 |
* This program is free software; you can redistribute it and/or |
|
12 |
* modify it under the terms of the GNU General Public License |
|
13 |
* as published by the Free Software Foundation; either version 2 |
|
14 |
* of the License, or (at your option) any later version. |
|
15 |
* |
|
16 |
* This program is distributed in the hope that it will be useful, |
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
* GNU General Public License for more details. |
|
20 |
* |
|
21 |
* You should have received a copy of the GNU General Public License |
|
22 |
* along with this program; if not, write to the Free Software |
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
24 |
* |
|
25 |
* For more information, contact: |
|
26 |
* |
|
27 |
* Generalitat Valenciana |
|
28 |
* Conselleria d'Infraestructures i Transport |
|
29 |
* Av. Blasco Ib��ez, 50 |
Also available in: Unified diff