Revision 22774
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.254/org.gvsig.raster.wms.io/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.raster.wms.io</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>org.gvsig.raster.wms.io</name> |
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.raster.wms</artifactId> |
|
10 |
<version>2.2.254</version> |
|
11 |
</parent> |
|
12 |
<dependencies> |
|
13 |
<dependency> |
|
14 |
<groupId>org.gvsig</groupId> |
|
15 |
<artifactId>org.gvsig.raster.cache.lib.api</artifactId> |
|
16 |
<scope>compile</scope> |
|
17 |
</dependency> |
|
18 |
<dependency> |
|
19 |
<groupId>org.gvsig</groupId> |
|
20 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
21 |
<scope>compile</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.raster.lib.impl</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.remoteclient</artifactId> |
|
36 |
<scope>compile</scope> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.raster.wms.remoteclient</artifactId> |
|
41 |
<scope>compile</scope> |
|
42 |
</dependency> |
|
43 |
<dependency> |
|
44 |
<groupId>org.gvsig</groupId> |
|
45 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
46 |
<scope>compile</scope> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.i18n</artifactId> |
|
51 |
<scope>compile</scope> |
|
52 |
</dependency> |
|
53 |
|
|
54 |
<dependency> |
|
55 |
<groupId>org.gvsig</groupId> |
|
56 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
57 |
<scope>compile</scope> |
|
58 |
</dependency> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.projection.cresques.impl</artifactId> |
|
62 |
<scope>runtime</scope> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.compat.api</artifactId> |
|
67 |
<scope>compile</scope> |
|
68 |
</dependency> |
|
69 |
<dependency> |
|
70 |
<groupId>org.gvsig</groupId> |
|
71 |
<artifactId>org.gvsig.compat.se</artifactId> |
|
72 |
<scope>compile</scope> |
|
73 |
</dependency> |
|
74 |
<dependency> |
|
75 |
<groupId>org.gvsig</groupId> |
|
76 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
77 |
<scope>compile</scope> |
|
78 |
</dependency> |
|
79 |
<dependency> |
|
80 |
<groupId>org.gvsig</groupId> |
|
81 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
82 |
<scope>compile</scope> |
|
83 |
</dependency> |
|
84 |
<dependency> |
|
85 |
<groupId>org.gvsig</groupId> |
|
86 |
<artifactId>org.gvsig.fmap.dal.file.lib</artifactId> |
|
87 |
<scope>compile</scope> |
|
88 |
</dependency> |
|
89 |
<dependency> |
|
90 |
<groupId>org.gvsig</groupId> |
|
91 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
92 |
<scope>compile</scope> |
|
93 |
</dependency> |
|
94 |
<dependency> |
|
95 |
<groupId>org.gvsig</groupId> |
|
96 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
97 |
<scope>compile</scope> |
|
98 |
</dependency> |
|
99 |
<!-- |
|
100 |
<dependency> |
|
101 |
<groupId>org.gvsig</groupId> |
|
102 |
<artifactId>org.gvsig.fmap.geometry.generalpath</artifactId> |
|
103 |
<scope>runtime</scope> |
|
104 |
</dependency> |
|
105 |
<dependency> |
|
106 |
<groupId>org.gvsig</groupId> |
|
107 |
<artifactId>org.gvsig.fmap.geometry.operation</artifactId> |
|
108 |
<scope>runtime</scope> |
|
109 |
</dependency> |
|
110 |
--> |
|
111 |
<dependency> |
|
112 |
<groupId>org.gvsig</groupId> |
|
113 |
<artifactId>org.gvsig.downloader.lib.api</artifactId> |
|
114 |
<scope>compile</scope> |
|
115 |
</dependency> |
|
116 |
<dependency> |
|
117 |
<groupId>org.apache.httpcomponents</groupId> |
|
118 |
<artifactId>httpcore</artifactId> |
|
119 |
<scope>compile</scope> |
|
120 |
</dependency> |
|
121 |
</dependencies> |
|
122 |
</project> |
|
0 | 123 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.254/org.gvsig.raster.wms.io/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your test classes. |
|
2 |
|
|
3 |
This folder is added to the Tests classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your tests classes. |
|
0 | 9 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.254/org.gvsig.raster.wms.io/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.wms.io.DefaultWMSIOLibrary |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.254/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/DefaultWMSIOLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.raster.wms.io; |
|
23 |
|
|
24 |
import org.gvsig.i18n.Messages; |
|
25 |
import org.gvsig.raster.wms.io.time.DefaultDimension; |
|
26 |
import org.gvsig.raster.wms.io.time.TimeDimension; |
|
27 |
import org.gvsig.tools.library.AbstractLibrary; |
|
28 |
import org.gvsig.tools.library.LibraryException; |
|
29 |
/** |
|
30 |
* |
|
31 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
32 |
*/ |
|
33 |
public class DefaultWMSIOLibrary extends AbstractLibrary { |
|
34 |
|
|
35 |
/*public DefaultWMSIOLibrary() { |
|
36 |
super(DefaultWMSIOLibrary.class,Library.TYPE.IMPL); |
|
37 |
require(ToolsLibrary.class); |
|
38 |
require(DALLibrary.class); |
|
39 |
require(DALFileLibrary.class); |
|
40 |
}*/ |
|
41 |
|
|
42 |
@Override |
|
43 |
protected void doInitialize() throws LibraryException { |
|
44 |
//RasterLibrary.wakeUp(); |
|
45 |
WMSLayerNode.registerPersistent(); |
|
46 |
RemoteWMSStyle.registerPersistent(); |
|
47 |
DefaultDimension.registerPersistent(); |
|
48 |
TimeDimension.registerPersistent(); |
|
49 |
|
|
50 |
Messages.addResourceFamily("org.gvsig.raster.wms.io.i18n.text", |
|
51 |
DefaultWMSIOLibrary.class.getClassLoader(), |
|
52 |
DefaultWMSIOLibrary.class.getClass().getName()); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
protected void doPostInitialize() throws LibraryException { |
|
57 |
WMSServerExplorerParameters.registerDynClass(); |
|
58 |
WMSDataParametersImpl.registerDynClass(); |
|
59 |
WMSProvider.register(); |
|
60 |
} |
|
61 |
} |
|
0 | 62 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.254/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/WMSLayerNode.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.raster.wms.io; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
import java.util.ArrayList; |
|
26 |
import java.util.Collections; |
|
27 |
import java.util.Comparator; |
|
28 |
import java.util.List; |
|
29 |
import java.util.Objects; |
|
30 |
import org.apache.commons.collections4.CollectionUtils; |
|
31 |
import org.apache.commons.lang3.StringUtils; |
|
32 |
import org.gvsig.raster.wms.io.time.DefaultDimension; |
|
33 |
import org.gvsig.raster.wms.io.time.RemoteTimeDimension; |
|
34 |
import org.gvsig.raster.wms.io.time.TimeDimension; |
|
35 |
import org.gvsig.tools.ToolsLocator; |
|
36 |
import org.gvsig.tools.dynobject.DynStruct; |
|
37 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
38 |
import org.gvsig.tools.persistence.Persistent; |
|
39 |
import org.gvsig.tools.persistence.PersistentState; |
|
40 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
41 |
|
|
42 |
/** |
|
43 |
* Class defining the node of the layer tree of a common WMS service. |
|
44 |
* @author jaume |
|
45 |
*/ |
|
46 |
@SuppressWarnings("unchecked") |
|
47 |
public class WMSLayerNode implements Persistent { |
|
48 |
private String _name = null; |
|
49 |
private String _title = null; |
|
50 |
private List<String> srs = null; |
|
51 |
private boolean queryable; |
|
52 |
private boolean transparency; |
|
53 |
private String lAbstract = null; |
|
54 |
private String latLonBox = null; |
|
55 |
private int selectedStyleIndex = 0; |
|
56 |
private List<RemoteWMSStyle> styles = new ArrayList<RemoteWMSStyle>(); |
|
57 |
private List<RemoteTimeDimension> dimensions = null; |
|
58 |
private List<String> keywords = null; |
|
59 |
private List<WMSLayerNode> children = new ArrayList<WMSLayerNode>(); |
|
60 |
private WMSLayerNode _parent = null; |
|
61 |
private Dimension fixedSize = null; |
|
62 |
|
|
63 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
64 |
this._name = state.getString("_name"); |
|
65 |
this._title = state.getString("_title"); |
|
66 |
this.srs = state.getList("srs"); |
|
67 |
this.queryable = state.getBoolean("queryable"); |
|
68 |
this.transparency = state.getBoolean("transparency"); |
|
69 |
this.lAbstract = state.getString("lAbstract"); |
|
70 |
this.latLonBox = state.getString("latLonBox"); |
|
71 |
this.selectedStyleIndex = state.getInt("selectedStyleIndex"); |
|
72 |
this.styles = state.getList("styles"); |
|
73 |
this.dimensions = state.getList("dimensions"); |
|
74 |
this.keywords = state.getList("keywords"); |
|
75 |
this.children = state.getList("children"); |
|
76 |
this._parent = (WMSLayerNode)state.get("_parent"); |
|
77 |
this.fixedSize = (Dimension)state.get("fixedSize"); |
|
78 |
} |
|
79 |
|
|
80 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
81 |
state.set("_name", _name); |
|
82 |
state.set("_title", _title); |
|
83 |
state.set("srs", srs); |
|
84 |
state.set("queryable", queryable); |
|
85 |
state.set("transparency", transparency); |
|
86 |
state.set("lAbstract", lAbstract); |
|
87 |
state.set("latLonBox", latLonBox); |
|
88 |
state.set("selectedStyleIndex", selectedStyleIndex); |
|
89 |
state.set("styles", styles); |
|
90 |
state.set("dimensions", dimensions); |
|
91 |
state.set("keywords", keywords); |
|
92 |
state.set("children", children); |
|
93 |
state.set("_parent", _parent); |
|
94 |
state.set("fixedSize", fixedSize); |
|
95 |
} |
|
96 |
|
|
97 |
public static void registerPersistent() { |
|
98 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
99 |
DynStruct definition = manager.getDefinition("WMSLayerNode_Persistent"); |
|
100 |
if( definition == null ) { |
|
101 |
definition = manager.addDefinition( |
|
102 |
WMSLayerNode.class, |
|
103 |
"WMSLayerNode_Persistent", |
|
104 |
"WMSLayerNode Persistence", |
|
105 |
null, |
|
106 |
null |
|
107 |
); |
|
108 |
} |
|
109 |
|
|
110 |
definition.addDynFieldString("_name").setMandatory(false); |
|
111 |
definition.addDynFieldString("_title").setMandatory(false); |
|
112 |
definition.addDynFieldList("srs").setClassOfItems(String.class).setMandatory(false); |
|
113 |
definition.addDynFieldBoolean("queryable").setMandatory(false); |
|
114 |
definition.addDynFieldBoolean("transparency").setMandatory(false); |
|
115 |
definition.addDynFieldString("lAbstract").setMandatory(false); |
|
116 |
definition.addDynFieldString("latLonBox").setMandatory(false); |
|
117 |
definition.addDynFieldInt("selectedStyleIndex").setMandatory(false); |
|
118 |
definition.addDynFieldList("styles").setClassOfItems(RemoteWMSStyle.class).setMandatory(false); |
|
119 |
definition.addDynFieldList("dimensions").setClassOfItems(RemoteTimeDimension.class).setMandatory(false); |
|
120 |
definition.addDynFieldList("keywords").setClassOfItems(String.class).setMandatory(false); |
|
121 |
definition.addDynFieldList("children").setClassOfItems(WMSLayerNode.class).setMandatory(false); |
|
122 |
definition.addDynFieldObject("_parent").setClassOfValue(WMSLayerNode.class).setMandatory(false); |
|
123 |
definition.addDynFieldObject("fixedSize").setClassOfValue(Dimension.class).setMandatory(false); |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* @return Returns the name. |
|
128 |
*/ |
|
129 |
public String getName() { |
|
130 |
return _name; |
|
131 |
} |
|
132 |
|
|
133 |
public List<WMSLayerNode> getChildren() { |
|
134 |
return children; |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* @param name The name to set. |
|
139 |
*/ |
|
140 |
public void setName(String name) { |
|
141 |
this._name = name; |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* @return Returns the namedStyles. |
|
146 |
*/ |
|
147 |
public List<RemoteWMSStyle> getStyles() { |
|
148 |
return styles; |
|
149 |
} |
|
150 |
|
|
151 |
public List<String> getKeywords() { |
|
152 |
return keywords; |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* @return Returns the queryable. |
|
157 |
*/ |
|
158 |
public boolean isQueryable() { |
|
159 |
return queryable; |
|
160 |
} |
|
161 |
|
|
162 |
/** |
|
163 |
* @param queryable The queryable to set. |
|
164 |
*/ |
|
165 |
public void setQueryable(boolean queryable) { |
|
166 |
this.queryable = queryable; |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* @return Returns the srs. |
|
171 |
*/ |
|
172 |
public List<String> getAllSrs() { |
|
173 |
if ((srs.size() == 0) && _parent!=null) |
|
174 |
return _parent.getAllSrs(); |
|
175 |
return srs; |
|
176 |
} |
|
177 |
|
|
178 |
/** |
|
179 |
* @param srs The srs to set. |
|
180 |
*/ |
|
181 |
public void setSrs(List<String> srs) { |
|
182 |
this.srs = srs; |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* @return Returns the title. |
|
187 |
*/ |
|
188 |
public String getTitle() { |
|
189 |
return _title; |
|
190 |
} |
|
191 |
|
|
192 |
public void setTitle(String title) { |
|
193 |
this._title = title.trim(); |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* @return Returns the transparency. |
|
198 |
*/ |
|
199 |
public boolean isTransparent() { |
|
200 |
return transparency; |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* @param transparency The transparency to set. |
|
205 |
*/ |
|
206 |
public void setTransparency(boolean transparency) { |
|
207 |
this.transparency = transparency; |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* Sets the list of sons of this layer. |
|
212 |
* @param children |
|
213 |
*/ |
|
214 |
public void setChildren(List<WMSLayerNode> children) { |
|
215 |
this.children = children; |
|
216 |
} |
|
217 |
|
|
218 |
public WMSLayerNode getParent() { |
|
219 |
return _parent; |
|
220 |
} |
|
221 |
|
|
222 |
public void setParent(WMSLayerNode parentNode) { |
|
223 |
this._parent = parentNode; |
|
224 |
} |
|
225 |
|
|
226 |
public List<RemoteTimeDimension> getDimensions() { |
|
227 |
return dimensions; |
|
228 |
} |
|
229 |
|
|
230 |
/** |
|
231 |
* Gets the layer abstract. |
|
232 |
* |
|
233 |
* @return Returns the abstract. |
|
234 |
*/ |
|
235 |
public String getAbstract() { |
|
236 |
return lAbstract; |
|
237 |
} |
|
238 |
|
|
239 |
/** |
|
240 |
* Sets the layer abstract. |
|
241 |
* |
|
242 |
* @param abstract The abstract to set. |
|
243 |
*/ |
|
244 |
public void setAbstract(String _abstract) { |
|
245 |
lAbstract = _abstract; |
|
246 |
} |
|
247 |
|
|
248 |
/** |
|
249 |
* @param name |
|
250 |
* @param units |
|
251 |
* @param unitSymbol |
|
252 |
* @param dimensionExpression |
|
253 |
*/ |
|
254 |
public void addDimension(String name, String units, String unitSymbol, String dimExpression) { |
|
255 |
if (dimensions == null) |
|
256 |
dimensions = new ArrayList<RemoteTimeDimension>(); |
|
257 |
if (name.equalsIgnoreCase("time")) { |
|
258 |
try { |
|
259 |
dimensions.add(new TimeDimension(units, unitSymbol, |
|
260 |
dimExpression)); |
|
261 |
} catch (IllegalArgumentException e) { |
|
262 |
// The TIME class does not yet support this kind of time so it |
|
263 |
// will be treated as a DefaultDimension |
|
264 |
dimensions.add(new DefaultDimension(name.toUpperCase(), |
|
265 |
units, unitSymbol, dimExpression)); |
|
266 |
} |
|
267 |
} else if (name.equalsIgnoreCase("sequence")) { |
|
268 |
// TODO Not yet implemented |
|
269 |
return; |
|
270 |
} else { |
|
271 |
dimensions.add(new DefaultDimension(name.toUpperCase(), units, |
|
272 |
unitSymbol, dimExpression)); |
|
273 |
} |
|
274 |
|
|
275 |
} |
|
276 |
|
|
277 |
|
|
278 |
public void setLatLonBox(String _latLonBox) { |
|
279 |
latLonBox = _latLonBox; |
|
280 |
} |
|
281 |
|
|
282 |
public String getLatLonBox() { |
|
283 |
return latLonBox; |
|
284 |
} |
|
285 |
|
|
286 |
/** |
|
287 |
* When a server cannot renderize images but just server them in constant size and |
|
288 |
* BBox, the layer must have this value set in order to correctly work. |
|
289 |
* |
|
290 |
* @param fixedWidth - the constant value for the image width |
|
291 |
* @param fixedHeight - the constant value for the image height |
|
292 |
*/ |
|
293 |
public void setFixedSize(int fixedWidth, int fixedHeight) { |
|
294 |
fixedSize = new Dimension(fixedWidth, fixedHeight); |
|
295 |
} |
|
296 |
|
|
297 |
public Dimension getFixedSize() { |
|
298 |
return fixedSize; |
|
299 |
} |
|
300 |
|
|
301 |
public boolean isSizeFixed() { |
|
302 |
return fixedSize != null && |
|
303 |
fixedSize.getWidth() > 0 && |
|
304 |
fixedSize.getHeight() > 0; |
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* |
|
309 |
* @param _name |
|
310 |
* @param _title |
|
311 |
* @param _abstract |
|
312 |
*/ |
|
313 |
public void addStyle(org.gvsig.remoteclient.wms.WMSStyle style) { |
|
314 |
if (style.getName().equalsIgnoreCase("default")) |
|
315 |
selectedStyleIndex = styles.size(); |
|
316 |
if (styles == null) |
|
317 |
styles = new ArrayList<RemoteWMSStyle>(); |
|
318 |
styles.add(new RemoteWMSStyle(style, this)); |
|
319 |
|
|
320 |
} |
|
321 |
|
|
322 |
public RemoteWMSStyle getSelectedStyle() { |
|
323 |
if (styles == null || selectedStyleIndex > styles.size() - 1 || selectedStyleIndex == -1) |
|
324 |
return null; |
|
325 |
return (RemoteWMSStyle) styles.get(selectedStyleIndex); |
|
326 |
} |
|
327 |
|
|
328 |
public void setSelectedStyleByIndex(int index) { |
|
329 |
selectedStyleIndex = index; |
|
330 |
} |
|
331 |
|
|
332 |
public void setSelectedStyleByName(String styName) { |
|
333 |
if (styName == null || styName.equals("")) |
|
334 |
setSelectedStyleByIndex(-1); |
|
335 |
for (int i = 0; i < styles.size(); i++) { |
|
336 |
RemoteWMSStyle sty = (RemoteWMSStyle) styles.get(i); |
|
337 |
if (sty.name.equalsIgnoreCase(styName)) { |
|
338 |
setSelectedStyleByIndex(i); |
|
339 |
return; |
|
340 |
} |
|
341 |
|
|
342 |
} |
|
343 |
setSelectedStyleByIndex(-1); |
|
344 |
} |
|
345 |
|
|
346 |
public void addKeyword(String keyword) { |
|
347 |
if (keywords == null) |
|
348 |
keywords = new ArrayList<String>(); |
|
349 |
keywords.add(keyword); |
|
350 |
} |
|
351 |
|
|
352 |
public String toString(){ |
|
353 |
String str; |
|
354 |
if (getName()==null) |
|
355 |
str = getTitle(); |
|
356 |
else |
|
357 |
str = "["+getName()+"] "+getTitle(); |
|
358 |
return str; |
|
359 |
} |
|
360 |
|
|
361 |
public Object clone() throws CloneNotSupportedException { |
|
362 |
WMSLayerNode clone = new WMSLayerNode(); |
|
363 |
clone._name = this._name; |
|
364 |
clone.queryable = this.queryable; |
|
365 |
clone.srs = this.srs; |
|
366 |
clone._title = this._title; |
|
367 |
clone.transparency = this.transparency; |
|
368 |
clone.styles = new ArrayList<RemoteWMSStyle>(); |
|
369 |
clone.lAbstract = this.lAbstract; |
|
370 |
clone.latLonBox = this.latLonBox; |
|
371 |
clone.selectedStyleIndex = this.selectedStyleIndex; |
|
372 |
|
|
373 |
if (keywords != null) { |
|
374 |
clone.keywords = new ArrayList<String>(keywords.size()); |
|
375 |
for (int i = 0; i < keywords.size(); i++) { |
|
376 |
clone.keywords.add((String) keywords.get(i)); |
|
377 |
} |
|
378 |
} |
|
379 |
if (styles != null) |
|
380 |
for (int i=0; i<styles.size(); i++){ |
|
381 |
RemoteWMSStyle sty = (RemoteWMSStyle) this.styles.get(i).clone(); |
|
382 |
((RemoteWMSStyle)sty).parent = this; |
|
383 |
clone.styles.add(sty); |
|
384 |
} |
|
385 |
|
|
386 |
if (dimensions!=null) |
|
387 |
for (int i = 0; i < dimensions.size(); i++) { |
|
388 |
clone.dimensions = new ArrayList<>(); |
|
389 |
clone.dimensions.add((RemoteTimeDimension) this.dimensions.get(i)); |
|
390 |
} |
|
391 |
|
|
392 |
return clone; |
|
393 |
} |
|
394 |
|
|
395 |
|
|
396 |
public void sort() { |
|
397 |
if(CollectionUtils.isEmpty(this.children)){ |
|
398 |
return; |
|
399 |
} |
|
400 |
Collections.sort(this.children, new Comparator<WMSLayerNode>() { |
|
401 |
@Override |
|
402 |
public int compare(WMSLayerNode o1, WMSLayerNode o2) { |
|
403 |
return StringUtils.compareIgnoreCase( |
|
404 |
Objects.toString(o1), |
|
405 |
Objects.toString(o2) |
|
406 |
); |
|
407 |
} |
|
408 |
}); |
|
409 |
for (WMSLayerNode child : this.children) { |
|
410 |
child.sort(); |
|
411 |
} |
|
412 |
} |
|
413 |
} |
|
0 | 414 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.254/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/WMSServerExplorer.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 IVER T.I {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.raster.wms.io; |
|
29 |
|
|
30 |
import java.awt.geom.Rectangle2D; |
|
31 |
import java.io.File; |
|
32 |
import java.io.IOException; |
|
33 |
import java.io.InputStream; |
|
34 |
import java.net.MalformedURLException; |
|
35 |
import java.net.URI; |
|
36 |
import java.net.URISyntaxException; |
|
37 |
import java.net.URL; |
|
38 |
import java.net.URLConnection; |
|
39 |
import java.util.ArrayList; |
|
40 |
import java.util.Hashtable; |
|
41 |
import java.util.List; |
|
42 |
import java.util.Vector; |
|
43 |
import java.util.logging.Level; |
|
44 |
import org.apache.commons.lang3.StringUtils; |
|
45 |
|
|
46 |
import org.gvsig.compat.net.ICancellable; |
|
47 |
import org.gvsig.fmap.dal.DALLocator; |
|
48 |
import org.gvsig.fmap.dal.DataManager; |
|
49 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
50 |
import org.gvsig.fmap.dal.DataStore; |
|
51 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
52 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
53 |
import org.gvsig.fmap.dal.coverage.exception.ConnectException; |
|
54 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
|
55 |
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer; |
|
56 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
57 |
import org.gvsig.fmap.dal.exception.DataException; |
|
58 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
59 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
60 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
61 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
62 |
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer; |
|
63 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
|
64 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
|
65 |
import org.gvsig.i18n.Messages; |
|
66 |
import org.gvsig.remoteclient.utils.Utilities; |
|
67 |
import org.gvsig.tools.task.Cancellable; |
|
68 |
|
|
69 |
import org.slf4j.Logger; |
|
70 |
import org.slf4j.LoggerFactory; |
|
71 |
|
|
72 |
/** |
|
73 |
* Explorer for a WMS server |
|
74 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
75 |
*/ |
|
76 |
public class WMSServerExplorer extends AbstractDataServerExplorer implements RasterDataServerExplorer, DataServerExplorerProvider { |
|
77 |
public static final String NAME = WMSProvider.NAME; |
|
78 |
private WMSConnector connector = null; |
|
79 |
// private WMSServerExplorerParameters parameters = null; |
|
80 |
private Logger log = LoggerFactory.getLogger(WMSServerExplorer.class); |
|
81 |
|
|
82 |
public WMSServerExplorer( |
|
83 |
WMSServerExplorerParameters parameters, |
|
84 |
DataServerExplorerProviderServices services) |
|
85 |
throws InitializeException { |
|
86 |
super(parameters, services); |
|
87 |
// this.parameters = parameters; |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Gets the provider's name |
|
92 |
* @return |
|
93 |
*/ |
|
94 |
public String getDataStoreProviderName() { |
|
95 |
return WMSProvider.NAME; |
|
96 |
} |
|
97 |
|
|
98 |
public String getDescription() { |
|
99 |
return WMSProvider.DESCRIPTION; |
|
100 |
} |
|
101 |
|
|
102 |
public boolean add(String provider, NewDataStoreParameters parameters, |
|
103 |
boolean overwrite) throws DataException { |
|
104 |
return false; |
|
105 |
} |
|
106 |
|
|
107 |
public boolean canAdd() { |
|
108 |
return false; |
|
109 |
} |
|
110 |
|
|
111 |
public boolean canAdd(String storeName) throws DataException { |
|
112 |
return false; |
|
113 |
} |
|
114 |
|
|
115 |
public NewDataStoreParameters getAddParameters(String storeName) |
|
116 |
throws DataException { |
|
117 |
return null; |
|
118 |
} |
|
119 |
|
|
120 |
public List<String> getDataStoreProviderNames() { |
|
121 |
return null; |
|
122 |
} |
|
123 |
|
|
124 |
public WMSServerExplorerParameters getParameters() { |
|
125 |
return (WMSServerExplorerParameters) super.getParameters(); |
|
126 |
} |
|
127 |
|
|
128 |
public List<DataStoreParameters> list() throws DataException { |
|
129 |
return null; |
|
130 |
} |
|
131 |
|
|
132 |
public List<DataStoreParameters> list(int mode) throws DataException { |
|
133 |
return null; |
|
134 |
} |
|
135 |
|
|
136 |
public void remove(DataStoreParameters parameters) throws DataException { |
|
137 |
|
|
138 |
} |
|
139 |
|
|
140 |
public String getProviderName() { |
|
141 |
return null; |
|
142 |
} |
|
143 |
|
|
144 |
//********************************************** |
|
145 |
//Connector |
|
146 |
//********************************************** |
|
147 |
|
|
148 |
@Override |
|
149 |
public DataStoreParameters get(String layerName) { |
|
150 |
WMSDataParameters params = (WMSDataParameters) this.getStoredParameters(); |
|
151 |
params.setLayerQuery(layerName); |
|
152 |
return params; |
|
153 |
} |
|
154 |
|
|
155 |
public DataStoreParameters getStoredParameters() { |
|
156 |
DataManager manager = DALLocator.getDataManager(); |
|
157 |
WMSDataParameters params = null; |
|
158 |
try { |
|
159 |
params = (WMSDataParameters) manager.createStoreParameters(this.getDataStoreProviderName()); |
|
160 |
params.setURI(new URI(getParameters().getHost())); |
|
161 |
|
|
162 |
/*if(WMSProvider.TILED) { |
|
163 |
TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store"); |
|
164 |
tileParams.setDataParameters(params); |
|
165 |
return tileParams; |
|
166 |
} */ |
|
167 |
} catch (InitializeException e) { |
|
168 |
log.debug("Error initializating parameters", e); |
|
169 |
} catch (ProviderNotRegisteredException e) { |
|
170 |
log.debug("Error getting parameters", e); |
|
171 |
} catch (URISyntaxException e) { |
|
172 |
log.debug("Can't create URI from "+getParameters().getHost(), e); |
|
173 |
} |
|
174 |
|
|
175 |
return params; |
|
176 |
} |
|
177 |
|
|
178 |
@Override |
|
179 |
public void open() throws OpenException { |
|
180 |
try { |
|
181 |
this.connect(null); |
|
182 |
} catch (ConnectException ex) { |
|
183 |
throw new OpenException(this.getHost(), ex); |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
public void connect(ICancellable cancellable) throws ConnectException { |
|
188 |
connect(cancellable, false); |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Connects to the server and throws a getCapabilities. This loads |
|
193 |
* the basic information to make requests. |
|
194 |
* @throws RemoteServiceException |
|
195 |
*/ |
|
196 |
public void connect(ICancellable cancellable, boolean updateCache) throws ConnectException { |
|
197 |
URL url = null; |
|
198 |
|
|
199 |
try { |
|
200 |
url = new URL(getParameters().getHost()); |
|
201 |
} catch (Exception e) { |
|
202 |
throw new ConnectException(Messages.getText("malformed_url"), e); |
|
203 |
} |
|
204 |
try { |
|
205 |
connector = WMSProvider.getConnectorFromURL(url, updateCache); |
|
206 |
if (!connector.connect(this.getParameters(), updateCache, cancellable)) |
|
207 |
throw new ConnectException(Messages.getText("error_connecting")); |
|
208 |
} catch (IOException e) { |
|
209 |
throw new ConnectException(Messages.getText("error_connecting"), e); |
|
210 |
} |
|
211 |
|
|
212 |
} |
|
213 |
|
|
214 |
/** |
|
215 |
* Checks if the network and host are reachable |
|
216 |
* @param timeout for the host |
|
217 |
* @return true if both are reachable and false if they are not |
|
218 |
*/ |
|
219 |
public boolean isHostReachable(int timeout) { |
|
220 |
URL url = null; |
|
221 |
try { |
|
222 |
url = new URL(getParameters().getHost()); |
|
223 |
File file = Utilities.downloadFile(url, "checkhost.dat", null); |
|
224 |
} catch (Exception e) { |
|
225 |
return false; |
|
226 |
} |
|
227 |
|
|
228 |
return true; |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* Checks if the network and host are reachable |
|
233 |
* @return true if both are reachable and false if they are not |
|
234 |
*/ |
|
235 |
public boolean isHostReachable() { |
|
236 |
int timeout = 10000; |
|
237 |
return isHostReachable(timeout); |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* Returns true if this provider is connected to the server |
|
242 |
* @return |
|
243 |
*/ |
|
244 |
public boolean isConnected() { |
|
245 |
if(connector != null) |
|
246 |
return true; |
|
247 |
return false; |
|
248 |
} |
|
249 |
|
|
250 |
/** |
|
251 |
* Gets the description of this service |
|
252 |
* @return |
|
253 |
*/ |
|
254 |
public String getAbstract() { |
|
255 |
if(connector != null) |
|
256 |
return connector.getAbstract(); |
|
257 |
return null; |
|
258 |
} |
|
259 |
|
|
260 |
/** |
|
261 |
* Gets the list of raster formats supported by the server |
|
262 |
* @return |
|
263 |
*/ |
|
264 |
@SuppressWarnings("unchecked") |
|
265 |
public String[] getFormats() { |
|
266 |
if(connector != null) { |
|
267 |
Vector f = connector.getFormats(); |
|
268 |
ArrayList formatos = new ArrayList(); |
|
269 |
for (int i = 0; i < f.size(); i++) { |
|
270 |
formatos.add(f.elementAt(i)); |
|
271 |
} |
|
272 |
return (String[]) formatos.toArray(new String[0]); |
|
273 |
} |
|
274 |
return null; |
|
275 |
} |
|
276 |
|
|
277 |
/** |
|
278 |
* Gets the list of raster information formats supported by the server |
|
279 |
* @return |
|
280 |
*/ |
|
281 |
@SuppressWarnings("unchecked") |
|
282 |
public String[] getInfoFormats() { |
|
283 |
if(connector != null) { |
|
284 |
Vector f = connector.getInfoFormats(); |
|
285 |
ArrayList formatos = new ArrayList(); |
|
286 |
for (int i = 0; i < f.size(); i++) { |
|
287 |
formatos.add(f.elementAt(i)); |
|
288 |
} |
|
289 |
return (String[]) formatos.toArray(new String[0]); |
|
290 |
} |
|
291 |
return null; |
|
292 |
} |
|
293 |
|
|
294 |
/** |
|
295 |
* Gets a tree of nodes which represents the server information |
|
296 |
* @return |
|
297 |
*/ |
|
298 |
public WMSLayerNode getLayerTree() { |
|
299 |
if(connector != null) { |
|
300 |
return connector.getLayersTree(); |
|
301 |
} |
|
302 |
return null; |
|
303 |
} |
|
304 |
|
|
305 |
/** |
|
306 |
* Gets the server title |
|
307 |
* @return |
|
308 |
*/ |
|
309 |
public String getServerType() { |
|
310 |
if (getVersion() == null) |
|
311 |
return "WMS"; |
|
312 |
return "WMS "+ getVersion(); |
|
313 |
} |
|
314 |
|
|
315 |
/** |
|
316 |
* Gets the online resources |
|
317 |
* @return |
|
318 |
*/ |
|
319 |
public Hashtable getOnlineResources() { |
|
320 |
if(connector != null) { |
|
321 |
return connector.getOnlineResources(); |
|
322 |
} |
|
323 |
return null; |
|
324 |
} |
|
325 |
|
|
326 |
/** |
|
327 |
* Gets the protocol supported by the server |
|
328 |
* @return |
|
329 |
*/ |
|
330 |
public String getVersion() { |
|
331 |
if(connector != null) { |
|
332 |
return (connector.getVersion() == null) ? "" : connector.getVersion(); |
|
333 |
} |
|
334 |
return null; |
|
335 |
} |
|
336 |
|
|
337 |
public Rectangle2D getLayersExtent(String[] layerName, String srs) { |
|
338 |
return connector.getLayersExtent(layerName, srs); |
|
339 |
} |
|
340 |
|
|
341 |
/** |
|
342 |
* Gets a layer using its name |
|
343 |
* @param layerName |
|
344 |
* @return |
|
345 |
*/ |
|
346 |
public WMSLayerNode getLayer(String layerName) { |
|
347 |
return connector.getLayer(layerName); |
|
348 |
} |
|
349 |
|
|
350 |
/** |
|
351 |
* Gets the host URI |
|
352 |
* @return |
|
353 |
*/ |
|
354 |
public String getHost() { |
|
355 |
return getParameters().getHost(); |
|
356 |
} |
|
357 |
|
|
358 |
public Rectangle2D getBoundingBox(String[] layerNames, String srs) { |
|
359 |
return connector.getLayersExtent(layerNames, srs); |
|
360 |
} |
|
361 |
|
|
362 |
public boolean isQueryable() { |
|
363 |
return connector.isQueryable(); |
|
364 |
} |
|
365 |
|
|
366 |
/** |
|
367 |
* Gets the title |
|
368 |
* @return |
|
369 |
*/ |
|
370 |
public String getTitle() { |
|
371 |
return null; |
|
372 |
} |
|
373 |
|
|
374 |
/** |
|
375 |
* @return The title of the service offered by the WMS server. |
|
376 |
*/ |
|
377 |
public String getServiceTitle() { |
|
378 |
return connector.getServiceTitle(); |
|
379 |
} |
|
380 |
|
|
381 |
public DataServerExplorerProviderServices getServerExplorerProviderServices() { |
|
382 |
return null; |
|
383 |
} |
|
384 |
|
|
385 |
@Override |
|
386 |
public DataStore open(DataStoreParameters par) throws DataException { |
|
387 |
String layerName = "unknown"; |
|
388 |
try { |
|
389 |
layerName = (String) par.getDynValue(WMSDataParametersImpl.FIELD_LAYERQUERY); |
|
390 |
DataManager datamanager = DALLocator.getDataManager(); |
|
391 |
RasterDataStore store = (RasterDataStore) datamanager.openStore(NAME, par); |
|
392 |
store.setExplorer(this); |
|
393 |
return store; |
|
394 |
} catch (Exception ex) { |
|
395 |
throw new OpenException(layerName,ex); |
|
396 |
} |
|
397 |
} |
|
398 |
|
|
399 |
@Override |
|
400 |
public Object getProperty(String name) { |
|
401 |
if( StringUtils.equalsIgnoreCase("OnlineResources", name) ) { |
|
402 |
return this.getOnlineResources(); |
|
403 |
} |
|
404 |
return super.getProperty(name); |
|
405 |
} |
|
406 |
|
|
407 |
} |
|
0 | 408 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.254/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/downloader/TileDownloaderForWMS.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.raster.wms.io.downloader; |
|
23 |
|
|
24 |
import java.awt.geom.Rectangle2D; |
|
25 |
import java.io.File; |
|
26 |
import java.io.IOException; |
|
27 |
import java.util.List; |
|
28 |
import java.util.Vector; |
|
29 |
|
|
30 |
import org.cresques.cts.IProjection; |
|
31 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
32 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
33 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
34 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
35 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
36 |
import org.gvsig.fmap.dal.coverage.exception.QueryException; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
38 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
|
39 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
40 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
|
41 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
42 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
43 |
import org.gvsig.raster.cache.tile.Tile; |
|
44 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
45 |
import org.gvsig.raster.impl.DefaultRasterManager; |
|
46 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
47 |
import org.gvsig.raster.impl.provider.tile.BaseTileDownloader; |
|
48 |
import org.gvsig.raster.util.DefaultProviderServices; |
|
49 |
import org.gvsig.raster.wms.io.RemoteWMSStyle; |
|
50 |
import org.gvsig.raster.wms.io.WMSConnector; |
|
51 |
import org.gvsig.raster.wms.io.WMSDataParameters; |
|
52 |
import org.gvsig.raster.wms.io.WMSProvider; |
|
53 |
import org.gvsig.remoteclient.utils.Utilities; |
|
54 |
import org.gvsig.remoteclient.wms.WMSStatus; |
|
55 |
import org.gvsig.tools.locator.LocatorException; |
|
56 |
|
|
57 |
/** |
|
58 |
* Tile getter |
|
59 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
60 |
*/ |
|
61 |
public class TileDownloaderForWMS extends BaseTileDownloader { |
|
62 |
private WMSConnector connector = null; |
|
63 |
private Extent lyrExtent = null; |
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
public TileDownloaderForWMS(RasterDataStore store, |
|
68 |
int tilePxWidth, |
|
69 |
int tilePxHeight) throws RemoteServiceException { |
|
70 |
super(store, tilePxWidth, tilePxHeight); |
|
71 |
this.connector = ((WMSProvider)store.getProvider()).getConnector(); |
|
72 |
lyrExtent = store.getExtent(); |
|
73 |
} |
|
74 |
|
|
75 |
public synchronized Tile downloadTile(Tile tile) throws TileGettingException { |
|
76 |
try { |
|
77 |
Rectangle2D r = new Rectangle2D.Double(tile.getExtent().getMinX(), |
|
78 |
tile.getExtent().getMinY() - tile.getExtent().getHeight(), |
|
79 |
tile.getExtent().getWidth(), |
|
80 |
tile.getExtent().getHeight()); |
|
81 |
//Extent tileExtent = RasterLocator.getManager().getDataStructFactory().createExtent(r); |
|
82 |
WMSDataParameters p = (WMSDataParameters)store.getParameters(); |
|
83 |
WMSStatus wmsStatus = new WMSStatus(); |
|
84 |
wmsStatus.setLayerNames(Utilities.createVector(p.getLayerQuery(), ",")); |
|
85 |
wmsStatus.setSrs(p.getSRSCode()); |
|
86 |
wmsStatus.setFormat(p.getFormat()); |
|
87 |
List<RemoteWMSStyle> listStyles = p.getStyles(); |
|
88 |
Vector<?> v = listStyles != null ? new Vector<RemoteWMSStyle>(listStyles) : null; |
|
89 |
wmsStatus.setStyles(v); |
|
90 |
wmsStatus.setDimensions(p.getDimensions()); |
|
91 |
wmsStatus.setTransparency(p.isWmsTransparent()); |
|
92 |
wmsStatus.setOnlineResource((String) p.getOnlineResource().get("GetMap")); |
|
93 |
wmsStatus.setExtent(r); |
|
94 |
wmsStatus.setHeight(tile.getHeightPx()); |
|
95 |
wmsStatus.setWidth(tile.getWidthPx()); |
|
96 |
wmsStatus.setXyAxisOrder(p.isXyAxisOrder()); |
|
97 |
|
|
98 |
IProjection proj = (IProjection)p.getSRS(); |
|
99 |
if(proj != null) |
|
100 |
wmsStatus.setProjected(proj.isProjected()); |
|
101 |
connector.getMap(wmsStatus, tile.getCancelled(), tile.getFile()); |
|
102 |
|
|
103 |
//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para |
|
104 |
//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros |
|
105 |
//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf"); |
|
106 |
//if(rmf.exists()) |
|
107 |
//rmf.delete(); |
|
108 |
} catch (RemoteServiceException e) { |
|
109 |
throw new TileGettingException(e); |
|
110 |
} |
|
111 |
readTileFromDisk(tile); |
|
112 |
return tile; |
|
113 |
} |
|
114 |
|
|
115 |
@SuppressWarnings("unused") |
|
116 |
private void fuseFiles(Extent dstExtent, int dstWidth, int dstHeight, File src, File dst, double pixelSize) |
|
117 |
throws RasterDriverException, ProcessInterruptedException, ProviderNotRegisteredException, InitializeException, LocatorException, NotSupportedExtensionException, IOException, QueryException { |
|
118 |
RasterProvider provider = DefaultProviderServices.loadProvider(src); |
|
119 |
|
|
120 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
|
121 |
Buffer bufInput = store.query(q); |
|
122 |
|
|
123 |
Buffer bufDst = DefaultRasterManager.getInstance().createMemoryBuffer(provider.getDataType()[0], dstWidth, dstHeight, provider.getBandCount(), true); |
|
124 |
String extension = RasterLocator.getManager().getFileUtils().getExtensionFromFileName(src.getAbsolutePath()); |
|
125 |
RasterLocator.getManager().getRasterUtils().copyToBuffer( |
|
126 |
bufDst, |
|
127 |
dstExtent, |
|
128 |
bufInput, |
|
129 |
lyrExtent, |
|
130 |
pixelSize, |
|
131 |
provider.getColorInterpretation().hasAlphaBand()); |
|
132 |
RasterLocator.getManager().getProviderServices().exportBufferToFile( |
|
133 |
bufDst, |
|
134 |
provider.getCellSize(), |
|
135 |
extension, |
|
136 |
provider.getColorInterpretation().hasAlphaBand(), |
|
137 |
dst, |
|
138 |
dstExtent, |
|
139 |
provider.getColorInterpretation()); |
|
140 |
} |
|
141 |
|
|
142 |
} |
|
0 | 143 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.254/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/downloader/WMSTileServer.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.raster.wms.io.downloader; |
|
23 |
|
|
24 |
import org.cresques.cts.IProjection; |
|
25 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
|
26 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
27 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
|
28 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
29 |
import org.gvsig.raster.cache.tile.TileCacheLibrary; |
|
30 |
import org.gvsig.raster.cache.tile.TileCacheLocator; |
|
31 |
import org.gvsig.raster.cache.tile.TileCacheManager; |
|
32 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
33 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
34 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
35 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
36 |
import org.gvsig.raster.wms.io.WMSProvider; |
|
37 |
import org.slf4j.Logger; |
|
38 |
import org.slf4j.LoggerFactory; |
|
39 |
|
|
40 |
/** |
|
41 |
* Data server for the tile cache in a WMSProvider |
|
42 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
43 |
*/ |
|
44 |
public class WMSTileServer implements TileServer { |
|
45 |
private static Logger logger = LoggerFactory.getLogger(WMSTileServer.class); |
|
46 |
private CacheStruct struct = null; |
|
47 |
private Downloader downloader = null; |
|
48 |
private RasterDataStore store = null; |
|
49 |
private String suffix = ".tif"; |
|
50 |
|
|
51 |
public WMSTileServer(RasterDataStore store) { |
|
52 |
this.store = store; |
|
53 |
this.suffix = ((RasterProvider)store.getProvider()).getFileSuffix(); |
|
54 |
} |
|
55 |
|
|
56 |
public Downloader getDownloader() { |
|
57 |
if(downloader == null || |
|
58 |
((TileDownloaderForWMS)downloader).getTileSize()[0] != TileCacheLibrary.ALTERNATIVE_TILESIZE || |
|
59 |
((TileDownloaderForWMS)downloader).getTileSize()[1] != TileCacheLibrary.ALTERNATIVE_TILESIZE) { |
|
60 |
try { |
|
61 |
downloader = new TileDownloaderForWMS( |
|
62 |
store, |
|
63 |
TileCacheLibrary.ALTERNATIVE_TILESIZE, |
|
64 |
TileCacheLibrary.ALTERNATIVE_TILESIZE); |
|
65 |
} catch (RemoteServiceException e) { |
|
66 |
return null; |
|
67 |
} |
|
68 |
} |
|
69 |
return downloader; |
|
70 |
} |
|
71 |
|
|
72 |
public CacheStruct getStruct() { |
|
73 |
if(struct == null) { |
|
74 |
TileCacheManager manager = TileCacheLocator.getManager(); |
|
75 |
|
|
76 |
int coordinates = CacheStruct.FLAT; |
|
77 |
if(store.getProjection() != null) |
|
78 |
coordinates = (store.getProjection() != null && store.getProjection().isProjected()) ? CacheStruct.FLAT : CacheStruct.GEOGRAFIC; |
|
79 |
else { |
|
80 |
Extent e = store.getExtent(); |
|
81 |
if(e.getULX() >= -180 && e.getULX() <= 180 && e.getLRX() >= -180 && e.getLRX() <= 180 && |
|
82 |
e.getULY() >= -90 && e.getULY() <= 90 && e.getLRY() >= -90 && e.getLRY() <= 90) { |
|
83 |
coordinates = CacheStruct.GEOGRAFIC; |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
String epsg = null; |
|
88 |
IProjection proj = store.getProjection(); |
|
89 |
if(proj != null) |
|
90 |
epsg = proj.getAbrev(); |
|
91 |
|
|
92 |
struct = manager.createCacheStructure(coordinates, |
|
93 |
TileCacheLibrary.DEFAULT_LEVELS, |
|
94 |
store.getExtent().toRectangle2D(), |
|
95 |
Double.POSITIVE_INFINITY,//provider.getCellSize(), |
|
96 |
TileCacheLibrary.ALTERNATIVE_TILESIZE, |
|
97 |
TileCacheLibrary.ALTERNATIVE_TILESIZE, |
|
98 |
((RasterProvider)store.getProvider()).getURIOfFirstProvider().getPath(), |
|
99 |
((WMSProvider)store.getProvider()).getParameters().getLayerQuery(), |
|
100 |
TileCacheLibrary.DEFAULT_STRUCTURE, |
|
101 |
RasterLibrary.pathTileCache, |
|
102 |
getFileSuffix(), |
|
103 |
epsg, |
|
104 |
0); |
|
105 |
} |
|
106 |
return struct; |
|
107 |
} |
|
108 |
|
|
109 |
public void setStruct(CacheStruct struct) { |
|
110 |
if(struct != null) { |
|
111 |
this.struct = struct; |
|
112 |
if(struct.getTileSizeByLevel(0) != null) { |
|
113 |
try { |
|
114 |
downloader = new TileDownloaderForWMS(store, |
|
115 |
struct.getTileSizeByLevel(0)[0], |
|
116 |
struct.getTileSizeByLevel(0)[1]); |
|
117 |
} catch (RemoteServiceException ex) { |
|
118 |
logger.error("Constructing TileDownloaderForWCS: " + ex.getMessage()); |
|
119 |
} |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
public String getFileSuffix() { |
|
125 |
return suffix; |
|
126 |
} |
|
127 |
|
|
128 |
public void setFileSuffix(String extension) { |
|
129 |
this.suffix = extension; |
|
130 |
} |
|
131 |
} |
|
0 | 132 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.254/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.raster.wms.io package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>WMS provider</p> |
|
11 |
|
|
12 |
</body> |
|
13 |
</html> |
|
0 | 14 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.254/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/time/DefaultDimension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.raster.wms.io.time; |
|
23 |
|
|
24 |
import org.gvsig.tools.ToolsLocator; |
|
25 |
import org.gvsig.tools.dynobject.DynStruct; |
|
26 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
27 |
import org.gvsig.tools.persistence.PersistentState; |
|
28 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
29 |
|
|
30 |
|
|
31 |
/** |
|
32 |
* This class instances a regular WMS dimension. It handles single, multiple and |
|
33 |
* interval values and uses them as they were a point, a list or a regularly |
|
34 |
* split line, respectivelly.<br> |
|
35 |
* <p> |
|
36 |
* As far as it implements RemoteTimeDimension it uses the same interface and |
|
37 |
* documentation. |
|
38 |
* </p> |
|
39 |
* @author jaume dominguez faus (jaume.dominguez@iver.es) |
|
40 |
* |
|
41 |
*/ |
|
42 |
public class DefaultDimension implements RemoteTimeDimension { |
|
43 |
static private final String digit = "[0-9]"; |
|
44 |
static private final String nonZeroDigit = "[1-9]"; |
|
45 |
static private final String letter = "[_$%a-zA-Z]"; |
|
46 |
static private final String word = letter+"("+letter+"|"+digit+")+"; // TODO Should be * instead of + ?? |
|
47 |
static private final String floatingPointNumber = "("+digit+"+(\\."+digit+"+)?)"; |
|
48 |
static private final String integerNumber = nonZeroDigit+digit+"+"; |
|
49 |
static private final String dimensionItem = "("+floatingPointNumber+"|"+word+")"; |
|
50 |
/** |
|
51 |
* regular expression for matching dimensions. |
|
52 |
*/ |
|
53 |
static private final String regexpDefaultDimensionExpression = |
|
54 |
"("+floatingPointNumber+"/"+floatingPointNumber+"/"+floatingPointNumber+"|"+ |
|
55 |
dimensionItem+"(,"+dimensionItem+")*)"; |
|
56 |
|
|
57 |
private String name; |
|
58 |
private String unit; |
|
59 |
private String unitSymbol; |
|
60 |
private String expression; |
|
61 |
private String period; |
|
62 |
private Object minValue; |
|
63 |
private Object maxValue; |
|
64 |
private int type; |
|
65 |
private boolean compiled = false; |
|
66 |
|
|
67 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
68 |
this.name = state.getString("name"); |
|
69 |
this.unit = state.getString("unit"); |
|
70 |
this.unitSymbol = state.getString("unitSymbol"); |
|
71 |
this.expression = state.getString("expression"); |
|
72 |
this.period = state.getString("period"); |
|
73 |
this.minValue = state.getString("minValue"); |
|
74 |
this.maxValue = state.getString("maxValue"); |
|
75 |
this.type = state.getInt("type"); |
|
76 |
this.compiled = state.getBoolean("compiled"); |
|
77 |
} |
|
78 |
|
|
79 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
80 |
state.set("name", name); |
|
81 |
state.set("unit", unit); |
|
82 |
state.set("unitSymbol", unitSymbol); |
|
83 |
state.set("expression", expression); |
|
84 |
state.set("period", period); |
|
85 |
state.set("minValue", minValue); |
|
86 |
state.set("maxValue", maxValue); |
|
87 |
state.set("type", type); |
|
88 |
state.set("compiled", compiled); |
|
89 |
} |
|
90 |
|
|
91 |
public static void registerPersistent() { |
|
92 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
93 |
DynStruct definition = manager.getDefinition("DefaultDimension_Persistent"); |
|
94 |
if( definition == null ) { |
|
95 |
definition = manager.addDefinition( |
|
96 |
DefaultDimension.class, |
|
97 |
"DefaultDimension_Persistent", |
|
98 |
"DefaultDimension Persistence", |
|
99 |
null, |
|
100 |
null |
|
101 |
); |
|
102 |
} |
|
103 |
|
Also available in: Unified diff