Revision 34708 branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/impl/DefaultGeometryLibrary.java
DefaultGeometryLibrary.java | ||
---|---|---|
1 | 1 |
/* gvSIG. Geographic Information System of the Valencian Government |
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
2 |
*
|
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
|
4 |
* of the Valencian Government (CIT)
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or
|
|
7 |
* modify it under the terms of the GNU General Public License
|
|
8 |
* as published by the Free Software Foundation; either version 2
|
|
9 |
* of the License, or (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
19 |
* MA 02110-1301, USA.
|
|
20 |
*
|
|
21 |
*/
|
|
22 | 22 |
|
23 | 23 |
/* |
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
24 |
* AUTHORS (In addition to CIT):
|
|
25 |
* 2009 {Iver T.I.} {Task}
|
|
26 |
*/
|
|
27 | 27 |
|
28 | 28 |
package org.gvsig.fmap.geom.impl; |
29 | 29 |
|
... | ... | |
74 | 74 |
|
75 | 75 |
/** |
76 | 76 |
* Registers the default implementation for {@link GeometryManager} |
77 |
* |
|
77 |
*
|
|
78 | 78 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
79 | 79 |
*/ |
80 |
public class DefaultGeometryLibrary extends AbstractLibrary {
|
|
80 |
public class DefaultGeometryLibrary extends AbstractLibrary { |
|
81 | 81 |
|
82 |
public DefaultGeometryLibrary() {
|
|
83 |
super(GeometryLibrary.class, Library.TYPE.IMPL);
|
|
84 |
}
|
|
85 |
|
|
86 |
protected void doInitialize() throws LibraryException {
|
|
87 |
//Register the default GeometryManager |
|
82 |
public DefaultGeometryLibrary() {
|
|
83 |
super(GeometryLibrary.class, Library.TYPE.IMPL);
|
|
84 |
}
|
|
85 |
|
|
86 |
protected void doInitialize() throws LibraryException {
|
|
87 |
// Register the default GeometryManager
|
|
88 | 88 |
GeometryLocator.registerGeometryManager(DefaultGeometryManager.class); |
89 |
}
|
|
89 |
}
|
|
90 | 90 |
|
91 |
protected void doPostInitialize() throws LibraryException {
|
|
92 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager();
|
|
91 |
protected void doPostInitialize() throws LibraryException {
|
|
92 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager();
|
|
93 | 93 |
|
94 |
DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager(); |
|
95 |
|
|
96 |
dataTypesManager.setCoercion(DataTypes.GEOMETRY, new CoerceToGeometry()); |
|
97 |
dataTypesManager.setCoercion(DataTypes.ENVELOPE, new CoerceToEnvelope()); |
|
98 |
dataTypesManager.setCoercion(DataTypes.STRING, new CoerceToString(dataTypesManager.getCoercion(DataTypes.STRING))); |
|
99 |
dataTypesManager.setCoercion(DataTypes.BYTEARRAY, new CoerceToByteArray(dataTypesManager.getCoercion(DataTypes.BYTEARRAY))); |
|
94 |
DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager(); |
|
100 | 95 |
|
101 |
GeometryOperation.OPERATION_INTERSECTS_CODE = |
|
102 |
GeometryLocator.getGeometryManager().getGeometryOperationCode( |
|
103 |
GeometryOperation.OPERATION_INTERSECTS_NAME);; |
|
104 |
|
|
105 |
GeometryOperation.OPERATION_CONTAINS_CODE = |
|
106 |
GeometryLocator.getGeometryManager().getGeometryOperationCode( |
|
107 |
GeometryOperation.OPERATION_CONTAINS_NAME);; |
|
96 |
dataTypesManager |
|
97 |
.setCoercion(DataTypes.GEOMETRY, new CoerceToGeometry()); |
|
98 |
dataTypesManager |
|
99 |
.setCoercion(DataTypes.ENVELOPE, new CoerceToEnvelope()); |
|
100 |
dataTypesManager.setCoercion(DataTypes.STRING, new CoerceToString( |
|
101 |
dataTypesManager.getCoercion(DataTypes.STRING))); |
|
102 |
dataTypesManager.setCoercion( |
|
103 |
DataTypes.BYTEARRAY, |
|
104 |
new CoerceToByteArray(dataTypesManager |
|
105 |
.getCoercion(DataTypes.BYTEARRAY))); |
|
108 | 106 |
|
109 |
//Register the geometries in 2D |
|
110 |
geometryManager.registerGeometryType(DefaultNullGeometry.class, "Null", TYPES.NULL, SUBTYPES.GEOM2D); |
|
111 |
geometryManager.registerGeometryType(Geometry2D.class, "Goemtry2D", TYPES.GEOMETRY, SUBTYPES.GEOM2D); |
|
112 |
geometryManager.registerGeometryType(Arc2D.class, "Arc2D", TYPES.ARC, SUBTYPES.GEOM2D); |
|
113 |
geometryManager.registerGeometryType(Circle2D.class, "Circle2D", TYPES.CIRCLE, SUBTYPES.GEOM2D); |
|
114 |
geometryManager.registerGeometryType(Curve2D.class, "Curve2D", TYPES.CURVE, SUBTYPES.GEOM2D); |
|
115 |
geometryManager.registerGeometryType(Ellipse2D.class, "Ellipse2D", TYPES.ELLIPSE, SUBTYPES.GEOM2D); |
|
116 |
geometryManager.registerGeometryType(EllipticArc2D.class, "EllipticArc2D", TYPES.ELLIPTICARC, SUBTYPES.GEOM2D); |
|
117 |
geometryManager.registerGeometryType(Point2D.class, "Point2D", TYPES.POINT, SUBTYPES.GEOM2D); |
|
118 |
geometryManager.registerGeometryType(Spline2D.class, "Spline2D", TYPES.SPLINE, SUBTYPES.GEOM2D); |
|
119 |
geometryManager.registerGeometryType(Surface2D.class, "Surface2D", TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
120 |
geometryManager.registerGeometryType(BaseMultiPrimitive2D.class, "MultiPrimitive2D", TYPES.AGGREGATE, SUBTYPES.GEOM2D); |
|
121 |
geometryManager.registerGeometryType(MultiCurve2D.class, "MultiCurve2D", TYPES.MULTICURVE, SUBTYPES.GEOM2D); |
|
122 |
geometryManager.registerGeometryType(MultiCurve2DZ.class, "MultiCurve2DZ", TYPES.MULTICURVE, SUBTYPES.GEOM2DZ); |
|
123 |
geometryManager.registerGeometryType(MultiPoint2D.class, "MultiPoint2D", TYPES.MULTIPOINT, SUBTYPES.GEOM2D); |
|
124 |
geometryManager.registerGeometryType(MultiSurface2D.class, "MultiSurface", TYPES.MULTISURFACE, SUBTYPES.GEOM2D); |
|
107 |
GeometryOperation.OPERATION_INTERSECTS_CODE = |
|
108 |
GeometryLocator.getGeometryManager().getGeometryOperationCode( |
|
109 |
GeometryOperation.OPERATION_INTERSECTS_NAME); |
|
110 |
; |
|
125 | 111 |
|
126 |
//Register the geometries in 2DZ |
|
127 |
geometryManager.registerGeometryType(DefaultNullGeometry.class, TYPES.NULL, SUBTYPES.GEOM2DZ); |
|
128 |
geometryManager.registerGeometryType(Arc2DZ.class, TYPES.ARC, SUBTYPES.GEOM2DZ); |
|
129 |
geometryManager.registerGeometryType(Circle2DZ.class, TYPES.CIRCLE, SUBTYPES.GEOM2DZ); |
|
130 |
geometryManager.registerGeometryType(Curve2DZ.class, TYPES.CURVE, SUBTYPES.GEOM2DZ); |
|
131 |
geometryManager.registerGeometryType(Ellipse2DZ.class, TYPES.ELLIPSE, SUBTYPES.GEOM2DZ); |
|
132 |
geometryManager.registerGeometryType(EllipticArc2DZ.class, TYPES.ELLIPTICARC, SUBTYPES.GEOM2DZ); |
|
133 |
geometryManager.registerGeometryType(Point2DZ.class, TYPES.POINT, SUBTYPES.GEOM2DZ); |
|
134 |
geometryManager.registerGeometryType(Spline2DZ.class, TYPES.SPLINE, SUBTYPES.GEOM2DZ); |
|
135 |
geometryManager.registerGeometryType(Surface2DZ.class, TYPES.SURFACE, SUBTYPES.GEOM2DZ); |
|
136 |
geometryManager.registerGeometryType(MultiPoint2DZ.class, TYPES.MULTIPOINT, SUBTYPES.GEOM2DZ); |
|
137 |
geometryManager.registerGeometryType(Solid2DZ.class, TYPES.SOLID, SUBTYPES.GEOM2DZ); |
|
138 |
|
|
139 |
//Persistence |
|
112 |
GeometryOperation.OPERATION_CONTAINS_CODE = |
|
113 |
GeometryLocator.getGeometryManager().getGeometryOperationCode( |
|
114 |
GeometryOperation.OPERATION_CONTAINS_NAME); |
|
115 |
; |
|
116 |
|
|
117 |
// Register the geometries in 2D |
|
118 |
geometryManager.registerGeometryType(DefaultNullGeometry.class, "Null", |
|
119 |
TYPES.NULL, SUBTYPES.GEOM2D); |
|
120 |
geometryManager.registerGeometryType(Geometry2D.class, "Goemtry2D", |
|
121 |
TYPES.GEOMETRY, SUBTYPES.GEOM2D); |
|
122 |
geometryManager.registerGeometryType(Arc2D.class, "Arc2D", TYPES.ARC, |
|
123 |
SUBTYPES.GEOM2D); |
|
124 |
geometryManager.registerGeometryType(Circle2D.class, "Circle2D", |
|
125 |
TYPES.CIRCLE, SUBTYPES.GEOM2D); |
|
126 |
geometryManager.registerGeometryType(Curve2D.class, "Curve2D", |
|
127 |
TYPES.CURVE, SUBTYPES.GEOM2D); |
|
128 |
geometryManager.registerGeometryType(Ellipse2D.class, "Ellipse2D", |
|
129 |
TYPES.ELLIPSE, SUBTYPES.GEOM2D); |
|
130 |
geometryManager.registerGeometryType(EllipticArc2D.class, |
|
131 |
"EllipticArc2D", TYPES.ELLIPTICARC, SUBTYPES.GEOM2D); |
|
132 |
geometryManager.registerGeometryType(Point2D.class, "Point2D", |
|
133 |
TYPES.POINT, SUBTYPES.GEOM2D); |
|
134 |
geometryManager.registerGeometryType(Spline2D.class, "Spline2D", |
|
135 |
TYPES.SPLINE, SUBTYPES.GEOM2D); |
|
136 |
geometryManager.registerGeometryType(Surface2D.class, "Surface2D", |
|
137 |
TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
138 |
geometryManager.registerGeometryType(BaseMultiPrimitive2D.class, |
|
139 |
"MultiPrimitive2D", TYPES.AGGREGATE, SUBTYPES.GEOM2D); |
|
140 |
geometryManager.registerGeometryType(MultiCurve2D.class, |
|
141 |
"MultiCurve2D", TYPES.MULTICURVE, SUBTYPES.GEOM2D); |
|
142 |
geometryManager.registerGeometryType(MultiCurve2DZ.class, |
|
143 |
"MultiCurve2DZ", TYPES.MULTICURVE, SUBTYPES.GEOM2DZ); |
|
144 |
geometryManager.registerGeometryType(MultiPoint2D.class, |
|
145 |
"MultiPoint2D", TYPES.MULTIPOINT, SUBTYPES.GEOM2D); |
|
146 |
geometryManager.registerGeometryType(MultiSurface2D.class, |
|
147 |
"MultiSurface", TYPES.MULTISURFACE, SUBTYPES.GEOM2D); |
|
148 |
|
|
149 |
// Register the geometries in 2DZ |
|
150 |
geometryManager.registerGeometryType(DefaultNullGeometry.class, |
|
151 |
TYPES.NULL, SUBTYPES.GEOM2DZ); |
|
152 |
geometryManager.registerGeometryType(Arc2DZ.class, TYPES.ARC, |
|
153 |
SUBTYPES.GEOM2DZ); |
|
154 |
geometryManager.registerGeometryType(Circle2DZ.class, TYPES.CIRCLE, |
|
155 |
SUBTYPES.GEOM2DZ); |
|
156 |
geometryManager.registerGeometryType(Curve2DZ.class, TYPES.CURVE, |
|
157 |
SUBTYPES.GEOM2DZ); |
|
158 |
geometryManager.registerGeometryType(Ellipse2DZ.class, TYPES.ELLIPSE, |
|
159 |
SUBTYPES.GEOM2DZ); |
|
160 |
geometryManager.registerGeometryType(EllipticArc2DZ.class, |
|
161 |
TYPES.ELLIPTICARC, SUBTYPES.GEOM2DZ); |
|
162 |
geometryManager.registerGeometryType(Point2DZ.class, TYPES.POINT, |
|
163 |
SUBTYPES.GEOM2DZ); |
|
164 |
geometryManager.registerGeometryType(Spline2DZ.class, TYPES.SPLINE, |
|
165 |
SUBTYPES.GEOM2DZ); |
|
166 |
geometryManager.registerGeometryType(Surface2DZ.class, TYPES.SURFACE, |
|
167 |
SUBTYPES.GEOM2DZ); |
|
168 |
geometryManager.registerGeometryType(MultiPoint2DZ.class, |
|
169 |
TYPES.MULTIPOINT, SUBTYPES.GEOM2DZ); |
|
170 |
geometryManager.registerGeometryType(Solid2DZ.class, TYPES.SOLID, |
|
171 |
SUBTYPES.GEOM2DZ); |
|
172 |
|
|
173 |
// Persistence |
|
140 | 174 |
DefaultEnvelope.registerPersistent(); |
141 | 175 |
Envelope2D.registerPersistent(); |
142 | 176 |
Envelope3D.registerPersistent(); |
143 |
|
|
144 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
145 |
|
|
177 |
|
|
178 |
PersistenceManager persistenceManager = |
|
179 |
ToolsLocator.getPersistenceManager(); |
|
180 |
|
|
146 | 181 |
persistenceManager.registerFactory(new GeometryPersistenceFactory()); |
147 |
} |
|
148 |
} |
|
182 |
} |
|
183 |
} |
Also available in: Unified diff