Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dalfile / src-test / org / gvsig / fmap / dal / store / dxf / TestDXF.java @ 24498

History | View | Annotate | Download (3.42 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.dal.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.dal.DALFileLibrary;
36
import org.gvsig.fmap.dal.DALLibrary;
37
import org.gvsig.fmap.dal.DALLocator;
38
import org.gvsig.fmap.dal.DataManager;
39
import org.gvsig.fmap.dal.exceptions.DataException;
40
import org.gvsig.fmap.dal.feature.Feature;
41
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
42
import org.gvsig.fmap.dal.feature.FeatureSet;
43
import org.gvsig.fmap.dal.feature.FeatureStore;
44
import org.gvsig.fmap.dal.feature.FeatureType;
45
import org.gvsig.fmap.dal.store.dxf.DXFLibrary;
46
import org.gvsig.fmap.dal.store.dxf.DXFStoreParameters;
47
import org.gvsig.fmap.dal.store.dxf.DXFStoreProvider;
48

    
49
public class TestDXF extends TestCase {
50

    
51
        public static final File file_prueba = new File(TestDXF.class.getResource(
52
                        "data/prueba.dxf").getFile());
53

    
54
        private static DataManager dataManager = null;
55

    
56

    
57
        protected void setUp() throws Exception {
58
                super.setUp();
59
                DALLibrary lib = new DALLibrary();
60
                lib.initialize();
61
                lib.postInitialize();
62

    
63
                DALFileLibrary libFile = new DALFileLibrary();
64
                libFile.initialize();
65
                libFile.postInitialize();
66

    
67
                DXFLibrary dxfLib = new DXFLibrary();
68
                dxfLib.initialize();
69
                dxfLib.postInitialize();
70

    
71
                dataManager = DALLocator.getDataManager();
72
        }
73

    
74
        public void testSimpleIteration() {
75
                FeatureStore store = null;
76
                DXFStoreParameters dxfParameters = null;
77

    
78
                try {
79
                        dxfParameters = (DXFStoreParameters) dataManager
80
                                        .createStoreParameters(DXFStoreProvider.NAME);
81

    
82
                        dxfParameters.setFileName(file_prueba.getAbsolutePath());
83
                        dxfParameters.setSRSID("EPSG:23030");
84

    
85
                        store = (FeatureStore) dataManager.createStore(dxfParameters);
86
                        FeatureSet set;
87
                        FeatureType type = store.getDefaultFeatureType();
88
                        set = store.getFeatureSet();
89

    
90
                        Iterator it = set.iterator();
91
                        Iterator ftIt;
92
                        FeatureAttributeDescriptor desc;
93

    
94
                        Feature feature;
95
                        while (it.hasNext()) {
96
                                ftIt = type.iterator();
97

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

    
110

    
111
                        }
112

    
113
                        set.dispose();
114

    
115

    
116
                } catch (DataException e3) {
117
                        e3.printStackTrace();
118
                        fail();
119
                        return;
120
                }
121

    
122

    
123
        }
124

    
125
}