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