svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dataFile / src-test / org / gvsig / fmap / data / feature / file / dgn / DGNTest.java @ 22373
History | View | Annotate | Download (4.07 KB)
1 |
package org.gvsig.fmap.data.feature.file.dgn; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.util.Iterator; |
5 |
|
6 |
import junit.framework.TestCase; |
7 |
|
8 |
import org.gvsig.fmap.data.CloseException; |
9 |
import org.gvsig.fmap.data.DataManager; |
10 |
import org.gvsig.fmap.data.InitializeException; |
11 |
import org.gvsig.fmap.data.OpenException; |
12 |
import org.gvsig.fmap.data.ReadException; |
13 |
import org.gvsig.fmap.data.feature.file.DataStoreTest; |
14 |
import org.gvsig.fmap.data.feature.Feature; |
15 |
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor; |
16 |
import org.gvsig.fmap.data.feature.FeatureCollection; |
17 |
import org.gvsig.fmap.data.feature.FeatureType; |
18 |
import org.gvsig.fmap.data.feature.file.dgn.DGNStore; |
19 |
import org.gvsig.fmap.data.feature.file.dgn.DGNStoreParameters; |
20 |
import org.gvsig.fmap.data.feature.file.dgn.Register; |
21 |
|
22 |
public class DGNTest extends TestCase { |
23 |
|
24 |
private File file = new File(DataStoreTest.class.getResource("data/prueba.dgn").getFile()); |
25 |
|
26 |
|
27 |
public static void main(String[] args) { |
28 |
} |
29 |
|
30 |
protected void setUp() throws Exception { |
31 |
super.setUp();
|
32 |
} |
33 |
|
34 |
public void testInitialize() { |
35 |
Register.selfRegister(); |
36 |
DataManager manager = DataManager.getManager(); |
37 |
DGNStore store = null;
|
38 |
|
39 |
DGNStoreParameters dgnParameters=null;
|
40 |
try {
|
41 |
dgnParameters=(DGNStoreParameters)manager.createDataStoreParameters(DGNStore.DATASTORE_NAME); |
42 |
} catch (InitializeException e1) {
|
43 |
e1.printStackTrace(); |
44 |
fail(); |
45 |
} |
46 |
dgnParameters.setFile(file); |
47 |
try {
|
48 |
store = (DGNStore)manager.createDataStore(dgnParameters); |
49 |
} catch (InitializeException e) {
|
50 |
// TODO Auto-generated catch block
|
51 |
e.printStackTrace(); |
52 |
} |
53 |
|
54 |
FeatureType ft=store.getDefaultFeatureType(); |
55 |
FeatureCollection featureCollection=null;
|
56 |
try {
|
57 |
featureCollection = (FeatureCollection)store.getDataCollection(ft,null,null); |
58 |
} catch (ReadException e) {
|
59 |
// TODO Auto-generated catch block
|
60 |
e.printStackTrace(); |
61 |
} |
62 |
Iterator iter = featureCollection.iterator();
|
63 |
while (iter.hasNext()) {
|
64 |
Feature feature = (Feature)iter.next(); |
65 |
System.out.println("DGN Feature ------------------- "); |
66 |
Iterator iterator=ft.iterator();
|
67 |
while (iterator.hasNext()) {
|
68 |
FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) iterator.next(); |
69 |
int i=descriptor.ordinal();
|
70 |
String type=descriptor.getDataType();
|
71 |
if (type.equals(FeatureAttributeDescriptor.TYPE_BOOLEAN)){
|
72 |
System.out.println("Boolean ----- "+ feature.getBoolean(i)); |
73 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_BYTE)){ |
74 |
System.out.println("Byte ----- "+ feature.getByte(i)); |
75 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_DATE)){ |
76 |
System.out.println("Date ----- "+ feature.getDate(i)); |
77 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_DOUBLE)){ |
78 |
System.out.println("Double ----- "+ feature.getDouble(i)); |
79 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_FLOAT)){ |
80 |
System.out.println("Float ----- "+ feature.getFloat(i)); |
81 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_INT)){ |
82 |
System.out.println("Integer ----- "+ feature.getInt(i)); |
83 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_LONG)){ |
84 |
System.out.println("Long ----- "+ feature.getLong(i)); |
85 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_STRING)){ |
86 |
System.out.println("String ----- "+ feature.getString(i)); |
87 |
}else if (type.equals(FeatureAttributeDescriptor.TYPE_GEOMETRY)){ |
88 |
|
89 |
System.out.println("Geometry ----- "+ feature.getGeometry(i)); |
90 |
} |
91 |
} |
92 |
} |
93 |
iter = null;
|
94 |
featureCollection.dispose(); |
95 |
|
96 |
try {
|
97 |
store.dispose(); |
98 |
} catch (CloseException e) {
|
99 |
// TODO Auto-generated catch block
|
100 |
e.printStackTrace(); |
101 |
} |
102 |
} |
103 |
|
104 |
public void test_Resources(){ |
105 |
|
106 |
DataManager manager = DataManager.getManager(); |
107 |
Register.selfRegister(); |
108 |
|
109 |
DGNStoreParameters parameters=null;
|
110 |
|
111 |
try {
|
112 |
parameters=(DGNStoreParameters)manager.createDataStoreParameters(DGNStore.DATASTORE_NAME); |
113 |
} catch (InitializeException e) {
|
114 |
e.printStackTrace(); |
115 |
fail(); |
116 |
} |
117 |
parameters.setFile(file); |
118 |
|
119 |
|
120 |
DataStoreTest.doFileResourceTest(parameters); |
121 |
} |
122 |
|
123 |
} |