Statistics
| Revision:

root / branches / v10 / extensions / extWFS2 / src-test / com / iver / cit / gvsig / wfs / WFSTest.java @ 8765

History | View | Annotate | Download (4.01 KB)

1
package com.iver.cit.gvsig.wfs;
2

    
3
import java.io.File;
4

    
5
import junit.framework.TestCase;
6

    
7
import org.gvsig.remoteClient.wfs.WFSClient;
8
import org.gvsig.remoteClient.wfs.WFSStatus;
9

    
10
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id: WFSTest.java 8765 2006-11-15 00:08:29Z jjdelcerro $
54
 * $Log$
55
 * Revision 1.1.2.2  2006-11-15 00:08:20  jjdelcerro
56
 * *** empty log message ***
57
 *
58
 * Revision 1.4  2006/10/10 12:55:06  jorpiell
59
 * Se ha a?adido el soporte de features complejas
60
 *
61
 * Revision 1.3  2006/10/02 09:09:45  jorpiell
62
 * Cambios del 10 copiados al head
63
 *
64
 * Revision 1.1.2.1  2006/09/19 12:27:08  jorpiell
65
 * Ya no se depende de geotools
66
 *
67
 * Revision 1.2  2006/09/18 12:07:31  jorpiell
68
 * Se ha sustituido geotools por el driver de remoteservices
69
 *
70
 * Revision 1.1  2006/06/14 07:56:36  jorpiell
71
 * Test de parseo de getfeature
72
 *
73
 *
74
 */
75
/**
76
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
77
 */
78
public class WFSTest extends TestCase {
79
        private String sUrl;
80
        private String feature;
81
        private String fields;
82
        private String fieldTypes;
83
        
84
        protected void setUp() throws Exception {
85
//                sUrl = "http://sercartlin:8080/geoserver/wfs?REQUEST=getCapabilities&SERVICE=WFS";
86
//                feature = "topp:states";
87
//                fields="tipo,municipio,the_geom";        
88
//                sUrl = "http://simon.coput.gva.es:2000/cgi-bin/mapserv483?map=/etc/mapserver/interno/wfs.map&REQUEST=getCapabilities&SERVICE=WFS";
89
//                feature = "cit:hidro_lin_300k";
90
//                fields="color,codigo";
91
                sUrl = "http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap";
92
                feature = "grid";
93
                fields = "msGeometry,F_CODE";
94
                fieldTypes = "gml:GeometryPropertyType,string";
95
                
96

    
97
        }        
98
        
99
        
100
        public void testWFS() throws Exception{
101
                WFSClient remoteServicesClient = new WFSClient(sUrl);
102
                File file = remoteServicesClient.getFeature(getStatus());
103
                System.out.println("Fin descarga");
104
//                WFSFeatureLayer fl = new WFSFeatureLayer(file,
105
//                                getNode(),
106
//                                getStatus());
107
//                IFeatureIterator iterator = fl.getIterator();                
108
//                System.out.println("Fin parseo");
109
//                int i=0;
110
//                while (iterator.hasNext()){
111
//                        IFeature feat = iterator.next();
112
////                        IGeometry geom = feat.getGeometry();
113
//                        i++;
114
//                }
115
//                System.out.println("Encontradas " + i + " Features");
116
        }
117
        
118
        private WFSStatus getStatus(){
119
                WFSStatus status = new WFSStatus(feature);
120
                status.setFields(fields.split(","));
121
                status.setUserName("");
122
                status.setPassword("");
123
                status.setTimeout(100000);
124
                status.setBuffer(1000);
125
                return status;
126
        }
127
        
128
        private WFSLayerNode[] getNode(){
129
                WFSLayerNode[] layers = new WFSLayerNode[1];
130
                layers[0] = new WFSLayerNode();
131
                layers[0].setName(feature);
132
                String[] vfields = fields.split(",");
133
                String[] vfieldTypes = fieldTypes.split(",");
134
//                for (int i=0 ; i<vfields.length ; i++){
135
//                        IXMLType attribute = new IXMLType();
136
//                        attribute.setName(vfields[i]);
137
//                        attribute.setType(vfieldTypes[i]);
138
//                        layers[0].getFields().add(attribute);
139
//                }
140
                return layers;
141
        }
142
}