PageRenderTime 34ms CodeModel.GetById 1ms app.highlight 25ms RepoModel.GetById 2ms app.codeStats 0ms

/webportal/src/main/java/au/org/emii/portal/util/LayerUtilities.java

http://alageospatialportal.googlecode.com/
Java | 314 lines | 93 code | 62 blank | 159 comment | 0 complexity | 2935cddd63ab9b159c8df04a53e5cbae MD5 | raw file
  1/*
  2 * To change this template, choose Tools | Templates
  3 * and open the template in the editor.
  4 */
  5
  6package au.org.emii.portal.util;
  7
  8import au.org.emii.portal.menu.MapLayer;
  9import java.util.Date;
 10import java.util.List;
 11
 12/**
 13 *
 14 * @author geoff
 15 */
 16public interface LayerUtilities {
 17    /**
 18     * Keyword to use in the config file for auto discovered wms servers
 19     */
 20    public String AUTO_DISCOVERY_TYPE = "AUTO";
 21    public int GEORSS = 6;
 22    public int KML = 7;
 23    public int GEOJSON = 8;
 24    public int WKT = 11;
 25    public int IMAGELAYER = 9;
 26    public int NCWMS = 4;
 27    public int THREDDS = 5;
 28    public int BING = 10;
 29    /**
 30     * layer dummy and sub types
 31     */
 32    public int MAP = 12;
 33    public int ALOC = 14;
 34    public int MAXENT = 15;
 35    public int GDM = 16;
 36    public int SCATTERPLOT = 17;
 37    public int TABULATION = 18;
 38    public int CONTEXTUAL = 19;
 39    public int GRID = 20;
 40    public int SPECIES = 21;
 41    public int ENVIRONMENTAL_ENVELOPE = 22;
 42    public int SPECIES_UPLOAD = 23;
 43    public int ODENSITY = 24;
 44    public int SRICHNESS = 25;
 45    
 46    /**
 47     * Constants used to indicate layer type.  Do not hard code these
 48     * value into other applications - they may change.  Instead, for
 49     * external non-java applications use the String representations
 50     * (above).
 51     *
 52     * Java applications may reference the constants in this class
 53     * statically.  If you need to access through EL (for .zul), the
 54     * LayerUtilies class is instantiated and stored in the users session
 55     * with the static fields exposed by getters, e.g:
 56     *
 57     * <script type="text/javascript>
 58     * var wms100 = ${session.attributes.portalSession.layerUtilities.wms100};
 59     * var wms110 = ${session.attributes.portalSession.layerUtilities.wms110};
 60     * var wms111 = ${session.attributes.portalSession.layerUtilities.wms111};
 61     * var wms130 = ${session.attributes.portalSession.layerUtilities.wms130};
 62     * var ncwms = ${session.attributes.portalSession.layerUtilities.ncwms};
 63     * var thredds = ${session.attributes.portalSession.layerUtilities.thredds};
 64     * var georss = ${session.attributes.portalSession.layerUtilities.georss};
 65     * var kml = ${session.attributes.portalSession.layerUtilities.kml};
 66     * var unsupported =${session.attributes.portalSession.layerUtilities.unsupported};
 67     * </script>
 68     */
 69    public int UNSUPPORTED = -1;
 70    public int WMS_1_0_0 = 0;
 71    public int WMS_1_1_0 = 1;
 72    public int WMS_1_1_1 = 2;
 73    public int WMS_1_3_0 = 3;
 74
 75    public String BING_SHADED = "VEMapStyle.Shaded";
 76    public String BING_AERIAL = "VEMapStyle.Aerial";
 77    public String BING_HYBRID = "VEMapStyle.Hybrid";
 78
 79    /**
 80     * Chomp the layer name if we need to
 81     * @param originalName
 82     * @return The original name if under maxLength or a chomped name
 83     * if over
 84     */
 85    public String chompLayerName(String layerName);
 86
 87    /**
 88     * Convert the internal integer constant representation of the
 89     * WMS version to an external string as used in the version=
 90     * URI parameter.  This is not the same as the version string
 91     * used in the config file.
 92     *
 93     * NCWMS and THREDDS are special cases and will return "1.3.0"
 94     * @param version
 95     * @return
 96     */
 97    public String externalVersion(int version);
 98
 99    /**
100     * Strip any version information from the URI and use
101     * the passed in version string instead
102     * @param uri
103     * @param version
104     * @return
105     */
106    public String fixVersion(String uri, String version);
107
108    public String getAnimationFeatureInfoUri(MapLayer mapLayer);
109
110    public String getAnimationFeatureInfoUriJS(MapLayer mapLayer);
111
112    public String getAnimationTimeSeriesPlotUri(MapLayer mapLayer);
113
114    public String getAnimationTimeSeriesPlotUriJS(MapLayer mapLayer);
115
116    public String getAnimationUri(MapLayer mapLayer);
117
118    public String getAnimationUriJS(MapLayer mapLayer);
119
120    /**
121     * Accessor to get the magic string currently being used to trigger
122     * auto discovery when used as 'type' in a Discovery instance.  Gets
123     * used in the AddLayer.zul file since ZUL EL can't access static
124     * variables (booooo!)
125     * @return
126     */
127    public String getAutoDiscoveryType();
128
129    /**
130     * Get the fully qualified URI (if it isn't already...)
131     * - this is to add a hostname to indirect cache requests
132     * which normally store the URI as /RemoteRequest?url=foo
133     */
134    public String getFQUri(String uri);
135
136    public int getGeorss();
137
138    /**
139     * Parse the image format from a uri
140     * @param uri
141     */
142    public String getImageFormat(String uri);
143
144    /**
145     * indirect caching requested - base url is to be requested
146     * through our RemoteRequest servlet so squid can cache it
147     * @throws UnsupportedEncodingException
148     */
149    public String getIndirectCacheUrl(String baseUri);
150
151    public int getKml();
152
153    public String getLayer(String uri);
154
155    /**
156     * Parse the requested layers from a uri
157     * @param uri
158     */
159    public String getLayers(String uri);
160
161    public String getLegendGraphicUri(String uri, String imageFormat);
162
163    public String getLegendGraphicUri(String uri, String layer, String imageFormat);
164
165    public String getLegendGraphicUri(String uri, String layer, String imageFormat, String envParams);
166
167    public int getMaxNameLength();
168
169    /**
170     * Construct a metadata uri.  For use with ncwms/thredds
171     * @param uri
172     * @param layer
173     * @return
174     */
175    public String getMetadataUri(String uri, String layer);
176
177    public String getNcWMSTimeStringsUri(String uri, String layer, String startDate, String endDate);
178
179    public int getNcwms();
180
181    public String getParameterValue(String parameter, String uri);
182
183    /**
184     * Get the list of supported versions as a human readable string (for
185     * debugging) - noone outside this class should need to get r/w access
186     * to the list of versions since they can just test for == UNSUPPORTED
187     * @return
188     */
189    public String getSupportedVersions();
190
191    /**
192     * Construct and return a URI for a 2x2 px test image
193     * from a GetMap uri.  This can be used to test individual
194     * wms layers are at least returning images when they are
195     * added to the map by the user - we don't do this for
196     * our own layers as we assume that they are working.
197     * @param uri
198     * @return
199     */
200    public String getTestImageUri(String uri);
201
202    public int getThredds();
203
204    public String getTimestepsUri(String uri, String layer, Date date);
205
206    public String getTooltip(String name, String description);
207
208    public int getUnsupported();
209
210    public String getVersionValue(String uri);
211
212    public int getWms100();
213
214    public int getWms110();
215
216    public int getWms111();
217
218    public int getWms130();
219    
220    public int getGeojson();
221
222    public int getWkt();
223
224    /**
225     * Convert a string WMS version eg (1.3.0) to its integer
226     * representation within the portal eg WMS_1_3_0
227     * @param requestedType
228     * @return Integer constant representing string representation
229     * of WMS version.  Returns UNSUPPORTED if nothing matches
230     */
231    public int internalVersion(String requestedType);
232
233    /**
234     * Application specific url tweaking - works for geoserver and
235     * ncwms at the moment
236     *
237     * Autodetect and tweak uri if we detect the presence of geoserver
238     * or ncwms
239     * @param uri original uri
240     * @return mangled uri or null if geoserver or ncwms are not found
241     */
242    public String mangleUriApplication(String uri);
243
244    /**
245     * Attempt to automatically construct a get capabilities uri for
246     * the passed in WMS version
247     * @param uri
248     * @return
249     */
250    public String mangleUriGetCapabilitiesAutoDiscover(String uri, int version);
251
252    public boolean needsChomp(String originalName);
253
254    /**
255     * Return either "", "&" or "?" as a conjunction to be
256     * used when generating urls based on the last character
257     * in the passed in uri according to the following rules:
258     *
259     * 1) 	uri ends with '?' or '&' - uri is ready to use,  return ""
260     * 2) 	uri doesn't end with '?' or '&' and contains and '?'
261     * somewhere within the string - return '&'
262     * 3)	uri doesn't end with '?' or '&' and doesn't contain '&'
263     * anywhere within the string - return '?'
264     * @param uri
265     * @return
266     */
267    public String queryConjunction(String uri);
268
269    public String stripParameter(String parameter, String uri);
270
271    public String stripUriBbox(String uri);
272
273    public String stripUriHeight(String uri);
274
275    public String stripUriRequest(String uri);
276
277    public String stripUriService(String uri);
278
279    public String stripUriVersion(String uri);
280
281    public String stripUriWidth(String uri);
282
283    /**
284     * only NCWMS and THREDDS support animation
285     * @param type
286     * @return
287     */
288    public boolean supportsAnimation(int type);
289
290    /**
291     * only NCWMS and THREDDS support metadata
292     * @param type
293     * @return
294     */
295   public boolean supportsMetadata(int type);
296
297    /**
298     * Check whether the passed in type is compatible with any
299     * WMS version.
300     *
301     * NcWMS and THREDDS are considered to be WMS compatible
302     * @param type
303     * @return
304     */
305    public boolean supportsWms(int type);
306
307    public String coerceLegendUri(MapLayer mapLayer);
308
309    public String getWmsVersion(MapLayer mapLayer);
310
311    public List<Double> getBBox(String uri);
312
313    public List<Double> getBBoxIndex(String uri);
314}