Revision 9374

View differences:

org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.80/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.80/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.80/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.80/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.80/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.80/org.gvsig.raster.wms.remoteclient/src/main/java/org/gvsig/remoteclient/wms/WMSLayer.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.IOException;
27
import java.util.ArrayList;
28
import java.util.Hashtable;
29
import java.util.TreeMap;
30
import java.util.Vector;
31

  
32
import org.kxml2.io.KXmlParser;
33
import org.xmlpull.v1.XmlPullParserException;
34

  
35
import org.gvsig.remoteclient.utils.BoundaryBox;
36
import org.gvsig.remoteclient.utils.CapabilitiesTags;
37

  
38
/**
39
 * <p>Abstract class that defines an WMSLayer.</p>
40
 *
41
 */
42
public abstract class WMSLayer implements org.gvsig.remoteclient.ILayer {
43

  
44
    protected ArrayList children;
45
    protected WMSLayer parent;
46

  
47
    /**
48
     * <p>Layer Abstract field in the capabilities document </p>
49
     */
50
    private String layerAbstract;
51

  
52
    /**
53
     * <p>Themes provided by the WMS for the layer</p>
54
     */
55
    public ArrayList styles = new ArrayList();
56

  
57
    /**
58
     * <p>Layer name</p>
59
     */
60
    private String name;
61

  
62
    /**
63
     * <p>Layer title</p>
64
     */
65
    private String title;
66

  
67
    private ArrayList keywordList = new ArrayList();
68
    /**
69
     * <p>CRS list of this layer (Tag CRS)</p>
70
     */
71
    protected Vector srs = new Vector();
72

  
73
    /**
74
     * <p>Bounding box por CRS (Tag BoundingBox)</p>
75
     */
76
    private Hashtable bBoxes  = new Hashtable();
77

  
78
    /**
79
     * <p>extents that defines the bbox for the LatLon projection
80
     * It can be included in the bBoxes vector as well, because it is the most used, we keep it separeted too, according
81
     *  with the OGC WMSCapabilities specifications...
82
     */
83
    private org.gvsig.remoteclient.utils.BoundaryBox latLonBbox;
84

  
85
    /**
86
     * <p>min scale for the layer to be visible</p>
87
     */
88
    private double scaleMin;
89

  
90
    /**
91
     * <p>max scale for the layer to be visible</p>
92
     */
93
    private double scaleMax;
94

  
95
    /**
96
     * <p>Dimensions defined for the layer in the capabilities doc</p>
97
     */
98
    protected java.util.ArrayList dimensions = new ArrayList();
99

  
100
    /**
101
     * Tells if this layer accepts getFeatureInfo requests.
102
     */
103
    private boolean queryable = false;
104

  
105
    /**
106
     * Tells if this layer is opaque.
107
     */
108
    private boolean opaque = false;
109
    /**
110
     * when set to true, noSubsets indicates that the server is not able to make a map
111
     * of a geographic area other than the layer's bounding box.
112
     */
113
    private boolean m_noSubSets = false;
114

  
115
    /**
116
     * when present and non-zero fixedWidth and fixedHeight indicate that the server is not
117
     * able to produce a map of the layer at a width and height different from the fixed sizes indicated.
118
     */
119
    private int fixedWidth = 0;
120
    private int fixedHeight = 0;
121

  
122
    /**
123
     * Tells if this layer can be served with transparency.
124
     */
125
    private boolean transparency;
126

  
127
    /**
128
     * <p>Parses the LAYER tag in the WMS capabilities, filling the WMSLayer object
129
     * loading the data in memory to be easily accesed</p>
130
     *
131
     */
132
    public abstract void parse(KXmlParser parser, TreeMap layerTreeMap)
133
    throws IOException, XmlPullParserException;
134

  
135
    //public abstract ArrayList getAllDimensions();
136

  
137
    /**
138
     * add a new keyword to the keywordList.
139
     * @param key
140
     */
141
    protected void addkeyword(String key) {
142
    	keywordList.add(key);
143
    }
144
    
145
    public ArrayList getKeywords() {
146
    	return keywordList;
147
    }
148
    
149
    /**
150
     * <p>Adds a style to the styles vector</p>
151
     * @param _style
152
     */
153
    public void addStyle(org.gvsig.remoteclient.wms.WMSStyle _style) {
154
        styles.add( _style );    
155
    }
156

  
157
    /**
158
     * <p>Gets the style vector</p>
159
     * @return
160
     */
161
    public ArrayList getStyles() {
162
    	ArrayList list = new ArrayList();
163
    	if (styles != null)
164
    		list.addAll(styles);
165
    	if (this.getParent()!= null) {
166
    		//return getAllStyles(this);
167
    		if(this.getParent().getStyles() != null)
168
    			list.addAll(this.getParent().getStyles());
169
    	}
170
        return list;
171
    }
172

  
173
    public ArrayList getAllStyles(WMSLayer layer) {
174
    	if (layer.getParent()!= null) {
175
    		ArrayList list = getAllStyles(layer.getParent());
176
    		for(int i = 0; i < this.styles.size(); i++) {
177
    			list.add(styles.get(i));
178
    		}
179
    		return list;
180
    	} else {
181
    		return styles;
182
    	}
183
    }
184
    
185
    /**
186
     * <p>Adds a bbox to the Bboxes vector</p>
187
     * @param bbox
188
     */
189
    public void addBBox(BoundaryBox bbox) {
190
        bBoxes.put(bbox.getSrs(), bbox);
191
    }
192

  
193
    /**
194
     * <p>returns the bbox with that id in the Bboxes vector</p>
195
     * @param id
196
     */
197
    public BoundaryBox getBbox(String id) {
198
    	//Si hay una bounding box definida para esa capa y ese crs, se usa esa
199
    	BoundaryBox b = (BoundaryBox) bBoxes.get(id);
200
    	if(b != null)
201
    		return b;
202
    	
203
    	if ((id.compareToIgnoreCase( CapabilitiesTags.EPSG_4326 )==0)
204
    		||(id.compareToIgnoreCase( CapabilitiesTags.CRS_84)==0)) {
205
    		if (latLonBbox != null)
206
    		return (BoundaryBox)latLonBbox;
207
    	}
208
        
209
        if (parent!=null)
210
            return parent.getBbox(id);
211
        return null;
212
    }
213

  
214
    /**
215
     * <p>Gets the bBoxes vector</p>
216
     * @return
217
     */
218
    public Hashtable getBboxes() {
219
        return bBoxes;
220
    }
221

  
222

  
223
    //Methods to manipulate the box that defines the layer extent in LatLon SRS.
224
    public BoundaryBox getLatLonBox() {
225
        return latLonBbox;
226
    }
227
    
228
    public void setLatLonBox(BoundaryBox box) {
229
        latLonBbox = box;
230
    }
231
    
232
    /**
233
     * <p>adds a new srs to the srs vector</p>
234
     */
235
    public void addSrs(String srs) {
236
    	if (!this.srs.contains(srs))
237
    		this.srs.add(srs);
238
    }
239
    
240
    public void removeSrs(String srs) {
241
   		this.srs.remove(srs);
242
    }
243

  
244
    public Vector getAllSrs() {
245
        Vector mySRSs = (Vector) this.srs.clone();
246
        if (parent!=null)
247
            mySRSs.addAll(parent.getAllSrs());
248
        return mySRSs;
249
    }
250

  
251
    /**
252
     * <p>gets the maximum scale for this layer</p>
253
     * @return
254
     */
255
    public double getScaleMax() {
256
        return scaleMax;
257
    }
258

  
259
    /**
260
     * <p>gets the minimum scale for this layer</p>
261
     * @return
262
     */
263
    public double getScaleMin() {
264
        return scaleMin;
265
    }
266

  
267
    /**
268
     * <p>sets the minimum scale for this layer to be visible.</p>
269
     *
270
     * @param scale
271
     */
272
    public void setScaleMin(double scale) {
273
        scaleMin = scale;
274
    }
275

  
276
    /**
277
     * <p>sets the maximum scale for this layer to be visible</p>
278
     * @param scale
279
     */
280
    public void setScaleMax(double scale) {
281
        scaleMax = scale;
282
    }
283

  
284
    /**
285
     * <p> gets the dimension vector defined in this layer</p>
286
     * @return
287
     */
288
    public abstract ArrayList getDimensions();
289

  
290
    public WMSDimension getDimension(String name) {
291
    	for(int i = 0; i < dimensions.size(); i++ ) {
292
    		if(((WMSDimension)dimensions.get(i)).getName().compareTo(name) == 0) {
293
    			return (WMSDimension)dimensions.get(i);
294
    		}
295
    	}
296
    	return null;
297
    }
298

  
299
    /**
300
     * <p>Adds a dimension to the dimension vector </p>
301
     * @param dimension
302
     */
303
    public void addDimension(org.gvsig.remoteclient.wms.WMSDimension dimension) {
304
        dimensions.add(dimension);
305
    }
306

  
307
    /**
308
     * <p>Gets layer name</p>
309
     * @return
310
     */
311
    public String getName() {
312
        return this.name;
313
    }
314

  
315
    /**
316
     * <p>Sets layer name</p>
317
     * @param _name
318
     */
319
    public void setName(String name) {
320
        this.name = name;
321
    }
322

  
323
    /**
324
     * <p>Gets layer title</p>
325
     * @return
326
     */
327
    public String getTitle() {
328
        return title;
329
    }
330

  
331
    /**
332
     * <p>Sets the layer title</p>
333
     * @param _title
334
     */
335
    public void setTitle(String title) {
336
        this.title = title;
337
    }
338

  
339
    /**
340
     * <p>Gets the layer abstract</p>
341
     * @return
342
     */
343
    public String getAbstract() {
344
        return layerAbstract;
345
    }
346

  
347
    /**
348
     * <p>Sets the layer abstract</p>
349
     * @param m_abstract
350
     */
351
    public void setAbstract(String _abstract) {
352
        layerAbstract = _abstract;
353
    }
354

  
355

  
356
    public ArrayList getChildren() {
357
        return children;
358
    }
359

  
360

  
361
    public void setChildren(ArrayList children) {
362
        this.children = children;
363
    }
364

  
365

  
366
    public WMSLayer getParent() {
367
        return parent;
368
    }
369

  
370

  
371
    public void setParent(WMSLayer parent) {
372
        this.parent = parent;
373
    }
374

  
375
    public String toString(){
376
        return this.getTitle();
377
    }
378

  
379

  
380
    /**
381
     * Tells if this layer accepts getFeatureInfo requests.
382
     */
383
    public boolean isQueryable() {
384
        return queryable;
385
    }
386

  
387

  
388
    /**
389
     * @param queryable The queryable to set.
390
     */
391
    public void setQueryable(boolean queryable) {
392
        this.queryable = queryable;
393
    }
394

  
395
    /**
396
     * Tells if this layer is opaque.
397
     */
398
    public boolean isOpaque() {
399
        return opaque;
400
    }
401
    /**
402
     * @param opaque.
403
     */
404
    public void setOpaque(boolean opaque) {
405
        this.opaque = opaque;
406
    }
407

  
408
    /**
409
     * Tells if this layer is subsettable
410
     */
411
    public boolean noSubSets() {
412
        return this.m_noSubSets;
413
    }
414
    /**
415
     * @param set layer nosubsets attribute.
416
     */
417
    public void setNoSubSets(boolean _noSubSets) {
418
        m_noSubSets = _noSubSets;
419
    }
420

  
421
    public void setfixedWidth(int w) {
422
        fixedWidth = w;
423
    }
424

  
425
    public int getfixedWidth() {
426
        return fixedWidth;
427
    }
428

  
429
    public void setfixedHeight(int h) {
430
        fixedHeight = h;
431
    }
432

  
433
    public int getfixedHeight() {
434
        return fixedHeight;
435
    }
436

  
437
    /**
438
     * @return <b>true</b> if this layer can be served with transparency, otherwise <b>false</b>
439
     */
440
    public boolean hasTransparency() {
441
        return transparency;
442
    }
443

  
444
    //Methods to parse tags that are common to several versions of WMS.
445
    //In case there is a version which has different implemantation of one of this tags
446
    // the subclass can overwrite this method
447

  
448
    /**
449
     * Parses the keywordlist from the capabilities and fills this list in the WMSLayer.
450
     * @param parser
451
     */
452
    protected void parseKeywordList(KXmlParser parser)  throws IOException, XmlPullParserException {
453
    	int currentTag;
454
    	boolean end = false;
455
    	String value;
456

  
457
    	parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.KEYWORDLIST);
458
    	currentTag = parser.nextTag();
459

  
460
        while (!end) {
461
			 switch(currentTag) {
462
				case KXmlParser.START_TAG:
463
					if (parser.getName().compareTo(CapabilitiesTags.KEYWORD) == 0) {
464
						value = parser.nextText();
465
						if ((value != null) && (value.length() > 0 ))
466
							addkeyword(value);
467
					}
468
					break;
469
				case KXmlParser.END_TAG:
470
					if (parser.getName().compareTo(CapabilitiesTags.KEYWORDLIST) == 0)
471
						end = true;
472
					break;
473
				case KXmlParser.TEXT:
474
					break;
475
			 }
476
			 if (!end) {
477
				 currentTag = parser.next();
478
			 }
479
    	}
480
    	parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.KEYWORDLIST);
481
    }
482

  
483
    /**
484
     * Reads and parses the layer attributes
485
     * Maybe this method should be moved to the WMSLayer. Until now the attributes are teh same for all versions.
486
     * @param parser
487
     */
488
    protected void readLayerAttributes(KXmlParser parser) {
489
    	String value = new String();
490

  
491
        //First of all set whether the layer is Queryable reading the attribute.
492
        value = parser.getAttributeValue("", CapabilitiesTags.QUERYABLE);
493
        if (value != null) {
494
            if (value.compareTo("0") == 0)
495
                setQueryable(false);
496
            else
497
                setQueryable(true);
498
        }
499
        value = parser.getAttributeValue("", CapabilitiesTags.OPAQUE);
500
        if (value != null) {
501
            if (value.compareTo("0") == 0)
502
                setOpaque(false);
503
            else
504
                setOpaque(true);
505
        }
506
        value = parser.getAttributeValue("", CapabilitiesTags.NOSUBSETS);
507
        if (value != null) {
508
            if (value.compareTo("0") == 0)
509
                setNoSubSets(false);
510
            else
511
            	setNoSubSets(true);
512
        }
513
        value = parser.getAttributeValue("", CapabilitiesTags.FIXEDWIDTH);
514
        if (value != null) {
515
        	setfixedWidth(Integer.parseInt(value));
516
        }
517
        value = parser.getAttributeValue("", CapabilitiesTags.FIXEDHEIGHT);
518
        if (value != null) {
519
        	setfixedHeight(Integer.parseInt(value));
520
        }
521
    }
522

  
523

  
524
    /**
525
     * <p>Inner class describing the MetadataURL tag in OGC specifications in WMS</p>
526
     *
527
     */
528
    protected class MetadataURL {
529
    	public MetadataURL() {
530
    		type = new String();
531
    		format = new String();
532
    		onlineResource_xlink = new String();
533
    		onlineResource_type = new String();
534
    		onlineResource_href = new String();
535
    	}
536
        public String type;
537
        public String format;
538
        public String onlineResource_xlink;
539
        public String onlineResource_type;
540
        public String onlineResource_href;
541
     }
542

  
543
    /**
544
     * <p>Inner class describing the DataURL tag in OGC specifications in WMS</p>
545
     *
546
     */
547
    protected class DataURL {
548
    	public DataURL() {
549
    		type = new String();
550
    		format = new String();
551
    		onlineResource_xlink = new String();
552
    		onlineResource_type = new String();
553
    		onlineResource_href = new String();
554
    	}
555
        public String type;
556
        public String format;
557
        public String onlineResource_xlink;
558
        public String onlineResource_type;
559
        public String onlineResource_href;
560
     }
561
}
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.80/org.gvsig.raster.wms.remoteclient/src/main/java/org/gvsig/remoteclient/wms/WMSClient.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.awt.geom.Rectangle2D;
28
import java.io.File;
29
import java.io.IOException;
30
import java.net.ConnectException;
31
import java.net.URL;
32
import java.util.TreeMap;
33
import java.util.Vector;
34
import org.apache.commons.lang3.StringUtils;
35

  
36
import org.gvsig.compat.net.ICancellable;
37
import org.gvsig.remoteclient.exceptions.ServerErrorException;
38
import org.gvsig.remoteclient.exceptions.WMSException;
39
import org.gvsig.remoteclient.utils.BoundaryBox;
40
import org.slf4j.Logger;
41
import org.slf4j.LoggerFactory;
42

  
43

  
44
/**
45
 * <p>Represents the class the with the necessary logic to connect to a OGCWMS and interpretate the data </p>
46
 * 
47
 */
48
public class WMSClient extends org.gvsig.remoteclient.RasterClient {
49
    
50
    private static final Logger logger = LoggerFactory.getLogger(WMSClient.class);
51
    private org.gvsig.remoteclient.wms.WMSProtocolHandler handler;
52
//    private TreeMap layers = new TreeMap();
53
//    private WMSLayer rootLayer;
54
    
55
    /**
56
     * @return Returns the rootLayer.
57
     */
58
    public WMSLayer getRootLayer() {
59
        return handler.rootLayer;
60
    }
61

  
62
    /**
63
     * Constructor.
64
     * the parameter host, indicates the WMS host to connect.
65
     * */
66
    public WMSClient(String host) throws ConnectException, IOException 
67
    {
68
    	setHost(host);
69
        try {        	
70
        	handler = WMSProtocolHandlerFactory.negotiate(host);
71
        	handler.setHost(host);        
72
        } catch(ConnectException conE) {
73
                logger.warn("Can't create WMS protocol handler for host '"+host+"'.",conE);
74
        	throw conE; 
75
        } catch(IOException ioE) {
76
                logger.warn("Can't create WMS protocol handler for host '"+host+"'.",ioE);
77
        	throw ioE; 
78
        } catch(Exception e) {
79
                logger.warn("Can't create WMS protocol handler for host '"+host+"'.",e);
80
        }
81
    }
82
    
83
    public String getVersion()
84
    {
85
        return handler.getVersion();
86
    }
87
    /**
88
     * <p>One of the three interfaces that OGC WMS defines. Request a map.</p> 
89
     * @throws ServerErrorException 
90
     */
91
    public File getMap(WMSStatus status, ICancellable cancel) throws WMSException, ServerErrorException{   
92
        return handler.getMap(status, cancel);
93
    } 
94
    
95
    /**
96
     * <p>Gets the GetMap URL. The final client should download the file</p> 
97
     * @throws ServerErrorException 
98
     */
99
    public URL getGetMapURL(WMSStatus status, ICancellable cancel) throws WMSException, ServerErrorException{   
100
       return handler.getMapURL(status, cancel);
101
    } 
102
    
103
    /**
104
     * Returns the exception message if the file is a XML instead of a image.
105
     * @param file
106
     * @return
107
     * @throws IOException 
108
     */
109
    public String getExceptionMessage(File file) throws IOException {
110
    	return handler.getExceptionMessage(file);
111
    }
112
    
113
    /**
114
     * <p>One of the three interfaces defined by OGC WMS, it gets the service capabilities</p>
115
     * @param override, if true the previous downloaded data will be overridden
116
     */
117
    public void getCapabilities(WMSStatus status, boolean override, ICancellable cancel) {        
118
        handler.getCapabilities(status, override, cancel);
119
    } 
120
    
121
    /**
122
     * <p>One of the three interfaces defined by the OGC WMS, it gets the information about a feature requested</p>
123
     * @return 
124
     */
125
    public String getFeatureInfo(WMSStatus status, int x, int y, int featureCount, ICancellable cancel) throws WMSException{        
126
        return handler.getFeatureInfo(status, x, y, featureCount, cancel);
127
    } 
128
    
129
    /**
130
     * <p>One of the three interfaces defined by the OGC WMS, it gets legend of a layer</p>
131
     * @return 
132
     */
133
    public File getLegendGraphic(WMSStatus status, String layerName, ICancellable cancel) throws WMSException, ServerErrorException{        
134
        return handler.getLegendGraphic(status, layerName, cancel);
135
    } 
136
    
137
    /**
138
     * <p> Reads from the WMS Capabilities, the layers available in the service</p>
139
     * @return a TreeMap with the available layers in the WMS 
140
     */
141
    public TreeMap getLayers() {        
142
        return handler.layers;
143
    } 
144
    
145
    /**
146
     * <p>Reads from the WMS Capabilities the number if layers available in the service</p>
147
     * @return, number of layers available
148
     */
149
    public int getNumberOfLayers() {        
150
        if (handler.layers != null)
151
        {
152
            return handler.layers.size();
153
        }
154
        return 0;
155
    } 
156
    
157
    /**
158
     * <p>Gets the WMSLayer with this name</p>
159
     * 
160
     * @param _name, layer name
161
     * @return the layer with this name
162
     */
163
    public WMSLayer getLayer(String _name) {        
164
        if (handler.layers.get(_name) != null)
165
        {
166
            return (WMSLayer)handler.layers.get(_name);
167
        }
168
        
169
        return null;
170
    } 
171
    
172
    public String[] getLayerNames()
173
    {    	
174
        WMSLayer[] lyrs;
175
        
176
        lyrs = (WMSLayer[])handler.layers.values().toArray(new WMSLayer[0]);
177
        
178
        String[] names = new String[lyrs.length];
179
        
180
        for(int i = 0; i<lyrs.length; i++)
181
        {
182
            names[i] = ((WMSLayer)lyrs[i]).getName();
183
        }
184
        return names;
185
    }
186
    
187
    public String[] getLayerTitles()
188
    {    	
189
        WMSLayer[] lyrs;
190
        
191
        lyrs = (WMSLayer[])handler.layers.values().toArray(new WMSLayer[0]);
192
        
193
        String[] titles = new String[lyrs.length];
194
        
195
        for(int i = 0; i<lyrs.length; i++)
196
        {
197
            titles[i] = ((WMSLayer)lyrs[i]).getTitle();
198
        }
199
        return titles;
200
    }
201
    /**
202
     * <p>Gets the image formats available in the Service to retrieve the maps</p>
203
     * @return a vector with all the available formats
204
     */
205
    public Vector getFormats() {        
206
        return ((WMSServiceInformation)handler.getServiceInformation()).formats;         
207
    } 
208
    
209
    /**
210
     * <p>Gets the information by point formats available in the Service</p>
211
     * @return a vector with all the available formats
212
     */
213
    public Vector getInfoFormats() {        
214
        return ((WMSServiceInformation)handler.getServiceInformation()).infoformats;
215
    } 
216
    
217
    public boolean isQueryable()
218
    {
219
    	return ((WMSServiceInformation)handler.getServiceInformation()).isQueryable();  
220
    }
221
    public boolean hasLegendGraphic()
222
    {
223
    	return ((WMSServiceInformation)handler.getServiceInformation()).hasLegendGraphic();  
224
    }
225
    
226
    public void close() {        
227
        // your code here
228
    } 
229
    
230
    
231
    /**
232
     * Returns the max extent that envolves the requested layers
233
     * */
234
    public Rectangle2D getLayersExtent(String[]layerNames, String srs) {
235
        try {
236
        	if (layerNames == null) {
237
        		return null;
238
        	}
239
        	
240
            BoundaryBox bbox = null;
241
            WMSLayer layer = getLayer(layerNames[0]);
242
            
243
            bbox = layer.getBbox(srs);
244
            if (bbox == null) {
245
            	return null;
246
            }
247
            double xmin = bbox.getXmin();
248
            double xmax = bbox.getXmax();
249
            double ymin = bbox.getYmin();
250
            double ymax = bbox.getYmax();
251
            
252
            for(int i = 1; i < layerNames.length; i++) {
253
                layer = getLayer(layerNames[i]);
254
                bbox = layer.getBbox(srs);
255
                if (bbox == null) return null;
256
                if (bbox.getXmin() < xmin) {
257
                    xmin = bbox.getXmin();
258
                }
259
                if (bbox.getYmin() < ymin) {
260
                    ymin = bbox.getYmin();
261
                }
262
                if (bbox.getXmax() > xmax) {
263
                    xmax = bbox.getXmax();
264
                }
265
                if (bbox.getYmax() > ymax) {
266
                    ymax = bbox.getYmax();
267
                }
268
            }	
269
            
270
            Rectangle2D extent = new Rectangle2D.Double(xmin, ymin, Math.abs(xmax-xmin), Math.abs(ymax-ymin));
271
            return extent;
272
        } catch(Exception e) {
273
            String msg = null;
274
            try {
275
                msg = "Can't get layers extent, layers='"+StringUtils.join(layerNames, ",")+"', srs='"+srs+"'.";
276
            } catch(Exception ex) {
277
                msg = "Can't get layers extent.";
278
            }
279
            logger.warn(msg,e);
280
            return null;
281
        }
282
    }
283
    
284
    
285
    /**
286
     * Gets the Service information included in the Capabilities
287
     * */    
288
    public WMSServiceInformation getServiceInformation()
289
    {
290
        return ((WMSServiceInformation)handler.getServiceInformation());
291
    }
292
    
293
    
294
    /**
295
     * <p>Checks the connection to the remote WMS and requests its capabilities.</p>
296
     * @param override, if true the previous downloaded data will be overridden
297
     * 
298
     * @deprecated Use {@link #connect(WMSStatus, boolean, ICancellable)} instead,
299
     * as the WMSStatus is necessary when connecting in order to correct
300
     * call the getCapabilities method.
301
     */
302
    public boolean connect(boolean override, ICancellable cancel) 
303
    {
304
    	return connect(null, override, cancel);
305
    }
306
    
307
    /**
308
     * <p>Checks the connection to the remote WMS and requests its capabilities.</p>
309
     * <p>This method should probably be moved to RemoteClient interface, as the
310
     * same problem will probably happen for other protocols</p>
311
     * 
312
     * @param override, if true the previous downloaded data will be overridden
313
     */
314
    public boolean connect(WMSStatus status, boolean override, ICancellable cancel) 
315
    {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff