svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_data / src / org / gvsig / fmap / data / feature / MemoryFeature.java @ 22373
History | View | Annotate | Download (2.22 KB)
1 |
package org.gvsig.fmap.data.feature; |
---|---|
2 |
|
3 |
import java.util.Iterator; |
4 |
import java.util.List; |
5 |
|
6 |
import org.gvsig.fmap.data.DataException; |
7 |
import org.gvsig.fmap.data.InitializeException; |
8 |
import org.gvsig.fmap.data.ReadException; |
9 |
import org.gvsig.fmap.geom.Geometry; |
10 |
import org.gvsig.fmap.geom.primitive.Envelope; |
11 |
|
12 |
public class MemoryFeature extends AbstractFeature implements Feature { |
13 |
|
14 |
/**
|
15 |
*
|
16 |
*/
|
17 |
private static final long serialVersionUID = 5866395773511247527L; |
18 |
|
19 |
public MemoryFeature(Feature feature) throws ReadException { |
20 |
super(feature.getType(),false); |
21 |
|
22 |
Iterator iter=this.featureType.iterator(); |
23 |
|
24 |
Object value;
|
25 |
FeatureAttributeDescriptor featureAttribute; |
26 |
int column;
|
27 |
this.loading();
|
28 |
while(iter.hasNext()){
|
29 |
featureAttribute=(FeatureAttributeDescriptor)iter.next(); |
30 |
column=((AttributeDescriptor)featureAttribute).originalPosition(); |
31 |
value=feature.get(column); |
32 |
try {
|
33 |
if (featureAttribute.getDataType().equals(FeatureAttributeDescriptor.TYPE_GEOMETRY)){
|
34 |
if (value != null) { |
35 |
value = ((Geometry) value).cloneGeometry(); |
36 |
} |
37 |
this.setGeometry(column, value);
|
38 |
|
39 |
}else if (featureAttribute.getDataType().equals(FeatureAttributeDescriptor.TYPE_OBJECT)){ |
40 |
//TODO falta clonar el objeto
|
41 |
// ((Cloneable)get(i)).clo
|
42 |
// set(i,.);
|
43 |
}else {
|
44 |
this.set(column, value);
|
45 |
} |
46 |
} catch (IsNotFeatureSettingException e){
|
47 |
throw new InitializeException("Feature",e); |
48 |
} |
49 |
|
50 |
} |
51 |
this.stopLoading();
|
52 |
|
53 |
|
54 |
} |
55 |
|
56 |
public MemoryFeature(FeatureType type,boolean defaultValues) throws ReadException { |
57 |
super(type,defaultValues);
|
58 |
} |
59 |
|
60 |
public FeatureID getID() {
|
61 |
return new MemoryFeatureID(this); |
62 |
} |
63 |
|
64 |
public Envelope getExtent() {
|
65 |
String geomColumn=featureType.getDefaultGeometry();
|
66 |
Geometry geometry=(Geometry)getGeometry(geomColumn); |
67 |
return geometry.getEnvelope();
|
68 |
} |
69 |
|
70 |
public List getAllSRS() { |
71 |
// TODO Auto-generated method stub
|
72 |
return null; |
73 |
} |
74 |
|
75 |
public String getDefaultSRS() { |
76 |
// TODO Auto-generated method stub
|
77 |
return null; |
78 |
} |
79 |
|
80 |
public void loading() { |
81 |
super.loading();
|
82 |
} |
83 |
public void stopLoading(){ |
84 |
super.stopLoading();
|
85 |
} |
86 |
|
87 |
protected Feature cloneFeature() throws DataException { |
88 |
return new MemoryFeature(this); |
89 |
} |
90 |
|
91 |
} |