root / trunk / libraries / libDataSourceBaseDrivers / src-test / org / gvsig / data / datastores / vectorial / driver / dgn / DGNTest.java @ 19736
History | View | Annotate | Download (3.58 KB)
1 |
package org.gvsig.data.datastores.vectorial.driver.dgn; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.util.Iterator; |
5 |
|
6 |
import junit.framework.TestCase; |
7 |
|
8 |
import org.gvsig.data.datastores.vectorial.driver.DataStoreTest; |
9 |
import org.gvsig.data.exception.CloseException; |
10 |
import org.gvsig.data.exception.InitializeException; |
11 |
import org.gvsig.data.exception.OpenException; |
12 |
import org.gvsig.data.exception.ReadException; |
13 |
import org.gvsig.data.vectorial.IFeature; |
14 |
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
15 |
import org.gvsig.data.vectorial.IFeatureCollection; |
16 |
import org.gvsig.data.vectorial.IFeatureType; |
17 |
import org.gvsig.data.vectorial.expansionadapter.FeatureManager; |
18 |
import org.gvsig.data.vectorial.expansionadapter.MemoryExpansionAdapter; |
19 |
|
20 |
public class DGNTest extends TestCase { |
21 |
DGNStore store = new DGNStore();
|
22 |
private File file = new File(DataStoreTest.class.getResource("data/cv_300_todo.dgn").getFile()); |
23 |
|
24 |
|
25 |
public static void main(String[] args) { |
26 |
} |
27 |
|
28 |
protected void setUp() throws Exception { |
29 |
super.setUp();
|
30 |
} |
31 |
|
32 |
/*
|
33 |
* Test method for 'com.iver.cit.gvsig.fmap.drivers.dbf.DBFDriver.initialize()'
|
34 |
*/
|
35 |
public void testInitialize() { |
36 |
Register.selfRegister(); |
37 |
DGNStoreParameters dgnParameters=new DGNStoreParameters();
|
38 |
dgnParameters.setDGNFile(file); |
39 |
try {
|
40 |
store.init(dgnParameters); |
41 |
} catch (InitializeException e) {
|
42 |
// TODO Auto-generated catch block
|
43 |
e.printStackTrace(); |
44 |
} |
45 |
try {
|
46 |
store.open(); |
47 |
} catch (OpenException e) {
|
48 |
// TODO Auto-generated catch block
|
49 |
e.printStackTrace(); |
50 |
} |
51 |
|
52 |
IFeatureType ft=store.getDefaultFeatureType(); |
53 |
FeatureManager featureManager=new FeatureManager(new MemoryExpansionAdapter()); |
54 |
IFeatureCollection featureCollection=null;
|
55 |
try {
|
56 |
featureCollection = (IFeatureCollection)store.getDataCollection(ft,null,null); |
57 |
} catch (ReadException e) {
|
58 |
// TODO Auto-generated catch block
|
59 |
e.printStackTrace(); |
60 |
} |
61 |
Iterator iter = featureCollection.iterator();
|
62 |
while (iter.hasNext()) {
|
63 |
IFeature feature = (IFeature)iter.next(); |
64 |
System.out.println("DGN Feature ------------------- "); |
65 |
for (int i=0;i<ft.size();i++){ |
66 |
|
67 |
IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)ft.get(i); |
68 |
String type=descriptor.getDataType();
|
69 |
if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){
|
70 |
System.out.println("Boolean ----- "+ feature.getBoolean(i)); |
71 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){ |
72 |
System.out.println("Byte ----- "+ feature.getByte(i)); |
73 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DATE)){ |
74 |
System.out.println("Date ----- "+ feature.getDate(i)); |
75 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){ |
76 |
System.out.println("Double ----- "+ feature.getDouble(i)); |
77 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){ |
78 |
System.out.println("Float ----- "+ feature.getFloat(i)); |
79 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_INT)){ |
80 |
System.out.println("Integer ----- "+ feature.getInt(i)); |
81 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_LONG)){ |
82 |
System.out.println("Long ----- "+ feature.getLong(i)); |
83 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_STRING)){ |
84 |
System.out.println("String ----- "+ feature.getString(i)); |
85 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){ |
86 |
|
87 |
System.out.println("Geometry ----- "+ feature.getGeometry(i)); |
88 |
} |
89 |
} |
90 |
} |
91 |
|
92 |
try {
|
93 |
store.close(); |
94 |
store.dispose(); |
95 |
} catch (CloseException e) {
|
96 |
// TODO Auto-generated catch block
|
97 |
e.printStackTrace(); |
98 |
} |
99 |
} |
100 |
} |