root / trunk / libraries / libRemoteServices / test / org / gvsig / remoteClient / gml / GMLReaderTest.java @ 7716
History | View | Annotate | Download (4.46 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 7716 2006-10-02 08:34:22Z jorpiell $
|
61 |
* $Log$
|
62 |
* Revision 1.3 2006-10-02 08:33:49 jorpiell
|
63 |
* Cambios del 10 copiados al head
|
64 |
*
|
65 |
* Revision 1.1.2.2 2006/09/25 11:35:15 jorpiell
|
66 |
* Se tienen en cuanta tablas a distintos niveles. En caso de anidamiento se cogen los resultados de la primera tabla que aparezca.
|
67 |
*
|
68 |
* Revision 1.1.2.1 2006/09/19 12:23:15 jorpiell
|
69 |
* Ya no se depende de geotools
|
70 |
*
|
71 |
* Revision 1.2 2006/09/18 12:08:55 jorpiell
|
72 |
* Se han hecho algunas modificaciones que necesitaba el WFS
|
73 |
*
|
74 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell
|
75 |
* Primer commit del driver de Gml
|
76 |
*
|
77 |
*
|
78 |
*/
|
79 |
/**
|
80 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
81 |
*/
|
82 |
public class GMLReaderTest extends TestCase { |
83 |
private static String gmlFileWFS = "test/WFS-dmsolutionsGetFeature.xml"; |
84 |
private static String gmlFileWFSDuplicados = "test/WFS-AtlasAvesGetFeature.xml"; |
85 |
private static String gmlFileWFSSercartlin = "test/WFS-sercartlinGetFeature.xml"; |
86 |
private static String gmlFilePoints = "test/GML-points.gml"; |
87 |
private static String gmlFileLines = "test/GML-lines.gml"; |
88 |
private static String gmlFilePolygons = "test/GML-polygons.gml"; |
89 |
private IGeometriesFactory factory = new GeometriesFactory(); |
90 |
|
91 |
public void testWFS() throws Exception{ |
92 |
parseFile(gmlFileWFS); |
93 |
assertEquals(XMLSchemasFactory.getType("wfs").getLocation(),"http://schemas.opengeospatial.net/wfs/1.0.0/WFS-basic.xsd"); |
94 |
} |
95 |
|
96 |
public void testWFSSercartlin() throws Exception{ |
97 |
parseFile(gmlFileWFSSercartlin); |
98 |
} |
99 |
|
100 |
public void testWFSDuplicados() throws Exception{ |
101 |
parseFile(gmlFileWFSDuplicados); |
102 |
} |
103 |
|
104 |
public void testParsePoints() throws Exception{ |
105 |
parseFile(gmlFilePoints); |
106 |
} |
107 |
|
108 |
public void testParseLines() throws Exception{ |
109 |
parseFile(gmlFileLines); |
110 |
} |
111 |
|
112 |
public void testParsePolygons() throws Exception{ |
113 |
parseFile(gmlFilePolygons); |
114 |
} |
115 |
|
116 |
public void parseFile(String file) throws Exception{ |
117 |
GMLReader reader = new GMLReader(new File(file),factory); |
118 |
Rectangle2D extent = reader.getExtent();
|
119 |
|
120 |
IGMLFeaturesIterator iterator = reader.getFeaturesIterator(); |
121 |
|
122 |
XMLElementsFactory.printElements(); |
123 |
XMLTypesFactory.printTypes(); |
124 |
XMLSchemasFactory.printSchemas(); |
125 |
|
126 |
int i=0; |
127 |
while (iterator.hasNext()){
|
128 |
System.out.println("********* FEATURE NUMBER " + i + " ***********+"); |
129 |
if (i == 33){ |
130 |
System.out.println("jm"); |
131 |
} |
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 |
System.out.println(params.get(j) + ": " + values.get(j)); |
138 |
} |
139 |
i++; |
140 |
} |
141 |
System.out.println("NUM FEATURES: " + i); |
142 |
} |
143 |
} |