Revision 38596 branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/impl/DefaultGeometryManager.java
DefaultGeometryManager.java | ||
---|---|---|
57 | 57 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
58 | 58 |
import org.gvsig.fmap.geom.primitive.NullGeometry; |
59 | 59 |
import org.gvsig.fmap.geom.primitive.Point; |
60 |
import org.gvsig.fmap.geom.primitive.PointGeometryType; |
|
60 | 61 |
import org.gvsig.fmap.geom.primitive.Surface; |
61 | 62 |
import org.gvsig.fmap.geom.primitive.impl.DefaultNullGeometry; |
62 | 63 |
import org.gvsig.fmap.geom.primitive.impl.Envelope2D; |
... | ... | |
109 | 110 |
*/ |
110 | 111 |
private GeometryType[][] geometryTypes; |
111 | 112 |
|
112 |
/** |
|
113 |
* GeometryType index counter. Each time a new geometry type (not |
|
114 |
* predefined) is registered it is assigned this counter's value as index |
|
115 |
* and after that |
|
116 |
* it is incremented by 1 |
|
117 |
*/ |
|
118 |
private int geometryTypeIndex = 0;// Geometry.EXTENDED_GEOMTYPE_OFFSET; |
|
119 |
// //65536;//2^16 |
|
120 |
|
|
121 | 113 |
// Initially create a matrix of 17 x 6, which are the current default |
122 | 114 |
// types and subtypes. If another type or subtype is registered, the |
123 | 115 |
// matrix will grow as needed |
... | ... | |
261 | 253 |
} |
262 | 254 |
|
263 | 255 |
public GeometryType registerGeometryType(Class geomClass, String name, |
264 |
int type, int subType, int[] superTypes, int[] superSubTypes) { |
|
265 |
return registerGeometryType(geomClass, name, geometryTypeIndex++, type, subType, |
|
266 |
superTypes, superSubTypes); |
|
267 |
} |
|
268 |
|
|
269 |
public GeometryType registerGeometryType(Class geomClass, String name, |
|
270 | 256 |
int type, int subType, int[] superTypes) { |
271 | 257 |
return registerGeometryType(geomClass, name, type, subType, |
272 | 258 |
superTypes, new int[0]); |
... | ... | |
287 | 273 |
* private static final GeometryType geomType = GeometryManager.getInstance() |
288 | 274 |
* .registerBasicGeometryType(Point2D.class, "Point2D", Geometry.TYPES.POINT); |
289 | 275 |
* |
290 |
* public static final int CODE = geomType.getId(); |
|
291 | 276 |
* ... |
292 | 277 |
* public int getType() { |
293 | 278 |
* return geomType.getType(); |
... | ... | |
317 | 302 |
* @throws IllegalArgumentException |
318 | 303 |
* If geomClass is null or does not implement Geometry |
319 | 304 |
*/ |
320 |
private GeometryType registerGeometryType(Class geomClass, String name,
|
|
321 |
int id, int type, int subType, int[] superTypes, int superSubTypes[]) {
|
|
305 |
public GeometryType registerGeometryType(Class geomClass, String name,
|
|
306 |
int type, int subType, int[] superTypes, int superSubTypes[]) { |
|
322 | 307 |
if (geomClass == null) { |
323 | 308 |
throw new IllegalArgumentException("geomClass cannot be null."); |
324 | 309 |
} |
... | ... | |
333 | 318 |
if (type >= geometryTypes.length || subType >= geometryTypes[0].length |
334 | 319 |
|| (geomType = geometryTypes[type][subType]) == null) { |
335 | 320 |
geomType = |
336 |
new DefaultGeometryType(geomClass, name, id, type, subType,
|
|
321 |
new DefaultGeometryType(geomClass, name, type, subType, |
|
337 | 322 |
superTypes, superSubTypes); |
338 | 323 |
registerGeometryType(geomType); |
339 | 324 |
geometryTypeName.put(geomClass.getName(), geomType); |
... | ... | |
345 | 330 |
return geomType; |
346 | 331 |
} |
347 | 332 |
|
348 |
private void registerGeometryType(GeometryType geometryType) {
|
|
333 |
public void registerGeometryType(GeometryType geometryType) {
|
|
349 | 334 |
if (geometryType.getType() >= geometryTypes.length |
350 | 335 |
|| geometryType.getSubType() >= geometryTypes[0].length) { |
351 | 336 |
|
... | ... | |
525 | 510 |
org.gvsig.fmap.geom.primitive.Point min = null; |
526 | 511 |
org.gvsig.fmap.geom.primitive.Point max = null; |
527 | 512 |
try { |
528 |
GeometryType gType = getGeometryType(TYPES.POINT, subType); |
|
529 |
min = (Point) gType.create(); |
|
530 |
min.setX(minX); |
|
531 |
min.setY(minY); |
|
532 |
max = (Point) gType.create(); |
|
533 |
max.setX(maxX); |
|
534 |
max.setY(maxY); |
|
535 |
// min = createPoint(minX, minY, subType); |
|
536 |
// max = createPoint(maxX, maxY, subType); |
|
537 |
} catch (CreateGeometryException e) { |
|
538 |
throw new CreateEnvelopeException(subType, e); |
|
513 |
PointGeometryType gType = (PointGeometryType) getGeometryType(TYPES.POINT, subType); |
|
514 |
min = gType.createPoint(minX, minY); |
|
515 |
max = gType.createPoint(maxX, maxY); |
|
539 | 516 |
} catch (GeometryTypeNotSupportedException e) { |
540 | 517 |
throw new CreateEnvelopeException(subType, e); |
541 | 518 |
} catch (GeometryTypeNotValidException e) { |
Also available in: Unified diff