Revision 21561
branches/Mobile_Compatible_Hito_1/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 |
branches/Mobile_Compatible_Hito_1/libFMap_geometries/build.xml | ||
---|---|---|
1 |
<project name="libFMap-Geometries" default="dist" basedir="."> |
|
2 |
<description> |
|
3 |
FMap Geometries |
|
4 |
</description> |
|
5 |
<property name="build" location="target/classes" /> |
|
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 |
<property name="operationsDir" location="src/org/gvsig/fmap/geom/operation" /> |
|
12 |
<property name="opsJarName" value="org.gvsig.fmap.geom.operation" /> |
|
13 |
|
|
14 |
|
|
15 |
<target name="dist" description="generate the distribution"> |
|
16 |
<!-- Create the distribution directory --> |
|
17 |
<mkdir dir="${dist}" /> |
|
18 |
|
|
19 |
<!-- library jar --> |
|
20 |
<jar jarfile="${dist}/${jarName}.jar" basedir="${build}" includes="**/geom/*.class,**/primitive/**,**/aggregate/**,**/complex/**,**/operation/*.class,**/type/**,**/handler/**" /> |
|
21 |
<!-- operations jar --> |
|
22 |
<jar jarfile="${dist}/${opsJarName}.jar" basedir="${build}" includes="**/operation/*/**,**/util/**" excludes="**/operation/*.class" /> |
|
23 |
|
|
24 |
<move todir="${targetDir}" overwrite="true"> |
|
25 |
<fileset dir="${dist}" includes="**/**" /> |
|
26 |
</move> |
|
27 |
|
|
28 |
|
|
29 |
</target> |
|
30 |
|
|
31 |
</project> |
|
0 | 32 |
branches/Mobile_Compatible_Hito_1/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 kind="lib" path="/_fwAndami/lib/log4j-1.2.8.jar"/> |
|
7 |
<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"/> |
|
8 |
<classpathentry kind="lib" path="lib/gt2-postgis.jar"/> |
|
9 |
<classpathentry kind="lib" path="lib/jts-1.8.jar"/> |
|
10 |
<classpathentry kind="lib" path="lib/org.cresques.cts.jar"/> |
|
11 |
<classpathentry kind="lib" path="lib/org.gvsig.exceptions.jar"/> |
|
12 |
<classpathentry kind="lib" path="lib/wkb4j-1.0-RC1.jar"/> |
|
13 |
<classpathentry kind="output" path="bin"/> |
|
14 |
</classpath> |
|
0 | 15 |
branches/Mobile_Compatible_Hito_1/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 |
branches/Mobile_Compatible_Hito_1/libFMap_geometries/src-test/org/gvsig/fmap/geom/GeometryManagerTest.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom; |
|
2 |
|
|
3 |
import junit.framework.TestCase; |
|
4 |
|
|
5 |
import org.apache.log4j.ConsoleAppender; |
|
6 |
import org.apache.log4j.Logger; |
|
7 |
import org.apache.log4j.SimpleLayout; |
|
8 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
|
9 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
10 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
11 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
12 |
import org.gvsig.fmap.geom.operation.ensureOrientation.EnsureOrientation; |
|
13 |
import org.gvsig.fmap.geom.operation.flip.Flip; |
|
14 |
import org.gvsig.fmap.geom.operation.isCCW.IsCCW; |
|
15 |
import org.gvsig.fmap.geom.operation.tojts.ToJTS; |
|
16 |
import org.gvsig.fmap.geom.operation.towkb.ToWKB; |
|
17 |
import org.gvsig.fmap.geom.primitive.Arc2D; |
|
18 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
19 |
import org.gvsig.fmap.geom.primitive.Curve2D; |
|
20 |
import org.gvsig.fmap.geom.primitive.Point; |
|
21 |
import org.gvsig.fmap.geom.primitive.Point2D; |
|
22 |
import org.gvsig.fmap.geom.primitive.Solid; |
|
23 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
24 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
|
25 |
|
|
26 |
public class GeometryManagerTest extends TestCase { |
|
27 |
|
|
28 |
private static Logger logger = Logger.getLogger("org.gvsig"); |
|
29 |
|
|
30 |
static { |
|
31 |
logger.addAppender(new ConsoleAppender(new SimpleLayout())); |
|
32 |
} |
|
33 |
|
|
34 |
private GeometryManager manager; |
|
35 |
private GeometryFactory factory; |
|
36 |
|
|
37 |
protected void setUp() throws Exception { |
|
38 |
super.setUp(); |
|
39 |
|
|
40 |
manager = GeometryManager.getInstance(); |
|
41 |
factory = manager.getGeometryFactory(); |
|
42 |
} |
|
43 |
|
|
44 |
public void testRegister() throws Exception { |
|
45 |
|
|
46 |
logger.debug("--------- testRegister() START ----------"); |
|
47 |
|
|
48 |
Point p2d = (Point) factory.createPoint2D(0,0); |
|
49 |
java.awt.geom.Point2D pt1 = new java.awt.geom.Point2D.Float(0,1); |
|
50 |
java.awt.geom.Point2D pt2 = new java.awt.geom.Point2D.Float(1,1); |
|
51 |
java.awt.geom.Point2D pt3 = new java.awt.geom.Point2D.Float(1,0); |
|
52 |
|
|
53 |
Arc2D c2d = (Arc2D) factory.createArc(pt1, pt2, pt3); |
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
GeometryType geomType1 = manager.getGeometryType(Point2D.class); |
|
58 |
GeometryType geomType2 = manager.getGeometryType(Arc2D.class); |
|
59 |
|
|
60 |
logger.debug("geomType2=" + geomType2); |
|
61 |
/* GeometryType geomType1 = manager.getGeometryType(Point2D.class);//)registerGeometryType(Point2D.class); |
|
62 |
GeometryType geomType2 = manager.getGeometryType(Curve2D.class);//registerGeometryType(Curve2D.class); |
|
63 |
*/ |
|
64 |
|
|
65 |
int op1 = manager.registerGeometryOperation("toJTS", new ToJTS(),geomType1); |
|
66 |
logger.debug("op1=" + op1); |
|
67 |
|
|
68 |
int op2 = -1; |
|
69 |
try { |
|
70 |
op2 = manager.registerGeometryOperation("toJTS", ToJTS.class,geomType1); |
|
71 |
logger.debug("op2=" + op2); |
|
72 |
} catch (Exception e) { |
|
73 |
logger.error("Error registrando operaci?n: ", e); |
|
74 |
} |
|
75 |
|
|
76 |
int op3 = manager.registerGeometryOperation("toWKB", new ToWKB(),geomType1); |
|
77 |
int op4 = manager.registerGeometryOperation("toWKB", new ToWKB(),geomType2); |
|
78 |
|
|
79 |
logger.debug("op3=" + op3); |
|
80 |
|
|
81 |
assertTrue("FALLO: op1 != op2", op1 == op2); |
|
82 |
assertTrue("FALLO: op1 == op3", op1 != op3); |
|
83 |
assertFalse("FALLO: op4 == op", op4 == op1); |
|
84 |
|
|
85 |
Point p = (Point) factory.createPoint2D(1, 2); |
|
86 |
|
|
87 |
GeometryOperationContext ctx = new GeometryOperationContext(); |
|
88 |
ctx.setAttribute("dummy", "DummyValue"); |
|
89 |
|
|
90 |
try { |
|
91 |
p.invokeOperation(ToWKB.CODE, ctx); |
|
92 |
p.invokeOperation(ToJTS.CODE, ctx); |
|
93 |
p.invokeOperation(Flip.CODE, ctx); |
|
94 |
} catch (Exception e) { |
|
95 |
logger.error("Error, ", e); |
|
96 |
} |
|
97 |
|
|
98 |
// Registramos una factory |
|
99 |
manager.registerGeometryFactory(new MyFactory()); |
|
100 |
MyFactory fact = (MyFactory) manager.getGeometryFactory(); |
|
101 |
Solid sol = fact.createTorus3D(0, 1); |
|
102 |
assertNotNull(sol); |
|
103 |
logger.debug(sol); |
|
104 |
manager.registerGeometryFactory(factory); |
|
105 |
logger.debug("--------- testRegister() END ----------"); |
|
106 |
} |
|
107 |
|
|
108 |
public void testGeneralPathXOperations(){ |
|
109 |
logger.debug("--------- Test GeneralPathX Operation START ----------"); |
|
110 |
|
|
111 |
//Registering the operation Flip() to all the geometries... |
|
112 |
manager.registerGeometryOperation("flip", new Flip()); |
|
113 |
|
|
114 |
//Registering the operation ensureOrientation() to all the geometries... |
|
115 |
manager.registerGeometryOperation("ensureOrientation", new EnsureOrientation()); |
|
116 |
|
|
117 |
//Registering the operation isCCW() to all the geometries... |
|
118 |
manager.registerGeometryOperation("isCCW", new IsCCW()); |
|
119 |
|
|
120 |
//Building the Points for a curve... |
|
121 |
java.awt.geom.Point2D p1 = new java.awt.geom.Point2D.Double(1,2); |
|
122 |
java.awt.geom.Point2D p2 = new java.awt.geom.Point2D.Double(2,1); |
|
123 |
java.awt.geom.Point2D p3 = new java.awt.geom.Point2D.Double(3,3); |
|
124 |
|
|
125 |
//Build a curve to get the operation invoked with the registered operation. |
|
126 |
Geometry curve = (Curve) factory.createArc(p1, p2, p3); |
|
127 |
|
|
128 |
|
|
129 |
try { |
|
130 |
curve.invokeOperation(Flip.CODE, null); |
|
131 |
} catch (GeometryOperationNotSupportedException e) { |
|
132 |
logger.error("Operation doesn't be registered for this geometry. \n", e); |
|
133 |
} catch (GeometryOperationException e) { |
|
134 |
logger.error("An error produced while the Operation was running. \n", e); |
|
135 |
} |
|
136 |
GeometryOperationContext ctx = new GeometryOperationContext(); |
|
137 |
ctx.setAttribute("bCCW",new Boolean(true)); |
|
138 |
Boolean aux1 = null; |
|
139 |
try { |
|
140 |
aux1 = (Boolean) curve.invokeOperation(EnsureOrientation.CODE, ctx); |
|
141 |
} catch (GeometryOperationNotSupportedException e) { |
|
142 |
logger.error("Operation doesn't be registered for this geometry. \n", e); |
|
143 |
} catch (GeometryOperationException e) { |
|
144 |
// TODO Auto-generated catch block |
|
145 |
logger.error("An error produced while the Operation was running. \n", e); |
|
146 |
} |
|
147 |
//True si es exterior, le ha dado la vuelta. |
|
148 |
assertTrue(aux1.booleanValue()); |
|
149 |
|
|
150 |
Boolean aux2 = null; |
|
151 |
try { |
|
152 |
aux2 = (Boolean) curve.invokeOperation(IsCCW.CODE, null); |
|
153 |
} catch (GeometryOperationNotSupportedException e) { |
|
154 |
logger.error("Operation doesn't be registered for this geometry. \n", e); |
|
155 |
} catch (GeometryOperationException e) { |
|
156 |
// TODO Auto-generated catch block |
|
157 |
logger.error("An error produced while the Operation was running. \n", e); |
|
158 |
} |
|
159 |
//True si es CCW. |
|
160 |
assertTrue(aux2.booleanValue()); |
|
161 |
|
|
162 |
logger.debug("--------- Test GeneralPathX Operation END ----------"); |
|
163 |
} |
|
164 |
|
|
165 |
public void testInvoke() { |
|
166 |
int size = 100000; |
|
167 |
|
|
168 |
// Fill the operation context with required params |
|
169 |
GeometryOperationContext ctx = new GeometryOperationContext(); |
|
170 |
GeometryOperationContext var = new GeometryOperationContext(); |
|
171 |
var.setAttribute("bCCW",new Boolean(true)); |
|
172 |
|
|
173 |
logger.debug("ToJTS.-"); |
|
174 |
indirectInvoke(ToJTS.CODE, ctx, size); |
|
175 |
directInvoke(ToJTS.CODE, ctx, size); |
|
176 |
logger.debug("ToWKB.-"); |
|
177 |
indirectInvoke(ToWKB.CODE, ctx, size); |
|
178 |
directInvoke(ToWKB.CODE, ctx, size); |
|
179 |
logger.debug("Flip.-"); |
|
180 |
indirectInvoke(Flip.CODE, ctx, size); |
|
181 |
directInvoke(Flip.CODE, ctx, size); |
|
182 |
logger.debug("EnsureOrientation.-"); |
|
183 |
//indirectInvoke(EnsureOrientation.CODE, var, size); |
|
184 |
directInvoke(EnsureOrientation.CODE, var, size); |
|
185 |
logger.debug("isCCW.-"); |
|
186 |
//indirectInvoke(IsCCW.CODE, ctx, size); |
|
187 |
directInvoke(IsCCW.CODE, ctx, size); |
|
188 |
|
|
189 |
} |
|
190 |
|
|
191 |
private Geometry[] createGeometryArray(int size) { |
|
192 |
Geometry[] geom = new Geometry[size]; |
|
193 |
for (int i = 0; i < size; i++) { |
|
194 |
geom[i] = factory.createPoint2D(Math.log(1 - i), Math.log(i + 1)); |
|
195 |
} |
|
196 |
return geom; |
|
197 |
} |
|
198 |
|
|
199 |
private long directInvoke(int opCode, GeometryOperationContext ctx, int size) { |
|
200 |
Geometry[] geoms = createGeometryArray(size); |
|
201 |
|
|
202 |
long t0 = System.currentTimeMillis(); |
|
203 |
|
|
204 |
GeometryOperation geomOp = null; |
|
205 |
try { |
|
206 |
geomOp = manager.getGeometryOperation(Point.class, ToJTS.CODE); |
|
207 |
} catch (GeometryTypeNotSupportedException gtnse) { |
|
208 |
logger.error("Error:", gtnse); |
|
209 |
} catch (GeometryOperationNotSupportedException gonse) { |
|
210 |
logger.error("Error:", gonse); |
|
211 |
} |
|
212 |
|
|
213 |
// Here is the main loop where you call the operation |
|
214 |
try { |
|
215 |
for (int i = 0; i < geoms.length; i++) { |
|
216 |
Object result = geomOp.invoke(geoms[i], ctx); |
|
217 |
// if(i%100 == 99) logger.debug(result); |
|
218 |
} |
|
219 |
|
|
220 |
} catch (GeometryOperationException goe) { |
|
221 |
logger.error("Error:", goe); |
|
222 |
} |
|
223 |
long t1 = System.currentTimeMillis(); |
|
224 |
long t = t1 - t0; |
|
225 |
logger.debug("Milliseconds (direct): " + t); |
|
226 |
return t; |
|
227 |
} |
|
228 |
|
|
229 |
private long indirectInvoke(int opCode, GeometryOperationContext ctx, |
|
230 |
int size) { |
|
231 |
Geometry[] geoms = createGeometryArray(size); |
|
232 |
|
|
233 |
long t0 = System.currentTimeMillis(); |
|
234 |
|
|
235 |
// Here is the main loop where you call the operation |
|
236 |
try { |
|
237 |
for (int i = 0; i < geoms.length; i++) { |
|
238 |
Object result = ((Geometry) geoms[i]).invokeOperation(opCode, |
|
239 |
ctx); |
|
240 |
// if(i%100 == 99) logger.debug(result); |
|
241 |
} |
|
242 |
} catch (GeometryOperationNotSupportedException gonse) { |
|
243 |
logger.error("Error:", gonse); |
|
244 |
} catch (GeometryOperationException goe) { |
|
245 |
logger.error("Error:", goe); |
|
246 |
} |
|
247 |
long t1 = System.currentTimeMillis(); |
|
248 |
long t = t1 - t0; |
|
249 |
logger.debug("Milliseconds (indirect): " + t); |
|
250 |
return t; |
|
251 |
} |
|
252 |
} |
branches/Mobile_Compatible_Hito_1/libFMap_geometries/src-test/org/gvsig/fmap/geom/MyFactory.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom; |
|
2 |
|
|
3 |
import org.gvsig.fmap.geom.primitive.Solid; |
|
4 |
import org.gvsig.fmap.geom.primitive.Solid2DZ; |
|
5 |
|
|
6 |
/** |
|
7 |
* Test class |
|
8 |
* @author jiyarza |
|
9 |
* |
|
10 |
*/ |
|
11 |
public class MyFactory extends GeometryFactory { |
|
12 |
public Solid createTorus3D(double r1, double r2) { |
|
13 |
return new Solid2DZ(null); |
|
14 |
} |
|
15 |
} |
branches/Mobile_Compatible_Hito_1/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.apache.log4j.Logger; |
|
49 |
import org.gvsig.fmap.geom.operation.GeometryOperation; |
|
50 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
51 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
52 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
53 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
54 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
|
55 |
|
|
56 |
/** |
|
57 |
* This singleton provides a centralized access to gvSIG's Geometry Model. |
|
58 |
* Its responsibilities are:<br> |
|
59 |
* |
|
60 |
* <ul> |
|
61 |
* <li>Offering a set of convenient methods for registering and retrieving geometry types. |
|
62 |
* <li>Offering a set of convenient methods for registering and retrieving geometry operations associated |
|
63 |
* to one or more geometry types. |
|
64 |
* <li><code>TODO:</code> Offering a set of convenient methods for registering and retrieving custom |
|
65 |
* geometry factories. |
|
66 |
* <ul> |
|
67 |
* |
|
68 |
* @author jiyarza |
|
69 |
* |
|
70 |
*/ |
|
71 |
public class GeometryManager { |
|
72 |
|
|
73 |
private static Logger logger = Logger.getLogger(GeometryManager.class); |
|
74 |
|
|
75 |
private static GeometryManager instance; |
|
76 |
|
|
77 |
/** This list holds the unique name of all registered geometry operations. |
|
78 |
* The index in which they are stored is also the operation code used to invoke each one of them */ |
|
79 |
private List geometryOperations = new ArrayList(); |
|
80 |
|
|
81 |
/** Common operations are registered here. Type specific operations are registered in the corresponding GeometryType instance */ |
|
82 |
private List commonOperations = new ArrayList(); |
|
83 |
|
|
84 |
/** Common operations are assigned an index greater or equal than this constant, so that it is easy and efficient for the manager |
|
85 |
* to decide whether to lookup in the common register or in the type specific register. */ |
|
86 |
private static final int COMMON_OPS_OFFSET = 1000; |
|
87 |
|
|
88 |
/** This map holds the instances of all registered GeometryType. The key is the name of the specific Geometry subclass. |
|
89 |
* In other words, the string "org.gvsig.fmap.geom.primitive.Point2D" is the hash key to obtain an instance of GeometryType holding the |
|
90 |
* operations associated to the class org.gvsig.fmap.geom.primitive.Point2D. |
|
91 |
*/ |
|
92 |
private Map geometryTypes = new HashMap(); |
|
93 |
|
|
94 |
/** GeometryType index counter. Each time a new geometry type is registered it is assigned this counter's value as index and after that |
|
95 |
* it is incremented by 1 */ |
|
96 |
private int geomTypeIndex = 10000; |
|
97 |
|
|
98 |
/** |
|
99 |
* Geometry Factory |
|
100 |
*/ |
|
101 |
private GeometryFactory factory = new GeometryFactory(); |
|
102 |
|
|
103 |
/** |
|
104 |
* Singleton's private constructor |
|
105 |
*/ |
|
106 |
private GeometryManager() { |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* Returns this singleton's unique instance |
|
111 |
* @return unique instance of GeometryManager |
|
112 |
*/ |
|
113 |
public static GeometryManager getInstance() { |
|
114 |
if (instance == null) { |
|
115 |
instance = new GeometryManager(); |
|
116 |
instance.registerGeometryFactory(new GeometryFactory()); |
|
117 |
} |
|
118 |
return instance; |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* Registers a GeometryFactory that will be used instead of the default one. |
|
123 |
* @param factory |
|
124 |
*/ |
|
125 |
public void registerGeometryFactory(GeometryFactory factory) { |
|
126 |
this.factory = factory; |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* Returns the current geometry factory |
|
131 |
* @return |
|
132 |
*/ |
|
133 |
public GeometryFactory getGeometryFactory() { |
|
134 |
return factory; |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* Registers the unique name of one operation. If it already exists then this method does nothing but returning |
|
139 |
* the name's corresponding index. |
|
140 |
* @param geomOpName Name used to register the geometry operation |
|
141 |
* @return index assigned to the operation name passed as parameter |
|
142 |
*/ |
|
143 |
private int registerGeometryOperationName(String geomOpName) { |
|
144 |
if (geomOpName == null) |
|
145 |
throw new IllegalArgumentException("geomOpName cannot be null."); |
|
146 |
|
|
147 |
int index = geometryOperations.indexOf(geomOpName); |
|
148 |
if (index == -1) { |
|
149 |
geometryOperations.add(geomOpName); |
|
150 |
index = geometryOperations.indexOf(geomOpName); |
|
151 |
} |
|
152 |
return index; |
|
153 |
} |
|
154 |
|
|
155 |
|
|
156 |
/** |
|
157 |
* Sets a common operation into the common operations map. |
|
158 |
* @param index index in which to set the operation |
|
159 |
* @param geomOp operation to be set |
|
160 |
*/ |
|
161 |
private void setCommonOperation(int index, GeometryOperation geomOp) { |
|
162 |
|
|
163 |
while (index > commonOperations.size()) { |
|
164 |
commonOperations.add(null); |
|
165 |
} |
|
166 |
|
|
167 |
if (index == commonOperations.size()) { |
|
168 |
commonOperations.add(geomOp); |
|
169 |
} else { |
|
170 |
commonOperations.set(index, geomOp); |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Registers a GeometryOperation associated to a GeometryType. |
|
176 |
* Returns an unique index that is used later to identify and invoke the operation. |
|
177 |
* |
|
178 |
* This method is only used if you already got a reference to the GeometryType. If not, |
|
179 |
* it is more convenient to use the method that receives the geometry class as parameter. |
|
180 |
* |
|
181 |
* By convention, the return value should be stored in a public constant within the class implementing |
|
182 |
* the operation:<BR> |
|
183 |
* <pre> |
|
184 |
* public class MyOperation extends GeometryOperation { |
|
185 |
* public static final int CODE = |
|
186 |
* GeometryManager.getInstance() |
|
187 |
* .registerGeometryOperation("MyOperation", new MyOperation(), geomType); |
|
188 |
* } |
|
189 |
* </pre> |
|
190 |
* @param geomOpName Operation's unique name |
|
191 |
* @param geomOp Specific GeometryOperation's instance implementing this operation |
|
192 |
* @param geomType GeometryType instance to which this operation should be associated |
|
193 |
* @return Index assigned to this operation. This index is used later to access the operation. |
|
194 |
* |
|
195 |
*/ |
|
196 |
public int registerGeometryOperation(String geomOpName, |
|
197 |
GeometryOperation geomOp, GeometryType geomType) { |
|
198 |
if (geomOp == null) |
|
199 |
throw new IllegalArgumentException("geomOp cannot be null."); |
|
200 |
if (geomType == null) |
|
201 |
throw new IllegalArgumentException("geomType cannot be null."); |
|
202 |
|
|
203 |
int index = registerGeometryOperationName(geomOpName); |
|
204 |
|
|
205 |
geomType.setGeometryOperation(index, geomOp); |
|
206 |
|
|
207 |
return index; |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* Registers a GeometryOperation that is common for all GeometryType (registered yet or not) |
|
212 |
* Returns an unique index that is used later to identify and invoke the operation. |
|
213 |
* |
|
214 |
* By convention, the return value should be stored in a public constant within the class implementing |
|
215 |
* the operation:<BR> |
|
216 |
* <pre> |
|
217 |
* public class MyOperation extends GeometryOperation { |
|
218 |
* public static final int CODE = |
|
219 |
* GeometryManager.getInstance() |
|
220 |
* .registerGeometryOperation("MyOperation", new MyOperation()); |
|
221 |
* } |
|
222 |
* </pre> |
|
223 |
* |
|
224 |
* @param geomOpName Operation's unique name |
|
225 |
* @param geomOp Specific GeometryOperation's instance implementing this operation |
|
226 |
* @return Index assigned to this operation. This index is used later to access the operation. |
|
227 |
*/ |
|
228 |
public int registerGeometryOperation(String geomOpName, |
|
229 |
GeometryOperation geomOp) { |
|
230 |
if (geomOpName == null) |
|
231 |
throw new IllegalArgumentException("geomOpName cannot be null."); |
|
232 |
if (geomOp == null) |
|
233 |
throw new IllegalArgumentException("geomOp cannot be null."); |
|
234 |
|
|
235 |
int index = registerGeometryOperationName(geomOpName); |
|
236 |
|
|
237 |
setCommonOperation(index, geomOp); |
|
238 |
|
|
239 |
|
|
240 |
return index + COMMON_OPS_OFFSET; |
|
241 |
|
|
242 |
} |
|
243 |
|
|
244 |
/** |
|
245 |
* Registers a GeometryOperation associated to a GeometryType. |
|
246 |
* Returns an unique index that is used later to identify and invoke the operation.<br> |
|
247 |
* |
|
248 |
* By convention, the return value should be stored in a public constant within the class implementing |
|
249 |
* the operation:<BR> |
|
250 |
* <pre> |
|
251 |
* public class MyOperation extends GeometryOperation { |
|
252 |
* public static final int CODE = |
|
253 |
* GeometryManager.getInstance() |
|
254 |
* .registerGeometryOperation("MyOperation", new MyOperation(), MyGeometry.class); |
|
255 |
* } |
|
256 |
* </pre> |
|
257 |
* |
|
258 |
* This method is only used if you have not a reference to the GeometryType associated to the |
|
259 |
* geometry class. If you have such reference then it is slightly faster to use the method that receives |
|
260 |
* the GeometryType.<br> |
|
261 |
* |
|
262 |
* @param geomOpName Operation's unique name |
|
263 |
* @param geomOp Specific GeometryOperation's instance implementing this operation |
|
264 |
* @param geomClass Geometry implementation class |
|
265 |
* @return Index assigned to this operation. This index is used later to access the operation. |
|
266 |
*/ |
|
267 |
public int registerGeometryOperation(String geomOpName, |
|
268 |
GeometryOperation geomOp, Class geomClass) { |
|
269 |
|
|
270 |
GeometryType geomType = getGeometryType(geomClass); |
|
271 |
return registerGeometryOperation(geomOpName, geomOp, geomType); |
|
272 |
} |
|
273 |
|
|
274 |
|
|
275 |
/** |
|
276 |
* Registers a GeometryOperation associated to a GeometryType. |
|
277 |
* Returns an unique index that is used later to identify and invoke the operation.<br> |
|
278 |
* |
|
279 |
* By convention, the return value should be stored in a public constant within the class implementing |
|
280 |
* the operation:<BR> |
|
281 |
* <pre> |
|
282 |
* public class MyOperation extends GeometryOperation { |
|
283 |
* public static final int CODE = |
|
284 |
* GeometryManager.getInstance() |
|
285 |
* .registerGeometryOperation("MyOperation", MyOperation.class, myGeomType); |
|
286 |
* } |
|
287 |
* </pre> |
|
288 |
* |
|
289 |
* @param geomOpName Operation's unique name |
|
290 |
* @param geomOpClass GeometryOperation class |
|
291 |
* @param geomType GeometryType instance to which this operation should be associated |
|
292 |
* @return Index assigned to this operation. This index is used later to access the operation. |
|
293 |
* @throws IllegalAccessException, {@link InstantiationException} Either exception maybe thrown when |
|
294 |
* trying to instance the geometry operation class. |
|
295 |
*/ |
|
296 |
public int registerGeometryOperation(String geomOpName, Class geomOpClass, |
|
297 |
GeometryType geomType) |
|
298 |
throws IllegalAccessException, InstantiationException { |
|
299 |
|
|
300 |
GeometryOperation geomOp = (GeometryOperation) geomOpClass.newInstance(); |
|
301 |
return registerGeometryOperation(geomOpName, geomOp, geomType); |
|
302 |
} |
|
303 |
|
|
304 |
/** |
|
305 |
* Registers a Geometry implementation class as a new geometry type and returns the |
|
306 |
* associated GeometryType instance. If the class is already registered |
|
307 |
* then this method does nothing but returning the associated GeometryType.<br> |
|
308 |
* |
|
309 |
* How to register a new geometry type: |
|
310 |
* <pre> |
|
311 |
* |
|
312 |
* public class MyGeom3D implements Solid { |
|
313 |
* private static final GeometryType geomType = GeometryManager.getInstance() |
|
314 |
* .registerGeometryType(MyGeom3D.class, "MyGeom3D"); |
|
315 |
* |
|
316 |
* public static final int .CODE = geomType.getType(); |
|
317 |
* ... |
|
318 |
* public int getType() { |
|
319 |
* return .CODE; |
|
320 |
* } |
|
321 |
* } |
|
322 |
* </pre> |
|
323 |
* |
|
324 |
* @param geomClass |
|
325 |
* Geometry subclass. It must not be null and must implement Geometry, otherwise an exception |
|
326 |
* is raised. |
|
327 |
* @param name |
|
328 |
* Symbolic name for the geometry type, it can be null. If it is null then the symbolic name |
|
329 |
* will be the simple class name. |
|
330 |
* @return Instance of GeometryType associated to the Geometry implementation class |
|
331 |
* geomClass |
|
332 |
* @throws IllegalArgumentException |
|
333 |
* If geomClass is null or does not implement Geometry |
|
334 |
*/ |
|
335 |
public GeometryType registerGeometryType(Class geomClass, String name) { |
|
336 |
|
|
337 |
if (geomClass == null) { |
|
338 |
throw new IllegalArgumentException("geomClass cannot be null."); |
|
339 |
} |
|
340 |
|
|
341 |
if (!Geometry.class.isAssignableFrom(geomClass)) { |
|
342 |
throw new IllegalArgumentException(geomClass.getName() |
|
343 |
+ " must implement the Geometry interface"); |
|
344 |
} |
|
345 |
|
|
346 |
// Check if it is registered |
|
347 |
GeometryType geomType = (GeometryType) geometryTypes.get(geomClass |
|
348 |
.getName()); |
|
349 |
|
|
350 |
// If it is not, register it |
|
351 |
if (geomType == null) { |
|
352 |
geomType = new GeometryType(geomClass, name, geomTypeIndex++); |
|
353 |
geometryTypes.put(geomClass.getName(), geomType); |
|
354 |
} else { |
|
355 |
// If it is already registered, throw exception |
|
356 |
throw new IllegalArgumentException("Attempt to register a geometry type that is already registered: " + geomClass.getName()); |
|
357 |
} |
|
358 |
logger.debug("Class " + geomType.getGeometryClass().getName() + " registered with name " + geomType.getName()); |
|
359 |
|
|
360 |
return geomType; |
|
361 |
} |
|
362 |
|
|
363 |
/** |
|
364 |
* Registers a Geometry implementation as a new geometry type and returns the |
|
365 |
* associated GeometryType instance. If the class is already registered |
|
366 |
* then this method does nothing but returning the associated GeometryType.<br> |
|
367 |
* |
|
368 |
* In this case the symbolic name will be the geometry's simple class name |
|
369 |
* |
|
370 |
* How to register a new geometry type: |
|
371 |
* <pre> |
|
372 |
* |
|
373 |
* public class MyGeom3D implements Solid { |
|
374 |
* private static final GeometryType geomType = GeometryManager.getInstance() |
|
375 |
* .registerGeometryType(MyGeom3D.class); |
|
376 |
* |
|
377 |
* public static final int .CODE = geomType.getType(); |
|
378 |
* ... |
|
379 |
* public int getType() { |
|
380 |
* return .CODE; |
|
381 |
* } |
|
382 |
* } |
|
383 |
* </pre> |
|
384 |
* |
|
385 |
* @param geomClass |
|
386 |
* Geometry implementation class. It must not be null and must implement Geometry, |
|
387 |
* otherwise an exception is thrown. |
|
388 |
* @return Instance of GeometryType associated to the Geometry implementation class |
|
389 |
* @throws IllegalArgumentException |
|
390 |
* If geomClass is null or does not implement Geometry |
|
391 |
*/ |
|
392 |
public GeometryType registerGeometryType(Class geomClass) { |
|
393 |
return registerGeometryType(geomClass, null); |
|
394 |
} |
|
395 |
/** |
|
396 |
* Returns an instance of GeometryType given the associated Geometry implementation |
|
397 |
* class. |
|
398 |
* |
|
399 |
* @param geomClass |
|
400 |
* @return Instance of GeometryType associated to the Geometry implementation class |
|
401 |
*/ |
|
402 |
public GeometryType getGeometryType(Class geomClass) { |
|
403 |
logger.debug("getting " + geomClass.getName()); |
|
404 |
return (GeometryType) geometryTypes.get(geomClass.getName()); |
|
405 |
} |
|
406 |
|
|
407 |
/** |
|
408 |
* Returns the associated GeometryType given the fully qualified name of |
|
409 |
* the Geometry implementation class. |
|
410 |
* |
|
411 |
* @param className |
|
412 |
* Fully qualified name of the Geometry implementation class |
|
413 |
* @return GeometryType associated to the class |
|
414 |
*/ |
|
415 |
public GeometryType getGeometryType(String className) { |
|
416 |
return (GeometryType) geometryTypes.get(className); |
|
417 |
} |
|
418 |
|
|
419 |
/** |
|
420 |
* Returns an operation given the Geometry implementation class and the operation |
|
421 |
* code. If opCode corresponds to a common operation (a common operation is an operation |
|
422 |
* registered for all geometries), then this method returns the common operation. |
|
423 |
* <br> |
|
424 |
* For better performance, if you need to call an operation multiple times, |
|
425 |
* use this method only once and keep the returned object in a local variable |
|
426 |
* over which you can iterate. For instance: |
|
427 |
* |
|
428 |
* <pre> |
|
429 |
* ... |
|
430 |
* // Get the operation you need |
|
431 |
* GeometryManager gm = GeometryManager.getInstance(); |
|
432 |
* GeometryOperation geomOp = null; |
|
433 |
* try { |
|
434 |
* geomOp = gm.getGeometryOperation(Point2D.class, Draw2D.CODE); |
|
435 |
* } catch (GeometryTypeNotSupportedException gtnse) { |
|
436 |
* // treat exception |
|
437 |
* } catch (GeometryOperationNotSupportedException gonse) { |
|
438 |
* // treat exception |
|
439 |
* } |
|
440 |
* |
|
441 |
* // Fill the operation context with required params |
|
442 |
* GeometryOperationContext ctx = new GeometryOperationContext(); |
|
443 |
* |
|
444 |
* // Here is the main loop where you call the operation |
|
445 |
* for (int i=0; i<MyGeometries.length; i++) { |
|
446 |
* Object result = geomOp.invoke(myGeometries[i], ctx); |
|
447 |
* } |
|
448 |
* |
|
449 |
* </pre> |
|
450 |
* |
|
451 |
* @param geomClass |
|
452 |
* @param opCode |
|
453 |
* @return Geometry operation |
|
454 |
*/ |
|
455 |
public GeometryOperation getGeometryOperation(Class geomClass, int opCode) throws GeometryTypeNotSupportedException, GeometryOperationNotSupportedException { |
|
456 |
|
|
457 |
GeometryOperation geomOp = null; |
|
458 |
|
|
459 |
// Check if it is a common operation, and if so, get it from the common registry |
|
460 |
if (opCode >= COMMON_OPS_OFFSET) { |
|
461 |
geomOp = ((GeometryOperation)commonOperations.get(opCode - COMMON_OPS_OFFSET)); |
|
462 |
|
|
463 |
if (geomOp == null) { |
|
464 |
throw new GeometryOperationNotSupportedException(opCode); |
|
465 |
} |
|
466 |
} else { |
|
467 |
// If it is type specific, get it from its type registry |
|
468 |
if (geomClass != null) { |
|
469 |
GeometryType geomType = getGeometryType(geomClass); |
|
470 |
|
|
471 |
// If the geometry type is not registered, throw an exception |
|
472 |
if (geomType == null) { |
|
473 |
throw new GeometryTypeNotSupportedException(geomClass); |
|
474 |
} |
|
475 |
|
|
476 |
// Get the operation |
|
477 |
geomOp = geomType.getGeometryOperation(opCode); |
|
478 |
|
|
479 |
// If the operation is not registered throw an exception |
|
480 |
if (geomOp == null) { |
|
481 |
throw new GeometryOperationNotSupportedException(opCode, geomType); |
|
482 |
} |
|
483 |
} |
|
484 |
} |
|
485 |
return geomOp; |
|
486 |
} |
|
487 |
|
|
488 |
/** |
|
489 |
* Invokes an operation given its code, the geometry and the operation context holding the |
|
490 |
* parameters required for the operation. |
|
491 |
* |
|
492 |
* @param opCode Operation code. |
|
493 |
* @param geom Geometry to which apply the operation |
|
494 |
* @param ctx Context holding the operation parameters |
|
495 |
* @return The object returned by an operation, depends on each operation. |
|
496 |
*/ |
|
497 |
public Object invokeOperation(int opCode, Geometry geom, GeometryOperationContext ctx) throws GeometryOperationNotSupportedException, GeometryOperationException { |
|
498 |
|
|
499 |
GeometryOperation geomOp = null; |
|
500 |
|
|
501 |
if (opCode < COMMON_OPS_OFFSET) { |
|
502 |
geomOp = geom.getGeometryType().getGeometryOperation(opCode); |
|
503 |
} else { |
|
504 |
geomOp = ((GeometryOperation)commonOperations.get(opCode - COMMON_OPS_OFFSET)); |
|
505 |
} |
|
506 |
|
|
507 |
if (geomOp != null) { |
|
508 |
return geomOp.invoke(geom, ctx); |
|
509 |
} |
|
510 |
|
|
511 |
throw new GeometryOperationNotSupportedException(opCode, geom.getGeometryType()); |
|
512 |
} |
|
513 |
} |
|
0 | 514 |
branches/Mobile_Compatible_Hito_1/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiPrimitive.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom.aggregate; |
|
2 |
|
|
3 |
public interface MultiPrimitive extends Aggregate { |
|
4 |
|
|
5 |
} |
|
0 | 6 |
branches/Mobile_Compatible_Hito_1/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiSurface.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom.aggregate; |
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id: MultiSurface.java,v 1.1 2008/03/12 08:46:20 cvs Exp $ |
|
45 |
* $Log: MultiSurface.java,v $ |
|
46 |
* Revision 1.1 2008/03/12 08:46:20 cvs |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
/** |
|
52 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
53 |
*/ |
|
54 |
public interface MultiSurface extends Aggregate{ |
|
55 |
|
|
56 |
} |
|
0 | 57 |
branches/Mobile_Compatible_Hito_1/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiPoint.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom.aggregate; |
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id: MultiPoint.java,v 1.1 2008/03/12 08:46:20 cvs Exp $ |
|
45 |
* $Log: MultiPoint.java,v $ |
|
46 |
* Revision 1.1 2008/03/12 08:46:20 cvs |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
/** |
|
52 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
53 |
*/ |
|
54 |
public interface MultiPoint extends Aggregate { |
|
55 |
|
|
56 |
} |
|
0 | 57 |
branches/Mobile_Compatible_Hito_1/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiPoint2DZ.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.primitive.FShape; |
|
49 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
50 |
|
|
51 |
/** |
|
52 |
* Multipunto 3D. |
|
53 |
* |
|
54 |
* @author Vicente Caballero Navarro |
|
55 |
*/ |
|
56 |
public class MultiPoint2DZ extends MultiPoint2D implements MultiPoint { |
|
57 |
|
|
58 |
private static final long serialVersionUID = 1L; |
|
59 |
|
|
60 |
// Registramos el tipo de geometria |
|
61 |
private static GeometryType geomType = GeometryManager.getInstance() |
|
62 |
.registerGeometryType(MultiPoint2DZ.class); |
|
63 |
|
|
64 |
public static int CODE = geomType.getType(); |
|
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 MultiPoint2DZ(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 MultiPoint2DZ(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 |
} |
|
0 | 119 |
branches/Mobile_Compatible_Hito_1/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiCurve2D.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.GeometryManager; |
|
6 |
import org.gvsig.fmap.geom.primitive.Curve2D; |
|
7 |
import org.gvsig.fmap.geom.primitive.FShape; |
|
8 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
9 |
|
|
10 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
11 |
* |
|
12 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
13 |
* |
|
14 |
* This program is free software; you can redistribute it and/or |
|
15 |
* modify it under the terms of the GNU General Public License |
|
16 |
* as published by the Free Software Foundation; either version 2 |
|
17 |
* of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, |
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
* GNU General Public License for more details. |
|
23 |
* |
|
24 |
* You should have received a copy of the GNU General Public License |
|
25 |
* along with this program; if not, write to the Free Software |
|
26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
27 |
* |
|
28 |
* For more information, contact: |
|
29 |
* |
|
30 |
* Generalitat Valenciana |
|
31 |
* Conselleria d'Infraestructures i Transport |
|
32 |
* Av. Blasco Ib??ez, 50 |
|
33 |
* 46010 VALENCIA |
|
34 |
* SPAIN |
|
35 |
* |
|
36 |
* +34 963862235 |
|
37 |
* gvsig@gva.es |
|
38 |
* www.gvsig.gva.es |
|
39 |
* |
|
40 |
* or |
|
41 |
* |
|
42 |
* IVER T.I. S.A |
|
43 |
* Salamanca 50 |
|
44 |
* 46005 Valencia |
|
45 |
* Spain |
|
46 |
* |
|
47 |
* +34 963163400 |
|
48 |
* dac@iver.es |
|
49 |
*/ |
|
50 |
/* CVS MESSAGES: |
|
51 |
* |
|
52 |
* $Id: FMultiPolyline2D.java,v 1.2 2008/03/25 08:47:41 cvs Exp $ |
|
53 |
* $Log: FMultiPolyline2D.java,v $ |
|
54 |
* Revision 1.2 2008/03/25 08:47:41 cvs |
|
55 |
* Visitors removed |
|
56 |
* |
|
57 |
* Revision 1.1 2008/03/12 08:46:20 cvs |
|
58 |
* *** empty log message *** |
|
59 |
* |
|
60 |
* |
|
61 |
*/ |
|
62 |
/** |
|
63 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
64 |
*/ |
|
65 |
public class MultiCurve2D extends BaseMultiPrimitive implements MultiCurve { |
|
66 |
|
|
67 |
private static final long serialVersionUID = 1L; |
|
68 |
|
|
69 |
private static GeometryType geomType = GeometryManager.getInstance() |
|
70 |
.registerGeometryType(MultiCurve2D.class); |
|
71 |
public static int CODE = geomType.getType(); |
|
72 |
|
|
73 |
public MultiCurve2D(String id, IProjection projection) { |
|
74 |
super(id, projection); |
|
75 |
} |
|
76 |
|
|
77 |
public MultiCurve2D(String id, IProjection projection, Curve2D[] lines) { |
|
78 |
super(id, projection, lines); |
|
79 |
} |
|
80 |
|
|
81 |
/* |
|
82 |
* (non-Javadoc) |
|
83 |
* |
|
84 |
* @see com.iver.cit.gvsig.fmap.core.FGeometryCollection#cloneGeometry() |
|
85 |
*/ |
|
86 |
public Geometry cloneGeometry() { |
|
87 |
Curve2D[] aux = new Curve2D[getPrimitivesNumber()]; |
|
88 |
for (int i = 0; i < getPrimitivesNumber(); i++) { |
|
89 |
aux[i] = (Curve2D) geometries[i].cloneGeometry(); |
|
90 |
} |
|
91 |
return new MultiCurve2D(id, projection, aux); |
|
92 |
} |
|
93 |
|
|
94 |
/* |
|
95 |
* (non-Javadoc) |
|
96 |
* |
|
97 |
* @see com.iver.cit.gvsig.fmap.core.FGeometryCollection#getGeometryType() |
|
98 |
*/ |
|
99 |
public int getShapeType() { |
|
100 |
return FShape.MULTIPOLYLINE; |
|
101 |
} |
|
102 |
|
|
103 |
} |
|
0 | 104 |
branches/Mobile_Compatible_Hito_1/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiSolid.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom.aggregate; |
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id: MultiSolid.java,v 1.1 2008/03/12 08:46:20 cvs Exp $ |
|
45 |
* $Log: MultiSolid.java,v $ |
|
46 |
* Revision 1.1 2008/03/12 08:46:20 cvs |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
/** |
|
52 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
53 |
*/ |
|
54 |
public interface MultiSolid extends Aggregate{ |
|
55 |
|
|
56 |
} |
|
0 | 57 |
branches/Mobile_Compatible_Hito_1/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/MultiSolid2DZ.java | ||
---|---|---|
1 |
package org.gvsig.fmap.geom.aggregate; |
|
2 |
|
|
3 |
import org.cresques.cts.IProjection; |
|
4 |
import org.gvsig.fmap.geom.GeometryManager; |
|
5 |
import org.gvsig.fmap.geom.primitive.Solid2DZ; |
|
6 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
7 |
|
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
9 |
* |
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
25 |
* |
|
26 |
* For more information, contact: |
|
27 |
* |
|
28 |
* Generalitat Valenciana |
|
29 |
* Conselleria d'Infraestructures i Transport |
|
30 |
* Av. Blasco Ib??ez, 50 |
|
31 |
* 46010 VALENCIA |
|
32 |
* SPAIN |
|
33 |
* |
|
34 |
* +34 963862235 |
|
35 |
* gvsig@gva.es |
|
36 |
* www.gvsig.gva.es |
|
37 |
* |
|
38 |
* or |
|
39 |
* |
|
40 |
* IVER T.I. S.A |
|
41 |
* Salamanca 50 |
|
42 |
* 46005 Valencia |
|
43 |
* Spain |
|
44 |
* |
|
45 |
* +34 963163400 |
|
46 |
* dac@iver.es |
|
47 |
*/ |
|
48 |
/* CVS MESSAGES: |
|
49 |
* |
|
50 |
* $Id: FMultiSolid.java,v 1.2 2008/03/25 08:47:41 cvs Exp $ |
|
51 |
* $Log: FMultiSolid.java,v $ |
|
52 |
* Revision 1.2 2008/03/25 08:47:41 cvs |
|
53 |
* Visitors removed |
|
54 |
* |
|
55 |
* Revision 1.1 2008/03/12 08:46:20 cvs |
|
56 |
* *** empty log message *** |
Also available in: Unified diff