Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dataFile / src-test / org / gvsig / fmap / data / store / shp / TestSHP.java @ 24452

History | View | Annotate | Download (3.46 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.shp;
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 TestSHP extends TestCase {
47

    
48
        public static final File file_prueba = new File(TestSHP.class.getResource(
49
                        "data/prueba.shp").getFile());
50
        public static final File file_pruebaNull = new File(TestSHP.class
51
                        .getResource("data/pruebaNull.shp").getFile());
52

    
53
        public static final File file_poly_valencia = new File(TestSHP.class
54
                        .getResource("data/poly-valencia.shp").getFile());
55

    
56
        private static DataManager dataManager = null;
57

    
58

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

    
65
                DALFileLibrary libFile = new DALFileLibrary();
66
                libFile.initialize();
67
                libFile.postInitialize();
68

    
69
                SHPLibrary shpLib = new SHPLibrary();
70
                shpLib.initialize();
71
                shpLib.postInitialize();
72

    
73
                dataManager = DALLocator.getDataManager();
74
        }
75

    
76
        public void testSimpleIteration() {
77
                FeatureStore store = null;
78
                SHPStoreParameters shpParameters = null;
79

    
80
                try {
81
                        shpParameters = (SHPStoreParameters) dataManager
82
                                        .createStoreParameters(SHPStoreProvider.NAME);
83

    
84
                        shpParameters.setFile(file_poly_valencia);
85

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

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

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

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

    
111

    
112
                        }
113

    
114
                        set.dispose();
115

    
116

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

    
123

    
124
        }
125

    
126
}