svn-gvsig-desktop / trunk / libraries / libDataSourceBaseDrivers / src-test / org / gvsig / data / datastores / vectorial / file / dxf / DXFTest.java @ 20421
History | View | Annotate | Download (4.14 KB)
1 | 19844 | vcaballero | package org.gvsig.data.datastores.vectorial.file.dxf; |
---|---|---|---|
2 | 19603 | vcaballero | |
3 | import java.io.File; |
||
4 | import java.util.Iterator; |
||
5 | |||
6 | import junit.framework.TestCase; |
||
7 | |||
8 | import org.cresques.cts.IProjection; |
||
9 | 19976 | jmvivo | import org.gvsig.data.DataManager; |
10 | 19844 | vcaballero | import org.gvsig.data.datastores.vectorial.file.DataStoreTest; |
11 | import org.gvsig.data.datastores.vectorial.file.dxf.DXFStore; |
||
12 | import org.gvsig.data.datastores.vectorial.file.dxf.DXFStoreParameters; |
||
13 | import org.gvsig.data.datastores.vectorial.file.dxf.Register; |
||
14 | 19736 | vcaballero | import org.gvsig.data.exception.CloseException; |
15 | 19603 | vcaballero | import org.gvsig.data.exception.InitializeException; |
16 | 19736 | vcaballero | import org.gvsig.data.exception.OpenException; |
17 | 19658 | vcaballero | import org.gvsig.data.exception.ReadException; |
18 | 19603 | vcaballero | import org.gvsig.data.vectorial.IFeature; |
19 | import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
||
20 | import org.gvsig.data.vectorial.IFeatureCollection; |
||
21 | import org.gvsig.data.vectorial.IFeatureType; |
||
22 | 20414 | vcaballero | import org.gvsig.data.vectorial.IsNotFeatureSettingException; |
23 | 19603 | vcaballero | import org.gvsig.data.vectorial.expansionadapter.FeatureManager; |
24 | import org.gvsig.data.vectorial.expansionadapter.MemoryExpansionAdapter; |
||
25 | |||
26 | import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
||
27 | |||
28 | public class DXFTest extends TestCase { |
||
29 | private File file = new File(DataStoreTest.class.getResource("data/prueba.dxf").getFile()); |
||
30 | |||
31 | |||
32 | public static void main(String[] args) { |
||
33 | } |
||
34 | |||
35 | protected void setUp() throws Exception { |
||
36 | super.setUp();
|
||
37 | } |
||
38 | |||
39 | public void testInitialize() { |
||
40 | Register.selfRegister(); |
||
41 | 19976 | jmvivo | DataManager manager = DataManager.getManager(); |
42 | DXFStore store =null;
|
||
43 | |||
44 | DXFStoreParameters dxfParameters=null;
|
||
45 | dxfParameters=(DXFStoreParameters)manager.createDataStoreParameters(DXFStore.DATASTORE_NAME); |
||
46 | 19603 | vcaballero | dxfParameters.setDXFFile(file); |
47 | IProjection proj = CRSFactory.getCRS("EPSG:23030");
|
||
48 | dxfParameters.setProjection(proj); |
||
49 | try {
|
||
50 | 19976 | jmvivo | store=(DXFStore)manager.createDataStore(dxfParameters); |
51 | 19603 | vcaballero | } catch (InitializeException e) {
|
52 | // TODO Auto-generated catch block
|
||
53 | e.printStackTrace(); |
||
54 | } |
||
55 | 19736 | vcaballero | try {
|
56 | store.open(); |
||
57 | } catch (OpenException e1) {
|
||
58 | // TODO Auto-generated catch block
|
||
59 | e1.printStackTrace(); |
||
60 | } |
||
61 | 19603 | vcaballero | |
62 | 19736 | vcaballero | IFeatureType ft=store.getDefaultFeatureType(); |
63 | 19658 | vcaballero | IFeatureCollection featureCollection=null;
|
64 | try {
|
||
65 | 19736 | vcaballero | featureCollection = (IFeatureCollection)store.getDataCollection(ft,null,null); |
66 | |||
67 | 19658 | vcaballero | } catch (ReadException e) {
|
68 | // TODO Auto-generated catch block
|
||
69 | e.printStackTrace(); |
||
70 | } |
||
71 | 19603 | vcaballero | Iterator iter = featureCollection.iterator();
|
72 | while (iter.hasNext()) {
|
||
73 | IFeature feature = (IFeature)iter.next(); |
||
74 | 19654 | vcaballero | System.out.println("DXF Feature ------------------- "); |
75 | 20414 | vcaballero | Iterator iterator=ft.iterator();
|
76 | while (iterator.hasNext()) {
|
||
77 | IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next(); |
||
78 | int i=descriptor.ordinal();
|
||
79 | 19603 | vcaballero | String type=descriptor.getDataType();
|
80 | if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){
|
||
81 | System.out.println("Boolean ----- "+ feature.getBoolean(i)); |
||
82 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){ |
||
83 | System.out.println("Byte ----- "+ feature.getByte(i)); |
||
84 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_DATE)){ |
||
85 | System.out.println("Date ----- "+ feature.getDate(i)); |
||
86 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){ |
||
87 | System.out.println("Double ----- "+ feature.getDouble(i)); |
||
88 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){ |
||
89 | System.out.println("Float ----- "+ feature.getFloat(i)); |
||
90 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_INT)){ |
||
91 | System.out.println("Integer ----- "+ feature.getInt(i)); |
||
92 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_LONG)){ |
||
93 | System.out.println("Long ----- "+ feature.getLong(i)); |
||
94 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_STRING)){ |
||
95 | System.out.println("String ----- "+ feature.getString(i)); |
||
96 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){ |
||
97 | |||
98 | System.out.println("Geometry ----- "+ feature.getGeometry(i)); |
||
99 | } |
||
100 | } |
||
101 | } |
||
102 | 19976 | jmvivo | iter = null;
|
103 | featureCollection.dispose(); |
||
104 | 19603 | vcaballero | |
105 | 19736 | vcaballero | try {
|
106 | store.close(); |
||
107 | |||
108 | store.dispose(); |
||
109 | } catch (CloseException e) {
|
||
110 | // TODO Auto-generated catch block
|
||
111 | e.printStackTrace(); |
||
112 | } |
||
113 | 19603 | vcaballero | } |
114 | } |