Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dataFile / src-test / org / gvsig / fmap / data / store / dxf / TestDXF.java @ 24456

History | View | Annotate | Download (3.27 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

    
28
package org.gvsig.fmap.data.store.dxf;
29

    
30
import java.io.File;
31
import java.util.Iterator;
32

    
33
import junit.framework.TestCase;
34

    
35
import org.gvsig.fmap.data.DALFileLibrary;
36
import org.gvsig.fmap.data.DALLibrary;
37
import org.gvsig.fmap.data.DALLocator;
38
import org.gvsig.fmap.data.DataManager;
39
import org.gvsig.fmap.data.exceptions.DataException;
40
import org.gvsig.fmap.data.feature.Feature;
41
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
42
import org.gvsig.fmap.data.feature.FeatureSet;
43
import org.gvsig.fmap.data.feature.FeatureStore;
44
import org.gvsig.fmap.data.feature.FeatureType;
45

    
46
public class TestDXF extends TestCase {
47

    
48
        public static final File file_prueba = new File(TestDXF.class.getResource(
49
                        "data/prueba.dxf").getFile());
50

    
51
        private static DataManager dataManager = null;
52

    
53

    
54
        protected void setUp() throws Exception {
55
                super.setUp();
56
                DALLibrary lib = new DALLibrary();
57
                lib.initialize();
58
                lib.postInitialize();
59

    
60
                DALFileLibrary libFile = new DALFileLibrary();
61
                libFile.initialize();
62
                libFile.postInitialize();
63

    
64
                DXFLibrary dxfLib = new DXFLibrary();
65
                dxfLib.initialize();
66
                dxfLib.postInitialize();
67

    
68
                dataManager = DALLocator.getDataManager();
69
        }
70

    
71
        public void testSimpleIteration() {
72
                FeatureStore store = null;
73
                DXFStoreParameters dxfParameters = null;
74

    
75
                try {
76
                        dxfParameters = (DXFStoreParameters) dataManager
77
                                        .createStoreParameters(DXFStoreProvider.NAME);
78

    
79
                        dxfParameters.setFileName(file_prueba.getAbsolutePath());
80
                        dxfParameters.setSRSID("EPSG:23030");
81

    
82
                        store = (FeatureStore) dataManager.createStore(dxfParameters);
83
                        FeatureSet set;
84
                        FeatureType type = store.getDefaultFeatureType();
85
                        set = store.getFeatureSet();
86

    
87
                        Iterator it = set.iterator();
88
                        Iterator ftIt;
89
                        FeatureAttributeDescriptor desc;
90

    
91
                        Feature feature;
92
                        while (it.hasNext()) {
93
                                ftIt = type.iterator();
94

    
95
                                feature = (Feature) it.next();
96
                                //                                while (ftIt.hasNext()) {
97
                                //                                        desc = (FeatureAttributeDescriptor) ftIt.next();
98
                                //                                        System.out.println(desc.getName() + ":"
99
                                //                                                        + feature.get(desc.getIndex()));
100
                                //
101
                                //                                }
102
                                //                                System.out.println(feature.get("NOMBRE"));
103
                                                                feature.getDefaultEnvelope();
104
                                //                                                                feature.getDefaultGeometry();
105
                                //                                                                feature.get("NOMBRE");
106

    
107

    
108
                        }
109

    
110
                        set.dispose();
111

    
112

    
113
                } catch (DataException e3) {
114
                        e3.printStackTrace();
115
                        fail();
116
                        return;
117
                }
118

    
119

    
120
        }
121

    
122
}