Search in sources :

Example 1 with WmsClient

use of com.revolsys.gis.wms.WmsClient in project com.revolsys.open by revolsys.

the class WmsLayerDefinition method getMapImage.

public GeoreferencedImage getMapImage(final BoundingBox boundingBox, final int imageWidth, final int imageHeight) {
    final BoundingBox queryBoundingBox = boundingBox.intersection(getLatLonBoundingBox());
    final String srs = "EPSG:" + queryBoundingBox.getCoordinateSystemId();
    final WmsClient wmsClient = getWmsClient();
    return wmsClient.getMapImage(this.name, getDefaultStyleName(), srs, queryBoundingBox, "image/png", imageWidth, imageHeight);
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) WmsClient(com.revolsys.gis.wms.WmsClient)

Example 2 with WmsClient

use of com.revolsys.gis.wms.WmsClient in project com.revolsys.open by revolsys.

the class OgcWmsImageLayer method initializeDo.

@Override
protected boolean initializeDo() {
    final boolean initialized = super.initializeDo();
    if (initialized) {
        try {
            final WmsClient wmsClient;
            if (Property.hasValue(this.connectionName)) {
                final WebService<?> webService = WebServiceConnectionManager.getWebService(this.connectionName);
                if (webService == null) {
                    Logs.error(this, getPath() + ": Web service " + this.connectionName + ": no connection configured");
                    return false;
                } else if (webService instanceof WmsClient) {
                    wmsClient = (WmsClient) webService;
                } else {
                    Logs.error(this, getPath() + ": Web service " + this.connectionName + ": is not a OGS WMS service");
                    return false;
                }
            } else if (Property.hasValue(this.serviceUrl)) {
                wmsClient = new WmsClient(this.serviceUrl);
            } else {
                Logs.error(this, getPath() + ": A record store layer requires a connection entry with a name or url, username, and password ");
                return false;
            }
            final WmsLayerDefinition wmsLayerDefinition = wmsClient.getLayer(this.layerName);
            setWmsLayerDefinition(wmsLayerDefinition);
            return wmsLayerDefinition != null;
        } catch (final WrappedException e) {
            final Throwable cause = Exceptions.unwrap(e);
            if (cause instanceof UnknownHostException) {
                return setNotExists("Unknown host: " + cause.getMessage());
            } else {
                throw e;
            }
        }
    }
    return initialized;
}
Also used : WrappedException(com.revolsys.util.WrappedException) UnknownHostException(java.net.UnknownHostException) WmsLayerDefinition(com.revolsys.gis.wms.capabilities.WmsLayerDefinition) WmsClient(com.revolsys.gis.wms.WmsClient)

Example 3 with WmsClient

use of com.revolsys.gis.wms.WmsClient in project com.revolsys.open by revolsys.

the class OgcWmsImageLayer method setWmsLayerDefinition.

protected void setWmsLayerDefinition(final WmsLayerDefinition wmsLayerDefinition) {
    this.wmsLayerDefinition = wmsLayerDefinition;
    if (wmsLayerDefinition == null) {
        setExists(false);
    } else {
        setExists(true);
        final WmsClient wmsClient = wmsLayerDefinition.getWmsClient();
        final String connectionName = wmsClient.getName();
        if (Property.hasValue(connectionName)) {
            this.connectionName = connectionName;
            this.serviceUrl = null;
        } else {
            this.serviceUrl = wmsClient.getServiceUrl().toString();
        }
        final String layerTitle = wmsLayerDefinition.getTitle();
        if (!Property.hasValue(getName())) {
            setName(layerTitle);
        }
        this.layerName = wmsLayerDefinition.getName();
        final long minimumScale = (long) wmsLayerDefinition.getMinimumScale();
        super.setMinimumScale(minimumScale);
        final long maximumScale = (long) wmsLayerDefinition.getMaximumScale();
        super.setMaximumScale(maximumScale);
        setBoundingBox(wmsLayerDefinition.getLatLonBoundingBox());
        final GeometryFactory geometryFactory = wmsLayerDefinition.getDefaultGeometryFactory();
        setGeometryFactory(geometryFactory);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) WmsClient(com.revolsys.gis.wms.WmsClient)

Aggregations

WmsClient (com.revolsys.gis.wms.WmsClient)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 WmsLayerDefinition (com.revolsys.gis.wms.capabilities.WmsLayerDefinition)1 WrappedException (com.revolsys.util.WrappedException)1 UnknownHostException (java.net.UnknownHostException)1