use of com.revolsys.gis.wms.capabilities.WmsCapabilities in project com.revolsys.open by revolsys.
the class WmsClient method getMapUrl.
public UrlResource getMapUrl(final List<String> layers, final List<String> styles, final String srid, final BoundingBox envelope, final String format, final int width, final int height) {
final WmsCapabilities capabilities = getCapabilities();
final String version = capabilities.getVersion();
final Map<String, Object> parameters = new LinkedHashMap<>();
parameters.put("SERVICE", "WMS");
if (version.equals("1.0.0")) {
parameters.put(WmsParameters.WMTVER, version);
parameters.put(WmsParameters.REQUEST, WmsParameterValues.MAP);
} else {
parameters.put(WmsParameters.VERSION, version);
parameters.put(WmsParameters.REQUEST, WmsParameterValues.GET_MAP);
}
parameters.put(WmsParameters.LAYERS, Strings.toString(layers));
String style;
if (styles == null) {
style = "";
} else {
style = Strings.toString(styles);
for (int i = styles.size(); i < layers.size(); i++) {
style += ",";
}
}
parameters.put(WmsParameters.STYLES, style);
if (version.equals("1.3.0")) {
parameters.put(WmsParameters.CRS, srid);
} else {
parameters.put(WmsParameters.SRS, srid);
}
final String bbox = envelope.getMinX() + "," + envelope.getMinY() + "," + envelope.getMaxX() + "," + envelope.getMaxY();
parameters.put(WmsParameters.BBOX, bbox);
parameters.put(WmsParameters.WIDTH, width);
parameters.put(WmsParameters.HEIGHT, height);
parameters.put(WmsParameters.FORMAT, format);
final String exceptionFormat = capabilities.getExceptionFormat();
parameters.put(WmsParameters.EXCEPTIONS, exceptionFormat);
parameters.put(WmsParameters.TRANSPARENT, "TRUE");
// = getCapabilities().getRequestUrl("GetMap",
UrlResource requestUrl = null;
// "GET");
if (requestUrl == null) {
requestUrl = getServiceUrl();
}
return requestUrl.newUrlResource(parameters);
}
use of com.revolsys.gis.wms.capabilities.WmsCapabilities in project com.revolsys.open by revolsys.
the class WmsClient method loadCapabilities.
public WmsCapabilities loadCapabilities() {
final Map<String, Object> parameters = new LinkedHashMap<>();
parameters.put(WmsParameters.SERVICE, WmsParameterValues.WMS);
parameters.put(WmsParameters.REQUEST, WmsParameterValues.GET_CAPABILITIES);
final UrlResource capabilitiesUrl = newServiceUrlResource(parameters);
try (InputStream in = capabilitiesUrl.getInputStream()) {
final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setValidating(false);
documentBuilderFactory.setNamespaceAware(true);
final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
final Document document = documentBuilder.parse(in);
this.capabilities = new WmsCapabilities(this, document.getDocumentElement());
return this.capabilities;
} catch (final Throwable e) {
throw Exceptions.wrap("Unable to read capabilities: " + capabilitiesUrl, e);
}
}
Aggregations