Revision 2208
org.gvsig.raster.wmts/tags/tagdate_11102013_11_26/org.gvsig.raster.wmts/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/tagdate_11102013_11_26/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSServerExplorerParameters.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 org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
31 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
|
32 |
import org.gvsig.tools.ToolsLocator; |
|
33 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
34 |
import org.gvsig.tools.dynobject.DynClass; |
|
35 |
import org.gvsig.tools.dynobject.DynField; |
|
36 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
37 |
|
|
38 |
/** |
|
39 |
* Parameters for the WMTS provider |
|
40 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
41 |
*/ |
|
42 |
public class WMTSServerExplorerParameters extends AbstractDataParameters implements DataServerExplorerParameters { |
|
43 |
public static final String DYNCLASS_NAME = "WMTSServerExplorerParameters"; |
|
44 |
protected static final String FIELD_HOST = "host"; |
|
45 |
protected static DynClass DYNCLASS = null; |
|
46 |
private DelegatedDynObject delegatedDynObject = null; |
|
47 |
private static final String AXIS_ORDER = "axisorder"; |
|
48 |
|
|
49 |
|
|
50 |
public WMTSServerExplorerParameters() { |
|
51 |
super(); |
|
52 |
initialize(); |
|
53 |
} |
|
54 |
|
|
55 |
protected void initialize() { |
|
56 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator |
|
57 |
.getDynObjectManager().createDynObject( |
|
58 |
DYNCLASS); |
|
59 |
} |
|
60 |
|
|
61 |
public static void registerDynClass() { |
|
62 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
63 |
DynClass dynClass; |
|
64 |
DynField field; |
|
65 |
|
|
66 |
if(dynman == null) |
|
67 |
return; |
|
68 |
|
|
69 |
if (DYNCLASS == null) { |
|
70 |
dynClass = dynman.add(DYNCLASS_NAME); |
|
71 |
|
|
72 |
field = dynClass.addDynFieldString(FIELD_HOST); |
|
73 |
field.setDescription("Uniform Resource Identifier (File name or URL)"); |
|
74 |
field.setMandatory(true); |
|
75 |
field.setClassOfValue(String.class); |
|
76 |
|
|
77 |
|
|
78 |
field = dynClass.addDynField(AXIS_ORDER); |
|
79 |
field.setDescription("Longitude first in axis order"); |
|
80 |
field.setMandatory(false); |
|
81 |
field.setClassOfValue(Boolean.class); |
|
82 |
field.setDefaultFieldValue(new Boolean(false)); |
|
83 |
|
|
84 |
DYNCLASS = dynClass; |
|
85 |
} |
|
86 |
|
|
87 |
} |
|
88 |
|
|
89 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
90 |
return delegatedDynObject; |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* Returns true if the longitude is first in axis order |
|
95 |
* @return |
|
96 |
*/ |
|
97 |
public boolean isLongitudeFirst() { |
|
98 |
Object obj = getDynValue(AXIS_ORDER); |
|
99 |
if(obj instanceof Boolean) { |
|
100 |
Boolean b = (Boolean)getDynValue(AXIS_ORDER); |
|
101 |
if(b != null) |
|
102 |
return ((Boolean)b).booleanValue(); |
|
103 |
} |
|
104 |
if(obj instanceof String) { |
|
105 |
String b = (String)getDynValue(AXIS_ORDER); |
|
106 |
if(b != null) |
|
107 |
return new Boolean(((String)b)); |
|
108 |
} |
|
109 |
return false; |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* Sets the longitude first in axis order |
|
114 |
* @param longFirst |
|
115 |
*/ |
|
116 |
public void setLongitudeFirst(boolean longFirst) { |
|
117 |
this.setDynValue(AXIS_ORDER, new Boolean(longFirst)); |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* Gets the assigned host |
|
122 |
* @return |
|
123 |
*/ |
|
124 |
public String getHost() { |
|
125 |
return (String) this.getDynValue(FIELD_HOST); |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* Assign the host to this explorer |
|
130 |
* @param host |
|
131 |
*/ |
|
132 |
public void setHost(String host) { |
|
133 |
this.setDynValue(FIELD_HOST, host); |
|
134 |
} |
|
135 |
|
|
136 |
/* |
|
137 |
* (non-Javadoc) |
|
138 |
* @see org.gvsig.fmap.dal.DataStoreParameters#getDataStoreName() |
|
139 |
*/ |
|
140 |
public String getDataStoreName() { |
|
141 |
return WMTSProvider.NAME; |
|
142 |
} |
|
143 |
|
|
144 |
/* |
|
145 |
* (non-Javadoc) |
|
146 |
* @see org.gvsig.fmap.dal.DataStoreParameters#getDescription() |
|
147 |
*/ |
|
148 |
public String getDescription() { |
|
149 |
return WMTSProvider.DESCRIPTION; |
|
150 |
} |
|
151 |
|
|
152 |
/* |
|
153 |
* (non-Javadoc) |
|
154 |
* @see org.gvsig.fmap.dal.DataServerExplorerParameters#getExplorerName() |
|
155 |
*/ |
|
156 |
public String getExplorerName() { |
|
157 |
return WMTSServerExplorer.NAME; |
|
158 |
} |
|
159 |
} |
|
0 | 160 |
org.gvsig.raster.wmts/tags/tagdate_11102013_11_26/org.gvsig.raster.wmts/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 |
|
|
27 |
import org.cresques.cts.IProjection; |
|
28 |
import org.gvsig.compat.net.ICancellable; |
|
29 |
import org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters; |
|
30 |
import org.gvsig.raster.wmts.ogc.WMTSClient; |
|
31 |
import org.gvsig.raster.wmts.ogc.struct.WMTSLayer; |
|
32 |
import org.gvsig.raster.wmts.ogc.struct.WMTSStyle; |
|
33 |
|
|
34 |
/** |
|
35 |
* Parameters for the WMTS provider |
|
36 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
37 |
*/ |
|
38 |
public interface WMTSDataParameters extends RemoteStoreParameters { |
|
39 |
public static final String DYNCLASS_NAME = "WMTSDataParameters"; |
|
40 |
public static final String FIELD_SRS = "srs"; |
|
41 |
public static final String FIELD_IMAGE_FORMAT = "imageformat"; |
|
42 |
public static final String FIELD_INFO_FORMAT = "infoformat"; |
|
43 |
public static final String FIELD_LAYER = "layer"; |
|
44 |
public static final String FIELD_STYLE = "style"; |
|
45 |
public static final String FIELD_NAME = "name"; |
|
46 |
public static final String FIELD_SRSSTR = "srsstr"; |
|
47 |
public static final String FIELD_OVERRIDE = "override"; |
|
48 |
public static final String FIELD_CANCEL = "cancellable"; |
|
49 |
public static final String FIELD_EXTENT = "extent"; |
|
50 |
public static final String FIELD_WIDTH = "width"; |
|
51 |
public static final String FIELD_HEIGHT = "height"; |
|
52 |
public static final String FIELD_DELETECACHE = "deletecache"; |
|
53 |
public static final String OGC_CLIENT = "ogcclient"; |
|
54 |
|
|
55 |
/** |
|
56 |
* Assign the fields of the selected WMTSDataParameters in the current |
|
57 |
* @param p |
|
58 |
*/ |
|
59 |
public void assignFields(WMTSDataParameters p); |
|
60 |
|
|
61 |
/** |
|
62 |
* Sets the style selected |
|
63 |
* @param layer |
|
64 |
*/ |
|
65 |
public void setStyle(WMTSStyle layer); |
|
66 |
|
|
67 |
/** |
|
68 |
* Gets the style |
|
69 |
* @return |
|
70 |
*/ |
|
71 |
public WMTSStyle getStyle(); |
|
72 |
|
|
73 |
/** |
|
74 |
* Gets the image format |
|
75 |
* @return Format |
|
76 |
*/ |
|
77 |
public String getImageFormat(); |
|
78 |
|
|
79 |
/** |
|
80 |
* Sets the image format |
|
81 |
* @param format |
|
82 |
*/ |
|
83 |
public void setImageFormat(String format); |
|
84 |
|
|
85 |
/** |
|
86 |
* Gets the format of the info by point |
|
87 |
* @return |
|
88 |
*/ |
|
89 |
public String getInfoFormat(); |
|
90 |
|
|
91 |
/** |
|
92 |
* Sets the format of the info by point |
|
93 |
*/ |
|
94 |
public void setInfoFormat(String format); |
|
95 |
|
|
96 |
/** |
|
97 |
* Sets the layer selected |
|
98 |
* @param layer |
|
99 |
*/ |
|
100 |
public void setLayer(WMTSLayer layer); |
|
101 |
|
|
102 |
/** |
|
103 |
* Gets the layer |
|
104 |
* @return |
|
105 |
*/ |
|
106 |
public WMTSLayer getLayer(); |
|
107 |
|
|
108 |
/** |
|
109 |
* Devuelve el SRS. |
|
110 |
* @return SRS. |
|
111 |
*/ |
|
112 |
public String getSRSCode(); |
|
113 |
|
|
114 |
public void setSRS(String m_srs); |
|
115 |
|
|
116 |
public void setSRS(IProjection srs); |
|
117 |
|
|
118 |
/** |
|
119 |
* Returns the projection |
|
120 |
* @return |
|
121 |
*/ |
|
122 |
public IProjection getSRS(); |
|
123 |
|
|
124 |
/** |
|
125 |
* Returns true if the layer is projected |
|
126 |
* @return |
|
127 |
*/ |
|
128 |
public boolean isProjected(); |
|
129 |
|
|
130 |
public String getSRSID(); |
|
131 |
|
|
132 |
public void setSRSID(String srsid); |
|
133 |
|
|
134 |
/** |
|
135 |
* Returns the current selected SRS. |
|
136 |
* @return |
|
137 |
*/ |
|
138 |
public String getEPSG(String value); |
|
139 |
|
|
140 |
public String getName(); |
|
141 |
|
|
142 |
public void setName(String name); |
|
143 |
|
|
144 |
public void setCancellable(ICancellable cancel); |
|
145 |
|
|
146 |
public ICancellable getCancellable(); |
|
147 |
|
|
148 |
public boolean isOverridingHost(); |
|
149 |
|
|
150 |
public void setOverrideHost(boolean over); |
|
151 |
/** |
|
152 |
* Assigns the extent. |
|
153 |
* When a provider is initialized this will need to know what is the extent before the request. |
|
154 |
* |
|
155 |
* @param bBox |
|
156 |
*/ |
|
157 |
public void setExtent(Rectangle2D bBox); |
|
158 |
|
|
159 |
/** |
|
160 |
* Sets the width |
|
161 |
* When a provider is initialized this will need to know what is the width before the request. |
|
162 |
* @param w |
|
163 |
*/ |
|
164 |
public void setWidth(int w); |
|
165 |
|
|
166 |
/** |
|
167 |
* Sets the height |
|
168 |
* When a provider is initialized this will need to know what is the height before the request. |
|
169 |
* @param h |
|
170 |
*/ |
|
171 |
public void setHeight(int h); |
|
172 |
|
|
173 |
/** |
|
174 |
* Gets the bounding box |
|
175 |
* @return |
|
176 |
*/ |
|
177 |
public Rectangle2D getExtent(); |
|
178 |
|
|
179 |
/** |
|
180 |
* Gets the width |
|
181 |
* @return |
|
182 |
*/ |
|
183 |
public int getWidth(); |
|
184 |
|
|
185 |
/** |
|
186 |
* Gets the height |
|
187 |
* @return |
|
188 |
*/ |
|
189 |
public int getHeight(); |
|
190 |
|
|
191 |
public boolean isSizeFixed(); |
|
192 |
|
|
193 |
public void setURI(String params); |
|
194 |
|
|
195 |
public String getURI(); |
|
196 |
|
|
197 |
public WMTSClient getOGCClient(); |
|
198 |
|
|
199 |
public void setOGCClient(WMTSClient ogcClient); |
|
200 |
} |
|
0 | 201 |
org.gvsig.raster.wmts/tags/tagdate_11102013_11_26/org.gvsig.raster.wmts/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 |
|
|
28 |
import org.cresques.cts.IProjection; |
|
29 |
import org.gvsig.compat.net.ICancellable; |
|
30 |
import org.gvsig.fmap.crs.CRSFactory; |
|
31 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
|
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 |
import org.gvsig.tools.ToolsLocator; |
|
36 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
37 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
38 |
import org.gvsig.tools.dynobject.DynClass; |
|
39 |
import org.gvsig.tools.dynobject.DynField; |
|
40 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
41 |
import org.gvsig.tools.dynobject.DynStruct; |
|
42 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
43 |
import org.gvsig.tools.persistence.PersistentState; |
|
44 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
45 |
import org.slf4j.LoggerFactory; |
|
46 |
|
|
47 |
/** |
|
48 |
* Parameters for the WMTS provider |
|
49 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
50 |
*/ |
|
51 |
public class WMTSDataParametersImpl extends AbstractRasterDataParameters implements WMTSDataParameters { |
|
52 |
private DelegatedDynObject delegatedDynObject = null; |
|
53 |
protected static DynClass DYNCLASS = null; |
|
54 |
//private Logger log = LoggerFactory.getLogger(WMTSDataParametersImpl.class); |
|
55 |
|
|
56 |
public static void registerPersistence() { |
|
57 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
58 |
DynStruct definition = manager.getDefinition("WMTSDataParametersImpl_Persistent"); |
|
59 |
if( definition == null ) { |
|
60 |
definition = manager.addDefinition( |
|
61 |
WMTSDataParametersImpl.class, |
|
62 |
"WMTSDataParametersImpl_Persistent", |
|
63 |
"WMTS DataParameters Persistency", |
|
64 |
null, |
|
65 |
null |
|
66 |
); |
|
67 |
AbstractRasterDataParameters.registerPersistence(definition); |
|
68 |
|
|
69 |
definition.addDynFieldObject(FIELD_EXTENT).setClassOfValue(Rectangle2D.class).setMandatory(false); |
|
70 |
definition.addDynFieldString(FIELD_IMAGE_FORMAT).setMandatory(false); |
|
71 |
definition.addDynFieldString(FIELD_INFO_FORMAT).setMandatory(false); |
|
72 |
definition.addDynFieldString(FIELD_NAME).setMandatory(false); |
|
73 |
definition.addDynFieldString(FIELD_SRSSTR).setMandatory(false); |
|
74 |
definition.addDynFieldBoolean(FIELD_OVERRIDE).setMandatory(false); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
80 |
super.saveToState(state); |
|
81 |
|
|
82 |
state.set(FIELD_NAME, getName()); |
|
83 |
state.set(FIELD_SRSSTR, getSRSCode()); |
|
84 |
state.set(FIELD_OVERRIDE, isOverridingHost()); |
|
85 |
state.set(FIELD_EXTENT, getExtent()); |
|
86 |
state.set(FIELD_IMAGE_FORMAT, getImageFormat()); |
|
87 |
state.set(FIELD_INFO_FORMAT, getInfoFormat()); |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public void loadFromState(PersistentState state) |
|
92 |
throws PersistenceException { |
|
93 |
super.loadFromState(state); |
|
94 |
|
|
95 |
setImageFormat(state.getString(FIELD_IMAGE_FORMAT)); |
|
96 |
setInfoFormat(state.getString(FIELD_INFO_FORMAT)); |
|
97 |
setName(state.getString(FIELD_NAME)); |
|
98 |
setSRS(state.getString(FIELD_SRSSTR)); |
|
99 |
setOverrideHost(state.getBoolean(FIELD_OVERRIDE)); |
|
100 |
setExtent((Rectangle2D)state.get(FIELD_EXTENT)); |
|
101 |
} |
|
102 |
|
|
103 |
/* |
|
104 |
* (non-Javadoc) |
|
105 |
* @see org.gvsig.raster.wmts.io.WMTSDataParameters#assignFields(org.gvsig.raster.wmts.io.WMTSDataParameters) |
|
106 |
*/ |
|
107 |
public void assignFields(WMTSDataParameters p) { |
|
108 |
setImageFormat(p.getImageFormat()); |
|
109 |
setInfoFormat(p.getInfoFormat()); |
|
110 |
setName(p.getName()); |
|
111 |
setSRS(p.getSRSCode()); |
|
112 |
setOverrideHost(p.isOverridingHost()); |
|
113 |
setExtent(p.getExtent()); |
|
114 |
} |
|
115 |
|
|
116 |
public WMTSDataParametersImpl() { |
|
117 |
super(); |
|
118 |
initialize(); |
|
119 |
} |
|
120 |
|
|
121 |
protected void initialize() { |
|
122 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator |
|
123 |
.getDynObjectManager().createDynObject( |
|
124 |
DYNCLASS); |
|
125 |
} |
|
126 |
|
|
127 |
@SuppressWarnings("deprecation") |
|
128 |
public static void registerDynClass() { |
|
129 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
130 |
DynClass dynClass; |
|
131 |
DynField field; |
|
132 |
|
|
133 |
if(dynman == null) |
|
134 |
return; |
|
135 |
|
|
136 |
if (DYNCLASS == null) { |
|
137 |
dynClass = AbstractRasterDataParameters.registerDynClass(WMTSDataParametersImpl.DYNCLASS_NAME); |
|
138 |
|
|
139 |
field = dynClass.addDynField(FIELD_LAYER); |
|
140 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
141 |
field.setDescription("Layer"); |
|
142 |
field.setType(DataTypes.OBJECT); |
|
143 |
field.setMandatory(false); |
|
144 |
|
|
145 |
field = dynClass.addDynField(FIELD_STYLE); |
|
146 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
147 |
field.setDescription("Style"); |
|
148 |
field.setType(DataTypes.OBJECT); |
|
149 |
field.setMandatory(false); |
|
150 |
|
|
151 |
field = dynClass.addDynField(FIELD_SRS); |
|
152 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
153 |
field.setDescription("SRS"); |
|
154 |
field.setType(org.cresques.DataTypes.CRS); |
|
155 |
field.setMandatory(false); |
|
156 |
|
|
157 |
field = dynClass.addDynField(FIELD_IMAGE_FORMAT); |
|
158 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
159 |
field.setDescription("Image Format"); |
|
160 |
field.setType(DataTypes.STRING); |
|
161 |
field.setMandatory(false); |
|
162 |
|
|
163 |
field = dynClass.addDynField(FIELD_INFO_FORMAT); |
|
164 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
165 |
field.setDescription("Info Format"); |
|
166 |
field.setType(DataTypes.STRING); |
|
167 |
field.setMandatory(false); |
|
168 |
|
|
169 |
field = dynClass.addDynField(FIELD_NAME); |
|
170 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
171 |
field.setDescription("Name"); |
|
172 |
field.setType(DataTypes.STRING); |
|
173 |
field.setMandatory(false); |
|
174 |
|
|
175 |
field = dynClass.addDynField(FIELD_SRSSTR); |
|
176 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
177 |
field.setDescription("String that represents the SRS"); |
|
178 |
field.setType(DataTypes.STRING); |
|
179 |
field.setMandatory(false); |
|
180 |
|
|
181 |
field = dynClass.addDynField(FIELD_OVERRIDE); |
|
182 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
183 |
field.setDescription("Override a host capabilities"); |
|
184 |
field.setType(DataTypes.BOOLEAN); |
|
185 |
field.setMandatory(false); |
|
186 |
|
|
187 |
field = dynClass.addDynField(FIELD_CANCEL); |
|
188 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
189 |
field.setDescription("Cancellable"); |
|
190 |
field.setType(DataTypes.OBJECT); |
|
191 |
field.setMandatory(false); |
|
192 |
|
|
193 |
field = dynClass.addDynField(FIELD_EXTENT); |
|
194 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
195 |
field.setDescription("Extent"); |
|
196 |
field.setType(DataTypes.OBJECT); |
|
197 |
field.setMandatory(false); |
|
198 |
|
|
199 |
field = dynClass.addDynField(FIELD_WIDTH); |
|
200 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
201 |
field.setDescription("Width"); |
|
202 |
field.setType(DataTypes.INT); |
|
203 |
field.setMandatory(false); |
|
204 |
|
|
205 |
field = dynClass.addDynField(FIELD_HEIGHT); |
|
206 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
207 |
field.setDescription("Height"); |
|
208 |
field.setType(DataTypes.INT); |
|
209 |
field.setMandatory(false); |
|
210 |
|
|
211 |
field = dynClass.addDynField(FIELD_DELETECACHE); |
|
212 |
field.setTheTypeOfAvailableValues(DynField.ANY); |
|
213 |
field.setDescription("Flag to delete cache the next request"); |
|
214 |
field.setType(DataTypes.BOOLEAN); |
|
215 |
field.setMandatory(false); |
|
216 |
|
|
217 |
field = dynClass.addDynFieldObject(OGC_CLIENT); |
|
218 |
field.setDescription("Driver to get access OGC library"); |
|
219 |
field.setClassOfValue(Object.class); |
|
220 |
field.setMandatory(false); |
|
221 |
|
|
222 |
DYNCLASS = dynClass; |
|
223 |
} |
|
224 |
|
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* Sets the style selected |
|
229 |
* @param layer |
|
230 |
*/ |
|
231 |
public void setStyle(WMTSStyle layer) { |
|
232 |
this.setDynValue(FIELD_STYLE, layer); |
|
233 |
} |
|
234 |
|
|
235 |
/** |
|
236 |
* Gets the style |
|
237 |
* @return |
|
238 |
*/ |
|
239 |
public WMTSStyle getStyle() { |
|
240 |
return (WMTSStyle) this.getDynValue(FIELD_STYLE); |
|
241 |
} |
|
242 |
|
|
243 |
/** |
|
244 |
* Gets the image format |
|
245 |
* @return Format |
|
246 |
*/ |
|
247 |
public String getImageFormat() { |
|
248 |
return (String) this.getDynValue(FIELD_IMAGE_FORMAT); |
|
249 |
} |
|
250 |
|
|
251 |
/** |
|
252 |
* Sets the image format |
|
253 |
* @param format |
|
254 |
*/ |
|
255 |
public void setImageFormat(String format) { |
|
256 |
this.setDynValue(FIELD_IMAGE_FORMAT, format); |
|
257 |
} |
|
258 |
|
|
259 |
/* |
|
260 |
* (non-Javadoc) |
|
261 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.WMTSStoreParameters#getImageFormat() |
|
262 |
*/ |
|
263 |
public String getInfoFormat() { |
|
264 |
return (String) this.getDynValue(FIELD_INFO_FORMAT); |
|
265 |
} |
|
266 |
|
|
267 |
/* |
|
268 |
* (non-Javadoc) |
|
269 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.WMTSStoreParameters#setImageFormat(java.lang.String) |
|
270 |
*/ |
|
271 |
public void setInfoFormat(String format) { |
|
272 |
this.setDynValue(FIELD_INFO_FORMAT, format); |
|
273 |
} |
|
274 |
|
|
275 |
/** |
|
276 |
* Sets the layer selected |
|
277 |
* @param layer |
|
278 |
*/ |
|
279 |
public void setLayer(WMTSLayer layer) { |
|
280 |
this.setDynValue(FIELD_LAYER, layer); |
|
281 |
} |
|
282 |
|
|
283 |
/** |
|
284 |
* Gets the layer |
|
285 |
* @return |
|
286 |
*/ |
|
287 |
public WMTSLayer getLayer() { |
|
288 |
return (WMTSLayer) this.getDynValue(FIELD_LAYER); |
|
289 |
} |
|
290 |
|
|
291 |
/** |
|
292 |
* Devuelve el SRS. |
|
293 |
* @return SRS. |
|
294 |
*/ |
|
295 |
public String getSRSCode() { |
|
296 |
return (String) this.getDynValue(FIELD_SRSSTR); |
|
297 |
} |
|
298 |
|
|
299 |
public void setSRS(String m_srs) { |
|
300 |
if(m_srs.compareTo("CRS:84") == 0) |
|
301 |
m_srs = "EPSG:4326"; |
|
302 |
this.setDynValue(FIELD_SRSSTR, m_srs); |
|
303 |
if(getEPSG(m_srs) != null) |
|
304 |
setSRS(CRSFactory.getCRS(getEPSG(m_srs))); |
|
305 |
} |
|
306 |
|
|
307 |
public void setSRS(IProjection srs) { |
|
308 |
setDynValue(FIELD_SRS, srs); |
|
309 |
} |
|
310 |
|
|
311 |
/** |
|
312 |
* Returns the projection |
|
313 |
* @return |
|
314 |
*/ |
|
315 |
public IProjection getSRS() { |
|
316 |
if (this.getSRSID() == null) { |
|
317 |
return null; |
|
318 |
} |
|
319 |
return (IProjection) getDynValue(FIELD_SRS); |
|
320 |
} |
|
321 |
|
|
322 |
/** |
|
323 |
* Returns true if the layer is projected |
|
324 |
* @return |
|
325 |
*/ |
|
326 |
public boolean isProjected() { |
|
327 |
IProjection proj = getSRS(); |
|
328 |
if(proj == null) |
|
329 |
return true; |
|
330 |
else { |
|
331 |
try { |
|
332 |
return proj.isProjected(); |
|
333 |
} catch (Exception e) { |
|
334 |
LoggerFactory.getLogger(WMTSDataParameters.class).debug("error in projection", e); |
|
335 |
return true; |
|
336 |
} |
|
337 |
} |
|
338 |
} |
|
339 |
|
|
340 |
public String getSRSID() { |
|
341 |
IProjection srs = (IProjection) getDynValue(FIELD_SRS); |
|
342 |
if (srs == null) { |
|
343 |
return null; |
|
344 |
} |
|
345 |
return srs.getAbrev(); |
|
346 |
} |
|
347 |
|
|
348 |
public void setSRSID(String srsid) { |
|
349 |
if (srsid == null) { |
|
350 |
setDynValue(FIELD_SRS, null); |
|
351 |
} else { |
|
352 |
setDynValue(FIELD_SRS, CRSFactory.getCRS(getEPSG(srsid))); |
|
353 |
} |
|
354 |
} |
|
355 |
|
|
356 |
/** |
|
357 |
* Returns the current selected SRS. |
|
358 |
* @return |
|
359 |
*/ |
|
360 |
public String getEPSG(String value) { |
|
361 |
if(value != null) { |
|
362 |
if(value.compareTo("CRS:84") == 0) |
|
363 |
return "EPSG:4326"; |
|
364 |
|
|
365 |
String s = value.substring(value.lastIndexOf(":") + 1); |
|
366 |
return "EPSG:" + s; |
|
367 |
} |
|
368 |
return null; |
|
369 |
} |
|
370 |
|
|
371 |
public String getName() { |
|
372 |
return (String) this.getDynValue(FIELD_NAME); |
|
373 |
} |
|
374 |
|
|
375 |
public void setName(String name) { |
|
376 |
this.setDynValue(FIELD_NAME, name); |
|
377 |
} |
|
378 |
|
|
379 |
public void setCancellable(ICancellable cancel) { |
|
380 |
this.setDynValue(FIELD_CANCEL, cancel); |
|
381 |
} |
|
382 |
|
|
383 |
public ICancellable getCancellable() { |
|
384 |
return (ICancellable) this.getDynValue(FIELD_CANCEL); |
|
385 |
} |
|
386 |
|
|
387 |
/* |
|
388 |
* (non-Javadoc) |
|
389 |
* @see org.gvsig.fmap.dal.coverage.store.RasterStoreParameters#isOverridingHost() |
|
390 |
*/ |
|
391 |
public boolean isOverridingHost() { |
|
392 |
Boolean b = (Boolean)getDynValue(FIELD_OVERRIDE); |
|
393 |
if(b != null) |
|
394 |
return ((Boolean)b).booleanValue(); |
|
395 |
return false; |
|
396 |
} |
|
397 |
|
|
398 |
/* |
|
399 |
* (non-Javadoc) |
|
400 |
* @see org.gvsig.fmap.dal.coverage.store.RasterStoreParameters#setOverrideHost(boolean) |
|
401 |
*/ |
|
402 |
public void setOverrideHost(boolean over) { |
|
403 |
this.setDynValue(FIELD_OVERRIDE, new Boolean(over));; |
|
404 |
} |
|
405 |
|
|
406 |
/** |
|
407 |
* Assigns the extent. |
|
408 |
* When a provider is initialized this will need to know what is the extent before the request. |
|
409 |
* |
|
410 |
* @param bBox |
|
411 |
*/ |
|
412 |
public void setExtent(Rectangle2D bBox) { |
|
413 |
this.setDynValue(FIELD_EXTENT, bBox); |
|
414 |
} |
|
415 |
|
|
416 |
/** |
|
417 |
* Sets the width |
|
418 |
* When a provider is initialized this will need to know what is the width before the request. |
|
419 |
* @param w |
|
420 |
*/ |
|
421 |
public void setWidth(int w) { |
|
422 |
this.setDynValue(FIELD_WIDTH, new Integer(w)); |
|
423 |
} |
|
424 |
|
|
425 |
/** |
|
426 |
* Sets the height |
|
427 |
* When a provider is initialized this will need to know what is the height before the request. |
|
428 |
* @param h |
|
429 |
*/ |
|
430 |
public void setHeight(int h) { |
|
431 |
this.setDynValue(FIELD_HEIGHT, new Integer(h)); |
|
432 |
} |
|
433 |
|
|
434 |
/** |
|
435 |
* Gets the bounding box |
|
436 |
* @return |
|
437 |
*/ |
|
438 |
public Rectangle2D getExtent() { |
|
439 |
return (Rectangle2D)getDynValue(FIELD_EXTENT); |
|
440 |
} |
|
441 |
|
|
442 |
/** |
|
443 |
* Gets the width |
|
444 |
* @return |
|
445 |
*/ |
|
446 |
public int getWidth() { |
|
447 |
Integer b = (Integer)getDynValue(FIELD_WIDTH); |
|
448 |
if(b != null) |
|
449 |
return ((Integer)b).intValue(); |
|
450 |
return 0; |
|
451 |
} |
|
452 |
|
|
453 |
/** |
|
454 |
* Gets the height |
|
455 |
* @return |
|
456 |
*/ |
|
457 |
public int getHeight() { |
|
458 |
Integer b = (Integer)getDynValue(FIELD_HEIGHT); |
|
459 |
if(b != null) |
|
460 |
return ((Integer)b).intValue(); |
|
461 |
return 0; |
|
462 |
} |
|
463 |
|
|
464 |
//********************************************** |
|
465 |
|
|
466 |
/* |
|
467 |
* (non-Javadoc) |
|
468 |
* @see org.gvsig.fmap.dal.DataStoreParameters#getDataStoreName() |
|
469 |
*/ |
|
470 |
public String getDataStoreName() { |
|
471 |
return WMTSProvider.NAME; |
|
472 |
} |
|
473 |
|
|
474 |
/* |
|
475 |
* (non-Javadoc) |
|
476 |
* @see org.gvsig.fmap.dal.DataStoreParameters#getDescription() |
|
477 |
*/ |
|
478 |
public String getDescription() { |
|
479 |
return WMTSProvider.DESCRIPTION; |
|
480 |
} |
|
481 |
|
|
482 |
public String getExplorerName() { |
|
483 |
return WMTSServerExplorer.NAME; |
|
484 |
} |
|
485 |
|
|
486 |
public boolean isValid() { |
|
487 |
return (this.getURI() != null); |
|
488 |
} |
|
489 |
|
|
490 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
491 |
return delegatedDynObject; |
|
492 |
} |
|
493 |
|
|
494 |
/** |
|
495 |
* Clones this structure |
|
496 |
* @return |
|
497 |
*/ |
|
498 |
public WMTSDataParameters clone() { |
|
499 |
WMTSDataParametersImpl p = new WMTSDataParametersImpl(); |
|
500 |
p.setImageFormat(getImageFormat()); |
|
501 |
p.setInfoFormat(getInfoFormat()); |
|
502 |
p.setHeight(getHeight()); |
|
503 |
p.setWidth(getWidth()); |
|
504 |
p.setExtent(getExtent()); |
|
505 |
p.setURI(getURI()); |
|
506 |
p.setName(getName()); |
|
507 |
p.setOverrideHost(isOverridingHost()); |
|
508 |
p.setSRS(getSRS()); |
|
509 |
p.setSRS(getSRSCode()); |
|
510 |
p.setCancellable(getCancellable()); |
|
511 |
return p; |
|
512 |
} |
|
513 |
|
|
514 |
/* |
|
515 |
* (non-Javadoc) |
|
516 |
* @see org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters#isSizeFixed() |
|
517 |
*/ |
|
518 |
public boolean isSizeFixed() { |
|
519 |
return true; |
|
520 |
} |
|
521 |
|
|
522 |
public void deleteCache(boolean deleteCache) { |
|
523 |
this.setDynValue(FIELD_DELETECACHE, new Boolean(deleteCache)); |
|
524 |
} |
|
525 |
|
|
526 |
public boolean isDeletingCache() { |
|
527 |
return ((Boolean)getDynValue(FIELD_DELETECACHE)).booleanValue(); |
|
528 |
} |
|
529 |
|
|
530 |
public WMTSClient getOGCClient() { |
|
531 |
return ((WMTSClient)getDynValue(OGC_CLIENT)); |
|
532 |
} |
|
533 |
|
|
534 |
public void setOGCClient(WMTSClient ogcClient) { |
|
535 |
setDynValue(OGC_CLIENT, ogcClient); |
|
536 |
} |
|
537 |
|
|
538 |
} |
|
0 | 539 |
org.gvsig.raster.wmts/tags/tagdate_11102013_11_26/org.gvsig.raster.wmts/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 |
* This class manages transactions between the producer and the consumer. The |
|
28 |
* producer download tiles from a server and the consumer is a tile provider |
|
29 |
* which will return downloaded tiles. |
|
30 |
* |
|
31 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
32 |
*/ |
|
33 |
public class TilePipe { |
|
34 |
//N?mero de threads m?ximos a lanzar para descarga. Cuando se lanzan m?s de estos el |
|
35 |
//invocador debe dormir hasta que se haya liberado alguno. |
|
36 |
public static int NTHREADS_QUEUE = 5; |
|
37 |
//N?mero m?ximo de elementos en la tuberia. Cuando se llene esta el setTile de esta clase debe |
|
38 |
//dormir hasta que getTile lo despierte. |
|
39 |
private final static int BUFFER_SIZE = 10; |
|
40 |
|
|
41 |
private WMTSTile buffer[] = new WMTSTile[BUFFER_SIZE]; |
|
42 |
private int next = 0; |
|
43 |
private boolean isFull = false; |
|
44 |
private boolean isEmpty = true; |
|
45 |
private Thread threadManager = null; |
|
46 |
|
|
47 |
/** |
|
48 |
* El thread manager no se usa con la pool solo para la implementaci?n de RequestThreadManager |
|
49 |
* @param threadManager |
|
50 |
*/ |
|
51 |
public void setRequestManager(Thread threadManager) { |
|
52 |
this.threadManager = threadManager; |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* Sets a tile in the pipe |
|
57 |
* @param tile |
|
58 |
*/ |
|
59 |
public synchronized void setTile(WMTSTile tile) { |
|
60 |
while( isFull == true ) { |
|
61 |
try { |
|
62 |
wait(); |
|
63 |
} catch( InterruptedException e ) { |
|
64 |
} |
|
65 |
} |
|
66 |
buffer[next] = tile; |
|
67 |
next++; |
|
68 |
if( next == BUFFER_SIZE ) |
|
69 |
isFull = true; |
|
70 |
isEmpty = false; |
|
71 |
notify(); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Gets a tile from the pipe |
|
76 |
* @return |
|
77 |
*/ |
|
78 |
public synchronized WMTSTile getTile() { |
|
79 |
while( isEmpty == true ) { |
|
80 |
try { |
|
81 |
wait(); |
|
82 |
} catch( InterruptedException e ) { |
|
83 |
} |
|
84 |
} |
|
85 |
next--; |
|
86 |
if( next == 0 ) |
|
87 |
isEmpty = true; |
|
88 |
isFull = false; |
|
89 |
notify(); |
|
90 |
if(threadManager != null && getSize() <= NTHREADS_QUEUE) { |
|
91 |
synchronized(threadManager) { |
|
92 |
threadManager.notify(); |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
return buffer[next] ; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Returns the number of elements in the queue |
|
101 |
* @return |
|
102 |
*/ |
|
103 |
public synchronized int getSize() { |
|
104 |
return next; |
|
105 |
} |
|
106 |
} |
|
0 | 107 |
org.gvsig.raster.wmts/tags/tagdate_11102013_11_26/org.gvsig.raster.wmts/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 |
WMTSDataParametersImpl.registerPersistence(); |
|
50 |
} |
|
51 |
} |
|
0 | 52 |
org.gvsig.raster.wmts/tags/tagdate_11102013_11_26/org.gvsig.raster.wmts/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.raster.cache.tile.Tile; |
|
32 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
33 |
import org.gvsig.raster.impl.provider.tile.BaseTileDownloader; |
|
34 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
35 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
|
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(WMTSProvider prov, |
|
50 |
int tilePxWidth, |
|
51 |
int tilePxHeight) { |
|
52 |
super(prov, 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)prov.getDataParameters(); |
|
63 |
ogcClient = p.getOGCClient(); |
|
64 |
if(ogcClient != null) |
|
65 |
return ogcClient; |
|
66 |
|
|
67 |
URL url = null; |
|
68 |
try { |
|
69 |
url = new URL(p.getURI()); |
|
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 |
/* |
|
94 |
* (non-Javadoc) |
|
95 |
* @see org.gvsig.raster.cache.tile.provider.Downloader#getTile(org.gvsig.raster.cache.tile.Tile) |
|
96 |
*/ |
|
97 |
public synchronized Tile downloadTile(Tile tile) throws TileGettingException { |
|
98 |
try { |
|
99 |
WMTSStatus status = (WMTSStatus)tile.getDownloaderParams("WMTSStatus"); |
|
100 |
status.setTileRow(tile.getRow()); |
|
101 |
status.setTileCol(tile.getCol()); |
|
102 |
File f = getOGCClient().getTile(status, tile.getCancelled(), tile.getFile()); |
|
103 |
tile.setFile(f); |
|
104 |
//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para |
|
105 |
//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros |
|
106 |
//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf"); |
|
107 |
//if(rmf.exists()) |
|
108 |
//rmf.delete(); |
|
109 |
} catch (WMTSException e) { |
|
110 |
throw new TileGettingException(e); |
|
111 |
} catch (ServerErrorException e) { |
|
112 |
throw new TileGettingException(e); |
|
113 |
} |
|
114 |
readTileFromDisk(tile); |
|
115 |
return tile; |
|
116 |
} |
|
117 |
|
|
118 |
} |
|
0 | 119 |
org.gvsig.raster.wmts/tags/tagdate_11102013_11_26/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/downloader/WMTSTileServer.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 org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
25 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
|
26 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
27 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
|
28 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix; |
|
29 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSetLink; |
|
30 |
|
|
31 |
/** |
|
32 |
* Data server for the tile cache in a WMTSProvider |
|
33 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
34 |
*/ |
|
35 |
public class WMTSTileServer implements TileServer { |
|
36 |
private CacheStruct struct = null; |
|
37 |
private Downloader downloader = null; |
|
38 |
private WMTSProvider provider = null; |
|
39 |
private String suffix = ".tif"; |
|
40 |
private WMTSTileMatrixSetLink tileMatrixSetLink = null; |
|
41 |
|
|
42 |
public WMTSTileServer(WMTSProvider prov, |
|
43 |
WMTSTileMatrixSetLink tileMatrixSetLink) { |
|
44 |
this.provider = prov; |
|
45 |
this.tileMatrixSetLink = tileMatrixSetLink; |
|
46 |
} |
|
47 |
|
|
48 |
/* |
|
49 |
* (non-Javadoc) |
|
50 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#getDownloader() |
|
51 |
*/ |
|
52 |
public Downloader getDownloader() { |
|
53 |
//if(downloader == null) { |
|
54 |
int tileWidth = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileWidth(); |
|
55 |
int tileHeight = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileHeight(); |
|
56 |
downloader = new TileDownloaderForWMTS(provider, tileWidth, tileHeight); |
|
57 |
//} |
|
58 |
return downloader; |
|
59 |
} |
|
60 |
|
|
61 |
public CacheStruct getStruct() { |
|
62 |
if(struct == null) { |
|
63 |
struct = new WMTSCacheStruct(provider, tileMatrixSetLink); |
|
64 |
} |
|
65 |
return struct; |
|
66 |
} |
|
67 |
|
|
68 |
/* |
|
69 |
* (non-Javadoc) |
|
70 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#setStruct(org.gvsig.raster.cache.tile.provider.CacheStruct) |
|
71 |
*/ |
|
72 |
public void setStruct(CacheStruct struct) { |
|
73 |
//La structura de cache es proporcionada por el servidor |
|
74 |
} |
|
75 |
|
|
76 |
/* |
|
77 |
* (non-Javadoc) |
|
78 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#getFileSuffix() |
|
79 |
*/ |
|
80 |
public String getFileSuffix() { |
|
81 |
return suffix; |
|
82 |
} |
|
83 |
|
|
84 |
/* |
|
85 |
* (non-Javadoc) |
|
86 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#setFileExtension(java.lang.String) |
|
87 |
*/ |
|
88 |
public void setFileSuffix(String extension) { |
|
89 |
this.suffix = extension; |
|
90 |
} |
|
91 |
} |
|
0 | 92 |
org.gvsig.raster.wmts/tags/tagdate_11102013_11_26/org.gvsig.raster.wmts/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.util.ArrayList; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
30 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
31 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
|
32 |
import org.gvsig.raster.cache.tile.Tile; |
|
33 |
import org.gvsig.raster.cache.tile.TileCacheLocator; |
|
34 |
import org.gvsig.raster.cache.tile.exception.TileBuildException; |
|
35 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
36 |
import org.gvsig.raster.wmts.io.WMTSDataParameters; |
|
37 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
|
38 |
import org.gvsig.raster.wmts.ogc.WMTSStatus; |
|
39 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTile; |
|
40 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix; |
|
41 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixLimits; |
|
42 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSet; |
|
43 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrixSetLink; |
|
44 |
|
|
45 |
/** |
|
46 |
* Implementation for a structure of a cache |
|
47 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
48 |
*/ |
|
49 |
public class WMTSCacheStruct implements CacheStruct { |
|
50 |
private String layerName = null; |
|
51 |
private String serverURL = null; |
|
52 |
private WMTSTileMatrixSet tileMatrixSet = null; |
|
53 |
private List<WMTSTileMatrixLimits> tileMatrixSetLimits = null; |
|
54 |
private double[] pixelSize = null; |
|
55 |
private WMTSProvider provider = null; |
|
56 |
|
|
57 |
public WMTSCacheStruct(WMTSProvider provider, WMTSTileMatrixSetLink tileMatrixSetLink) { |
|
58 |
this.provider = provider; |
|
59 |
this.tileMatrixSet = tileMatrixSetLink.getTileMatrixSet(); |
|
60 |
this.tileMatrixSetLimits = tileMatrixSetLink.getTileMatrixLimits(); |
|
61 |
pixelSize = provider.getPixelSizeByLevel(); |
|
62 |
serverURL = provider.getURIOfFirstProvider(); |
|
63 |
layerName = ((WMTSDataParameters)provider.getDataParameters()).getLayer().getTitle(); |
|
64 |
} |
|
65 |
|
|
66 |
/* |
|
67 |
* (non-Javadoc) |
|
68 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getNumberOfLevels() |
|
69 |
*/ |
|
70 |
public int getNumberOfLevels() { |
|
71 |
return tileMatrixSet.getTileMatrix().size(); |
|
72 |
} |
|
73 |
|
|
74 |
/* |
|
75 |
* (non-Javadoc) |
|
76 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerName() |
|
77 |
*/ |
|
78 |
public String getLayerName() { |
|
79 |
return layerName; |
|
80 |
} |
|
81 |
|
|
82 |
/* |
|
83 |
* (non-Javadoc) |
|
84 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getServerURL() |
|
85 |
*/ |
|
86 |
public String getServerURL() { |
|
87 |
return serverURL; |
|
88 |
} |
|
89 |
|
|
90 |
/* |
|
91 |
* (non-Javadoc) |
|
92 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getTileSizeByLevel(int) |
|
93 |
*/ |
|
94 |
public int[] getTileSizeByLevel(int level) { |
|
95 |
return new int[] { |
|
96 |
((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileWidth(), |
|
97 |
((WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level)).getTileHeight() |
|
98 |
}; |
|
99 |
} |
|
100 |
|
|
101 |
/* |
|
102 |
* (non-Javadoc) |
|
103 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerWidthOfTileMatrixByLevel(int) |
|
104 |
*/ |
|
105 |
public int getLayerWidthOfTileMatrixByLevel(int level) { |
|
106 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
107 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
108 |
return l.getMaxTileRow() - l.getMinTileRow(); |
|
109 |
} else { |
|
110 |
WMTSTileMatrix tm = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level); |
|
111 |
return (int)tm.getMatrixWidth(); |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
/* |
|
116 |
* (non-Javadoc) |
|
117 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerHeightOfTileMatrixByLevel(int) |
|
118 |
*/ |
|
119 |
public int getLayerHeightOfTileMatrixByLevel(int level) { |
|
120 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
121 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
122 |
return l.getMaxTileCol() - l.getMinTileCol(); |
|
123 |
} else { |
|
124 |
WMTSTileMatrix tm = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(level); |
|
125 |
return (int)tm.getMatrixHeight(); |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
/* |
|
130 |
* (non-Javadoc) |
|
131 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerInitXTilePositionByLevel(int) |
|
132 |
*/ |
|
133 |
public int getLayerInitXTilePositionByLevel(int level) { |
|
134 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
135 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
136 |
return l.getMinTileCol(); |
|
137 |
} else |
|
138 |
return 0; |
|
139 |
} |
|
140 |
|
|
141 |
/* |
|
142 |
* (non-Javadoc) |
|
143 |
* @see org.gvsig.raster.cache.tile.provider.CacheStruct#getLayerInitYTilePositionByLevel(int) |
|
144 |
*/ |
|
145 |
public int getLayerInitYTilePositionByLevel(int level) { |
|
146 |
if(tileMatrixSetLimits != null && tileMatrixSetLimits.size() > level) { |
|
147 |
WMTSTileMatrixLimits l = (WMTSTileMatrixLimits)tileMatrixSetLimits.get(level); |
|
148 |
return l.getMinTileRow(); |
|
149 |
} else |
|
150 |
return 0; |
Also available in: Unified diff