svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dataFile / src-test / org / gvsig / data / datastores / vectorial / file / dgn / DGNTest.java @ 20971
History | View | Annotate | Download (3.85 KB)
1 |
package org.gvsig.data.datastores.vectorial.file.dgn; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.util.Iterator; |
5 |
|
6 |
import junit.framework.TestCase; |
7 |
|
8 |
import org.gvsig.data.CloseException; |
9 |
import org.gvsig.data.DataManager; |
10 |
import org.gvsig.data.InitializeException; |
11 |
import org.gvsig.data.OpenException; |
12 |
import org.gvsig.data.ReadException; |
13 |
import org.gvsig.data.datastores.vectorial.file.DataStoreTest; |
14 |
import org.gvsig.data.vectorial.IFeature; |
15 |
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
16 |
import org.gvsig.data.vectorial.IFeatureCollection; |
17 |
import org.gvsig.data.vectorial.IFeatureType; |
18 |
|
19 |
public class DGNTest extends TestCase { |
20 |
|
21 |
private File file = new File(DataStoreTest.class.getResource("data/prueba.dgn").getFile()); |
22 |
|
23 |
|
24 |
public static void main(String[] args) { |
25 |
} |
26 |
|
27 |
protected void setUp() throws Exception { |
28 |
super.setUp();
|
29 |
} |
30 |
|
31 |
public void testInitialize() { |
32 |
Register.selfRegister(); |
33 |
DataManager manager = DataManager.getManager(); |
34 |
DGNStore store = null;
|
35 |
|
36 |
DGNStoreParameters dgnParameters; |
37 |
dgnParameters=(DGNStoreParameters)manager.createDataStoreParameters(DGNStore.DATASTORE_NAME); |
38 |
dgnParameters.setFile(file); |
39 |
try {
|
40 |
store = (DGNStore)manager.createDataStore(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 |
IFeatureCollection featureCollection=null;
|
54 |
try {
|
55 |
featureCollection = (IFeatureCollection)store.getDataCollection(ft,null,null); |
56 |
} catch (ReadException e) {
|
57 |
// TODO Auto-generated catch block
|
58 |
e.printStackTrace(); |
59 |
} |
60 |
Iterator iter = featureCollection.iterator();
|
61 |
while (iter.hasNext()) {
|
62 |
IFeature feature = (IFeature)iter.next(); |
63 |
System.out.println("DGN Feature ------------------- "); |
64 |
Iterator iterator=ft.iterator();
|
65 |
while (iterator.hasNext()) {
|
66 |
IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next(); |
67 |
int i=descriptor.ordinal();
|
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 |
iter = null;
|
92 |
featureCollection.dispose(); |
93 |
|
94 |
try {
|
95 |
store.close(); |
96 |
store.dispose(); |
97 |
} catch (CloseException e) {
|
98 |
// TODO Auto-generated catch block
|
99 |
e.printStackTrace(); |
100 |
} |
101 |
} |
102 |
|
103 |
public void test_Resources(){ |
104 |
|
105 |
DataManager manager = DataManager.getManager(); |
106 |
Register.selfRegister(); |
107 |
|
108 |
DGNStoreParameters parameters; |
109 |
|
110 |
parameters=(DGNStoreParameters)manager.createDataStoreParameters(DGNStore.DATASTORE_NAME); |
111 |
parameters.setFile(file); |
112 |
|
113 |
|
114 |
DataStoreTest.doFileResourceTest(parameters); |
115 |
} |
116 |
|
117 |
} |