01: /**
02: *
03: */package org.geotools.feature.iso.simple;
04:
05: import org.geotools.geometry.jts.ReferencedEnvelope;
06: import org.opengis.feature.GeometryAttribute;
07: import org.opengis.geometry.BoundingBox;
08: import org.opengis.referencing.crs.CoordinateReferenceSystem;
09:
10: import com.vividsolutions.jts.geom.Geometry;
11:
12: class IndexGeometryAttribute extends IndexAttribute implements
13: GeometryAttribute {
14:
15: ArraySimpleFeature feature;
16:
17: BoundingBox bounds = null;
18:
19: public IndexGeometryAttribute(ArraySimpleFeature feature, int index) {
20: super (feature, index);
21: this .feature = feature;
22: }
23:
24: public CoordinateReferenceSystem getCRS() {
25: return this .feature.type.getCRS();
26: }
27:
28: public void setCRS(CoordinateReferenceSystem crs) {
29: if (!this .feature.type.getCRS().equals(crs)) {
30: throw new IllegalArgumentException(
31: "Provided crs does not match");
32: }
33: }
34:
35: public void setBounds(BoundingBox bbox) {
36: bounds = bbox;
37: }
38:
39: public synchronized BoundingBox getBounds() {
40: if (bounds == null) {
41: if (this .feature.values[index] instanceof Geometry) {
42: Geometry geometry = (Geometry) this .feature.values[index];
43: bounds = new ReferencedEnvelope(geometry
44: .getEnvelopeInternal(), this .feature.type
45: .getCRS());
46: }
47: }
48: return bounds;
49: }
50:
51: public void setValue(Object geom) {
52: this.feature.values[index] = geom;
53: }
54:
55: }
|