Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap / src-test / org / gvsig / fmap / drivers / iterators / DBFeatureIteratorTest.java @ 20984

History | View | Annotate | Download (2.85 KB)

1
/*
2
 * Created on 28-may-2007
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: DBFeatureIteratorTest.java 20984 2008-05-28 10:58:22Z jmvivo $
47
* $Log$
48
* Revision 1.2  2007-09-20 08:08:29  jaume
49
* ReadExpansionFileException removed from this context
50
*
51
* Revision 1.1  2007/05/29 19:11:03  azabala
52
* *** empty log message ***
53
*
54
*
55
*/
56
package org.gvsig.fmap.drivers.iterators;
57

    
58
import java.awt.geom.Rectangle2D;
59

    
60
import org.gvsig.fmap.drivers.reading.IFeatureIterator;
61
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
62
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
63

    
64
import junit.framework.TestCase;
65

    
66
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
67

    
68
public class DBFeatureIteratorTest extends TestCase {
69

    
70
//        test with mysql jdbc driver
71
        public void test2(){
72
                try {
73
                        FLyrVect layer = FeatureIteratorTest.newJdbcLayer("muni");
74
                        IFeatureIterator iterator = layer.getSource().getFeatureIterator();
75
                        int numFeatures = 0;
76
                        while(iterator.hasNext()){
77
                                iterator.next();
78
                                numFeatures++;
79
                        }
80
                        assert(layer.getSource().getShapeCount() == numFeatures);
81
                        double xmin = 260000d;
82
                        double xmax = 340000d;
83
                        double ymin = 4098300d;
84
                        double ymax = 4180500d;
85
                        Rectangle2D rect = new Rectangle2D.Double(xmin, ymin,
86
                                        (xmax-xmin), (ymax-ymin));
87
                        iterator = layer.getSource().getFeatureIterator(rect, null, FeatureIteratorTest.newProjection, true);
88
                        numFeatures = 0;
89
                        while(iterator.hasNext()){
90
                                iterator.next();
91
                                numFeatures++;
92
                        }
93
                        assert(layer.getSource().getShapeCount() > numFeatures);
94

    
95

    
96
                } catch (LoadLayerException e) {
97
                        e.printStackTrace();
98
                } catch (ReadDriverException e) {
99
                        e.printStackTrace();
100
                } catch(Exception e){
101
                        //Si se trata de ejecutar el test sin tener MySQL
102
                        e.printStackTrace();
103
                }
104

    
105
        }
106

    
107
}
108