Statistics
| Revision:

root / branches / v10 / extensions / extPublish / src-test / com / iver / cit / gvsig / publish / infoProject / Test_queryLayer.java @ 13570

History | View | Annotate | Download (4.64 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *   Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Iba?ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *   +34 963862235
28
 *   gvsig@gva.es
29
 *   www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.publish.infoProject;
42

    
43
import java.io.File;
44
import java.net.URL;
45

    
46
import com.iver.cit.gvsig.fmap.layers.FLayer;
47
import com.iver.cit.gvsig.project.documents.view.ProjectView;
48
import com.iver.cit.gvsig.publish.infoProject.ILayerInfo;
49
import com.iver.cit.gvsig.publish.infoProject.IViewInfo;
50
import com.iver.cit.gvsig.publish.infoProject.InfoFactory;
51
import com.iver.cit.gvsig.publish.util.LocalResourcesTestUtilities;
52

    
53
import junit.framework.TestCase;
54

    
55
public class Test_queryLayer extends TestCase {
56
        //gvSIG ProjectView
57
        private ProjectView gvView = null;
58
        //information about the view to publish
59
        private IViewInfo viewInfo = null;
60
        //get Resources from gvSIG like layers, views, ...
61
        private LocalResourcesTestUtilities util = null;
62
        
63
        protected void setUp() throws Exception {
64
                super.setUp();
65
                File f = null;        
66
                //gets absolute path
67
                URL url = this.getClass().getResource("../resources");
68
                if (url == null) 
69
                        throw new Exception("Can't find resources directory");                
70
                f = new File(url.getFile());
71
                if (!f.exists()) 
72
                        throw new Exception("Can't find resources dir");
73
                
74
                //gets a new view from the utilities
75
                util = new LocalResourcesTestUtilities(f.getAbsolutePath());
76
                
77
                //creates a database 
78
                //util.createDBPostGIS();
79
        }
80

    
81
        protected void tearDown() throws Exception {
82
                super.tearDown();
83
                //util.dropDBPostGIS();
84
        }
85
        
86
        /**
87
         * test simple layer
88
         */
89
        public void test_simpleLayer(){                
90
                //gvView = util.getBasicView();
91
                gvView = util.getBasic2layersView();
92
                viewInfo = InfoFactory.getViewInfo(gvView);
93
                //System.err.println("View name: " + viewInfo.getName());
94
                //query all layers
95
                for (int i = 0; i < this.viewInfo.getLayers().length; i++){                        
96
                        System.err.println("Layer " + i + " --------------");
97
                        printLayerInfo(this.viewInfo.getLayers()[i]);                                        
98
                }                
99
        }
100
        /**
101
         * 
102
         */
103
        public void test_groupedLayer(){
104
                //gvView = util.getBasicView();
105
                gvView = util.getGroupView();
106
                viewInfo = InfoFactory.getViewInfo(gvView);
107
                System.err.println("=====================================");
108
                for (int i = 0; i < this.viewInfo.getLayers().length; i++){
109
                        System.err.println("Layer " + i + " --------------");
110
                        printLayerInfo(this.viewInfo.getLayers()[i]);
111
                }                
112
        }
113
        private void printLayerInfo(ILayerInfo l){
114
                System.err.println("Name: " + l.getName());
115
                System.err.println("Title: " + l.getTitle());
116
                System.err.println("MaxScale: " + l.getMaxscale());
117
                System.err.println("MinScale: " + l.getMinscale());
118
                System.err.println("MaxX: " + l.getMaxX());
119
                System.err.println("MaxY: " + l.getMaxY());
120
                System.err.println("MinX: " + l.getMinX());
121
                if (l.getLayers() == null){
122
                        System.err.println("Grouped?: falso");                                        
123
                }else{
124
                        System.err.println("Grouped?: verdadero");
125
                        ILayerInfo[] group = l.getLayers();
126
                        for(int i= 0; i < group.length; i++ ){
127
                                printLayerInfo(group[i]);
128
                        }
129
                }
130
                
131
                
132
        }
133
        /**
134
         * test getDataSource
135
         *
136
        public void test_getDataSource(){
137
                //ECW
138
                FLayer lyr = util.getLayerECW();
139
                DefaultLayerInfo lyrInf= new DefaultLayerInfo(lyr);
140
                lyrInf.getDataSource();
141
                //PostGIS
142
                lyr = util.getLayerPostGIS();
143
                lyrInf = new DefaultLayerInfo(lyr);
144
                lyrInf.getDataSource();                                
145
        }*/
146
        
147
        /**
148
         * test getDataSource: nested layers
149
         *
150
        public void test_getDataSource2(){
151
                this.gvView = util.getGroupView();
152
                //creates a instance to get view information
153
                this.viewInfo = InfoFactory.getViewInfo(gvView);
154
                //query all layers
155
                for (int i = 0; i < this.viewInfo.getLayers().length; i++){
156
                        this.viewInfo.getLayers()[i].getDataSource();
157
                }
158
        }*/
159

    
160
}