root / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / impl / DefaultGeometryLibrary.java @ 38545
History | View | Annotate | Download (9.87 KB)
1 | 26328 | jpiera | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | 34708 | jjdelcerro | *
|
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | * of the Valencian Government (CIT)
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | */
|
||
22 | 26328 | jpiera | |
23 | /*
|
||
24 | 34708 | jjdelcerro | * AUTHORS (In addition to CIT):
|
25 | * 2009 {Iver T.I.} {Task}
|
||
26 | */
|
||
27 | 29051 | jmvivo | |
28 | 27042 | jpiera | package org.gvsig.fmap.geom.impl; |
29 | 26328 | jpiera | |
30 | 34690 | jjdelcerro | import org.gvsig.fmap.geom.DataTypes; |
31 | import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
||
32 | import org.gvsig.fmap.geom.Geometry.TYPES; |
||
33 | 33032 | jjdelcerro | import org.gvsig.fmap.geom.GeometryLibrary; |
34 | 27042 | jpiera | import org.gvsig.fmap.geom.GeometryLocator; |
35 | import org.gvsig.fmap.geom.GeometryManager; |
||
36 | 27029 | jpiera | import org.gvsig.fmap.geom.aggregate.impl.BaseMultiPrimitive2D; |
37 | import org.gvsig.fmap.geom.aggregate.impl.MultiCurve2D; |
||
38 | 29051 | jmvivo | import org.gvsig.fmap.geom.aggregate.impl.MultiCurve2DZ; |
39 | 27029 | jpiera | import org.gvsig.fmap.geom.aggregate.impl.MultiPoint2D; |
40 | import org.gvsig.fmap.geom.aggregate.impl.MultiPoint2DZ; |
||
41 | 35613 | jpiera | import org.gvsig.fmap.geom.aggregate.impl.MultiSolid2DZ; |
42 | 27029 | jpiera | import org.gvsig.fmap.geom.aggregate.impl.MultiSurface2D; |
43 | 35613 | jpiera | import org.gvsig.fmap.geom.aggregate.impl.MultiSurface3D; |
44 | 34690 | jjdelcerro | import org.gvsig.fmap.geom.impl.coerce.CoerceToByteArray; |
45 | import org.gvsig.fmap.geom.impl.coerce.CoerceToEnvelope; |
||
46 | import org.gvsig.fmap.geom.impl.coerce.CoerceToGeometry; |
||
47 | import org.gvsig.fmap.geom.impl.coerce.CoerceToString; |
||
48 | 31221 | jldominguez | import org.gvsig.fmap.geom.operation.GeometryOperation; |
49 | 27029 | jpiera | import org.gvsig.fmap.geom.primitive.impl.Arc2D; |
50 | import org.gvsig.fmap.geom.primitive.impl.Arc2DZ; |
||
51 | import org.gvsig.fmap.geom.primitive.impl.Circle2D; |
||
52 | import org.gvsig.fmap.geom.primitive.impl.Circle2DZ; |
||
53 | import org.gvsig.fmap.geom.primitive.impl.Curve2D; |
||
54 | import org.gvsig.fmap.geom.primitive.impl.Curve2DZ; |
||
55 | 33388 | jpiera | import org.gvsig.fmap.geom.primitive.impl.DefaultEnvelope; |
56 | 27037 | jpiera | import org.gvsig.fmap.geom.primitive.impl.DefaultNullGeometry; |
57 | 27029 | jpiera | import org.gvsig.fmap.geom.primitive.impl.Ellipse2D; |
58 | import org.gvsig.fmap.geom.primitive.impl.Ellipse2DZ; |
||
59 | import org.gvsig.fmap.geom.primitive.impl.EllipticArc2D; |
||
60 | import org.gvsig.fmap.geom.primitive.impl.EllipticArc2DZ; |
||
61 | 33388 | jpiera | import org.gvsig.fmap.geom.primitive.impl.Envelope2D; |
62 | import org.gvsig.fmap.geom.primitive.impl.Envelope3D; |
||
63 | 37336 | fdiaz | import org.gvsig.fmap.geom.primitive.impl.Geometry2D; |
64 | 38545 | jldominguez | import org.gvsig.fmap.geom.primitive.impl.Geometry2DZ; |
65 | 27029 | jpiera | import org.gvsig.fmap.geom.primitive.impl.Point2D; |
66 | import org.gvsig.fmap.geom.primitive.impl.Point2DZ; |
||
67 | import org.gvsig.fmap.geom.primitive.impl.Solid2DZ; |
||
68 | import org.gvsig.fmap.geom.primitive.impl.Spline2D; |
||
69 | import org.gvsig.fmap.geom.primitive.impl.Spline2DZ; |
||
70 | import org.gvsig.fmap.geom.primitive.impl.Surface2D; |
||
71 | import org.gvsig.fmap.geom.primitive.impl.Surface2DZ; |
||
72 | 37322 | cordinyana | import org.gvsig.fmap.geom.type.persistence.GeometryTypePersistenceFactory; |
73 | 33650 | jpiera | import org.gvsig.tools.ToolsLocator; |
74 | 34690 | jjdelcerro | import org.gvsig.tools.dataTypes.DataTypesManager; |
75 | 30633 | cordinyana | import org.gvsig.tools.library.AbstractLibrary; |
76 | 30580 | cordinyana | import org.gvsig.tools.library.LibraryException; |
77 | 33650 | jpiera | import org.gvsig.tools.persistence.PersistenceManager; |
78 | 26328 | jpiera | |
79 | /**
|
||
80 | * Registers the default implementation for {@link GeometryManager}
|
||
81 | 34708 | jjdelcerro | *
|
82 | 26328 | jpiera | * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
83 | */
|
||
84 | 34708 | jjdelcerro | public class DefaultGeometryLibrary extends AbstractLibrary { |
85 | 29051 | jmvivo | |
86 | 35142 | cordinyana | public void doRegistration() { |
87 | registerAsImplementationOf(GeometryLibrary.class); |
||
88 | 34708 | jjdelcerro | } |
89 | |||
90 | protected void doInitialize() throws LibraryException { |
||
91 | // Register the default GeometryManager
|
||
92 | 26866 | jpiera | GeometryLocator.registerGeometryManager(DefaultGeometryManager.class); |
93 | 34708 | jjdelcerro | } |
94 | 26328 | jpiera | |
95 | 34708 | jjdelcerro | protected void doPostInitialize() throws LibraryException { |
96 | GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
||
97 | 34690 | jjdelcerro | |
98 | 34708 | jjdelcerro | DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager(); |
99 | 34690 | jjdelcerro | |
100 | 34708 | jjdelcerro | dataTypesManager |
101 | 35185 | jpiera | .setCoercion(DataTypes.GEOMETRY, new CoerceToGeometry());
|
102 | 34708 | jjdelcerro | dataTypesManager |
103 | 35185 | jpiera | .setCoercion(DataTypes.ENVELOPE, new CoerceToEnvelope());
|
104 | 34708 | jjdelcerro | dataTypesManager.setCoercion(DataTypes.STRING, new CoerceToString(
|
105 | dataTypesManager.getCoercion(DataTypes.STRING))); |
||
106 | dataTypesManager.setCoercion( |
||
107 | DataTypes.BYTEARRAY, |
||
108 | new CoerceToByteArray(dataTypesManager
|
||
109 | .getCoercion(DataTypes.BYTEARRAY))); |
||
110 | 31221 | jldominguez | |
111 | 34708 | jjdelcerro | GeometryOperation.OPERATION_INTERSECTS_CODE = |
112 | GeometryLocator.getGeometryManager().getGeometryOperationCode( |
||
113 | GeometryOperation.OPERATION_INTERSECTS_NAME); |
||
114 | 29051 | jmvivo | |
115 | 34708 | jjdelcerro | GeometryOperation.OPERATION_CONTAINS_CODE = |
116 | GeometryLocator.getGeometryManager().getGeometryOperationCode( |
||
117 | GeometryOperation.OPERATION_CONTAINS_NAME); |
||
118 | |||
119 | // Register the geometries in 2D
|
||
120 | geometryManager.registerGeometryType(DefaultNullGeometry.class, "Null",
|
||
121 | TYPES.NULL, SUBTYPES.GEOM2D); |
||
122 | 37336 | fdiaz | |
123 | geometryManager.registerGeometryType(Geometry2D.class, "Geometry2D",
|
||
124 | TYPES.GEOMETRY, SUBTYPES.GEOM2D); |
||
125 | 38545 | jldominguez | geometryManager.registerGeometryType(Geometry2DZ.class, "Geometry3D",
|
126 | TYPES.GEOMETRY, SUBTYPES.GEOM3D); |
||
127 | 35185 | jpiera | |
128 | //Register points in 2D
|
||
129 | geometryManager.registerGeometryType(Point2D.class, "Point2D", |
||
130 | TYPES.POINT, SUBTYPES.GEOM2D); |
||
131 | |||
132 | //Register curves in 2D
|
||
133 | 34708 | jjdelcerro | geometryManager.registerGeometryType(Curve2D.class, "Curve2D",
|
134 | TYPES.CURVE, SUBTYPES.GEOM2D); |
||
135 | 35185 | jpiera | geometryManager.registerGeometryType(Arc2D.class, "Arc2D", |
136 | TYPES.ARC, SUBTYPES.GEOM2D, TYPES.CURVE); |
||
137 | 34708 | jjdelcerro | geometryManager.registerGeometryType(Spline2D.class, "Spline2D",
|
138 | 35185 | jpiera | TYPES.SPLINE, SUBTYPES.GEOM2D, TYPES.CURVE); |
139 | |||
140 | //Register surfaces in 2D
|
||
141 | 34708 | jjdelcerro | geometryManager.registerGeometryType(Surface2D.class, "Surface2D",
|
142 | 35185 | jpiera | TYPES.SURFACE, SUBTYPES.GEOM2D, TYPES.SURFACE); |
143 | geometryManager.registerGeometryType(Circle2D.class, "Circle2D",
|
||
144 | TYPES.CIRCLE, SUBTYPES.GEOM2D, TYPES.SURFACE); |
||
145 | geometryManager.registerGeometryType(Ellipse2D.class, "Ellipse2D", |
||
146 | TYPES.ELLIPSE, SUBTYPES.GEOM2D, TYPES.SURFACE); |
||
147 | geometryManager.registerGeometryType(EllipticArc2D.class,"EllipticArc2D",
|
||
148 | TYPES.ELLIPTICARC, SUBTYPES.GEOM2D, TYPES.SURFACE); |
||
149 | 34708 | jjdelcerro | |
150 | 35185 | jpiera | //Register multigeometries in 2D
|
151 | geometryManager.registerGeometryType(BaseMultiPrimitive2D.class, "MultiPrimitive2D",
|
||
152 | TYPES.AGGREGATE, SUBTYPES.GEOM2D); |
||
153 | geometryManager.registerGeometryType(MultiPoint2D.class, "MultiPoint2D",
|
||
154 | TYPES.MULTIPOINT, SUBTYPES.GEOM2D, TYPES.AGGREGATE); |
||
155 | geometryManager.registerGeometryType(MultiCurve2D.class, "MultiCurve2D",
|
||
156 | TYPES.MULTICURVE, SUBTYPES.GEOM2D, TYPES.AGGREGATE); |
||
157 | 35613 | jpiera | geometryManager.registerGeometryType(MultiSurface2D.class,"MultiSurface2D",
|
158 | 35185 | jpiera | TYPES.MULTISURFACE, SUBTYPES.GEOM2D, TYPES.AGGREGATE); |
159 | |||
160 | // Register the geometries in 3D
|
||
161 | 34708 | jjdelcerro | geometryManager.registerGeometryType(DefaultNullGeometry.class, |
162 | 34899 | jpiera | TYPES.NULL, SUBTYPES.GEOM3D); |
163 | 35185 | jpiera | |
164 | //Register points in 3D
|
||
165 | geometryManager.registerGeometryType(Point2DZ.class, "Point3D",
|
||
166 | TYPES.POINT, SUBTYPES.GEOM3D, new int[0], new int[]{SUBTYPES.GEOM2D}); |
||
167 | |||
168 | //Register curves in 3D
|
||
169 | geometryManager.registerGeometryType(Curve2DZ.class, "Curve3D",
|
||
170 | TYPES.CURVE, SUBTYPES.GEOM3D, new int[0], new int[]{SUBTYPES.GEOM2D}); |
||
171 | geometryManager.registerGeometryType(Arc2DZ.class, "Arc3D",
|
||
172 | TYPES.ARC, SUBTYPES.GEOM3D, TYPES.CURVE, SUBTYPES.GEOM2D); |
||
173 | geometryManager.registerGeometryType(Spline2DZ.class, "Spline3D",
|
||
174 | TYPES.SPLINE, SUBTYPES.GEOM3D, TYPES.CURVE, SUBTYPES.GEOM2D); |
||
175 | |||
176 | //Register surfaces in 2D
|
||
177 | geometryManager.registerGeometryType(Surface2DZ.class, "Surface3D",
|
||
178 | TYPES.SURFACE, SUBTYPES.GEOM3D, new int[0], new int[]{SUBTYPES.GEOM2D}); |
||
179 | geometryManager.registerGeometryType(Circle2DZ.class, "Circle3D",
|
||
180 | TYPES.CIRCLE, SUBTYPES.GEOM3D, TYPES.SURFACE, SUBTYPES.GEOM2D); |
||
181 | geometryManager.registerGeometryType(Ellipse2DZ.class, "Ellipse3D",
|
||
182 | TYPES.ELLIPSE,SUBTYPES.GEOM3D, TYPES.SURFACE, SUBTYPES.GEOM2D); |
||
183 | 34899 | jpiera | geometryManager.registerGeometryType(EllipticArc2DZ.class, "EllipticArc3D",
|
184 | 35185 | jpiera | TYPES.ELLIPTICARC, SUBTYPES.GEOM3D, TYPES.SURFACE, SUBTYPES.GEOM2D); |
185 | |||
186 | //Register multigeometries in 3D
|
||
187 | 34899 | jpiera | geometryManager.registerGeometryType(MultiPoint2DZ.class, "Multipoint3D",
|
188 | 35185 | jpiera | TYPES.MULTIPOINT, SUBTYPES.GEOM3D, TYPES.AGGREGATE, SUBTYPES.GEOM2D); |
189 | geometryManager.registerGeometryType(MultiCurve2DZ.class,"MultiCurve3D",
|
||
190 | TYPES.MULTICURVE, SUBTYPES.GEOM3D, TYPES.AGGREGATE, SUBTYPES.GEOM2D); |
||
191 | 35613 | jpiera | geometryManager.registerGeometryType(MultiSurface3D.class,"MultiSurface3D",
|
192 | TYPES.MULTISURFACE, SUBTYPES.GEOM3D, TYPES.AGGREGATE, SUBTYPES.GEOM2D); |
||
193 | 34708 | jjdelcerro | |
194 | 35185 | jpiera | //Register solids
|
195 | geometryManager.registerGeometryType(Solid2DZ.class, "Solid3D",
|
||
196 | TYPES.SOLID, SUBTYPES.GEOM3D); |
||
197 | 35613 | jpiera | geometryManager.registerGeometryType(MultiSolid2DZ.class,"MultiSolid3D",
|
198 | TYPES.MULTISOLID, SUBTYPES.GEOM3D, TYPES.AGGREGATE); |
||
199 | 35185 | jpiera | |
200 | 34708 | jjdelcerro | // Persistence
|
201 | 33388 | jpiera | DefaultEnvelope.registerPersistent(); |
202 | Envelope2D.registerPersistent(); |
||
203 | Envelope3D.registerPersistent(); |
||
204 | 34708 | jjdelcerro | |
205 | PersistenceManager persistenceManager = |
||
206 | ToolsLocator.getPersistenceManager(); |
||
207 | |||
208 | 33650 | jpiera | persistenceManager.registerFactory(new GeometryPersistenceFactory());
|
209 | 37322 | cordinyana | persistenceManager |
210 | .registerFactory(new GeometryTypePersistenceFactory());
|
||
211 | 34708 | jjdelcerro | } |
212 | } |