root / trunk / libraries / libRemoteServices / test / org / gvsig / remoteClient / gml / GMLReaderTest.java @ 8017
History | View | Annotate | Download (5.27 KB)
1 |
package org.gvsig.remoteClient.gml; |
---|---|
2 |
|
3 |
import java.awt.geom.Rectangle2D; |
4 |
import java.io.File; |
5 |
import java.io.IOException; |
6 |
import java.util.ArrayList; |
7 |
import java.util.Hashtable; |
8 |
|
9 |
import org.gvsig.remoteClient.gml.factories.GeometriesFactory; |
10 |
import org.gvsig.remoteClient.gml.factories.IGeometriesFactory; |
11 |
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory; |
12 |
import org.gvsig.remoteClient.gml.factories.XMLSchemasFactory; |
13 |
import org.gvsig.remoteClient.gml.factories.XMLTypesFactory; |
14 |
import org.gvsig.remoteClient.gml.v2.GMLSimpleFeature_v2; |
15 |
import org.xmlpull.v1.XmlPullParserException; |
16 |
|
17 |
import junit.framework.TestCase; |
18 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
19 |
*
|
20 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
21 |
*
|
22 |
* This program is free software; you can redistribute it and/or
|
23 |
* modify it under the terms of the GNU General Public License
|
24 |
* as published by the Free Software Foundation; either version 2
|
25 |
* of the License, or (at your option) any later version.
|
26 |
*
|
27 |
* This program is distributed in the hope that it will be useful,
|
28 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
29 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
30 |
* GNU General Public License for more details.
|
31 |
*
|
32 |
* You should have received a copy of the GNU General Public License
|
33 |
* along with this program; if not, write to the Free Software
|
34 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
35 |
*
|
36 |
* For more information, contact:
|
37 |
*
|
38 |
* Generalitat Valenciana
|
39 |
* Conselleria d'Infraestructures i Transport
|
40 |
* Av. Blasco Ib??ez, 50
|
41 |
* 46010 VALENCIA
|
42 |
* SPAIN
|
43 |
*
|
44 |
* +34 963862235
|
45 |
* gvsig@gva.es
|
46 |
* www.gvsig.gva.es
|
47 |
*
|
48 |
* or
|
49 |
*
|
50 |
* IVER T.I. S.A
|
51 |
* Salamanca 50
|
52 |
* 46005 Valencia
|
53 |
* Spain
|
54 |
*
|
55 |
* +34 963163400
|
56 |
* dac@iver.es
|
57 |
*/
|
58 |
/* CVS MESSAGES:
|
59 |
*
|
60 |
* $Id: GMLReaderTest.java 8017 2006-10-10 12:52:28Z jorpiell $
|
61 |
* $Log$
|
62 |
* Revision 1.4 2006-10-10 12:52:28 jorpiell
|
63 |
* Soporte para features complejas.
|
64 |
*
|
65 |
* Revision 1.3 2006/10/02 08:33:49 jorpiell
|
66 |
* Cambios del 10 copiados al head
|
67 |
*
|
68 |
* Revision 1.1.2.2 2006/09/25 11:35:15 jorpiell
|
69 |
* Se tienen en cuanta tablas a distintos niveles. En caso de anidamiento se cogen los resultados de la primera tabla que aparezca.
|
70 |
*
|
71 |
* Revision 1.1.2.1 2006/09/19 12:23:15 jorpiell
|
72 |
* Ya no se depende de geotools
|
73 |
*
|
74 |
* Revision 1.2 2006/09/18 12:08:55 jorpiell
|
75 |
* Se han hecho algunas modificaciones que necesitaba el WFS
|
76 |
*
|
77 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell
|
78 |
* Primer commit del driver de Gml
|
79 |
*
|
80 |
*
|
81 |
*/
|
82 |
/**
|
83 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
84 |
*/
|
85 |
public class GMLReaderTest extends TestCase { |
86 |
private static String gmlFileWFS = "test/WFS-dmsolutionsGetFeature.xml"; |
87 |
private static String gmlFileWFSDuplicados = "test/WFS-AtlasAvesGetFeature.xml"; |
88 |
private static String gmlFileWFSSercartlin = "test/WFS-sercartlinGetFeature.xml"; |
89 |
private static String gmlFilePoints = "test/GML-points.gml"; |
90 |
private static String gmlFileLines = "test/GML-lines.gml"; |
91 |
private static String gmlFilePolygons = "test/GML-polygons.gml"; |
92 |
private IGeometriesFactory factory = new GeometriesFactory(); |
93 |
|
94 |
// public void testWFS() throws Exception{
|
95 |
// parseFile(gmlFileWFS);
|
96 |
// assertEquals(XMLSchemasFactory.getType("wfs").getLocation(),"http://schemas.opengeospatial.net/wfs/1.0.0/WFS-basic.xsd");
|
97 |
// }
|
98 |
//
|
99 |
// public void testWFSSercartlin() throws Exception{
|
100 |
// parseFile(gmlFileWFSSercartlin);
|
101 |
// }
|
102 |
|
103 |
public void testWFSDuplicados() throws Exception{ |
104 |
parseFile(gmlFileWFSDuplicados); |
105 |
} |
106 |
|
107 |
// public void testParsePoints() throws Exception{
|
108 |
// parseFile(gmlFilePoints);
|
109 |
// }
|
110 |
//
|
111 |
// public void testParseLines() throws Exception{
|
112 |
// parseFile(gmlFileLines);
|
113 |
// }
|
114 |
//
|
115 |
// public void testParsePolygons() throws Exception{
|
116 |
// parseFile(gmlFilePolygons);
|
117 |
// }
|
118 |
|
119 |
public void parseFile(String file) throws Exception{ |
120 |
GMLReader reader = new GMLReader(new File(file),factory); |
121 |
Rectangle2D extent = reader.getExtent();
|
122 |
|
123 |
IGMLFeaturesIterator iterator = reader.getFeaturesIterator(); |
124 |
|
125 |
XMLElementsFactory.printEntities(); |
126 |
XMLTypesFactory.printTypes(); |
127 |
XMLSchemasFactory.printSchemas(); |
128 |
|
129 |
// int i=0;
|
130 |
// while (iterator.hasNext()){
|
131 |
// System.out.println("********* FEATURE NUMBER " + i + " ***********+");
|
132 |
// GMLSimpleFeature_v2 feature = (GMLSimpleFeature_v2) iterator.next();
|
133 |
// ArrayList params = feature.getParams();
|
134 |
// ArrayList values = feature.getValues();
|
135 |
// System.out.println("GEOMETRY: " + feature.getGeom());
|
136 |
// for (int j=0 ; j<params.size() ; j++){
|
137 |
// if (params.get(j) instanceof ArrayList){
|
138 |
// printComplexType((ArrayList)params.get(j),(ArrayList)values.get(j),1);
|
139 |
// }else{
|
140 |
// System.out.println(params.get(j) + ": ");
|
141 |
// if (values.get(j) != null){
|
142 |
// System.out.println(values.get(j));
|
143 |
// }
|
144 |
// }
|
145 |
// }
|
146 |
// i++;
|
147 |
// }
|
148 |
// System.out.println("NUM FEATURES: " + i);
|
149 |
} |
150 |
|
151 |
private void printComplexType(ArrayList params,ArrayList values,int level){ |
152 |
String tab = ""; |
153 |
for (int i=0 ; i<level ; i++){ |
154 |
tab = tab + "\t";
|
155 |
} |
156 |
level++; |
157 |
for (int j=0 ; j<params.size() ; j++){ |
158 |
if (params.get(j) instanceof ArrayList){ |
159 |
printComplexType((ArrayList)params.get(j),(ArrayList)values.get(j),level); |
160 |
}else{
|
161 |
System.out.print(tab + params.get(j) + ": "); |
162 |
if (values.get(j) != null){ |
163 |
System.out.print(values.get(j) + "\n"); |
164 |
}else{
|
165 |
System.out.print("\n"); |
166 |
} |
167 |
} |
168 |
} |
169 |
} |
170 |
} |