Search in sources :

Example 1 with ArcGisRestCatalog

use of com.revolsys.record.io.format.esri.rest.ArcGisRestCatalog in project com.revolsys.open by revolsys.

the class MapService method getMapService.

public static MapService getMapService(String url) {
    url = url.replaceAll("/*MapServer/*(\\?.*)?", "") + "/MapServer";
    final ArcGisRestCatalog catalog = ArcGisRestCatalog.newArcGisRestCatalog(url);
    final PathName path = PathName.newPathName(url.substring(catalog.getServiceUrl().toString().length()));
    final MapService service = catalog.getWebServiceResource(path, MapService.class);
    return service;
}
Also used : ArcGisRestCatalog(com.revolsys.record.io.format.esri.rest.ArcGisRestCatalog) PathName(com.revolsys.io.PathName)

Example 2 with ArcGisRestCatalog

use of com.revolsys.record.io.format.esri.rest.ArcGisRestCatalog in project com.revolsys.open by revolsys.

the class MapGuideWebServerRecordLayer method initializeDo.

@Override
protected boolean initializeDo() {
    FeatureLayer webServiceLayer = getWebServiceLayer();
    if (webServiceLayer == null) {
        final String url = getUrl();
        final PathName layerPath = getLayerPath();
        if (url == null) {
            Logs.error(this, Classes.className(this) + " requires a url: " + getPath());
            return false;
        }
        if (layerPath == null) {
            Logs.error(this, Classes.className(this) + " requires a layerPath: " + getPath());
            return false;
        }
        ArcGisRestCatalog server;
        try {
            server = ArcGisRestCatalog.newArcGisRestCatalog(url);
        } catch (final Throwable e) {
            Logs.error(this, "Unable to connect to server: " + url + " for " + getPath(), e);
            return false;
        }
        try {
            webServiceLayer = server.getWebServiceResource(layerPath, FeatureLayer.class);
        } catch (final IllegalArgumentException e) {
            Logs.error(this, "Layer is not valid: " + getPath(), e);
            return false;
        }
        if (webServiceLayer == null) {
            Logs.error(this, "Layer does not exist: " + layerPath + " for " + getPath());
            return false;
        } else {
            setWebServiceLayer(webServiceLayer);
        }
    }
    if (webServiceLayer != null) {
        final RecordDefinition recordDefinition = webServiceLayer.getRecordDefinition();
        if (recordDefinition != null) {
            setRecordDefinition(recordDefinition);
            setBoundingBox(webServiceLayer.getBoundingBox());
            // initRenderer();
            return super.initializeDo();
        }
    }
    return false;
}
Also used : FeatureLayer(com.revolsys.record.io.format.mapguide.FeatureLayer) ArcGisRestCatalog(com.revolsys.record.io.format.esri.rest.ArcGisRestCatalog) PathName(com.revolsys.io.PathName) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 3 with ArcGisRestCatalog

use of com.revolsys.record.io.format.esri.rest.ArcGisRestCatalog in project com.revolsys.open by revolsys.

the class ArcGisRestServerRecordLayer method initializeDo.

@Override
protected boolean initializeDo() {
    FeatureLayer layerDescription = getLayerDescription();
    if (layerDescription == null) {
        final String url = getUrl();
        final PathName layerPath = getLayerPath();
        if (url == null) {
            Logs.error(this, "An ArcGIS Rest server requires a url: " + getPath());
            return false;
        }
        if (layerPath == null) {
            Logs.error(this, "An ArcGIS Rest server requires a layerPath: " + getPath());
            return false;
        }
        ArcGisRestCatalog server;
        try {
            server = ArcGisRestCatalog.newArcGisRestCatalog(url);
        } catch (final Throwable e) {
            Logs.error(this, "Unable to connect to server: " + url + " for " + getPath(), e);
            return false;
        }
        try {
            layerDescription = server.getWebServiceResource(layerPath, FeatureLayer.class);
        } catch (final IllegalArgumentException e) {
            Logs.error(this, "ArcGIS Rest service is not a layer " + getPath(), e);
            return false;
        }
        if (layerDescription == null) {
            Logs.error(this, "No ArcGIS Rest layer with name: " + layerPath + " for " + getPath());
            return false;
        } else {
            setLayerDescription(layerDescription);
        }
    }
    if (layerDescription != null) {
        final RecordDefinition recordDefinition = layerDescription.getRecordDefinition();
        if (recordDefinition != null) {
            setRecordDefinition(recordDefinition);
            setBoundingBox(layerDescription.getBoundingBox());
            initRenderer();
            return super.initializeDo();
        }
    }
    return false;
}
Also used : FeatureLayer(com.revolsys.record.io.format.esri.rest.map.FeatureLayer) ArcGisRestCatalog(com.revolsys.record.io.format.esri.rest.ArcGisRestCatalog) PathName(com.revolsys.io.PathName) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 4 with ArcGisRestCatalog

use of com.revolsys.record.io.format.esri.rest.ArcGisRestCatalog in project com.revolsys.open by revolsys.

the class ArcGisRestServerTileCacheLayer method initializeDo.

@Override
protected boolean initializeDo() {
    synchronized (this.initSync) {
        if (this.mapService == null) {
            try {
                if (Property.hasValue(this.connectionName)) {
                    final WebService<?> webService = WebServiceConnectionManager.getWebService(this.connectionName);
                    if (webService instanceof ArcGisRestCatalog) {
                        final ArcGisRestCatalog catalog = (ArcGisRestCatalog) webService;
                        final WebServiceResource service = catalog.getWebServiceResource(this.servicePath);
                        if (service instanceof MapService) {
                            this.mapService = (MapService) service;
                        } else {
                            Logs.error(this, getPath() + ": Web service " + this.connectionName + " is not a ArcGIS service");
                            return false;
                        }
                    } else {
                        Logs.error(this, getPath() + ": Web service " + this.connectionName + " " + this.servicePath + " is not a ArcGIS Map service");
                        return false;
                    }
                } else {
                    // TODO username/password
                    this.mapService = MapService.getMapService(this.url);
                }
                if (this.mapService == null) {
                    Logs.error(this, "Unable to connect to ArcGIS rest server");
                    return false;
                } else {
                    final TileInfo tileInfo = this.mapService.getTileInfo();
                    if (tileInfo == null) {
                        Logs.info(this, this.url + " does not contain a tileInfo definition.");
                        return false;
                    } else {
                        this.geometryFactory = tileInfo.getGeometryFactory();
                        final BoundingBox boundingBox = this.mapService.getFullExtent();
                        setBoundingBox(boundingBox);
                        return true;
                    }
                }
            } catch (final WrappedException e) {
                final Throwable cause = Exceptions.unwrap(e);
                if (cause instanceof UnknownHostException) {
                    // cause.getMessage());
                    return setNotExists("Unknown host: " + cause.getMessage());
                } else {
                    throw e;
                }
            }
        } else {
            return true;
        }
    }
}
Also used : ArcGisRestCatalog(com.revolsys.record.io.format.esri.rest.ArcGisRestCatalog) TileInfo(com.revolsys.record.io.format.esri.rest.map.TileInfo) WrappedException(com.revolsys.util.WrappedException) UnknownHostException(java.net.UnknownHostException) WebServiceResource(com.revolsys.webservice.WebServiceResource) BoundingBox(com.revolsys.geometry.model.BoundingBox) MapService(com.revolsys.record.io.format.esri.rest.map.MapService)

Aggregations

ArcGisRestCatalog (com.revolsys.record.io.format.esri.rest.ArcGisRestCatalog)4 PathName (com.revolsys.io.PathName)3 RecordDefinition (com.revolsys.record.schema.RecordDefinition)2 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 FeatureLayer (com.revolsys.record.io.format.esri.rest.map.FeatureLayer)1 MapService (com.revolsys.record.io.format.esri.rest.map.MapService)1 TileInfo (com.revolsys.record.io.format.esri.rest.map.TileInfo)1 FeatureLayer (com.revolsys.record.io.format.mapguide.FeatureLayer)1 WrappedException (com.revolsys.util.WrappedException)1 WebServiceResource (com.revolsys.webservice.WebServiceResource)1 UnknownHostException (java.net.UnknownHostException)1