Revision 22443

View differences:

org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.250/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.250/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.250/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.250/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.250/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.250/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.250/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.250/org.gvsig.raster.wms.remoteclient/src/main/java/org/gvsig/remoteclient/wms/WMSOperation.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

  
25
package org.gvsig.remoteclient.wms;
26

  
27
import java.util.Hashtable;
28

  
29
import org.gvsig.remoteclient.ogc.OGCClientOperation;
30
import org.gvsig.remoteclient.utils.CapabilitiesTags;
31

  
32
/**
33
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
34
 */
35
public class WMSOperation extends OGCClientOperation{ 
36
	protected static Hashtable operations = new Hashtable();
37

  
38
	static{
39
		operations.put(CapabilitiesTags.GETCAPABILITIES, new WMSOperation(CapabilitiesTags.GETCAPABILITIES));
40
		operations.put(CapabilitiesTags.GETFEATUREINFO, new WMSOperation(CapabilitiesTags.GETFEATUREINFO));
41
		operations.put(CapabilitiesTags.GETLEGENDGRAPHIC, new WMSOperation(CapabilitiesTags.GETLEGENDGRAPHIC));
42
		operations.put(CapabilitiesTags.GETMAP, new WMSOperation(CapabilitiesTags.GETMAP));
43
		operations.put(CapabilitiesTags.DESCRIBELAYER, new WMSOperation(CapabilitiesTags.DESCRIBELAYER));
44
	}
45
	
46
	public WMSOperation(String operationName) {
47
		super(operationName);		
48
	}
49

  
50
	public WMSOperation(String operationName, String onlineResource) {
51
		super(operationName, onlineResource);		
52
	}
53
	
54
	/*
55
	 * (non-Javadoc)
56
	 * @see org.gvsig.remoteClient.OGCClientOperation#getOperations()
57
	 */
58
	public Hashtable getOperations() {
59
		return operations;
60
	}
61
}
62

  
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.250/org.gvsig.raster.wms.remoteclient/src/main/java/org/gvsig/remoteclient/wms/WMSStyle.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

  
25
package org.gvsig.remoteclient.wms;
26

  
27
import java.io.IOException;
28

  
29
import org.kxml2.io.KXmlParser;
30
import org.xmlpull.v1.XmlPullParserException;
31

  
32
import org.gvsig.remoteclient.utils.CapabilitiesTags;
33

  
34
/**
35
 * <p>Defines a OGC style. Theme that describes the appeareance of certain layer.</p>
36
 *
37
 */
38
public abstract class WMSStyle {
39

  
40
	//style name, defined in the WMS capabilities
41
	private String name;
42
	//style title, defined in the WMS capabilities
43
	private String title;
44
	// style abstract, defined in the WMS capabilities
45
    private String styleAbstract;
46

  
47
    private org.gvsig.remoteclient.wms.WMSStyle.LegendURL legendURL;
48

  
49
    /**
50
     * <p>Parses the STYLE tag in the WMS capabilities, filling the WMSStyle object
51
     * loading the data in memory to be easily accesed</p>
52
     *
53
     */
54
    public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException;
55

  
56
    /**
57
     * Parses the legendURL tag.
58
     * @param parser
59
     * @throws IOException
60
     * @throws XmlPullParserException
61
     */
62
    protected void parseLegendURL(KXmlParser parser) throws IOException, XmlPullParserException
63
    {
64
    	int currentTag;
65
    	boolean end = false;
66

  
67
    	parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.LEGENDURL);
68

  
69
    	String value = new String();
70
    	legendURL = new LegendURL();
71

  
72
    	//First of all set whether the layer is Queryable reading the attribute.
73
    	value = parser.getAttributeValue("", CapabilitiesTags.WIDTH);
74
    	if (value != null)
75
    	{
76
    		legendURL.width = Integer.parseInt( value );
77
    	}
78
    	value = parser.getAttributeValue("", CapabilitiesTags.HEIGHT);
79
    	if (value != null)
80
    	{
81
    		legendURL.height = Integer.parseInt( value );
82
    	}
83
    	currentTag = parser.nextTag();
84

  
85
    	while (!end)
86
    	{
87
    		switch(currentTag)
88
    		{
89
    		case KXmlParser.START_TAG:
90
    			if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0)
91
    			{
92
    				legendURL.format = parser.nextText();
93
    			}
94
    			else if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0)
95
    			{
96
    				value = parser.getAttributeValue("", CapabilitiesTags.XLINK_TYPE);
97
    				if (value != null)
98
    					legendURL.onlineResource_type = value;
99
    				value = parser.getAttributeValue("", CapabilitiesTags.XLINK_HREF);
100
    				if (value != null)
101
    					legendURL.onlineResource_href = value;
102
    			}
103
    			break;
104
    		case KXmlParser.END_TAG:
105
    			if (parser.getName().compareTo(CapabilitiesTags.LEGENDURL) == 0)
106
    				end = true;
107
    			break;
108
    		case KXmlParser.TEXT:
109
    			break;
110
    		}
111
    		if (!end)
112
    		{
113
    			currentTag = parser.next();
114
    		}
115
    	}
116
    	parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.LEGENDURL);
117
    }
118

  
119
    /**
120
     * gets the LegendURL OnlineResource type
121
     */
122
    public String getLegendURLOnlineResourceType()
123
    {
124
    	if (legendURL != null)
125
    	{
126
    		return legendURL.onlineResource_type;
127
    	}
128
    	else
129
    	{
130
    		return null;
131
    	}
132
    }
133

  
134
    /**
135
     * gets the LegendURL OnlineResource href
136
     */
137
    public String getLegendURLOnlineResourceHRef()
138
    {
139
    	if (legendURL != null)
140
    	{
141
    		return legendURL.onlineResource_href;
142
    	}
143
    	else
144
    	{
145
    		return null;
146
    	}
147
    }
148
    public String getLegendURLFormat()
149
    {
150
    	if (legendURL != null)
151
    	{
152
    		return legendURL.format;
153
    	}
154
    	else
155
    	{
156
    		return null;
157
    	}
158
    }
159
    public int getLegendURLWidth()
160
    {
161
    	if (legendURL != null)
162
    	{
163
    		return legendURL.width;
164
    	}
165
    	return 0;
166
    }
167
    public int getLegendURLHeight()
168
    {
169
    	if (legendURL != null)
170
    	{
171
    		return legendURL.height;
172
    	}
173
    	return 0;
174
    }
175

  
176
    /**
177
     * sets LegendURL
178
     */
179
    protected void setLegendURL(LegendURL legendURL)
180
    {
181
    	this.legendURL = legendURL;
182
    }
183

  
184
    /**
185
     * <p>gets the style name</p>
186
     *
187
     * @return style name
188
     */
189
    public String getName() {
190
    	return name;
191
    }
192

  
193
    /**
194
     * <p>sets the style name.</p>
195
     *
196
     * @param _name
197
     */
198
    public void setName(String _name) {
199
    	name = _name;
200
    }
201

  
202
    /**
203
     * <p>gets the style title</p>
204
     *
205
     *
206
     * @return style title
207
     */
208
    public String getTitle() {
209
    	return title;
210
    }
211

  
212
    /**
213
     * <p>Sets style title</p>
214
     *
215
     *
216
     * @param _title
217
     */
218
    public void setTitle(String _title) {
219
    	title = _title.trim();
220
    }
221

  
222
    /**
223
     * <p>gets style abstract</p>
224
     *
225
     *
226
     * @return style abstract
227
     */
228
    public String getAbstract() {
229
    	return styleAbstract;
230
    }
231

  
232
    /**
233
     * <p>sets style abstract</p>
234
     *
235
     *
236
     * @param _abstract, style abstract
237
     */
238
    public void setAbstract(String _abstract) {
239
    	styleAbstract = _abstract;
240
    }
241

  
242
    /**
243
     * <p>Inner class describing the Legend URL defined for styles in the OGC specifications in WMS</p>
244
     *
245
     */
246
    protected class LegendURL
247
    {
248
    	public LegendURL()
249
    	{
250
    		width = 0;
251
    		height= 0;
252
    		format = new String();
253
    		onlineResource_type = new String();
254
    		onlineResource_href = new String();
255
    	}
256

  
257
    	public int width;
258
    	public int height;
259
    	public String format;
260
    	public String onlineResource_type;
261
    	public String onlineResource_href;
262
    }
263
}
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.250/org.gvsig.raster.wms.remoteclient/src/main/java/org/gvsig/remoteclient/wms/wms_1_3_0/WMSProtocolHandler1_3_0.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

  
25
package org.gvsig.remoteclient.wms.wms_1_3_0;
26

  
27
import java.io.ByteArrayInputStream;
28
import java.io.File;
29
import java.io.IOException;
30
import java.util.ArrayList;
31
import java.util.Collection;
32
import java.util.Enumeration;
33
import java.util.TreeMap;
34

  
35
import org.kxml2.io.KXmlParser;
36
import org.xmlpull.v1.XmlPullParserException;
37
import org.gvsig.compat.net.ICancellable;
38
import org.gvsig.remoteclient.epsg.CrsAxisOrder;
39
import org.gvsig.remoteclient.utils.BoundaryBox;
40
import org.gvsig.remoteclient.utils.CapabilitiesTags;
41
import org.gvsig.remoteclient.utils.EncodingXMLParser;
42
import org.gvsig.remoteclient.utils.ExceptionTags;
43
import org.gvsig.remoteclient.wms.WMSLayer;
44
import org.gvsig.remoteclient.wms.WMSServiceInformation;
45
import org.gvsig.remoteclient.wms.WMSStatus;
46
import org.gvsig.remoteclient.wms.request.WMSGetCapabilitiesRequest;
47
import org.gvsig.remoteclient.wms.request.WMSGetFeatureInfoRequest;
48
import org.gvsig.remoteclient.wms.request.WMSGetLegendGraphicRequest;
49
import org.gvsig.remoteclient.wms.request.WMSGetMapRequest;
50
import org.gvsig.remoteclient.wms.wms_1_1_1.WMSProtocolHandler1_1_1;
51
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetCapabilitiesRequest1_3_0;
52
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetFeatureInfoRequest1_1_3;
53
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetLegendGraphicRequest1_1_3;
54
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetMapRequest1_1_3;
55
import org.slf4j.Logger;
56
import org.slf4j.LoggerFactory;
57

  
58
/**
59
 * <p>
60
 * Describes the handler to comunicate to a WMS 1.3.0
61
 * </p>
62
 */
63
public class WMSProtocolHandler1_3_0 extends org.gvsig.remoteclient.wms.WMSProtocolHandler {
64

  
65
        private static final Logger logger = LoggerFactory.getLogger(WMSProtocolHandler1_3_0.class);
66
	private WMSLayer1_3_0 fakeRootLayer;
67

  
68
	public WMSProtocolHandler1_3_0()
69
	{
70
		this.version = "1.3.0";
71
		this.name = "WMS1.3.0";
72
		this.serviceInfo = new WMSServiceInformation();
73
		this.layers = new TreeMap();
74
	}
75

  
76
//------------------------------------------------------------------------------
77
// Parsing methods....
78
//------------------------------------------------------------------------------
79

  
80
	@Override
81
	public void getCapabilities(WMSStatus status, boolean override,
82
			ICancellable cancel) {
83
		super.getCapabilities(status, override, cancel);
84
		if (rootLayer!=null && status!=null && !status.isXyAxisOrder()) {
85
			/*	WMSLayer parser gets no information about the user preferences regarding
86
	 			axis order, so the bboxes should be post-processed here,
87
	 			where we get the user preference from the WMSStatus
88
			 */
89
			processLayer(rootLayer);
90
		}
91
	}
92

  
93
	/**
94
	 * WMSLayer parser gets no information about the user preferences regarding
95
	 * axis order, so the bboxes should be should be post-processed here,
96
	 * where we get the information from  at the
97
	 * protocol hanlder
98
	 * @param layer
99
	 */
100
	protected void processLayer(WMSLayer layer) {
101
        if (layer.getBboxes()!=null) {
102
            Collection<BoundaryBox> col = (Collection<BoundaryBox>) layer.getBboxes().values();
103
            for (BoundaryBox bbox: col) {
104
                if (!CrsAxisOrder.isXyAxisOrder(bbox.getSrs())) {
105
                    double auxX = bbox.getXmin();
106
                    double auxY = bbox.getYmin();
107
                    bbox.setXmin(auxY);
108
                    bbox.setYmin(auxX);
109
                    auxX = bbox.getXmax();
110
                    auxY = bbox.getYmax();
111
                    bbox.setXmax(auxY);
112
                    bbox.setYmax(auxX);
113
                }
114
            }
115
        }
116
        ArrayList children = layer.getChildren();
117
        if (children!=null) {
118
            for (int i=0; i<children.size(); i++) {
119
                WMSLayer child = (WMSLayer) children.get(i);
120
                processLayer(child);
121
            }
122
        }
123
    }
124

  
125
    public boolean parseCapabilities(File f)
126
    {
127
    	rootLayer = null;
128

  
129
    	int tag;
130
      	EncodingXMLParser kxmlParser = null;
131
    	kxmlParser = new EncodingXMLParser();
132
    	try
133
    	{
134
    	   	kxmlParser.setInput(f);
135
			kxmlParser.nextTag();
136
    		if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT )
137
    		{
138
    			kxmlParser.require(KXmlParser.START_TAG, null, CapabilitiesTags.CAPABILITIES_ROOT1_3_0);
139
    			tag = kxmlParser.nextTag();
140
				 while(tag != KXmlParser.END_DOCUMENT)
141
				 {
142
                     switch(tag)
143
					 {
144
						case KXmlParser.START_TAG:
145
							if (kxmlParser.getName().compareTo(CapabilitiesTags.SERVICE )==0)
146
							{
147
								parseServiceTag(kxmlParser);
148
							}
149
							else if (kxmlParser.getName().compareTo(CapabilitiesTags.CAPABILITY)==0)
150
							{
151
								parseCapabilityTag(kxmlParser);
152
							}
153
							break;
154
						case KXmlParser.END_TAG:
155
							break;
156
						case KXmlParser.TEXT:
157
							//System.out.println("[TEXT]["+kxmlParser.getText()+"]");
158
						break;
159
					 }
160
    				 tag = kxmlParser.next();
161
    			 }//while !END_DOCUMENT
162
    		}
163
    	}
164
    	catch(XmlPullParserException parser_ex){
165
                logger.warn("Error parsing capabilites.",parser_ex);
166
    		return false;
167
    	}
168
   		catch (IOException ioe) {
169
                        logger.warn("Error parsing capabilites.",ioe);
170
   			return false;
171
 		} finally {
172
            return true;
173
        }
174
   		// In the parsing process the layer has been filled
175
    }
176

  
177
    /**
178
     * <p>Parses the Service Information </p>
179
     */
180
    private void parseServiceTag(KXmlParser parser) throws IOException, XmlPullParserException
181
    {
182
    	int currentTag;
183
    	boolean end = false;
184

  
185
    	parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.SERVICE);
186
    	currentTag = parser.next();
187

  
188
    	while (!end)
189
    	{
190
			 switch(currentTag)
191
			 {
192
				case KXmlParser.START_TAG:
193
					if (parser.getName().compareTo(CapabilitiesTags.NAME)==0)
194
					{
195
						serviceInfo.name = parser.nextText();
196
					}
197
					else if (parser.getName().compareTo(CapabilitiesTags.TITLE)==0)
198
					{
199
						serviceInfo.title = parser.nextText();
200
					}
201
					else if (parser.getName().compareTo(CapabilitiesTags.ABSTRACT)==0)
202
					{
203
						serviceInfo.abstr = parser.nextText();
204
					}
205
					else if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0)
206
					{
207
				    	String value = new String();
208
				        value = parser.getAttributeValue("", CapabilitiesTags.XLINK_HREF);
209
				        if (value != null){
210
				        	serviceInfo.online_resource = value;
211
				        }
212
					}
213
					else if ((parser.getName().compareTo(CapabilitiesTags.KEYWORDLIST)==0) ||
214
							(parser.getName().compareTo(CapabilitiesTags.CONTACTINFORMATION)==0))
215
					{
216
						parser.skipSubTree();
217
					}
218
					break;
219
				case KXmlParser.END_TAG:
220
					if (parser.getName().compareTo(CapabilitiesTags.SERVICE) == 0)
221
						end = true;
222
					break;
223
				case KXmlParser.TEXT:
224
				break;
225
			 }
226
             if (!end)
227
                 currentTag = parser.next();
228
    	}
229
    	parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.SERVICE);
230
    }
231

  
232
    /**
233
     * <p>Parses the Capability Tag </p>
234
     */
235
    private void parseCapabilityTag(KXmlParser parser) throws IOException, XmlPullParserException
236
    {
237
    	int currentTag;
238
    	boolean end = false;
239

  
240
    	parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.CAPABILITY);
241
    	currentTag = parser.next();
242

  
243
    	while (!end)
244
    	{
245
			 switch(currentTag)
246
			 {
247
				case KXmlParser.START_TAG:
248
					if (parser.getName().compareTo(CapabilitiesTags.REQUEST)==0)
249
					{
250
						parseRequestTag(parser);
251
					}
252
					else if (parser.getName().compareTo(CapabilitiesTags.EXCEPTION)==0)
253
					{
254
						//TODO:
255
						//Add to serviceInformation the supported exception formats.
256
					}
257
					else if (parser.getName().compareTo(CapabilitiesTags.LAYER)==0)
258
					{
259
						WMSLayer1_3_0 lyr = new WMSLayer1_3_0();
260
                        if (rootLayer == null)
261
                            rootLayer = lyr;
262
                        else {
263
                            // Handles when there is no general root layer, will use
264
                            // a fake non-queryable one.
265
                            if (!rootLayer.equals(getFakeRootLayer())){
266
                                WMSLayer1_3_0 aux = (WMSLayer1_3_0) rootLayer;
267
                                rootLayer  = getFakeRootLayer();
268
                                rootLayer.getChildren().add(aux);
269
                            }
270
                            rootLayer.getChildren().add(lyr);
271
                        }
272
						lyr.parse(parser, layers);
273

  
274
                        if (lyr.getName()!=null)
275
						    layers.put(lyr.getName(), lyr);
276
					}
277
					else if ((parser.getName().compareTo(CapabilitiesTags.VENDORSPECIFICCAPABILITIES)==0) ||
278
							(parser.getName().compareTo(CapabilitiesTags.USERDEFINEDSYMBOLIZATION )==0))
279
					{
280
						parser.skipSubTree();
281
					}
282
					break;
283
				case KXmlParser.END_TAG:
284
					if (parser.getName().compareTo(CapabilitiesTags.CAPABILITY) == 0)
285
						end = true;
286
					break;
287
				case KXmlParser.TEXT:
288
				break;
289
			 }
290
			 if (!end)
291
				 currentTag = parser.next();
292
    	}
293
    	//parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.CAPABILITY);
294
    }
295

  
296
    private WMSLayer1_3_0 getFakeRootLayer(){
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff