root / trunk / libraries / libDataSourceBaseDrivers / src / org / gvsig / data / datastores / vectorial / driver / dgn / DGNFeaturesReader.java @ 19794
History | View | Annotate | Download (2.38 KB)
1 |
package org.gvsig.data.datastores.vectorial.driver.dgn; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.Collection; |
5 |
import java.util.Comparator; |
6 |
import java.util.TreeSet; |
7 |
|
8 |
import org.gvsig.data.datastores.vectorial.driver.IFeaturesReader; |
9 |
import org.gvsig.data.exception.ReadException; |
10 |
import org.gvsig.data.vectorial.IFeature; |
11 |
import org.gvsig.data.vectorial.IFeatureCollection; |
12 |
import org.gvsig.data.vectorial.IFeatureStore; |
13 |
import org.gvsig.data.vectorial.IFeatureType; |
14 |
import org.gvsig.data.vectorial.expansionadapter.FeatureManager; |
15 |
import org.gvsig.data.vectorial.filter.FeatureFilterParser; |
16 |
import org.gvsig.data.vectorial.order.FeatureComparator; |
17 |
|
18 |
class DGNFeaturesReader implements IFeaturesReader { |
19 |
private DGNStore store;
|
20 |
|
21 |
public void init(IFeatureStore store) { |
22 |
this.store=(DGNStore)store;
|
23 |
} |
24 |
|
25 |
public IFeatureCollection getFeatures(FeatureManager featureManager,IFeatureType type, String filter, String order) { |
26 |
IFeatureCollection coll; |
27 |
|
28 |
//TODO aplicar filtro, orden e incluso y el featureType
|
29 |
FeatureFilterParser parser = null;
|
30 |
if (filter!=null){ |
31 |
parser = new FeatureFilterParser(filter,type);
|
32 |
} |
33 |
ArrayList originalFeatures=store.getFeatures();
|
34 |
int num=0; |
35 |
if (featureManager!=null){ |
36 |
num=featureManager.getNum(); |
37 |
} |
38 |
int originalSize=originalFeatures.size();
|
39 |
Collection allFeatures=null; |
40 |
if (order!=null){ |
41 |
Comparator comparator = new FeatureComparator(type,order); |
42 |
allFeatures = new TreeSet(comparator); |
43 |
}else{
|
44 |
allFeatures=new ArrayList(); |
45 |
} |
46 |
int j=0; |
47 |
for (int i = 0; i < originalSize+num; i++) { |
48 |
IFeature feature=null;
|
49 |
if (i<store.getFeatureCount()){
|
50 |
feature=store.getFeature(i); |
51 |
}else{
|
52 |
feature=featureManager.getFeature(i-originalSize); |
53 |
} |
54 |
if (featureManager == null || !featureManager.isDeleted(feature)){ |
55 |
try {
|
56 |
|
57 |
DGNFeature auxfeature=new DGNFeature(feature);
|
58 |
if (filter==null || parser.match(auxfeature)){ |
59 |
// System.err.println(i);
|
60 |
// j++;
|
61 |
// System.err.println("j= "+j);
|
62 |
if (!allFeatures.add(auxfeature)){
|
63 |
// System.err.println("Fallo " +auxfeature);
|
64 |
}else{
|
65 |
System.out.println("Correcto " +auxfeature); |
66 |
} |
67 |
} |
68 |
|
69 |
} catch (ReadException e) {
|
70 |
// TODO Auto-generated catch block
|
71 |
e.printStackTrace(); |
72 |
} |
73 |
} |
74 |
|
75 |
} |
76 |
|
77 |
coll=new DGNFeatureCollection(allFeatures);
|
78 |
return coll;
|
79 |
} |
80 |
|
81 |
} |