/** * Finds URL to WMS service and attempts to slice away the service parameter, since we will add * that anyway. * * @param wms * @return */ private String getWMSUrl(WebMapServer wms) { // // http://sigma.openplans.org:8080/geoserver/wms?SERVICE=WMS& String wmsUrl = wms.getCapabilities().getRequest().getGetCapabilities().getGet().toString(); int queryStart = wmsUrl.lastIndexOf("?"); if (queryStart > 0) { String preQuery = wmsUrl.substring(queryStart); if (preQuery.equalsIgnoreCase("?service=wms&")) { wmsUrl = wmsUrl.substring(0, wmsUrl.lastIndexOf("?")); } } return wmsUrl; }
/** * Creates a new WebMapServer from a WMSCapablitiles document. * * <p>The implementation assumes that the server is located at: * capabilities.getRequest().getGetCapabilities().getGet() * * @param capabilities * @throws IOException * @throws ServiceException */ public WebMapServer(WMSCapabilities capabilities) throws IOException, ServiceException { super(capabilities, capabilities.getRequest().getGetCapabilities().getGet()); }
public WMSCoverageReader(WebMapServer wms, Layer layer, String style) { this.wms = wms; // init the reader addLayer(layer, style); // best guess at the format with a preference for PNG (since it's normally transparent) List<String> formats = wms.getCapabilities().getRequest().getGetMap().getFormats(); this.format = formats.iterator().next(); for (String format : formats) { if ("image/png".equals(format) || "image/png24".equals(format) || "png".equals(format) || "png24".equals(format) || "image/png; mode=24bit".equals(format)) { this.format = format; break; } } }
public GeneralParameterDescriptor createFormatReadParam() { Map properties = fillProperties("FORMAT", "Value contains the desired format"); GeneralParameterDescriptor param = new DefaultParameterDescriptor(properties, String.class, capabilities.getRequest().getGetMap().getFormats().toArray(new String[capabilities.getRequest().getGetMap().getFormats().size()]), null, null, null, null, true); return param; }
/** * The source of this WMS is the capabilities document. * * <p>We make an effort here to look in the capabilities document provided for the * unambiguous capabilities URI. This covers the case where the capabilities document has * been cached on disk and we are restoring a WebMapServer instance. */ public URI getSource() { try { URL source = getCapabilities().getRequest().getGetCapabilities().getGet(); return source.toURI(); } catch (NullPointerException huh) { } catch (URISyntaxException e) { } try { return serverURL.toURI(); } catch (URISyntaxException e) { return null; } }
public GetStylesRequest createGetStylesRequest() throws UnsupportedOperationException { if (getCapabilities().getRequest().getGetStyles() == null) { throw new UnsupportedOperationException( "Server does not specify a GetStyles operation. Cannot be performed"); } URL onlineResource = getCapabilities().getRequest().getGetStyles().getGet(); if (onlineResource == null) { onlineResource = serverURL; } GetStylesRequest request = getSpecification().createGetStylesRequest(onlineResource); return request; }
public DescribeLayerRequest createDescribeLayerRequest() throws UnsupportedOperationException { if (getCapabilities().getRequest().getDescribeLayer() == null ) { throw new UnsupportedOperationException("Server does not specify a DescribeLayer operation. Cannot be performed"); } URL onlineResource = getCapabilities().getRequest().getDescribeLayer().getGet(); if (onlineResource == null) { onlineResource = serverURL; } DescribeLayerRequest request = getSpecification().createDescribeLayerRequest(onlineResource); return request; }
public PutStylesRequest createPutStylesRequest() throws UnsupportedOperationException { if (getCapabilities().getRequest().getPutStyles() == null) { throw new UnsupportedOperationException( "Server does not specify a PutStyles operation. Cannot be performed"); } URL onlineResource = getCapabilities().getRequest().getPutStyles().getGet(); if (onlineResource == null) { onlineResource = serverURL; } PutStylesRequest request = getSpecification().createPutStylesRequest(onlineResource); return request; }
private String getCascadingFormat(WebMapServer server) { // best guess at the format with a preference for PNG (since it's normally transparent) List<String> formats = server.getCapabilities().getRequest().getGetMap().getFormats(); String requestFormat = null; for (String format : formats) { if (format.toLowerCase().contains("image/png") || "png".equalsIgnoreCase(format)) { requestFormat = format; break; } } // if we did not find any format looking like PNG choose any that ImageIO would likely read if (requestFormat == null) { for (String format : formats) { String loFormat = format.toLowerCase(); if (loFormat.contains("jpeg") || loFormat.contains("gif") || loFormat.contains("tif")) { requestFormat = format; break; } } } if (requestFormat == null) { throw new WPSException( "Could not find a suitable WMS cascading format among server supported formats: " + formats); } return requestFormat; }
public DescribeLayerRequest createDescribeLayerRequest() throws UnsupportedOperationException { if (getCapabilities().getRequest().getDescribeLayer() == null) { throw new UnsupportedOperationException( "Server does not specify a DescribeLayer operation. Cannot be performed"); } URL onlineResource = getCapabilities().getRequest().getDescribeLayer().getGet(); if (onlineResource == null) { onlineResource = serverURL; } DescribeLayerRequest request = getSpecification().createDescribeLayerRequest(onlineResource); return request; }
public GetLegendGraphicRequest createGetLegendGraphicRequest() throws UnsupportedOperationException { if (getCapabilities().getRequest().getGetLegendGraphic() == null) { throw new UnsupportedOperationException("Server does not specify a GetLegendGraphic operation. Cannot be performed"); } URL onlineResource = getCapabilities().getRequest().getGetLegendGraphic().getGet(); if (onlineResource == null) { onlineResource = serverURL; } GetLegendGraphicRequest request = getSpecification().createGetLegendGraphicRequest(onlineResource); return request; }
public GetStylesRequest createGetStylesRequest() throws UnsupportedOperationException{ if (getCapabilities().getRequest().getGetStyles() == null) { throw new UnsupportedOperationException("Server does not specify a GetStyles operation. Cannot be performed"); } URL onlineResource = getCapabilities().getRequest().getGetStyles().getGet(); if (onlineResource == null) { onlineResource = serverURL; } GetStylesRequest request = getSpecification().createGetStylesRequest(onlineResource); return request; }
public PutStylesRequest createPutStylesRequest() throws UnsupportedOperationException { if (getCapabilities().getRequest().getPutStyles() == null) { throw new UnsupportedOperationException("Server does not specify a PutStyles operation. Cannot be performed"); } URL onlineResource = getCapabilities().getRequest().getPutStyles().getGet(); if (onlineResource == null) { onlineResource = serverURL; } PutStylesRequest request = getSpecification().createPutStylesRequest(onlineResource); return request; }
/** * Creates a GetFeatureInfoRequest that can be configured and then passed to issueRequest(). * * @param getMapRequest a previous configured GetMapRequest * @return a GetFeatureInfoRequest * @throws UnsupportedOperationException if the server does not support GetFeatureInfo */ public GetFeatureInfoRequest createGetFeatureInfoRequest(GetMapRequest getMapRequest) { if (getCapabilities().getRequest().getGetFeatureInfo() == null) { throw new UnsupportedOperationException( "This Web Map Server does not support GetFeatureInfo requests"); } URL onlineResource = findURL(getCapabilities().getRequest().getGetFeatureInfo()); GetFeatureInfoRequest request = getSpecification().createGetFeatureInfoRequest(onlineResource, getMapRequest); return request; }
public GetLegendGraphicRequest createGetLegendGraphicRequest() throws UnsupportedOperationException { if (getCapabilities().getRequest().getGetLegendGraphic() == null) { throw new UnsupportedOperationException( "Server does not specify a GetLegendGraphic operation. Cannot be performed"); } URL onlineResource = getCapabilities().getRequest().getGetLegendGraphic().getGet(); if (onlineResource == null) { onlineResource = serverURL; } GetLegendGraphicRequest request = getSpecification().createGetLegendGraphicRequest(onlineResource); return request; }
/** * Creates a GetFeatureInfoRequest that can be configured and then passed to * issueRequest(). * * @param getMapRequest a previous configured GetMapRequest * @return a GetFeatureInfoRequest * @throws UnsupportedOperationException if the server does not support GetFeatureInfo */ public GetFeatureInfoRequest createGetFeatureInfoRequest( GetMapRequest getMapRequest ) { if (getCapabilities().getRequest().getGetFeatureInfo() == null) { throw new UnsupportedOperationException("This Web Map Server does not support GetFeatureInfo requests"); } URL onlineResource = findURL(getCapabilities().getRequest().getGetFeatureInfo()); GetFeatureInfoRequest request = getSpecification().createGetFeatureInfoRequest(onlineResource, getMapRequest); return request; }
/** * Creates a GetMapRequest that can be configured and then passed to issueRequest(). * * @return a configureable GetMapRequest object */ public GetMapRequest createGetMapRequest() { URL onlineResource = findURL(getCapabilities().getRequest().getGetMap()); return (GetMapRequest) getSpecification().createGetMapRequest(onlineResource); }
/** * Creates a GetMapRequest that can be configured and then passed to * issueRequest(). * * @return a configureable GetMapRequest object */ public GetMapRequest createGetMapRequest() { URL onlineResource = findURL(getCapabilities().getRequest().getGetMap()); return (GetMapRequest) getSpecification().createGetMapRequest(onlineResource); }
/** Returns true if the layer can be queried */ public boolean isQueryable(LayerInfo layer) { try { if (layer.getResource() instanceof WMSLayerInfo) { WMSLayerInfo info = (WMSLayerInfo) layer.getResource(); Layer wl = info.getWMSLayer(null); if (!wl.isQueryable()) { return false; } WMSCapabilities caps = info.getStore().getWebMapServer(null).getCapabilities(); OperationType featureInfo = caps.getRequest().getGetFeatureInfo(); if (featureInfo == null || !featureInfo.getFormats().contains("application/vnd.ogc.gml")) { return false; } } else if (layer.getResource() instanceof WMTSLayerInfo) { return false; } return layer.isQueryable(); } catch (IOException e) { LOGGER.log( Level.INFO, "Failed to determine if the layer is queryable, assuming it's not", e); return false; } }
info.setName(owsLayer.getName()); info.setDescription(owsLayer.getTitle()); OperationType operationTypeFeatureInfo = wmsMapServer.getCapabilities().getRequest().getGetFeatureInfo();