Revision 4967
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.29/org.gvsig.raster.wms.remoteclient/src/test/java/org/gvsig/remoteclient/wms/wms_1_1_1/WMSProtocolHandler_1_1_1Test.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.wms.wms_1_1_1; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
|
|
28 |
import junit.framework.TestCase; |
|
29 |
|
|
30 |
/** |
|
31 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
32 |
*/ |
|
33 |
public class WMSProtocolHandler_1_1_1Test extends TestCase { |
|
34 |
WMSProtocolHandler1_1_1 handler1, handler2, handler3, handler4; |
|
35 |
|
|
36 |
public void setUp() { |
|
37 |
System.out.println("Setting up test.."); |
|
38 |
handler1 = new WMSProtocolHandler1_1_1(); |
|
39 |
} |
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
public void testParsing() { |
|
44 |
long t1 = System.currentTimeMillis(); |
|
45 |
handler1.parseCapabilities(new File("testdata/wms/wms.xml")); |
|
46 |
long t2 = System.currentTimeMillis(); |
|
47 |
System.out.println("Test parsing done with apparently no errors in "+ (t2-(float)t1)/1000+" seconds"); |
|
48 |
} |
|
49 |
} |
|
50 |
|
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.29/org.gvsig.raster.wms.remoteclient/src/test/java/org/gvsig/remoteclient/wms/WMSStatusTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.wms; |
|
25 |
|
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
import java.util.Vector; |
|
28 |
|
|
29 |
import junit.framework.TestCase; |
|
30 |
/** |
|
31 |
* |
|
32 |
* @author jaume |
|
33 |
* |
|
34 |
*/ |
|
35 |
public class WMSStatusTest extends TestCase { |
|
36 |
WMSStatus st1, st2, st3, st4; |
|
37 |
protected void setUp() { |
|
38 |
st1 = new WMSStatus(); |
|
39 |
// Layer names |
|
40 |
Vector v1 = new Vector(); |
|
41 |
v1.add("a"); |
|
42 |
v1.add("b"); |
|
43 |
v1.add("c"); |
|
44 |
st1.setLayerNames(v1); |
|
45 |
v1.clear(); |
|
46 |
// Styles |
|
47 |
v1.add("s1"); |
|
48 |
v1.add("s2"); |
|
49 |
v1.add("s3"); |
|
50 |
st1.setStyles(v1); |
|
51 |
// Transparency |
|
52 |
st1.setTransparency(false); |
|
53 |
v1.clear(); |
|
54 |
v1.add("TIME=february"); |
|
55 |
v1.add("WAVELENGTH=200nm"); |
|
56 |
st1.setDimensions(v1); |
|
57 |
// Extent |
|
58 |
Rectangle2D rect1 = new Rectangle2D.Double(1.0, 1.00000001, 5.000000, 6.8); |
|
59 |
st1.setExtent(rect1); |
|
60 |
// Exception format |
|
61 |
st1.setExceptionFormat("bla"); |
|
62 |
// SRS |
|
63 |
st1.setSrs("bla bla"); |
|
64 |
// Format |
|
65 |
st1.setFormat("image/mpeg"); |
|
66 |
// Width |
|
67 |
st1.setWidth(800); |
|
68 |
// Height |
|
69 |
st1.setHeight(600); |
|
70 |
// Online resource |
|
71 |
st1.setOnlineResource("alkjf"); |
|
72 |
|
|
73 |
st2 = new WMSStatus(); |
|
74 |
// Layer names |
|
75 |
Vector v2 = new Vector(); |
|
76 |
v2.add("a"); |
|
77 |
v2.add("b"); |
|
78 |
v2.add("c"); |
|
79 |
st2.setLayerNames(v2); |
|
80 |
v2.clear(); |
|
81 |
// Styles |
|
82 |
v2.add("s1"); |
|
83 |
v2.add("s2"); |
|
84 |
v2.add("s3"); |
|
85 |
st2.setStyles(v2); |
|
86 |
// Transparency |
|
87 |
st2.setTransparency(false); |
|
88 |
v2.clear(); |
|
89 |
// Dimensions |
|
90 |
v2.add("TIME=february"); |
|
91 |
v2.add("WAVELENGTH=200nm"); |
|
92 |
st2.setDimensions(v2); |
|
93 |
// Extent |
|
94 |
Rectangle2D rect2 = new Rectangle2D.Double(1.0, 1.00000001, 5.000000, 6.8); |
|
95 |
st2.setExtent(rect2); |
|
96 |
// Exception format |
|
97 |
st2.setExceptionFormat("bla"); |
|
98 |
// SRS |
|
99 |
st2.setSrs("bla bla"); |
|
100 |
// Format |
|
101 |
st2.setFormat("image/mpeg"); |
|
102 |
// Width |
|
103 |
st2.setWidth(800); |
|
104 |
// Height |
|
105 |
st2.setHeight(600); |
|
106 |
// Online resource |
|
107 |
st2.setOnlineResource("alkjf"); |
|
108 |
|
|
109 |
st3 = new WMSStatus(); |
|
110 |
// Layer names |
|
111 |
Vector v3 = new Vector(); |
|
112 |
v3.add("a"); |
|
113 |
v3.add("b"); |
|
114 |
v3.add("c"); |
|
115 |
st3.setLayerNames(v3); |
|
116 |
v3.clear(); |
|
117 |
// Styles |
|
118 |
v3.add("s1"); |
|
119 |
v3.add("s2"); |
|
120 |
v3.add("s3"); |
|
121 |
st3.setStyles(v3); |
|
122 |
// Transparency |
|
123 |
st3.setTransparency(false); |
|
124 |
v3.clear(); |
|
125 |
// Dimensions |
|
126 |
v3.add("TIME=february"); |
|
127 |
v3.add("WAVELENGTH=200nm"); |
|
128 |
st3.setDimensions(v3); |
|
129 |
// Extent |
|
130 |
Rectangle2D rect3 = new Rectangle2D.Double(2.0, 1.00000001, 5.000000, 6.8); |
|
131 |
st3.setExtent(rect3); |
|
132 |
// Exception format |
|
133 |
st3.setExceptionFormat("bla"); |
|
134 |
// SRS |
|
135 |
st3.setSrs("bla bla"); |
|
136 |
// Format |
|
137 |
st3.setFormat("image/mpeg"); |
|
138 |
// Width |
|
139 |
st3.setWidth(800); |
|
140 |
// Height |
|
141 |
st3.setHeight(600); |
|
142 |
// Online resource |
|
143 |
st3.setOnlineResource("alkjf"); |
|
144 |
|
|
145 |
st4 = new WMSStatus(); |
|
146 |
// Layer names |
|
147 |
Vector v4 = new Vector(); |
|
148 |
v4.add("a"); |
|
149 |
v4.add("b"); |
|
150 |
v4.add("c"); |
|
151 |
st4.setLayerNames(v4); |
|
152 |
v4.clear(); |
|
153 |
// Styles |
|
154 |
v4.add("s1"); |
|
155 |
v4.add("s2"); |
|
156 |
v4.add("s3"); |
|
157 |
st4.setStyles(v4); |
|
158 |
// Transparency |
|
159 |
st4.setTransparency(false); |
|
160 |
v4.clear(); |
|
161 |
// Dimensions |
|
162 |
v4.add("TIME=february"); |
|
163 |
v4.add("WAVELENGTH=200nm"); |
|
164 |
st4.setDimensions(v4); |
|
165 |
// Extent |
|
166 |
Rectangle2D rect4 = new Rectangle2D.Double(2.0, 1.00000001, 5.000000, 6.8); |
|
167 |
st4.setExtent(rect3); |
|
168 |
// Exception format |
|
169 |
st4.setExceptionFormat("bla"); |
|
170 |
// SRS |
|
171 |
st4.setSrs("bla bla"); |
|
172 |
// Format |
|
173 |
st4.setFormat("image/mpeg"); |
|
174 |
// Width |
|
175 |
st4.setWidth(800); |
|
176 |
// Height |
|
177 |
st4.setHeight(600); |
|
178 |
// Online resource |
|
179 |
st4.setOnlineResource("alkjfa"); |
|
180 |
} |
|
181 |
|
|
182 |
public void testEquality() { |
|
183 |
assertTrue(st1.equals(st2)); |
|
184 |
assertFalse(st1.equals(st3)); // (distinct extent) |
|
185 |
assertFalse(st3.equals(st4)); // (distinct online resources) |
|
186 |
} |
|
187 |
} |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.29/org.gvsig.raster.wms.remoteclient/src/test/java/org/gvsig/remoteclient/AllTests.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient; |
|
25 |
|
|
26 |
import junit.framework.Test; |
|
27 |
import junit.framework.TestSuite; |
|
28 |
|
|
29 |
import org.gvsig.remoteclient.wms.WMSStatusTest; |
|
30 |
import org.gvsig.remoteclient.wms.wms_1_1_1.WMSProtocolHandler_1_1_1Test; |
|
31 |
|
|
32 |
public class AllTests { |
|
33 |
|
|
34 |
public static Test suite() { |
|
35 |
TestSuite suite = new TestSuite("Test for org.gvsig.remoteClient"); |
|
36 |
//$JUnit-BEGIN$ |
|
37 |
suite.addTestSuite(Test.class); |
|
38 |
|
|
39 |
//commented until there is a way to simulate the needed servers. |
|
40 |
//suite.addTestSuite(URLRetrieveTest.class); |
|
41 |
suite.addTestSuite(WMSProtocolHandler_1_1_1Test.class); |
|
42 |
suite.addTestSuite(WMSStatusTest.class); |
|
43 |
|
|
44 |
//$JUnit-END$ |
|
45 |
return suite; |
|
46 |
} |
|
47 |
|
|
48 |
} |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.29/org.gvsig.raster.wms.remoteclient/src/test/resources/wms/wms.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding="ISO-8859-1" standalone="no" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2013 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 3 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE WMT_MS_Capabilities SYSTEM "http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd" |
|
28 |
[ |
|
29 |
<!ELEMENT VendorSpecificCapabilities EMPTY> |
|
30 |
]> <!-- end of DOCTYPE declaration --> |
|
31 |
|
|
32 |
<WMT_MS_Capabilities version="1.3.0"> |
|
33 |
|
|
34 |
<!-- MapServer version 4.10.1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=JPEG INPUT=SDE INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE DEBUG=MSDEBUG --> |
|
35 |
|
|
36 |
<Service> |
|
37 |
<Name>OGC:WMS</Name> |
|
38 |
<Title>WMS Server</Title> |
|
39 |
<Abstract>CHG WMS Server</Abstract> |
|
40 |
<KeywordList> |
|
41 |
<Keyword>WMS</Keyword> |
|
42 |
<Keyword> Servidor de mapas en red</Keyword> |
|
43 |
</KeywordList> |
|
44 |
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/> |
|
45 |
<ContactInformation> |
|
46 |
<ContactAddress> |
|
47 |
<!-- WARNING: Mandatory metadata '..._addresstype' was missing in this context. --> |
|
48 |
<Address>Avda. de Portugal s/n</Address> |
|
49 |
<City>Sevilla</City> |
|
50 |
<StateOrProvince>Sevilla</StateOrProvince> |
|
51 |
<PostCode>41004</PostCode> |
|
52 |
<Country>Spain</Country> |
|
53 |
</ContactAddress> |
|
54 |
</ContactInformation> |
|
55 |
</Service> |
|
56 |
|
|
57 |
<Capability> |
|
58 |
<Request> |
|
59 |
<GetCapabilities> |
|
60 |
<Format>application/vnd.ogc.wms_xml</Format> |
|
61 |
<DCPType> |
|
62 |
<HTTP> |
|
63 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
64 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
65 |
</HTTP> |
|
66 |
</DCPType> |
|
67 |
</GetCapabilities> |
|
68 |
<GetMap> |
|
69 |
<Format>image/jpeg</Format> |
|
70 |
<Format>image/gif</Format> |
|
71 |
<Format>image/png</Format> |
|
72 |
<Format>image/png; mode=24bit</Format> |
|
73 |
<Format>image/wbmp</Format> |
|
74 |
<Format>image/tiff</Format> |
|
75 |
<DCPType> |
|
76 |
<HTTP> |
|
77 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
78 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
79 |
</HTTP> |
|
80 |
</DCPType> |
|
81 |
</GetMap> |
|
82 |
<GetFeatureInfo> |
|
83 |
<Format>text/plain</Format> |
|
84 |
<Format>application/vnd.ogc.gml</Format> |
|
85 |
<DCPType> |
|
86 |
<HTTP> |
|
87 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
88 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
89 |
</HTTP> |
|
90 |
</DCPType> |
|
91 |
</GetFeatureInfo> |
|
92 |
<DescribeLayer> |
|
93 |
<Format>text/xml</Format> |
|
94 |
<DCPType> |
|
95 |
<HTTP> |
|
96 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
97 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
98 |
</HTTP> |
|
99 |
</DCPType> |
|
100 |
</DescribeLayer> |
|
101 |
<GetLegendGraphic> |
|
102 |
<Format>image/jpeg</Format> |
|
103 |
<Format>image/gif</Format> |
|
104 |
<Format>image/png</Format> |
|
105 |
<Format>image/png; mode=24bit</Format> |
|
106 |
<Format>image/wbmp</Format> |
|
107 |
<DCPType> |
|
108 |
<HTTP> |
|
109 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
110 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
111 |
</HTTP> |
|
112 |
</DCPType> |
|
113 |
</GetLegendGraphic> |
|
114 |
<GetStyles> |
|
115 |
<Format>text/xml</Format> |
|
116 |
<DCPType> |
|
117 |
<HTTP> |
|
118 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
119 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
120 |
</HTTP> |
|
121 |
</DCPType> |
|
122 |
</GetStyles> |
|
123 |
</Request> |
|
124 |
<Exception> |
|
125 |
<Format>application/vnd.ogc.se_xml</Format> |
|
126 |
<Format>application/vnd.ogc.se_inimage</Format> |
|
127 |
<Format>application/vnd.ogc.se_blank</Format> |
|
128 |
</Exception> |
|
129 |
<VendorSpecificCapabilities /> |
|
130 |
<UserDefinedSymbolization SupportSLD="1" UserLayer="0" UserStyle="1" RemoteWFS="0"/> |
|
131 |
<Layer> |
|
132 |
<Name>CHG</Name> |
|
133 |
<Title>WMS Server</Title> |
|
134 |
<SRS>epsg:23030</SRS> |
|
135 |
<LatLonBoundingBox minx="-6.84474" miny="36.6506" maxx="-2.09263" maxy="38.5449" /> |
|
136 |
<BoundingBox SRS="EPSG:23030" |
|
137 |
minx="164590" miny="4.06274e+006" maxx="579080" maxy="4.26635e+006" /> |
|
138 |
<Layer queryable="0" opaque="0" cascaded="0"> |
|
139 |
<Name>time_idx</Name> |
|
140 |
<Title>TIME INDEX</Title> |
|
141 |
<SRS>EPSG:23030</SRS> |
|
142 |
<LatLonBoundingBox minx="-6.8471" miny="36.682" maxx="-2.16907" maxy="38.75" /> |
|
143 |
<BoundingBox SRS="EPSG:23030" |
|
144 |
minx="165338" miny="4.0662e+006" maxx="572211" maxy="4.2891e+006" /> |
|
145 |
<Dimension name="time" units="ISO8601"/> |
|
146 |
<Extent name="time" nearestValue="0">2004-01-01/2004-12-1/15D</Extent> |
|
147 |
</Layer> |
|
148 |
<Layer> |
|
149 |
<Name>NDVI</Name> |
|
150 |
<Title>NDVI</Title> |
|
151 |
<Abstract>NDVI</Abstract> |
|
152 |
<Layer queryable="0" opaque="0" cascaded="0"> |
|
153 |
<Name>NDVI</Name> |
|
154 |
<Title>NDVI</Title> |
|
155 |
<SRS>EPSG:23030</SRS> |
|
156 |
<LatLonBoundingBox minx="-6.8471" miny="36.682" maxx="-2.16907" maxy="38.75" /> |
|
157 |
<BoundingBox SRS="EPSG:23030" |
|
158 |
minx="165338" miny="4.0662e+006" maxx="572211" maxy="4.2891e+006" /> |
|
159 |
<Dimension name="time" units="ISO8601"/> |
|
160 |
<Extent name="time" default="2004-01-01" nearestValue="0">2004-01-01/2004-12-1/15D</Extent> |
|
161 |
</Layer> |
|
162 |
</Layer> |
|
163 |
</Layer> |
|
164 |
</Capability> |
|
165 |
</WMT_MS_Capabilities> |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.29/org.gvsig.raster.wms.remoteclient/src/test/resources/wms/wms | ||
---|---|---|
1 |
<?xml version='1.0' encoding="ISO-8859-1" standalone="no" ?> |
|
2 |
<!DOCTYPE WMT_MS_Capabilities SYSTEM "http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd" |
|
3 |
[ |
|
4 |
<!ELEMENT VendorSpecificCapabilities EMPTY> |
|
5 |
]> <!-- end of DOCTYPE declaration --> |
|
6 |
|
|
7 |
<WMT_MS_Capabilities version="1.1.1"> |
|
8 |
|
|
9 |
<!-- MapServer version 4.10.1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=JPEG INPUT=SDE INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE DEBUG=MSDEBUG --> |
|
10 |
|
|
11 |
<Service> |
|
12 |
<Name>OGC:WMS</Name> |
|
13 |
<Title>WMS Server</Title> |
|
14 |
<Abstract>CHG WMS Server</Abstract> |
|
15 |
<KeywordList> |
|
16 |
<Keyword>WMS</Keyword> |
|
17 |
<Keyword> Servidor de mapas en red</Keyword> |
|
18 |
</KeywordList> |
|
19 |
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/> |
|
20 |
<ContactInformation> |
|
21 |
<ContactAddress> |
|
22 |
<!-- WARNING: Mandatory metadata '..._addresstype' was missing in this context. --> |
|
23 |
<Address>Avda. de Portugal s/n</Address> |
|
24 |
<City>Sevilla</City> |
|
25 |
<StateOrProvince>Sevilla</StateOrProvince> |
|
26 |
<PostCode>41004</PostCode> |
|
27 |
<Country>Spain</Country> |
|
28 |
</ContactAddress> |
|
29 |
</ContactInformation> |
|
30 |
</Service> |
|
31 |
|
|
32 |
<Capability> |
|
33 |
<Request> |
|
34 |
<GetCapabilities> |
|
35 |
<Format>application/vnd.ogc.wms_xml</Format> |
|
36 |
<DCPType> |
|
37 |
<HTTP> |
|
38 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
39 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
40 |
</HTTP> |
|
41 |
</DCPType> |
|
42 |
</GetCapabilities> |
|
43 |
<GetMap> |
|
44 |
<Format>image/jpeg</Format> |
|
45 |
<Format>image/gif</Format> |
|
46 |
<Format>image/png</Format> |
|
47 |
<Format>image/png; mode=24bit</Format> |
|
48 |
<Format>image/wbmp</Format> |
|
49 |
<Format>image/tiff</Format> |
|
50 |
<DCPType> |
|
51 |
<HTTP> |
|
52 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
53 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
54 |
</HTTP> |
|
55 |
</DCPType> |
|
56 |
</GetMap> |
|
57 |
<GetFeatureInfo> |
|
58 |
<Format>text/plain</Format> |
|
59 |
<Format>application/vnd.ogc.gml</Format> |
|
60 |
<DCPType> |
|
61 |
<HTTP> |
|
62 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
63 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
64 |
</HTTP> |
|
65 |
</DCPType> |
|
66 |
</GetFeatureInfo> |
|
67 |
<DescribeLayer> |
|
68 |
<Format>text/xml</Format> |
|
69 |
<DCPType> |
|
70 |
<HTTP> |
|
71 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
72 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
73 |
</HTTP> |
|
74 |
</DCPType> |
|
75 |
</DescribeLayer> |
|
76 |
<GetLegendGraphic> |
|
77 |
<Format>image/jpeg</Format> |
|
78 |
<Format>image/gif</Format> |
|
79 |
<Format>image/png</Format> |
|
80 |
<Format>image/png; mode=24bit</Format> |
|
81 |
<Format>image/wbmp</Format> |
|
82 |
<DCPType> |
|
83 |
<HTTP> |
|
84 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
85 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
86 |
</HTTP> |
|
87 |
</DCPType> |
|
88 |
</GetLegendGraphic> |
|
89 |
<GetStyles> |
|
90 |
<Format>text/xml</Format> |
|
91 |
<DCPType> |
|
92 |
<HTTP> |
|
93 |
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Get> |
|
94 |
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://sanlucar:81/cgi-bin/wms?"/></Post> |
|
95 |
</HTTP> |
|
96 |
</DCPType> |
|
97 |
</GetStyles> |
|
98 |
</Request> |
|
99 |
<Exception> |
|
100 |
<Format>application/vnd.ogc.se_xml</Format> |
|
101 |
<Format>application/vnd.ogc.se_inimage</Format> |
|
102 |
<Format>application/vnd.ogc.se_blank</Format> |
|
103 |
</Exception> |
|
104 |
<VendorSpecificCapabilities /> |
|
105 |
<UserDefinedSymbolization SupportSLD="1" UserLayer="0" UserStyle="1" RemoteWFS="0"/> |
|
106 |
<Layer> |
|
107 |
<Name>CHG</Name> |
|
108 |
<Title>WMS Server</Title> |
|
109 |
<SRS>epsg:23030</SRS> |
|
110 |
<LatLonBoundingBox minx="-6.84474" miny="36.6506" maxx="-2.09263" maxy="38.5449" /> |
|
111 |
<BoundingBox SRS="EPSG:23030" |
|
112 |
minx="164590" miny="4.06274e+006" maxx="579080" maxy="4.26635e+006" /> |
|
113 |
<Layer queryable="0" opaque="0" cascaded="0"> |
|
114 |
<Name>time_idx</Name> |
|
115 |
<Title>TIME INDEX</Title> |
|
116 |
<SRS>EPSG:23030</SRS> |
|
117 |
<LatLonBoundingBox minx="-6.8471" miny="36.682" maxx="-2.16907" maxy="38.75" /> |
|
118 |
<BoundingBox SRS="EPSG:23030" |
|
119 |
minx="165338" miny="4.0662e+006" maxx="572211" maxy="4.2891e+006" /> |
|
120 |
<Dimension name="time" units="ISO8601"/> |
|
121 |
<Extent name="time" nearestValue="0">2004-01-01/2004-12-1/15D</Extent> |
|
122 |
</Layer> |
|
123 |
<Layer> |
|
124 |
<Name>NDVI</Name> |
|
125 |
<Title>NDVI</Title> |
|
126 |
<Abstract>NDVI</Abstract> |
|
127 |
<Layer queryable="0" opaque="0" cascaded="0"> |
|
128 |
<Name>NDVI</Name> |
|
129 |
<Title>NDVI</Title> |
|
130 |
<SRS>EPSG:23030</SRS> |
|
131 |
<LatLonBoundingBox minx="-6.8471" miny="36.682" maxx="-2.16907" maxy="38.75" /> |
|
132 |
<BoundingBox SRS="EPSG:23030" |
|
133 |
minx="165338" miny="4.0662e+006" maxx="572211" maxy="4.2891e+006" /> |
|
134 |
<Dimension name="time" units="ISO8601"/> |
|
135 |
<Extent name="time" default="2004-01-01" nearestValue="0">2004-01-01/2004-12-1/15D</Extent> |
|
136 |
</Layer> |
|
137 |
</Layer> |
|
138 |
</Layer> |
|
139 |
</Capability> |
|
140 |
</WMT_MS_Capabilities> |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.29/org.gvsig.raster.wms.remoteclient/src/main/java/org/gvsig/remoteclient/epsg/CrsAxisOrder.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.epsg; |
|
2 |
|
|
3 |
import java.io.BufferedReader; |
|
4 |
import java.io.IOException; |
|
5 |
import java.io.InputStream; |
|
6 |
import java.io.InputStreamReader; |
|
7 |
import java.util.HashSet; |
|
8 |
|
|
9 |
/** |
|
10 |
* <p>Utility class to get the axis order of a coordinate reference system (CRS). |
|
11 |
* It should be generalized and moved to the projection API on some future |
|
12 |
* version.</p> |
|
13 |
* |
|
14 |
* @author Cesar Martinez Izquierdo |
|
15 |
* |
|
16 |
*/ |
|
17 |
public class CrsAxisOrder { |
|
18 |
/* |
|
19 |
* Set containing the EPSG codes for projections using Y-X axis order. |
|
20 |
*/ |
|
21 |
private static HashSet<String> yxAxisOrder = null; |
|
22 |
|
|
23 |
/** |
|
24 |
* Returns a set containing the EPSG codes for projections using Y-X axis |
|
25 |
* order. |
|
26 |
* |
|
27 |
* @return |
|
28 |
*/ |
|
29 |
private static HashSet<String> getYxAxisOrder() { |
|
30 |
if (yxAxisOrder==null) { |
|
31 |
yxAxisOrder = new HashSet(); |
|
32 |
try { |
|
33 |
InputStream is = CrsAxisOrder.class.getClassLoader().getResourceAsStream("/axisOrder/mapaxisorder.csv"); |
|
34 |
if (is!=null) { |
|
35 |
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "ISO-8859-1")); |
|
36 |
// skip the first line which contains the CSV header |
|
37 |
String line = reader.readLine(); |
|
38 |
// read the codes |
|
39 |
while ((line=reader.readLine())!=null) { |
|
40 |
yxAxisOrder.add(line); |
|
41 |
} |
|
42 |
} |
|
43 |
} catch (IOException e) { |
|
44 |
} |
|
45 |
} |
|
46 |
return yxAxisOrder; |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* <p>Returns <code>true</code> if the CRS defined by the |
|
51 |
* provided EPSG code follows the XY axis order (i.e. |
|
52 |
* the first coordinate corresponds to the horizontal |
|
53 |
* axis while the second coordinate corresponds to |
|
54 |
* the vertical axis). Returns <false> if the |
|
55 |
* EPSG registry defines YX order.</p> |
|
56 |
* |
|
57 |
* <p>Note that it will also return true for any unknown CRS</p>. |
|
58 |
* |
|
59 |
* @param epsgCode The EPSG code of the CRS to check, as integer. |
|
60 |
* @return |
|
61 |
*/ |
|
62 |
public static boolean isXyAxisOrder(int epsgCode) { |
|
63 |
if (getYxAxisOrder().contains(Integer.toString(epsgCode))) { |
|
64 |
return false; |
|
65 |
} |
|
66 |
return true; |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* <p>Returns <code>true</code> if the CRS defined by the |
|
71 |
* provided EPSG code follows the XY axis order (i.e. |
|
72 |
* the first coordinate corresponds to the horizontal |
|
73 |
* axis while the second coordinate corresponds to |
|
74 |
* the vertical axis). Returns <false> if the |
|
75 |
* EPSG registry defines YX order.</p> |
|
76 |
* |
|
77 |
* <p>Note that it will also return true for any unknown CRS</p>. |
|
78 |
* |
|
79 |
* @param epsgCode Epsg code as string, for instance "EPSG:4326" or just |
|
80 |
* "4326". |
|
81 |
* @return |
|
82 |
*/ |
|
83 |
public static boolean isXyAxisOrder(String epsgCode) { |
|
84 |
if (epsgCode!=null) { |
|
85 |
if (epsgCode.toUpperCase().startsWith("EPSG:")) { |
|
86 |
epsgCode = epsgCode.substring(5); |
|
87 |
} |
|
88 |
if (getYxAxisOrder().contains(epsgCode)) { |
|
89 |
return false; |
|
90 |
} |
|
91 |
} |
|
92 |
return true; |
|
93 |
} |
|
94 |
} |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.29/org.gvsig.raster.wms.remoteclient/src/main/java/org/gvsig/remoteclient/exceptions/WMSException.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.exceptions; |
|
25 |
|
|
26 |
/** |
|
27 |
* Excepci?n provocada por el WMS. |
|
28 |
* |
|
29 |
* @author Vicente Caballero Navarro |
|
30 |
*/ |
|
31 |
public class WMSException extends Exception |
|
32 |
{ |
|
33 |
private String wms_message = null; |
|
34 |
|
|
35 |
/** |
|
36 |
* |
|
37 |
*/ |
|
38 |
public WMSException() { |
|
39 |
super(); |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* Crea WMSException. |
|
44 |
* |
|
45 |
* @param message |
|
46 |
*/ |
|
47 |
public WMSException(String message) { |
|
48 |
super(message); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* Crea WMSException. |
|
53 |
* |
|
54 |
* @param message |
|
55 |
* @param cause |
|
56 |
*/ |
|
57 |
public WMSException(String message, Throwable cause) { |
|
58 |
super(message, cause); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Crea WMSException. |
|
63 |
* |
|
64 |
* @param cause |
|
65 |
*/ |
|
66 |
public WMSException(Throwable cause) { |
|
67 |
super(cause); |
|
68 |
} |
|
69 |
|
|
70 |
public String getWMSMessage() |
|
71 |
{ |
|
72 |
if (wms_message == null) |
|
73 |
return ""; |
|
74 |
else |
|
75 |
return wms_message; |
|
76 |
} |
|
77 |
|
|
78 |
public void setWMSMessage(String mes) |
|
79 |
{ |
|
80 |
wms_message = mes; |
|
81 |
} |
|
82 |
} |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.29/org.gvsig.raster.wms.remoteclient/src/main/java/org/gvsig/remoteclient/exceptions/WMSWrongSizeException.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.exceptions; |
|
25 |
|
|
26 |
/** |
|
27 |
* La petici?n al servidor era de un tama?o equivocado. |
|
28 |
* Reconoce execepciones de algunos tipos:<br> |
|
29 |
* <li>El server http://wms.jpl.nasa.gov/wms.cgi da estos: |
|
30 |
* <pre> |
|
31 |
<?xml version='1.0' encoding="UTF-8" standalone="no" ?> |
|
32 |
<!DOCTYPE ServiceExceptionReport SYSTEM "http://www.digitalearth.gov/wmt/xml/exception_1_1_0.dtd "> |
|
33 |
<ServiceExceptionReport version="1.1.0"> |
|
34 |
<ServiceException> |
|
35 |
Requested image is too wide, max allowed width is 4096 |
|
36 |
</ServiceException> |
|
37 |
</ServiceExceptionReport> |
|
38 |
|
|
39 |
<?xml version='1.0' encoding="UTF-8" standalone="no" ?> |
|
40 |
<!DOCTYPE ServiceExceptionReport SYSTEM "http://www.digitalearth.gov/wmt/xml/exception_1_1_0.dtd "> |
|
41 |
<ServiceExceptionReport version="1.1.0"> |
|
42 |
<ServiceException> |
|
43 |
Requested image is too tall, max allowed height is 4096 |
|
44 |
</ServiceException> |
|
45 |
</ServiceExceptionReport> |
|
46 |
* </pre> |
|
47 |
* <li>El server http://www.idee.es/wms/IDEE-Base/IDEE-Base da |
|
48 |
* <pre> |
|
49 |
<ERROR Operation="GetMap Request" status="ERROR" source="Web Map Server" description="El servidor no ha podido realizar la operacion"> |
|
50 |
<ERROR CODE="El tamano en pixels pedido no es valido."/> |
|
51 |
<ERROR CODE="Su valor debe ser mayor que 0 y menor que el limite de descarga: anchura = 1500, altura = 1500"/> |
|
52 |
</ERROR> |
|
53 |
* </pre> |
|
54 |
* <li>El server http://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx da |
|
55 |
* <pre> |
|
56 |
<ServiceExceptionReport version="1.1.1"> |
|
57 |
- |
|
58 |
<ServiceException code="InvalidFormat"> |
|
59 |
|
|
60 |
Par?metros erroneos: |
|
61 |
prefijo = |
|
62 |
mapa = 0 |
|
63 |
formato = IMAGE/JPEG |
|
64 |
XMin = 1.1578804698593 |
|
65 |
YMin = 53.5852110737936 |
|
66 |
XMax = 10.3 |
|
67 |
YMax = 53.8000038968219 |
|
68 |
AnchoPixels = 64 |
|
69 |
AltoPixels = 5023 |
|
70 |
Transparente = TRUE |
|
71 |
Descripci?n error: |
|
72 |
AltoPixels > 2000 |
|
73 |
</ServiceException> |
|
74 |
</ServiceExceptionReport> |
|
75 |
* </pre> |
|
76 |
* |
|
77 |
* <pre> |
|
78 |
<?xml version='1.0' encoding="ISO-8859-1" standalone="no" ?> |
|
79 |
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengeospatial.net/wms/1.1.1/exception_1_1_1.dtd"> |
|
80 |
<ServiceExceptionReport version="1.1.1"> |
|
81 |
<ServiceException> |
|
82 |
msWMSLoadGetMapParams(): WMS server error. Image size out of range, WIDTH and HEIGHT must be between 1 and 2048 pixels. |
|
83 |
</ServiceException> |
|
84 |
</ServiceExceptionReport> |
|
85 |
|
|
86 |
* </pre> |
|
87 |
* |
|
88 |
*/ |
|
89 |
public class WMSWrongSizeException extends WMSException |
|
90 |
{ |
|
91 |
private int height = -1; |
|
92 |
private int width = -1; |
|
93 |
|
|
94 |
/** |
|
95 |
* |
|
96 |
*/ |
|
97 |
public WMSWrongSizeException() { |
|
98 |
super(); |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* Crea WMSException. |
|
103 |
* |
|
104 |
* @param message |
|
105 |
*/ |
|
106 |
public WMSWrongSizeException(String message) { |
|
107 |
super(message); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* Crea WMSException. |
|
112 |
* |
|
113 |
* @param message |
|
114 |
* @param cause |
|
115 |
*/ |
|
116 |
public WMSWrongSizeException(String message, Throwable cause) { |
|
117 |
super(message, cause); |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* Crea WMSException. |
|
122 |
* |
|
123 |
* @param cause |
|
124 |
*/ |
|
125 |
public WMSWrongSizeException(Throwable cause) { |
|
126 |
super(cause); |
|
127 |
} |
|
128 |
|
|
129 |
public int getWidth() |
|
130 |
{ |
|
131 |
return width; |
|
132 |
} |
|
133 |
public int getHeight() |
|
134 |
{ |
|
135 |
return height; |
|
136 |
} |
|
137 |
public void setWidth(int w) |
|
138 |
{ |
|
139 |
width =w; |
|
140 |
} |
|
141 |
public void setHeight(int h) |
|
142 |
{ |
|
143 |
height =h; |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* Checks if the argument is a WrongSizeError message, in this |
|
148 |
* case throws a WMSWrongSizeException |
|
149 |
* @param errorMsg El mensaje de error que pasa el server. |
|
150 |
* @throws WMSException |
|
151 |
*/ |
|
152 |
public static void check(String errorMsg) throws WMSException |
|
153 |
{ |
|
154 |
//TODO: |
|
155 |
//check the errorMsg to see if it matches with one of the |
|
156 |
// well known string error messages. |
|
157 |
} |
|
158 |
} |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.29/org.gvsig.raster.wms.remoteclient/src/main/java/org/gvsig/remoteclient/wms/WMSProtocolHandler.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.wms; |
|
25 |
|
|
26 |
import java.io.ByteArrayInputStream; |
|
27 |
import java.io.File; |
|
28 |
import java.io.FileInputStream; |
|
29 |
import java.io.FileReader; |
|
30 |
import java.io.IOException; |
|
31 |
import java.io.InputStream; |
|
32 |
import java.net.URL; |
|
33 |
import java.net.URLConnection; |
|
34 |
import java.nio.ByteBuffer; |
|
35 |
import java.nio.channels.FileChannel; |
|
36 |
import java.util.ArrayList; |
|
37 |
import java.util.Iterator; |
|
38 |
import java.util.StringTokenizer; |
|
39 |
import java.util.TreeMap; |
|
40 |
|
|
41 |
import org.gvsig.compat.net.ICancellable; |
|
42 |
import org.gvsig.remoteclient.exceptions.ServerErrorException; |
|
43 |
import org.gvsig.remoteclient.exceptions.WMSException; |
|
44 |
import org.gvsig.remoteclient.ogc.OGCProtocolHandler; |
|
45 |
import org.gvsig.remoteclient.ogc.OGCServiceInformation; |
|
46 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
47 |
import org.gvsig.remoteclient.utils.ExceptionTags; |
|
48 |
import org.gvsig.remoteclient.utils.Utilities; |
|
49 |
import org.gvsig.remoteclient.wms.request.WMSGetCapabilitiesRequest; |
|
50 |
import org.gvsig.remoteclient.wms.request.WMSGetFeatureInfoRequest; |
|
51 |
import org.gvsig.remoteclient.wms.request.WMSGetLegendGraphicRequest; |
|
52 |
import org.gvsig.remoteclient.wms.request.WMSGetMapRequest; |
|
53 |
import org.kxml2.io.KXmlParser; |
|
54 |
import org.slf4j.Logger; |
|
55 |
import org.slf4j.LoggerFactory; |
|
56 |
import org.xmlpull.v1.XmlPullParserException; |
|
57 |
|
|
58 |
/** |
|
59 |
* <p> Abstract class that represents handlers to comunicate via WMS protocol. |
|
60 |
* </p> |
|
61 |
* |
|
62 |
*/ |
|
63 |
public abstract class WMSProtocolHandler extends OGCProtocolHandler { |
|
64 |
|
|
65 |
private static final Logger logger = LoggerFactory.getLogger(WMSProtocolHandler.class); |
|
66 |
/** |
|
67 |
* Encoding used to parse different xml documents. |
|
68 |
*/ |
|
69 |
protected String encoding = "UTF-8"; |
|
70 |
/** |
|
71 |
* WMS metadata |
|
72 |
*/ |
|
73 |
protected WMSServiceInformation serviceInfo; |
|
74 |
public TreeMap layers; |
|
75 |
public WMSLayer rootLayer; |
|
76 |
|
|
77 |
/** |
|
78 |
* returns the alfanumeric information of the layers at the specified point. |
|
79 |
* the diference between the other getfeatureInfo method is that this will |
|
80 |
* be implemented by each specific version because the XML from the server will be |
|
81 |
* parsed and presented by a well known structure. |
|
82 |
*/ |
|
83 |
|
|
84 |
public String getName() { |
|
85 |
return name; |
|
86 |
} |
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
90 |
* @see org.gvsig.remoteClient.ogc.OGCProtocolHandler#getServiceInformation() |
|
91 |
*/ |
|
92 |
public OGCServiceInformation getServiceInformation() { |
|
93 |
return serviceInfo; |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* <p>Builds a GetCapabilities request that is sent to the WMS |
|
98 |
* the response will be parse to extract the data needed by the |
|
99 |
* WMS client</p> |
|
100 |
* @param override, if true the previous downloaded data will be overridden |
|
101 |
*/ |
|
102 |
public void getCapabilities(WMSStatus status, boolean override, ICancellable cancel) { |
|
103 |
URL request = null; |
|
104 |
try { |
|
105 |
request = new URL(buildCapabilitiesRequest(status)); |
|
106 |
} catch(Exception e) { |
|
107 |
logger.warn("Can't get capabilities, error building url.",e); |
|
108 |
} |
|
109 |
try { |
|
110 |
if (override) |
|
111 |
Utilities.removeURL(request); |
|
112 |
File f = Utilities.downloadFile(request,"wms_capabilities.xml", cancel); |
|
113 |
if (f == null) |
|
114 |
return; |
|
115 |
clear(); |
|
116 |
parseCapabilities(f); |
|
117 |
} catch(Exception e) { |
|
118 |
logger.warn("Can't get capabilities.",e); |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
private void clear() { |
|
123 |
layers.clear(); |
|
124 |
serviceInfo.clear(); |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* <p>It will send a GetFeatureInfo request to the WMS |
|
129 |
* Parsing the response and redirecting the info to the WMS client</p> |
|
130 |
* TODO: return a stored file instead a String. |
|
131 |
*/ |
|
132 |
public String getFeatureInfo(WMSStatus status, int x, int y, int featureCount, ICancellable cancel) |
|
133 |
{ |
|
134 |
StringBuffer output = new StringBuffer(); |
|
135 |
String outputFormat = new String(); |
|
136 |
String ServiceException = "ServiceExceptionReport"; |
|
137 |
StringBuffer sb = new StringBuffer(); |
|
138 |
sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); |
|
139 |
try |
|
140 |
{ |
|
141 |
WMSGetFeatureInfoRequest request = createGetFeatureInfoRequest(status, x, y); |
|
142 |
URL url = request.getURL(); |
|
143 |
outputFormat = url.openConnection().getContentType(); |
|
144 |
File f = request.sendRequest(cancel); |
|
145 |
if (f == null){ |
|
146 |
return ""; |
|
147 |
} |
|
148 |
|
|
149 |
FileReader fReader = new FileReader(f); |
|
150 |
char[] buffer = new char[1024*256]; |
|
151 |
for (int i = fReader.read(buffer); i>0; i = fReader.read(buffer)) |
|
152 |
{ |
|
153 |
String str = new String(buffer,0,i); |
|
154 |
output.append(str); |
|
155 |
} |
|
156 |
if ( (outputFormat == null) || (outputFormat.indexOf("xml") != -1) |
|
157 |
||output.toString().toLowerCase().startsWith("<?xml") |
|
158 |
||(outputFormat.indexOf("gml") != -1)) |
|
159 |
{ |
|
160 |
int tag; |
|
161 |
KXmlParser kxmlParser = null; |
|
162 |
kxmlParser = new KXmlParser(); |
|
163 |
//kxmlParser.setInput(new StringReader(output.toString())); |
|
164 |
kxmlParser.setInput(new FileReader(f)); |
|
165 |
|
|
166 |
tag = kxmlParser.nextTag(); |
|
167 |
if (kxmlParser.getName().compareTo(ServiceException)==0) |
|
168 |
{ |
|
169 |
sb.append("<INFO>").append(parseException( output.toString().getBytes())).append("</INFO>"); |
|
170 |
return sb.toString(); |
|
171 |
} |
|
172 |
else if (kxmlParser.getName().compareToIgnoreCase("ERROR")==0) |
|
173 |
{ |
|
174 |
return output.toString(); |
|
175 |
} |
|
176 |
else |
|
177 |
{ |
|
178 |
return output.toString(); |
|
179 |
} |
|
180 |
} |
|
181 |
else |
|
182 |
{ |
|
183 |
//Para que funcione con el GetFeatureInfo Viewer generico hay que devolver: |
|
184 |
return output.toString(); |
|
185 |
} |
|
186 |
} |
|
187 |
catch(XmlPullParserException parserEx) |
|
188 |
{ |
|
189 |
if (output.toString().toLowerCase().indexOf("xml") != -1) |
|
190 |
{ |
|
191 |
return output.toString().trim(); |
|
192 |
} |
|
193 |
else |
|
194 |
{ |
|
195 |
sb.append("<INFO>").append("Info format not supported").append("</INFO>"); |
|
196 |
return sb.toString(); |
|
197 |
} |
|
198 |
} |
|
199 |
catch(Exception e) |
|
200 |
{ |
|
201 |
logger.warn("Can't get information by point.",e); |
|
202 |
sb.append("<INFO>").append("Info format not supported").append("</INFO>"); |
|
203 |
return sb.toString(); |
|
204 |
|
|
205 |
} |
|
206 |
} |
|
207 |
/** |
|
208 |
* <p>Builds a GetMap request that is sent to the WMS |
|
209 |
* the response (image) will be redirect to the |
|
210 |
* WMS client</p> |
|
211 |
*/ |
|
212 |
public byte[] _getMap(WMSStatus status) throws ServerErrorException, WMSException |
|
213 |
{ |
|
214 |
try |
|
215 |
{ |
|
216 |
//TODO: |
|
217 |
//pass this buildXXXRequest to the WMSProtocolHandlerXXX: The request can depend on the WMS version. |
|
218 |
WMSGetMapRequest request = createGetMapRequest(status); |
|
219 |
URL url = request.getURL(); |
|
220 |
|
|
221 |
URLConnection conn = url.openConnection(); |
|
222 |
logger.info(request.toString()); |
|
223 |
String type = conn.getContentType(); |
|
224 |
|
|
225 |
|
|
226 |
byte[] imageBytes = null; |
|
227 |
byte[] buffer = new byte[1024*256]; |
|
228 |
InputStream is = conn.getInputStream(); |
|
229 |
int readed = 0; |
|
230 |
|
|
231 |
for (int i = is.read(buffer); i>0; i = is.read(buffer)){ |
|
232 |
// Creates a new buffer to contain the previous readed bytes and the next bunch of bytes |
|
233 |
byte[] buffered = new byte[readed+i]; |
|
234 |
for (int j = 0; j < buffered.length; j++) { |
|
235 |
if (j<readed){ |
|
236 |
// puts the previously downloaded bytes into the image buffer |
|
237 |
buffered[j] = imageBytes[j]; |
|
238 |
} |
|
239 |
else { |
|
240 |
// appends the recently downloaded bytes to the image buffer. |
|
241 |
buffered[j] = buffer[j-readed]; |
|
242 |
} |
|
243 |
} |
|
244 |
imageBytes = (byte[]) buffered.clone(); |
|
245 |
readed += i; |
|
246 |
} |
|
247 |
|
|
248 |
if ((type !=null && !type.subSequence(0,5).equals("image")) |
|
249 |
||(Utilities.isTextData(imageBytes))) |
|
250 |
{ |
|
251 |
WMSException wmsEx = null; |
|
252 |
|
|
253 |
String exceptionMessage = parseException(imageBytes); |
|
254 |
if (exceptionMessage==null) |
|
255 |
{ |
|
256 |
String error = new String(imageBytes); |
|
257 |
int pos = error.indexOf("<?xml"); |
|
258 |
if (pos!= -1) |
|
259 |
{ |
|
260 |
String xml = error.substring(pos,error.length()); |
|
261 |
exceptionMessage = parseException(xml.getBytes()); |
|
262 |
if (exceptionMessage == null) |
|
263 |
exceptionMessage = new String(imageBytes); |
|
264 |
} |
|
265 |
} |
|
266 |
wmsEx = new WMSException(exceptionMessage); |
|
267 |
wmsEx.setWMSMessage(new String(imageBytes)); |
|
268 |
throw wmsEx; |
|
269 |
} |
|
270 |
return imageBytes; |
|
271 |
} |
|
272 |
catch(IOException e) |
|
273 |
{ |
|
274 |
logger.warn("Can't build map request.",e); |
|
275 |
throw new ServerErrorException(); |
|
276 |
} |
|
277 |
} |
|
278 |
|
|
279 |
public File getLegendGraphic_old(WMSStatus status, String layerName, ICancellable cancel) throws ServerErrorException, WMSException |
|
280 |
{ |
|
281 |
try |
|
282 |
{ |
|
283 |
WMSGetLegendGraphicRequest request = createGetLegendGraphicRequest(status, layerName); |
|
284 |
File f = request.sendRequest(cancel); |
|
285 |
if (f== null) |
|
286 |
return null; |
|
287 |
if (Utilities.isTextFile(f)) { |
|
288 |
|
|
289 |
byte[] data = fileToBytes(f); |
|
290 |
|
|
291 |
WMSException wmsEx = null; |
|
292 |
|
|
293 |
String exceptionMessage = parseException(data); |
|
294 |
if (exceptionMessage==null) |
|
295 |
{ |
|
296 |
String error = new String(data); |
|
297 |
int pos = error.indexOf("<?xml"); |
|
298 |
if (pos!= -1) |
|
299 |
{ |
|
300 |
String xml = error.substring(pos,error.length()); |
|
301 |
exceptionMessage = parseException(xml.getBytes()); |
|
302 |
} |
|
303 |
if (exceptionMessage == null) |
|
304 |
exceptionMessage = new String(data); |
|
305 |
|
|
306 |
} |
|
307 |
wmsEx = new WMSException(exceptionMessage); |
|
308 |
wmsEx.setWMSMessage(new String(data)); |
|
309 |
downloader.removeURL(request); |
|
310 |
throw wmsEx; |
|
311 |
} |
|
312 |
return f; |
|
313 |
} |
|
314 |
catch(IOException e) |
|
315 |
{ |
|
316 |
logger.warn("Can't get legend graphics.",e); |
|
317 |
throw new ServerErrorException(); |
|
318 |
} |
|
319 |
} |
|
320 |
|
|
321 |
public File getLegendGraphic(WMSStatus status, String layerName, ICancellable cancel) |
|
322 |
throws ServerErrorException, WMSException { |
|
323 |
URL request = null; |
|
324 |
try { |
|
325 |
status.setOnlineResource(status.getOnlineResource().replaceAll(" ", "%20")); |
|
326 |
request = new URL(buildGetLegendGraphicRequest(status, layerName)); |
|
327 |
logger.info(request.toString()); |
|
328 |
File f = Utilities.downloadFile(request, "wmsGetLegendGraphic", cancel); |
|
329 |
if (f== null) |
|
330 |
return null; |
|
331 |
if (Utilities.isTextFile(f)) { |
|
332 |
FileInputStream fis = new FileInputStream(f); |
|
333 |
FileChannel fc = fis.getChannel(); |
|
334 |
byte[] data = new byte[(int)fc.size()]; |
|
335 |
ByteBuffer bb = ByteBuffer.wrap(data); |
|
336 |
fc.read(bb); |
|
337 |
|
|
338 |
WMSException wmsEx = null; |
|
339 |
|
|
340 |
String exceptionMessage = parseException(data); |
|
341 |
if (exceptionMessage == null) { |
|
342 |
String error = new String(data); |
|
343 |
int pos = error.indexOf("<?xml"); |
|
344 |
if (pos!= -1) { |
|
345 |
String xml = error.substring(pos,error.length()); |
|
346 |
exceptionMessage = parseException(xml.getBytes()); |
|
347 |
} |
|
348 |
if (exceptionMessage == null) |
|
349 |
exceptionMessage = new String(data); |
|
350 |
|
|
351 |
} |
|
352 |
wmsEx = new WMSException(exceptionMessage); |
|
353 |
wmsEx.setWMSMessage(new String(data)); |
|
354 |
Utilities.removeURL(request); |
|
355 |
throw wmsEx; |
|
356 |
} |
|
357 |
return f; |
|
358 |
} catch(IOException e) { |
|
359 |
logger.warn("Can't get legend graphics",e); |
|
360 |
throw new ServerErrorException(); |
|
361 |
} |
|
362 |
} |
|
363 |
|
|
364 |
/** |
|
365 |
* @return string that represents the url for getting the wms legend |
|
366 |
* If the layer has the object layer-->style-->legendurl that url will be returned |
|
367 |
* otherwise builds the getLegendGraphic according to the OGC WMS Specifications |
|
368 |
* |
|
369 |
*/ |
|
370 |
private String buildGetLegendGraphicRequest(WMSStatus status, String layerName) { |
|
371 |
//TODO: deal with more than one layer |
|
372 |
WMSLayer lyr = (WMSLayer) this.layers.get(layerName); |
|
373 |
WMSStyle sty =null; |
|
374 |
if (lyr != null){ |
|
375 |
Iterator it = lyr.getStyles().iterator(); |
|
376 |
while (it.hasNext()){ |
|
377 |
sty = (WMSStyle) it.next(); |
|
378 |
if (sty.getName().equals(status.getStyles().get(0).toString())){ |
|
379 |
return sty.getLegendURLOnlineResourceHRef().replaceAll(" ", "%20"); |
|
380 |
} |
|
381 |
} |
|
382 |
} |
|
383 |
//TODO: pass by parameter the legend output format? |
|
384 |
StringBuffer req = new StringBuffer(); |
|
385 |
String symbol = null; |
|
386 |
String onlineResource = null; |
|
387 |
|
|
388 |
if (status.getOnlineResource() == null) |
|
389 |
onlineResource = getHost(); |
|
390 |
else |
|
391 |
onlineResource = status.getOnlineResource(); |
|
392 |
symbol = getSymbol(onlineResource); |
|
393 |
|
|
394 |
req.append(onlineResource + symbol + "REQUEST=GetLegendGraphic&SERVICE=WMS&VERSION=").append(getVersion()); |
|
395 |
req.append("&LAYER=" + layerName).append("&TRANSPARENT=TRUE").append("&FORMAT=image/png"); |
|
396 |
String aux = req.toString().replaceAll(" ", "%20"); |
|
397 |
logger.info("GetLegendGraphic url:" + aux); |
|
398 |
return aux; |
|
399 |
} |
|
400 |
|
|
401 |
public URL getMapURL(WMSStatus status, ICancellable cancel) throws ServerErrorException, WMSException { |
|
402 |
try { |
|
403 |
WMSGetMapRequest request = createGetMapRequest(status); |
|
404 |
return request.getURL(); |
|
405 |
} catch(IOException e) { |
|
406 |
logger.warn("Can't get map URL",e); |
|
407 |
throw new ServerErrorException(); |
|
408 |
} |
|
409 |
} |
|
410 |
|
|
411 |
/** |
|
412 |
* Returns the exception message if the file is a XML instead of a image. |
|
413 |
* @param file3 |
|
414 |
* @return |
|
415 |
* @throws IOException |
|
416 |
*/ |
|
417 |
public String getExceptionMessage(File f) throws IOException { |
|
418 |
if (f == null) |
|
419 |
return null; |
|
420 |
|
|
421 |
if (Utilities.isTextFile(f)) { |
|
422 |
byte[] data = fileToBytes(f); |
|
423 |
|
|
424 |
String exceptionMessage = parseException(data); |
|
425 |
if (exceptionMessage == null) { |
|
426 |
String error = new String(data); |
|
427 |
int pos = error.indexOf("<?xml"); |
|
428 |
if (pos!= -1) { |
|
429 |
String xml = error.substring(pos,error.length()); |
|
430 |
exceptionMessage = parseException(xml.getBytes()); |
|
431 |
} |
|
432 |
if (exceptionMessage == null) |
|
433 |
exceptionMessage = new String(data); |
|
434 |
} |
|
435 |
return exceptionMessage; |
|
436 |
} |
|
437 |
return null; |
|
438 |
} |
|
439 |
|
|
440 |
public File getMap(WMSStatus status, ICancellable cancel) throws ServerErrorException, WMSException { |
|
441 |
try { |
|
442 |
WMSGetMapRequest request = createGetMapRequest(status); |
|
443 |
File f = request.sendRequest(cancel); |
|
444 |
|
|
445 |
if (f== null) |
|
446 |
return null; |
|
447 |
if (Utilities.isTextFile(f)) { |
|
448 |
byte[] data = fileToBytes(f); |
|
449 |
|
|
450 |
WMSException wmsEx = null; |
|
451 |
|
|
452 |
String exceptionMessage = parseException(data); |
|
453 |
if (exceptionMessage==null) { |
|
454 |
String error = new String(data); |
|
455 |
int pos = error.indexOf("<?xml"); |
|
456 |
if (pos!= -1) { |
|
457 |
String xml = error.substring(pos,error.length()); |
|
458 |
exceptionMessage = parseException(xml.getBytes()); |
|
459 |
// if (exceptionMessage == null) |
|
460 |
// exceptionMessage = new String(data); |
|
461 |
} |
|
462 |
if (exceptionMessage == null) |
|
463 |
exceptionMessage = new String(data); |
|
464 |
|
|
465 |
} |
|
466 |
wmsEx = new WMSException(exceptionMessage); |
|
467 |
wmsEx.setWMSMessage(new String(data)); |
|
468 |
|
|
469 |
// Since it is an error file, It must be deleted from the cache |
|
470 |
downloader.removeURL(request); |
|
471 |
throw wmsEx; |
|
472 |
} |
|
473 |
return f; |
|
474 |
} catch(IOException e) { |
|
475 |
throw new ServerErrorException(e.getMessage(), e); |
|
476 |
} |
|
477 |
} |
|
478 |
|
|
479 |
|
|
480 |
/* (non-Javadoc) |
|
481 |
* @see org.gvsig.remoteClient.wms.WMSProtocolHandler#parseException(byte[]) |
|
482 |
*/ |
|
483 |
protected String parseException(byte[] data) { |
|
484 |
ArrayList errors = new ArrayList(); |
|
485 |
KXmlParser kxmlParser = new KXmlParser(); |
|
486 |
try |
|
487 |
{ |
|
488 |
kxmlParser.setInput(new ByteArrayInputStream(data), encoding); |
|
489 |
kxmlParser.nextTag(); |
|
490 |
int tag; |
|
491 |
if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT ) |
|
492 |
{ |
|
493 |
kxmlParser.require(KXmlParser.START_TAG, null, ExceptionTags.EXCEPTION_ROOT); |
|
494 |
tag = kxmlParser.nextTag(); |
|
495 |
while(tag != KXmlParser.END_DOCUMENT) |
|
496 |
{ |
|
497 |
switch(tag) |
|
498 |
{ |
|
499 |
case KXmlParser.START_TAG: |
|
500 |
if (kxmlParser.getName().compareTo(ExceptionTags.SERVICE_EXCEPTION)==0){ |
|
501 |
String errorCode = kxmlParser.getAttributeValue("", ExceptionTags.CODE); |
|
502 |
errorCode = (errorCode != null) ? "["+errorCode+"] " : ""; |
|
503 |
String errorMessage = kxmlParser.nextText(); |
|
504 |
errors.add(errorCode+errorMessage); |
|
505 |
} |
|
506 |
break; |
|
507 |
case KXmlParser.END_TAG: |
|
508 |
break; |
|
509 |
|
|
510 |
} |
|
511 |
tag = kxmlParser.nextTag(); |
|
512 |
} |
|
513 |
//kxmlParser.require(KXmlParser.END_DOCUMENT, null, null); |
|
514 |
} |
|
515 |
} |
|
516 |
catch(XmlPullParserException parser_ex){ |
|
517 |
logger.warn("",parser_ex); |
|
518 |
} |
|
519 |
catch (IOException ioe) { |
|
520 |
logger.warn("",ioe); |
|
521 |
} |
|
522 |
String message = errors.size()>0? "" : null; |
|
523 |
for (int i = 0; i < errors.size(); i++) { |
|
524 |
message += (String) errors.get(i)+"\n"; |
|
525 |
} |
|
526 |
return message; |
|
527 |
} |
|
528 |
/** |
|
529 |
* Builds the GetCapabilitiesRequest according to the OGC WMS Specifications |
|
530 |
* without a VERSION, to get the highest version than a WMS supports. |
|
531 |
*/ |
|
532 |
public static String buildCapabilitiesSuitableVersionRequest(String _host, String _version) |
Also available in: Unified diff