Statistics
| Revision:

root / trunk / extensions / extWFS2 / src-test / com / iver / cit / gvsig / wfs / WFSTest.java @ 7721

History | View | Annotate | Download (3.97 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.WFSAttribute;
8
import org.gvsig.remoteClient.wfs.WFSClient;
9
import org.gvsig.remoteClient.wfs.WFSStatus;
10

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

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