Revision 4824
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.22/org.gvsig.raster.wmts.io/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.wmts.io.DefaultWMTSIOLibrary |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.22/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSDataParameters.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 |
package org.gvsig.raster.wmts.io; |
|
24 |
|
|
25 |
import java.awt.geom.Rectangle2D; |
|
26 |
import java.net.URI; |
|
27 |
|
|
28 |
import org.cresques.cts.IProjection; |
|
29 |
|
|
30 |
import org.gvsig.compat.net.ICancellable; |
|
31 |
import org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters; |
|
32 |
import org.gvsig.raster.wmts.ogc.WMTSClient; |
|
33 |
import org.gvsig.raster.wmts.ogc.struct.WMTSLayer; |
|
34 |
import org.gvsig.raster.wmts.ogc.struct.WMTSStyle; |
|
35 |
|
|
36 |
/** |
|
37 |
* Parameters for the WMTS provider |
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
39 |
*/ |
|
40 |
public interface WMTSDataParameters extends RemoteStoreParameters { |
|
41 |
public static final String DYNCLASS_NAME = "WMTSDataParameters"; |
|
42 |
public static final String FIELD_IMAGE_FORMAT = "imageformat"; |
|
43 |
public static final String FIELD_INFO_FORMAT = "infoformat"; |
|
44 |
public static final String FIELD_NAME = "name"; |
|
45 |
public static final String FIELD_SRSSTR = "srsstr"; |
|
46 |
public static final String FIELD_OVERRIDE = "override"; |
|
47 |
public static final String FIELD_WIDTH = "width"; |
|
48 |
public static final String FIELD_HEIGHT = "height"; |
|
49 |
public static final String FIELD_DELETECACHE = "deletecache"; |
|
50 |
public static final String FIELD_STYLE_NAME = "style"; |
|
51 |
public static final String FIELD_EXTENT = "extent"; |
|
52 |
public static final String FIELD_DIMENSION = "dimension"; |
|
53 |
public static final String FIELD_DIMENSION_VALUE = "selected_dimension_value"; |
|
54 |
|
|
55 |
/** |
|
56 |
* Gets the selected dimension |
|
57 |
* @return |
|
58 |
*/ |
|
59 |
public String getDimension(); |
|
60 |
|
|
61 |
/** |
|
62 |
* Sets the selected dimension |
|
63 |
* @param dimension |
|
64 |
*/ |
|
65 |
public void setDimension(String dimension); |
|
66 |
|
|
67 |
/** |
|
68 |
* Gets the value for the selected dimension |
|
69 |
* @return |
|
70 |
*/ |
|
71 |
public String getDimensionSelectedValue(); |
|
72 |
|
|
73 |
/** |
|
74 |
* Sets the value for the selected dimension |
|
75 |
* @param dimension |
|
76 |
*/ |
|
77 |
public void setDimensionSelectedValue(String dimension); |
|
78 |
|
|
79 |
/** |
|
80 |
* Sets the style selected |
|
81 |
* @param layer |
|
82 |
*/ |
|
83 |
public void setStyle(WMTSStyle layer); |
|
84 |
|
|
85 |
/** |
|
86 |
* Gets the style |
|
87 |
* @return |
|
88 |
*/ |
|
89 |
public WMTSStyle getStyle(); |
|
90 |
|
|
91 |
/** |
|
92 |
* Gets the image format |
|
93 |
* @return Format |
|
94 |
*/ |
|
95 |
public String getImageFormat(); |
|
96 |
|
|
97 |
/** |
|
98 |
* Sets the image format |
|
99 |
* @param format |
|
100 |
*/ |
|
101 |
public void setImageFormat(String format); |
|
102 |
|
|
103 |
/** |
|
104 |
* Gets the format of the info by point |
|
105 |
* @return |
|
106 |
*/ |
|
107 |
public String getInfoFormat(); |
|
108 |
|
|
109 |
/** |
|
110 |
* Sets the format of the info by point |
|
111 |
*/ |
|
112 |
public void setInfoFormat(String format); |
|
113 |
|
|
114 |
/** |
|
115 |
* Sets the layer selected |
|
116 |
* @param layer |
|
117 |
*/ |
|
118 |
public void setLayer(WMTSLayer layer); |
|
119 |
|
|
120 |
/** |
|
121 |
* Gets the layer |
|
122 |
* @return |
|
123 |
*/ |
|
124 |
public WMTSLayer getLayer(); |
|
125 |
|
|
126 |
/** |
|
127 |
* Devuelve el SRS. |
|
128 |
* @return SRS. |
|
129 |
*/ |
|
130 |
public String getSRSCode(); |
|
131 |
|
|
132 |
public void setSRS(String m_srs); |
|
133 |
|
|
134 |
public void setSRS(IProjection srs); |
|
135 |
|
|
136 |
/** |
|
137 |
* Returns the projection |
|
138 |
* @return |
|
139 |
*/ |
|
140 |
public IProjection getSRS(); |
|
141 |
|
|
142 |
/** |
|
143 |
* Returns true if the layer is projected |
|
144 |
* @return |
|
145 |
*/ |
|
146 |
public boolean isProjected(); |
|
147 |
|
|
148 |
public String getSRSID(); |
|
149 |
|
|
150 |
public void setSRSID(String srsid); |
|
151 |
|
|
152 |
/** |
|
153 |
* Returns the current selected SRS. |
|
154 |
* @return |
|
155 |
*/ |
|
156 |
public String getEPSG(String value); |
|
157 |
|
|
158 |
public String getName(); |
|
159 |
|
|
160 |
public void setName(String name); |
|
161 |
|
|
162 |
public void setCancellable(ICancellable cancel); |
|
163 |
|
|
164 |
public ICancellable getCancellable(); |
|
165 |
|
|
166 |
public boolean isOverridingHost(); |
|
167 |
|
|
168 |
public void setOverrideHost(boolean over); |
|
169 |
/** |
|
170 |
* Assigns the extent. |
|
171 |
* When a provider is initialized this will need to know what is the extent before the request. |
|
172 |
* |
|
173 |
* @param bBox |
|
174 |
*/ |
|
175 |
public void setExtent(Rectangle2D bBox); |
|
176 |
|
|
177 |
/** |
|
178 |
* Sets the width |
|
179 |
* When a provider is initialized this will need to know what is the width before the request. |
|
180 |
* @param w |
|
181 |
*/ |
|
182 |
public void setWidth(int w); |
|
183 |
|
|
184 |
/** |
|
185 |
* Sets the height |
|
186 |
* When a provider is initialized this will need to know what is the height before the request. |
|
187 |
* @param h |
|
188 |
*/ |
|
189 |
public void setHeight(int h); |
|
190 |
|
|
191 |
/** |
|
192 |
* Gets the bounding box |
|
193 |
* @return |
|
194 |
*/ |
|
195 |
public Rectangle2D getExtent(); |
|
196 |
|
|
197 |
/** |
|
198 |
* Gets the width |
|
199 |
* @return |
|
200 |
*/ |
|
201 |
public int getWidth(); |
|
202 |
|
|
203 |
/** |
|
204 |
* Gets the height |
|
205 |
* @return |
|
206 |
*/ |
|
207 |
public int getHeight(); |
|
208 |
|
|
209 |
public boolean isSizeFixed(); |
|
210 |
|
|
211 |
public void setURI(URI uri); |
|
212 |
|
|
213 |
public URI getURI(); |
|
214 |
|
|
215 |
public WMTSClient getOGCClient(); |
|
216 |
|
|
217 |
public void setOGCClient(WMTSClient ogcClient); |
|
218 |
} |
|
0 | 219 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.22/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSDataParametersImpl.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 |
package org.gvsig.raster.wmts.io; |
|
24 |
|
|
25 |
|
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import org.cresques.cts.IProjection; |
|
30 |
import org.gvsig.compat.net.ICancellable; |
|
31 |
import org.gvsig.fmap.crs.CRSFactory; |
|
32 |
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer; |
|
33 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
34 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
|
35 |
import org.gvsig.raster.wmts.ogc.WMTSClient; |
|
36 |
import org.gvsig.raster.wmts.ogc.struct.WMTSLayer; |
|
37 |
import org.gvsig.raster.wmts.ogc.struct.WMTSStyle; |
|
38 |
import org.gvsig.tools.ToolsLocator; |
|
39 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
40 |
import org.gvsig.tools.dynobject.DynStruct; |
|
41 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
42 |
import org.slf4j.LoggerFactory; |
|
43 |
|
|
44 |
/** |
|
45 |
* Parameters for the WMTS provider |
|
46 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
47 |
*/ |
|
48 |
public class WMTSDataParametersImpl extends AbstractRasterDataParameters implements WMTSDataParameters { |
|
49 |
private DelegatedDynObject delegatedDynObject = null; |
|
50 |
private WMTSClient ogcClient = null; |
|
51 |
private ICancellable cancel = null; |
|
52 |
private WMTSStyle style = null; |
|
53 |
private WMTSLayer layer = null; |
|
54 |
|
|
55 |
public WMTSDataParametersImpl() { |
|
56 |
super(); |
|
57 |
initialize(); |
|
58 |
} |
|
59 |
|
|
60 |
protected void initialize() { |
|
61 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator |
|
62 |
.getDynObjectManager().createDynObject(registerDynClass()); |
|
63 |
} |
|
64 |
|
|
65 |
public static DynStruct registerDynClass() { |
|
66 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
67 |
DynStruct definition = manager.getDefinition("WMTSDataParameters_Persistent"); |
|
68 |
if( definition == null ) { |
|
69 |
definition = manager.addDefinition( |
|
70 |
WMTSDataParametersImpl.class, |
|
71 |
"WMTSDataParameters_Persistent", |
|
72 |
"WMTS DataParameters Persistency", |
|
73 |
null, |
|
74 |
null |
|
75 |
); |
|
76 |
} |
|
77 |
|
|
78 |
AbstractRasterDataParameters.registerDynClass(definition); |
|
79 |
|
|
80 |
definition.addDynFieldBoolean(FIELD_DELETECACHE) |
|
81 |
.setDescription("Flag to delete cache the next request") |
|
82 |
.setMandatory(false); |
|
83 |
|
|
84 |
definition.addDynFieldInt(FIELD_WIDTH) |
|
85 |
.setDescription("Width") |
|
86 |
.setMandatory(false); |
|
87 |
|
|
88 |
definition.addDynFieldInt(FIELD_HEIGHT) |
|
89 |
.setDescription("Height") |
|
90 |
.setMandatory(false); |
|
91 |
|
|
92 |
definition.addDynFieldBoolean(FIELD_OVERRIDE) |
|
93 |
.setDescription("Override a host capabilities") |
|
94 |
.setMandatory(false); |
|
95 |
|
|
96 |
definition.addDynFieldString(FIELD_SRSSTR) |
|
97 |
.setDescription("String that represents the SRS") |
|
98 |
.setMandatory(false); |
|
99 |
|
|
100 |
definition.addDynFieldString(FIELD_NAME) |
|
101 |
.setDescription("Layer name") |
|
102 |
.setMandatory(false); |
|
103 |
|
|
104 |
definition.addDynFieldString(FIELD_INFO_FORMAT) |
|
105 |
.setDescription("Info Format") |
|
106 |
.setMandatory(false); |
|
107 |
|
|
108 |
definition.addDynFieldString(FIELD_IMAGE_FORMAT) |
|
109 |
.setDescription("Image Format") |
|
110 |
.setMandatory(false); |
|
111 |
|
|
112 |
definition.addDynFieldString(FIELD_STYLE_NAME) |
|
113 |
.setDescription("Style") |
|
114 |
.setMandatory(false); |
|
115 |
|
|
116 |
definition.addDynFieldObject(FIELD_EXTENT) |
|
117 |
.setClassOfValue(Rectangle2D.class) |
|
118 |
.setDescription("Bounding box") |
|
119 |
.setMandatory(false); |
|
120 |
|
|
121 |
definition.addDynFieldString(FIELD_DIMENSION) |
|
122 |
.setDescription("Dimensions") |
|
123 |
.setMandatory(false); |
|
124 |
|
|
125 |
definition.addDynFieldString(FIELD_DIMENSION_VALUE) |
|
126 |
.setDescription("Value selected for the current dimension") |
|
127 |
.setMandatory(false); |
|
128 |
|
|
129 |
return definition; |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* Gets the selected dimension |
|
134 |
* @return |
|
135 |
*/ |
|
136 |
public String getDimension() { |
|
137 |
return (String)getDynValue(FIELD_DIMENSION); |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* Sets the selected dimension |
|
142 |
* @param dimension |
|
143 |
*/ |
|
144 |
public void setDimension(String dimension) { |
|
145 |
setDynValue(FIELD_DIMENSION, dimension); |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Gets the value for the selected dimension |
|
150 |
* @return |
|
151 |
*/ |
|
152 |
public String getDimensionSelectedValue() { |
|
153 |
return (String)getDynValue(FIELD_DIMENSION_VALUE); |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Sets the value for the selected dimension |
|
158 |
* @param dimension |
|
159 |
*/ |
|
160 |
public void setDimensionSelectedValue(String dimension) { |
|
161 |
setDynValue(FIELD_DIMENSION_VALUE, dimension); |
|
162 |
} |
|
163 |
|
|
164 |
/** |
|
165 |
* Gets the bounding box |
|
166 |
* @return |
|
167 |
*/ |
|
168 |
public Rectangle2D getExtent() { |
|
169 |
return (Rectangle2D)getDynValue(FIELD_EXTENT); |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* Assigns the extent. |
|
174 |
* When a provider is initialized this will need to know what is the extent before the request. |
|
175 |
* |
|
176 |
* @param bBox |
|
177 |
*/ |
|
178 |
public void setExtent(Rectangle2D bBox) { |
|
179 |
setDynValue(FIELD_EXTENT, bBox); |
|
180 |
} |
|
181 |
|
|
182 |
/** |
|
183 |
* Sets the style selected |
|
184 |
* @param layer |
|
185 |
*/ |
|
186 |
public void setStyle(WMTSStyle style) { |
|
187 |
setDynValue(FIELD_STYLE_NAME, style.getTitle()); |
|
188 |
this.style = style; |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Gets the style |
|
193 |
* @return |
|
194 |
*/ |
|
195 |
public WMTSStyle getStyle() { |
|
196 |
return style; |
|
197 |
} |
|
198 |
|
|
199 |
/** |
|
200 |
* Gets the image format |
|
201 |
* @return Format |
|
202 |
*/ |
|
203 |
public String getImageFormat() { |
|
204 |
return (String) this.getDynValue(FIELD_IMAGE_FORMAT); |
|
205 |
} |
|
206 |
|
|
207 |
/** |
|
208 |
* Sets the image format |
|
209 |
* @param format |
|
210 |
*/ |
|
211 |
public void setImageFormat(String format) { |
|
212 |
this.setDynValue(FIELD_IMAGE_FORMAT, format); |
|
213 |
} |
|
214 |
|
|
215 |
public String getInfoFormat() { |
|
216 |
return (String) this.getDynValue(FIELD_INFO_FORMAT); |
|
217 |
} |
|
218 |
|
|
219 |
public void setInfoFormat(String format) { |
|
220 |
this.setDynValue(FIELD_INFO_FORMAT, format); |
|
221 |
} |
|
222 |
|
|
223 |
/** |
|
224 |
* Devuelve el SRS. |
|
225 |
* @return SRS. |
|
226 |
*/ |
|
227 |
public String getSRSCode() { |
|
228 |
return (String) this.getDynValue(FIELD_SRSSTR); |
|
229 |
} |
|
230 |
|
|
231 |
public void setSRS(String m_srs) { |
|
232 |
m_srs = srsValidation(m_srs); |
|
233 |
this.setDynValue(FIELD_SRSSTR, m_srs); |
|
234 |
if(getEPSG(m_srs) != null) |
|
235 |
setSRS(CRSFactory.getCRS(getEPSG(m_srs))); |
|
236 |
} |
|
237 |
|
|
238 |
private String srsValidation(String srs) { |
|
239 |
if(srs == null) |
|
240 |
return null; |
|
241 |
if(srs.contains("CRS:84") || srs.contains("CRS84")) { |
|
242 |
return "EPSG:4326"; |
|
243 |
} |
|
244 |
|
|
245 |
if(srs.startsWith("EPSG") && !srs.startsWith("EPSG:")) { |
|
246 |
return "EPSG:" + srs.substring(srs.lastIndexOf("EPSG") + 1); |
|
247 |
} |
|
248 |
|
|
249 |
if(srs.contains("EPSG:") && !srs.startsWith("EPSG:")) { |
|
250 |
return "EPSG:" + srs.substring(srs.lastIndexOf(":") + 1); |
|
251 |
} |
|
252 |
return srs; |
|
253 |
} |
|
254 |
|
|
255 |
/** |
|
256 |
* Returns true if the layer is projected |
|
257 |
* @return |
|
258 |
*/ |
|
259 |
public boolean isProjected() { |
|
260 |
IProjection proj = getSRS(); |
|
261 |
if(proj == null) |
|
262 |
return true; |
|
263 |
else { |
|
264 |
try { |
|
265 |
return proj.isProjected(); |
|
266 |
} catch (Exception e) { |
|
267 |
LoggerFactory.getLogger(WMTSDataParameters.class).debug("error in projection", e); |
|
268 |
return true; |
|
269 |
} |
|
270 |
} |
|
271 |
} |
|
272 |
|
|
273 |
/** |
|
274 |
* Returns the current selected SRS. |
|
275 |
* @return |
|
276 |
*/ |
|
277 |
public String getEPSG(String value) { |
|
278 |
if(value != null) { |
|
279 |
if(value.compareTo("CRS:84") == 0) |
|
280 |
return "EPSG:4326"; |
|
281 |
|
|
282 |
String s = value.substring(value.lastIndexOf(":") + 1); |
|
283 |
return "EPSG:" + s; |
|
284 |
} |
|
285 |
return null; |
|
286 |
} |
|
287 |
|
|
288 |
public String getName() { |
|
289 |
return (String) this.getDynValue(FIELD_NAME); |
|
290 |
} |
|
291 |
|
|
292 |
public void setName(String name) { |
|
293 |
this.setDynValue(FIELD_NAME, name); |
|
294 |
} |
|
295 |
|
|
296 |
public boolean isOverridingHost() { |
|
297 |
Boolean b = (Boolean)getDynValue(FIELD_OVERRIDE); |
|
298 |
if(b != null) |
|
299 |
return ((Boolean)b).booleanValue(); |
|
300 |
return false; |
|
301 |
} |
|
302 |
|
|
303 |
public void setOverrideHost(boolean over) { |
|
304 |
this.setDynValue(FIELD_OVERRIDE, new Boolean(over));; |
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* Sets the width |
|
309 |
* When a provider is initialized this will need to know what is the width before the request. |
|
310 |
* @param w |
|
311 |
*/ |
|
312 |
public void setWidth(int w) { |
|
313 |
this.setDynValue(FIELD_WIDTH, new Integer(w)); |
|
314 |
} |
|
315 |
|
|
316 |
/** |
|
317 |
* Sets the height |
|
318 |
* When a provider is initialized this will need to know what is the height before the request. |
|
319 |
* @param h |
|
320 |
*/ |
|
321 |
public void setHeight(int h) { |
|
322 |
this.setDynValue(FIELD_HEIGHT, new Integer(h)); |
|
323 |
} |
|
324 |
|
|
325 |
/** |
|
326 |
* Gets the width |
|
327 |
* @return |
|
328 |
*/ |
|
329 |
public int getWidth() { |
|
330 |
Integer b = (Integer)getDynValue(FIELD_WIDTH); |
|
331 |
if(b != null) |
|
332 |
return ((Integer)b).intValue(); |
|
333 |
return 0; |
|
334 |
} |
|
335 |
|
|
336 |
/** |
|
337 |
* Gets the height |
|
338 |
* @return |
|
339 |
*/ |
|
340 |
public int getHeight() { |
|
341 |
Integer b = (Integer)getDynValue(FIELD_HEIGHT); |
|
342 |
if(b != null) |
|
343 |
return ((Integer)b).intValue(); |
|
344 |
return 0; |
|
345 |
} |
|
346 |
|
|
347 |
public void deleteCache(boolean deleteCache) { |
|
348 |
this.setDynValue(FIELD_DELETECACHE, new Boolean(deleteCache)); |
|
349 |
} |
|
350 |
|
|
351 |
public boolean isDeletingCache() { |
|
352 |
return ((Boolean)getDynValue(FIELD_DELETECACHE)).booleanValue(); |
|
353 |
} |
|
354 |
|
|
355 |
//********************************************** |
|
356 |
|
|
357 |
public String getDataStoreName() { |
|
358 |
return WMTSProvider.NAME; |
|
359 |
} |
|
360 |
|
|
361 |
public String getDescription() { |
|
362 |
return WMTSProvider.DESCRIPTION; |
|
363 |
} |
|
364 |
|
|
365 |
public String getExplorerName() { |
|
366 |
return WMTSServerExplorer.NAME; |
|
367 |
} |
|
368 |
|
|
369 |
public boolean isValid() { |
|
370 |
return (this.getURI() != null); |
|
371 |
} |
|
372 |
|
|
373 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
374 |
return delegatedDynObject; |
|
375 |
} |
|
376 |
|
|
377 |
/** |
|
378 |
* Clones this structure |
|
379 |
* @return |
|
380 |
*/ |
|
381 |
public WMTSDataParameters clone() { |
|
382 |
WMTSDataParametersImpl p = new WMTSDataParametersImpl(); |
|
383 |
p.setImageFormat(getImageFormat()); |
|
384 |
p.setInfoFormat(getInfoFormat()); |
|
385 |
p.setHeight(getHeight()); |
|
386 |
p.setWidth(getWidth()); |
|
387 |
p.setExtent(getExtent()); |
|
388 |
p.setURI(getURI()); |
|
389 |
p.setName(getName()); |
|
390 |
p.setOverrideHost(isOverridingHost()); |
|
391 |
p.setSRS(getSRS()); |
|
392 |
p.setSRS(getSRSCode()); |
|
393 |
p.setCancellable(getCancellable()); |
|
394 |
return p; |
|
395 |
} |
|
396 |
|
|
397 |
public boolean isSizeFixed() { |
|
398 |
return true; |
|
399 |
} |
|
400 |
|
|
401 |
public WMTSClient getOGCClient() { |
|
402 |
return ogcClient; |
|
403 |
} |
|
404 |
|
|
405 |
public void setOGCClient(WMTSClient ogcClient) { |
|
406 |
this.ogcClient = ogcClient; |
|
407 |
} |
|
408 |
|
|
409 |
/** |
|
410 |
* Sets the layer selected |
|
411 |
* @param layer |
|
412 |
*/ |
|
413 |
public void setLayer(WMTSLayer layer) { |
|
414 |
setName(layer.getTitle()); |
|
415 |
this.layer = layer; |
|
416 |
} |
|
417 |
|
|
418 |
/** |
|
419 |
* Gets the layer |
|
420 |
* @return |
|
421 |
*/ |
|
422 |
public WMTSLayer getLayer() { |
|
423 |
return layer; |
|
424 |
} |
|
425 |
|
|
426 |
public void setCancellable(ICancellable cancel) { |
|
427 |
this.cancel = cancel; |
|
428 |
} |
|
429 |
|
|
430 |
public ICancellable getCancellable() { |
|
431 |
return cancel; |
|
432 |
} |
|
433 |
|
|
434 |
public void assignFields(RasterDataParameters par, RasterDataServerExplorer explorer) { |
|
435 |
super.assignFields(par, explorer); |
|
436 |
WMTSDataParameters p = null; |
|
437 |
if(par instanceof WMTSDataParameters) |
|
438 |
p = (WMTSDataParameters)par; |
|
439 |
else |
|
440 |
return; |
|
441 |
|
|
442 |
setWidth(p.getWidth()); |
|
443 |
setHeight(p.getHeight()); |
|
444 |
setImageFormat(p.getImageFormat()); |
|
445 |
setInfoFormat(p.getInfoFormat()); |
|
446 |
setName(p.getName()); |
|
447 |
setSRS(p.getSRSCode()); |
|
448 |
setOverrideHost(p.isOverridingHost()); |
|
449 |
setExtent(p.getExtent()); |
|
450 |
|
|
451 |
if(explorer instanceof WMTSServerExplorer) { |
|
452 |
WMTSLayer wmtsLayer = ((WMTSServerExplorer)explorer).getOGCClient().getLayer(p.getName()); |
|
453 |
setLayer(wmtsLayer); |
|
454 |
List<WMTSStyle> wmtsStyles = wmtsLayer.getStyle(); |
|
455 |
for (int i = 0; i < wmtsStyles.size(); i++) { |
|
456 |
WMTSStyle style = wmtsStyles.get(i); |
|
457 |
if(style.getTitle() != null && style.getTitle().equals((String)getDynValue(FIELD_STYLE_NAME))) { |
|
458 |
this.style = style; |
|
459 |
} |
|
460 |
} |
|
461 |
if(this.style == null && wmtsStyles.size() > 0) |
|
462 |
this.style = wmtsStyles.get(0); |
|
463 |
} |
|
464 |
} |
|
465 |
|
|
466 |
} |
|
0 | 467 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.22/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/TilePipe.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.wmts.io; |
|
23 |
|
|
24 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTile; |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* This class manages transactions between the producer and the consumer. The |
|
29 |
* producer download tiles from a server and the consumer is a tile provider |
|
30 |
* which will return downloaded tiles. |
|
31 |
* |
|
32 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
33 |
*/ |
|
34 |
public class TilePipe { |
|
35 |
//N?mero de threads m?ximos a lanzar para descarga. Cuando se lanzan m?s de estos el |
|
36 |
//invocador debe dormir hasta que se haya liberado alguno. |
|
37 |
public static int NTHREADS_QUEUE = 5; |
|
38 |
//N?mero m?ximo de elementos en la tuberia. Cuando se llene esta el setTile de esta clase debe |
|
39 |
//dormir hasta que getTile lo despierte. |
|
40 |
private final static int BUFFER_SIZE = 10; |
|
41 |
|
|
42 |
private WMTSTile buffer[] = new WMTSTile[BUFFER_SIZE]; |
|
43 |
private int next = 0; |
|
44 |
private boolean isFull = false; |
|
45 |
private boolean isEmpty = true; |
|
46 |
private Thread threadManager = null; |
|
47 |
|
|
48 |
/** |
|
49 |
* El thread manager no se usa con la pool solo para la implementaci?n de RequestThreadManager |
|
50 |
* @param threadManager |
|
51 |
*/ |
|
52 |
public void setRequestManager(Thread threadManager) { |
|
53 |
this.threadManager = threadManager; |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* Sets a tile in the pipe |
|
58 |
* @param tile |
|
59 |
*/ |
|
60 |
public synchronized void setTile(WMTSTile tile) { |
|
61 |
while( isFull == true ) { |
|
62 |
try { |
|
63 |
wait(); |
|
64 |
} catch( InterruptedException e ) { |
|
65 |
} |
|
66 |
} |
|
67 |
buffer[next] = tile; |
|
68 |
next++; |
|
69 |
if( next == BUFFER_SIZE ) |
|
70 |
isFull = true; |
|
71 |
isEmpty = false; |
|
72 |
notify(); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* Gets a tile from the pipe |
|
77 |
* @return |
|
78 |
*/ |
|
79 |
public synchronized WMTSTile getTile() { |
|
80 |
while( isEmpty == true ) { |
|
81 |
try { |
|
82 |
wait(); |
|
83 |
} catch( InterruptedException e ) { |
|
84 |
} |
|
85 |
} |
|
86 |
next--; |
|
87 |
if( next == 0 ) |
|
88 |
isEmpty = true; |
|
89 |
isFull = false; |
|
90 |
notify(); |
|
91 |
if(threadManager != null && getSize() <= NTHREADS_QUEUE) { |
|
92 |
synchronized(threadManager) { |
|
93 |
threadManager.notify(); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
return buffer[next] ; |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Returns the number of elements in the queue |
|
102 |
* @return |
|
103 |
*/ |
|
104 |
public synchronized int getSize() { |
|
105 |
return next; |
|
106 |
} |
|
107 |
} |
|
0 | 108 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.22/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/DefaultWMTSIOLibrary.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.wmts.io; |
|
23 |
|
|
24 |
import org.gvsig.tools.library.AbstractLibrary; |
|
25 |
import org.gvsig.tools.library.LibraryException; |
|
26 |
/** |
|
27 |
* |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
*/ |
|
30 |
public class DefaultWMTSIOLibrary extends AbstractLibrary { |
|
31 |
|
|
32 |
public DefaultWMTSIOLibrary() { |
|
33 |
/*super(DefaultWMTSIOLibrary.class,Library.TYPE.IMPL); |
|
34 |
require(ToolsLibrary.class); |
|
35 |
require(DALLibrary.class); |
|
36 |
require(DALFileLibrary.class);*/ |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
protected void doInitialize() throws LibraryException { |
|
41 |
//RasterLibrary.wakeUp(); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void doPostInitialize() throws LibraryException { |
|
46 |
WMTSServerExplorerParameters.registerDynClass(); |
|
47 |
WMTSDataParametersImpl.registerDynClass(); |
|
48 |
WMTSProvider.register(); |
|
49 |
} |
|
50 |
} |
|
0 | 51 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.22/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/WMTSCacheStruct.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.wmts.io.downloader; |
|
23 |
|
|
24 |
import java.awt.geom.Point2D; |
|
25 |
import java.awt.geom.Rectangle2D; |
|
26 |
import java.io.File; |
|
27 |
import java.net.URL; |
|
28 |
import java.util.ArrayList; |
|
29 |
import java.util.List; |
|
30 |
|
|
31 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
32 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
33 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
34 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
|
35 |
import org.gvsig.raster.cache.tile.Tile; |
|
36 |
import org.gvsig.raster.cache.tile.TileCacheLocator; |
|
37 |
import org.gvsig.raster.cache.tile.exception.TileBuildException; |
|
38 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
39 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
40 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
|
41 |
import org.gvsig.raster.wmts.ogc.WMTSStatus; |
|
42 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTile; |
|
43 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix; |
|
44 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixLimits; |
|
45 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSet; |
|
46 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSetLink; |
|
47 |
|
|
48 |
/** |
|
49 |
* Implementation for a structure of a cache |
|
50 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
51 |
*/ |
|
52 |
public class WMTSCacheStruct implements CacheStruct { |
|
53 |
private String layerName = null; |
|
54 |
private String serverURL = null; |
|
55 |
private WMTSTileMatrixSet tileMatrixSet = null; |
|
56 |
private List<WMTSTileMatrixLimits> tileMatrixSetLimits = null; |
|
57 |
private double[] pixelSize = null; |
|
58 |
private RasterDataStore store = null; |
|
59 |
|
|
60 |
public WMTSCacheStruct(RasterDataStore store, WMTSTileMatrixSetLink tileMatrixSetLink) { |
|
61 |
this.store = store; |
|
62 |
this.tileMatrixSet = tileMatrixSetLink.getTileMatrixSet(); |
|
63 |
this.tileMatrixSetLimits = tileMatrixSetLink.getTileMatrixLimits(); |
|
64 |
pixelSize = ((WMTSProvider)store.getProvider()).getPixelSizeByLevel(); |
|
65 |
serverURL = ((WMTSProvider)store.getProvider()).getURIOfFirstProvider().getPath(); |
|
66 |
layerName = ((WMTSDataParameters)store.getParameters()).getLayer().getTitle(); |
|
67 |
} |
|
68 |
|
|
69 |
public int getNumberOfLevels() { |
|
70 |
return tileMatrixSet.getTileMatrix().size(); |
|
71 |
} |
|
72 |
|
|
73 |
public String getLayerName() { |
|
74 |
return layerName; |
|
75 |
} |
|
76 |
|
|
77 |
public String getServerURL() { |
|
78 |
return serverURL + getDimension(); |
|
79 |
} |
|
80 |
|
|
81 |
public int[] getTileSizeByLevel(int level) { |
|
82 |
return new int[] { |
|
83 |
((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileWidth(), |
|
84 |
((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileHeight() |
|
85 |
}; |
|
86 |
} |
|
87 |
|
|
88 |
public int getLayerWidthOfTileMatrixByLevel(int level) { |
|
89 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
90 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
91 |
return l.getMaxTileRow() - l.getMinTileRow(); |
|
92 |
} else { |
|
93 |
WMTSTileMatrix tm = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level); |
|
94 |
return (int)tm.getMatrixWidth(); |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
public int getLayerHeightOfTileMatrixByLevel(int level) { |
|
99 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
100 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
101 |
return l.getMaxTileCol() - l.getMinTileCol(); |
|
102 |
} else { |
|
103 |
WMTSTileMatrix tm = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level); |
|
104 |
return (int)tm.getMatrixHeight(); |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
public int getLayerInitXTilePositionByLevel(int level) { |
|
109 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
110 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
111 |
return l.getMinTileCol(); |
|
112 |
} else |
|
113 |
return 0; |
|
114 |
} |
|
115 |
|
|
116 |
public int getLayerInitYTilePositionByLevel(int level) { |
|
117 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
118 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
119 |
return l.getMinTileRow(); |
|
120 |
} else |
|
121 |
return 0; |
|
122 |
} |
|
123 |
|
|
124 |
public long getWorldHeightOfTileMatrixByLevel(int level) { |
|
125 |
return ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getMatrixWidth(); |
|
126 |
} |
|
127 |
|
|
128 |
public long getWorldWidthOfTileMatrixByLevel(int level) { |
|
129 |
return ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getMatrixHeight(); |
|
130 |
} |
|
131 |
|
|
132 |
public double getPixelSizeByLevel(int level) { |
|
133 |
if(level < pixelSize.length) |
|
134 |
return pixelSize[level]; |
|
135 |
else |
|
136 |
return pixelSize[pixelSize.length - 1]; |
|
137 |
} |
|
138 |
|
|
139 |
public Point2D[] getTileExtent(Tile tile) { |
|
140 |
return getTileExtent(tile.getLevel(), tile.getCol(), tile.getRow()); |
|
141 |
} |
|
142 |
|
|
143 |
public Point2D[] getTileExtent(int level, int col, int row) { |
|
144 |
double[] ul = tileMatrixSet.getBoundingBox().getUpperCorner(); |
|
145 |
long tileWidth = ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileWidth(); |
|
146 |
long tileHeight = ((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileHeight(); |
|
147 |
double mtsWidthTile = tileWidth * pixelSize[level]; |
|
148 |
double mtsHeightTile = tileHeight * pixelSize[level]; |
|
149 |
double ulx = ul[0] + (col * mtsWidthTile); |
|
150 |
double uly = ulx + mtsWidthTile; |
|
151 |
double lrx = ul[1] - (row * mtsHeightTile); |
|
152 |
double lry = lrx - mtsHeightTile; |
|
153 |
return new Point2D[]{new Point2D.Double(ulx, uly), new Point2D.Double(lrx, lry)}; |
|
154 |
} |
|
155 |
|
|
156 |
public Tile getTileStructure(int level, int tileCol, int tileRow, Point2D ul, Point2D lr) throws TileBuildException { |
|
157 |
int[] size = getTileSizeByLevel(level); |
|
158 |
Tile tile = TileCacheLocator.getManager().createTile(level, tileRow, tileCol); |
|
159 |
tile.setUl(ul); |
|
160 |
tile.setLr(lr); |
|
161 |
tile.setWidthPx(size[0]); |
|
162 |
tile.setHeightPx(size[1]); |
|
163 |
|
|
164 |
Rectangle2D r = new Rectangle2D.Double(Math.min(ul.getX(), lr.getX()), |
|
165 |
Math.min(ul.getY(), lr.getY()), |
|
166 |
Math.abs(ul.getX() - lr.getX()), |
|
167 |
Math.abs(ul.getY() - lr.getY())); |
|
168 |
int bufWidth = (int)(r.getWidth() / getPixelSizeByLevel(level)); |
|
169 |
int bufHeight = (int)(r.getHeight() / getPixelSizeByLevel(level)); |
|
170 |
try { |
|
171 |
WMTSStatus status = ((WMTSProvider)store.getProvider()).buildWMTSStatus(r, bufWidth, bufHeight); |
|
172 |
tile.setDownloaderParams("WMTSStatus", status); |
|
173 |
} catch (RasterDriverException e) { |
|
174 |
throw new TileBuildException(e); |
|
175 |
} |
|
176 |
|
|
177 |
return tile; |
|
178 |
} |
|
179 |
|
|
180 |
public List<Tile> getTileList(Point2D ul, Point2D lr, double mtsPixelRequest) throws TileBuildException { |
|
181 |
Rectangle2D r = new Rectangle2D.Double(Math.min(ul.getX(), lr.getX()), |
|
182 |
Math.min(ul.getY(), lr.getY()), |
|
183 |
Math.abs(ul.getX() - lr.getX()), |
|
184 |
Math.abs(ul.getY() - lr.getY())); |
|
185 |
int bufWidth = (int)(r.getWidth() / mtsPixelRequest); |
|
186 |
int bufHeight = (int)(r.getHeight() / mtsPixelRequest); |
|
187 |
try { |
|
188 |
WMTSStatus status = ((WMTSProvider)store.getProvider()).buildWMTSStatus(r, bufWidth, bufHeight); |
|
189 |
|
|
190 |
//Conversi?n a tiles de la librer?a |
|
191 |
List<WMTSTile> tiles = status.getTileList(); |
|
192 |
List<Tile> tileList = new ArrayList<Tile>(); |
|
193 |
for (int i = 0; i < tiles.size(); i++) { |
|
194 |
WMTSTile tOrigin = (WMTSTile) tiles.get(i); |
|
195 |
Tile t = TileCacheLocator.getManager().createTile(status.getLevel(), tOrigin.getCol(), tOrigin.getRow()); |
|
196 |
t.setUl(new Point2D.Double(tOrigin.getULX(), tOrigin.getULY())); |
|
197 |
t.setLr(new Point2D.Double(tOrigin.getLRX(), tOrigin.getLRY())); |
|
198 |
t.setWidthPx(tOrigin.getWidthPx()); |
|
199 |
t.setHeightPx(tOrigin.getHeightPx()); |
|
200 |
t.setDownloaderParams("WMTSStatus", status.cloneStatus()); |
|
201 |
tileList.add(t); |
|
202 |
} |
|
203 |
return tileList; |
|
204 |
} catch (RasterDriverException e) { |
|
205 |
throw new TileBuildException(e); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
public double[] getTileSizeInRealCoordsByLevel(int level) { |
|
210 |
return new double[] { |
|
211 |
getPixelSizeByLevel(level) * getTileSizeByLevel(level)[0], |
|
212 |
getPixelSizeByLevel(level) * getTileSizeByLevel(level)[1] |
|
213 |
}; |
|
214 |
} |
|
215 |
|
|
216 |
public String getFileSuffix() { |
|
217 |
return ((WMTSProvider)store.getProvider()).getFileSuffix(); |
|
218 |
} |
|
219 |
|
|
220 |
public boolean compare(CacheStruct struct) { |
|
221 |
MathUtils mu = RasterLocator.getManager().getMathUtils(); |
|
222 |
//Compara: n?mero de niveles, tama?o de tile, |
|
223 |
//anchoXalto de la matriz, tama?o de pixel por nivel, |
|
224 |
//coordenadas de al menos un tile de la matriz |
|
225 |
if(struct.getNumberOfLevels() == getNumberOfLevels()) { |
|
226 |
for (int i = 0; i < getNumberOfLevels(); i++) { |
|
227 |
if( struct.getTileSizeByLevel(i)[0] == getTileSizeByLevel(i)[0] && |
|
228 |
struct.getTileSizeByLevel(i)[1] == getTileSizeByLevel(i)[1] && |
|
229 |
struct.getWorldHeightOfTileMatrixByLevel(i) == getWorldHeightOfTileMatrixByLevel(i) && |
|
230 |
struct.getWorldWidthOfTileMatrixByLevel(i) == getWorldWidthOfTileMatrixByLevel(i) && |
|
231 |
mu.clipDecimals(struct.getPixelSizeByLevel(i), 2) == mu.clipDecimals(getPixelSizeByLevel(i), 2) && |
|
232 |
compareExtents(struct.getTileExtent(i, 0, 0), getTileExtent(i, 0, 0))) { |
|
233 |
return true; |
|
234 |
} |
|
235 |
} |
|
236 |
} |
|
237 |
return false; |
|
238 |
} |
|
239 |
|
|
240 |
private boolean compareExtents(Point2D[] p, Point2D[] p1) { |
|
241 |
return (p[0].getX() == p1[0].getX() && p[0].getY() == p1[0].getY() && |
|
242 |
p[1].getX() == p1[1].getX() && p[1].getY() == p1[1].getY()); |
|
243 |
} |
|
244 |
|
|
245 |
public String getEPSG() { |
|
246 |
/*IProjection proj = provider.getProjection(); |
|
247 |
if(proj != null) |
|
248 |
return proj.getAbrev(); |
|
249 |
return null;*/ |
|
250 |
return ((WMTSProvider)store.getProvider()).getSRSCode(); |
|
251 |
} |
|
252 |
|
|
253 |
private String getDimension() { |
|
254 |
WMTSDataParameters p = (WMTSDataParameters)(((WMTSProvider)store.getProvider()).getDataParameters()); |
|
255 |
String dimension = p.getDimension(); |
|
256 |
String dimensionValue = p.getDimensionSelectedValue(); |
|
257 |
if(dimension != null && dimensionValue != null) |
|
258 |
return dimension + "_" + dimensionValue; |
|
259 |
return ""; |
|
260 |
} |
|
261 |
|
|
262 |
public String getFileSize() { |
|
263 |
return "0"; |
|
264 |
} |
|
265 |
|
|
266 |
public List<Tile> getTileList(int x, int y, int w, int h) { |
|
267 |
return null; |
|
268 |
} |
|
269 |
|
|
270 |
public ArrayList<Tile> getTileList(Rectangle2D r) { |
|
271 |
return null; |
|
272 |
} |
|
273 |
} |
|
0 | 274 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.22/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/TileDownloaderForWMTS.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.wmts.io.downloader; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import java.net.ConnectException; |
|
27 |
import java.net.URL; |
|
28 |
|
|
29 |
import org.gvsig.compat.net.ICancellable; |
|
30 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
|
31 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
32 |
import org.gvsig.raster.cache.tile.Tile; |
|
33 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
34 |
import org.gvsig.raster.impl.provider.tile.BaseTileDownloader; |
|
35 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
36 |
import org.gvsig.raster.wmts.ogc.WMTSClient; |
|
37 |
import org.gvsig.raster.wmts.ogc.WMTSOGCLocator; |
|
38 |
import org.gvsig.raster.wmts.ogc.WMTSStatus; |
|
39 |
import org.gvsig.raster.wmts.ogc.exception.ServerErrorException; |
|
40 |
import org.gvsig.raster.wmts.ogc.exception.WMTSException; |
|
41 |
|
|
42 |
/** |
|
43 |
* Tile getter |
|
44 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
45 |
*/ |
|
46 |
public class TileDownloaderForWMTS extends BaseTileDownloader { |
|
47 |
private WMTSClient ogcClient = null; |
|
48 |
|
|
49 |
public TileDownloaderForWMTS(RasterDataStore store, |
|
50 |
int tilePxWidth, |
|
51 |
int tilePxHeight) { |
|
52 |
super(store, tilePxWidth, tilePxHeight); |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* Gets the connector from the URL |
|
57 |
* @return |
|
58 |
* @throws RemoteServiceException |
|
59 |
*/ |
|
60 |
public WMTSClient getOGCClient() throws WMTSException { |
|
61 |
if(ogcClient == null) { |
|
62 |
WMTSDataParameters p = (WMTSDataParameters)store.getParameters(); |
|
63 |
ogcClient = p.getOGCClient(); |
|
64 |
if(ogcClient != null) |
|
65 |
return ogcClient; |
|
66 |
|
|
67 |
URL url = null; |
|
68 |
try { |
|
69 |
url = p.getURI().toURL(); |
|
70 |
} catch (Exception e) { |
|
71 |
throw new WMTSException("Malformed URL",e); |
|
72 |
} |
|
73 |
try { |
|
74 |
ogcClient = WMTSOGCLocator.getManager().createWMTSClient(url.toString()); |
|
75 |
ogcClient.connect(false, new ICancellable() { |
|
76 |
public boolean isCanceled() { |
|
77 |
return false; |
|
78 |
} |
|
79 |
|
|
80 |
public Object getID() { |
|
81 |
return null; |
|
82 |
} |
|
83 |
}); |
|
84 |
} catch (ConnectException e) { |
|
85 |
throw new WMTSException("Connect exception",e); |
|
86 |
} catch (IOException e) { |
|
87 |
throw new WMTSException("Connect exception",e); |
|
88 |
} |
|
89 |
} |
|
90 |
return ogcClient; |
|
91 |
} |
|
92 |
|
|
93 |
public synchronized Tile downloadTile(Tile tile) throws TileGettingException { |
|
94 |
try { |
|
95 |
WMTSStatus status = (WMTSStatus)tile.getDownloaderParams("WMTSStatus"); |
|
96 |
status.setTileRow(tile.getRow()); |
|
97 |
status.setTileCol(tile.getCol()); |
|
98 |
|
|
99 |
String urlFromTemplate = status.getResourceURL(tile.getRow() + "" + tile.getCol() + ""); |
|
100 |
//System.out.println(urlFromTemplate); |
|
101 |
File f = null; |
|
102 |
if(urlFromTemplate != null) |
|
103 |
f = getOGCClient().getTile(urlFromTemplate, tile.getCancelled(), tile.getFile()); |
|
104 |
else |
|
105 |
f = getOGCClient().getTile(status, tile.getCancelled(), tile.getFile()); |
|
106 |
tile.setFile(f); |
|
107 |
//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para |
|
108 |
//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros |
|
109 |
//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf"); |
|
110 |
//if(rmf.exists()) |
|
111 |
//rmf.delete(); |
|
112 |
} catch (WMTSException e) { |
|
113 |
throw new TileGettingException(e); |
|
114 |
} catch (ServerErrorException e) { |
|
115 |
throw new TileGettingException(e); |
|
116 |
} |
|
117 |
readTileFromDisk(tile); |
|
118 |
return tile; |
|
119 |
} |
|
120 |
|
|
121 |
} |
|
0 | 122 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.22/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/WMTSTileServer.java | ||
---|---|---|
1 |
package org.gvsig.raster.wmts.io.downloader; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
4 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
5 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
6 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
7 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix; |
|
8 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSetLink; |
|
9 |
|
|
10 |
/** |
|
11 |
* Data server for the tile cache in a WMTSProvider |
|
12 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
13 |
*/ |
|
14 |
public class WMTSTileServer implements TileServer { |
|
15 |
private CacheStruct struct = null; |
|
16 |
private Downloader downloader = null; |
|
17 |
private RasterDataStore store = null; |
|
18 |
private String suffix = ".tif"; |
|
19 |
private WMTSTileMatrixSetLink tileMatrixSetLink = null; |
|
20 |
|
|
21 |
public WMTSTileServer(RasterDataStore store, |
|
22 |
WMTSTileMatrixSetLink tileMatrixSetLink) { |
|
23 |
this.store = store; |
|
24 |
this.tileMatrixSetLink = tileMatrixSetLink; |
|
25 |
} |
|
26 |
|
|
27 |
public Downloader getDownloader() { |
|
28 |
//if(downloader == null) { |
|
29 |
int tileWidth = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileWidth(); |
|
30 |
int tileHeight = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileHeight(); |
|
31 |
downloader = new TileDownloaderForWMTS(store, tileWidth, tileHeight); |
|
32 |
//} |
|
33 |
return downloader; |
|
34 |
} |
|
35 |
|
|
36 |
public CacheStruct getStruct() { |
|
37 |
if(struct == null) { |
|
38 |
struct = new WMTSCacheStruct(store, tileMatrixSetLink); |
|
39 |
} |
|
40 |
return struct; |
|
41 |
} |
|
42 |
|
|
43 |
public void setStruct(CacheStruct struct) { |
|
44 |
//La structura de cache es proporcionada por el servidor |
|
45 |
} |
|
46 |
|
|
47 |
public String getFileSuffix() { |
|
48 |
return suffix; |
|
49 |
} |
|
50 |
|
|
51 |
public void setFileSuffix(String extension) { |
|
52 |
this.suffix = extension; |
|
53 |
} |
|
54 |
} |
|
0 | 55 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.22/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/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.wmts.io package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>WMTS provider</p> |
|
11 |
|
|
12 |
</body> |
|
13 |
</html> |
|
0 | 14 |
org.gvsig.raster.wmts/tags/org.gvsig.raster.wmts-2.2.22/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSServerExplorer.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.wmts.io; |
|
29 |
|
|
30 |
import java.io.IOException; |
|
31 |
import java.io.InputStream; |
|
32 |
import java.net.MalformedURLException; |
|
33 |
import java.net.URI; |
|
34 |
import java.net.URISyntaxException; |
|
35 |
import java.net.URL; |
|
36 |
import java.net.URLConnection; |
|
37 |
import java.util.List; |
|
38 |
|
|
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
41 |
|
|
42 |
import org.gvsig.compat.net.ICancellable; |
|
43 |
import org.gvsig.fmap.dal.DALLocator; |
|
44 |
import org.gvsig.fmap.dal.DataManager; |
|
45 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
46 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
47 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
48 |
import org.gvsig.fmap.dal.coverage.exception.ConnectException; |
|
49 |
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer; |
|
50 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
51 |
import org.gvsig.fmap.dal.exception.DataException; |
|
52 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
53 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
54 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
|
55 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
|
56 |
import org.gvsig.raster.wmts.ogc.WMTSClient; |
|
57 |
import org.gvsig.raster.wmts.ogc.WMTSOGCLocator; |
|
58 |
|
|
59 |
/** |
|
60 |
* Explorer for a WMTS server |
|
61 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
62 |
*/ |
|
63 |
public class WMTSServerExplorer implements RasterDataServerExplorer, DataServerExplorerProvider { |
|
64 |
public static final String NAME = WMTSProvider.NAME; |
|
65 |
private WMTSClient ogcClient = null; |
|
66 |
private WMTSServerExplorerParameters parameters = null; |
|
67 |
private static final Logger logger = LoggerFactory.getLogger(WMTSServerExplorer.class); |
|
68 |
|
|
69 |
public WMTSServerExplorer( |
|
70 |
WMTSServerExplorerParameters parameters, |
|
71 |
DataServerExplorerProviderServices services) |
|
72 |
throws InitializeException { |
|
73 |
this.parameters = parameters; |
|
74 |
} |
|
75 |
|
|
76 |
public String getDataStoreProviderName() { |
|
77 |
return WMTSProvider.NAME; |
|
78 |
} |
|
79 |
|
|
80 |
public String getDescription() { |
|
81 |
return WMTSProvider.DESCRIPTION; |
|
82 |
} |
|
83 |
|
|
84 |
public boolean add(String provider, NewDataStoreParameters parameters, |
|
85 |
boolean overwrite) throws DataException { |
|
86 |
return false; |
|
87 |
} |
|
88 |
|
|
89 |
public boolean canAdd() { |
|
90 |
return false; |
|
91 |
} |
|
92 |
|
|
93 |
public boolean canAdd(String storeName) throws DataException { |
|
94 |
return false; |
|
95 |
} |
|
96 |
|
|
97 |
public NewDataStoreParameters getAddParameters(String storeName) |
|
98 |
throws DataException { |
|
99 |
return null; |
Also available in: Unified diff