Search in sources :

Example 1 with GPGeoserverCoverageInfo

use of org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo in project geo-platform by geosdi.

the class GeoserverConnectorCoverageStoresTest method n_readCoverageInfo.

@Test()
public void n_readCoverageInfo() throws Exception {
    GeoserverLoadCoverageWithUrlRequest gpGeoserverLoadCoverageWithUrlRequest = this.geoserverConnectorStore.loadCoverageInfoWithUrl().withUrl("http://150.145.141.180/geoserver/rest/workspaces/nurc/coveragestores/mosaic/coverages/mosaic.json");
    GPGeoserverCoverageInfo gpGeoserverFeatureTypeInfo = gpGeoserverLoadCoverageWithUrlRequest.getResponse();
    logger.info("########################BBOX {}\n", gpGeoserverFeatureTypeInfo.getLatLonBoundingBox());
    logger.info("########################BBOX {}\n", gpGeoserverFeatureTypeInfo.getLatLonBoundingBox().getCrs());
}
Also used : GeoserverLoadCoverageWithUrlRequest(org.geosdi.geoplatform.connector.geoserver.request.workspaces.coverages.GeoserverLoadCoverageWithUrlRequest) GPGeoserverCoverageInfo(org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo) GeoserverConnectorTest(org.geosdi.geoplatform.geoserver.GeoserverConnectorTest) Test(org.junit.Test)

Example 2 with GPGeoserverCoverageInfo

use of org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo in project geo-platform by geosdi.

the class GeoserverConnectorCoverageStoresTest method e_splitDimensions.

@Test
public void e_splitDimensions() throws Exception {
    GPGeoserverCoverageInfo gpGeoserverCoverageInfo = this.geoserverConnectorStore.loadCoverageInfoWithUrl().withUrl("http://150.145.141.180/geoserver/rest/workspaces/nurc/coveragestores/mosaic/coverages/mosaic.json").getResponse();
    logger.info("################{}\n", gpGeoserverCoverageInfo.getDimensions().getCoverageDimension());
    logger.info("##############{}\n", StreamSupport.stream(gpGeoserverCoverageInfo.getDimensions().getCoverageDimension().spliterator(), Boolean.FALSE).collect(Collectors.toList()));
    RESTLayer restLayer = this.restReader.getLayer("nurc", "mosaic");
    RESTCoverage coverage = this.restReader.getCoverage(restLayer);
    StreamSupport.stream(coverage.getEncodedDimensionsInfoList().spliterator(), Boolean.FALSE).forEach(c -> System.out.println(c.getName()));
}
Also used : GPGeoserverCoverageInfo(org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo) RESTLayer(it.geosolutions.geoserver.rest.decoder.RESTLayer) RESTCoverage(it.geosolutions.geoserver.rest.decoder.RESTCoverage) GeoserverConnectorTest(org.geosdi.geoplatform.geoserver.GeoserverConnectorTest) Test(org.junit.Test)

Example 3 with GPGeoserverCoverageInfo

use of org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo in project geo-platform by geosdi.

the class GPGeoserverCoverageInfoJacksonTest method b_unmarshallGPGeoserverCoverageInfoFromXmlFileTest.

@Test
public void b_unmarshallGPGeoserverCoverageInfoFromXmlFileTest() throws Exception {
    GPGeoserverCoverageInfo coverageInfo = JACKSON_JAXB_XML_SUPPORT.getDefaultMapper().readValue(new File(of(new File(".").getCanonicalPath(), "src", "test", "resources", "CoverageTypeInfo").collect(joining(separator, "", ".xml"))), GPGeoserverCoverageInfo.class);
    logger.info("@@@@@@@@@@@@@@@@@@@@@@@GP_GEOSERVER_COVERAGE_INFO : {}\n", coverageInfo);
}
Also used : GPGeoserverCoverageInfo(org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo) File(java.io.File) Test(org.junit.Test)

Example 4 with GPGeoserverCoverageInfo

use of org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo in project geo-platform by geosdi.

the class GPPublisherBasicServiceImpl method getTIFURLByLayerName.

private InfoPreview getTIFURLByLayerName(String workspace, String layerName) {
    String userWorkspace = workspace;
    if (userWorkspace == null) {
        userWorkspace = this.getWorkspace(workspace);
    }
    GeoserverLayer geoserverLayer = null;
    try {
        geoserverLayer = this.geoserverConnectorStore.loadWorkspaceLayerRequest().withLayerName(layerName).withWorkspaceName(workspace).getResponse();
    } catch (Exception e) {
        final String error = "Error to load layer with workspace name: " + workspace + " and layer name:" + layerName + " " + e;
        logger.error(error);
        throw new IllegalArgumentException(error, e.getCause());
    }
    if (geoserverLayer == null) {
        throw new ResourceNotFoundFault("The layer: " + layerName + " with workspace: " + workspace + " does not exists");
    }
    if (geoserverLayer.getLayerType().getType() != GeoserverLayerType.Raster.getType()) {
        throw new ResourceNotFoundFault("Bad layer type for layer " + layerName);
    }
    InfoPreview info = null;
    try {
        GeoserverLoadCoverageWithUrlRequest gpGeoserverLoadCoverageWithUrlRequest = this.geoserverConnectorStore.loadCoverageInfoWithUrl().withUrl(geoserverLayer.getLayerResource().getHref());
        GPGeoserverCoverageInfo gpGeoserverFeatureTypeInfo = gpGeoserverLoadCoverageWithUrlRequest.getResponse();
        Integer code = this.getEPSGCodeFromString(gpGeoserverFeatureTypeInfo.getLatLonBoundingBox().getCrs());
        String epsgCode = null;
        if (code != null) {
            epsgCode = "EPSG:" + code.toString();
        }
        info = new InfoPreview(RESTURL, userWorkspace, layerName, gpGeoserverFeatureTypeInfo.getLatLonBoundingBox().getMinx(), gpGeoserverFeatureTypeInfo.getLatLonBoundingBox().getMiny(), gpGeoserverFeatureTypeInfo.getLatLonBoundingBox().getMaxx(), gpGeoserverFeatureTypeInfo.getLatLonBoundingBox().getMaxy(), epsgCode, geoserverLayer.getDefaultStyle().getName(), FALSE, Lists.<LayerPublishAction>newArrayList(LayerPublishAction.OVERRIDE, LayerPublishAction.RENAME));
    } catch (Exception e) {
        final String error = "The layer " + layerName + " is published in the " + userWorkspace + " workspace, but the server cannot provide info. " + e;
        logger.error(error);
        throw new IllegalArgumentException(error, e.getCause());
    // info = new InfoPreview(layerName,
    // "The layer " + layerName + " is published in the " + userWorkspace + " workspace, but the server cannot provide info");
    }
    return info;
}
Also used : GeoserverLoadCoverageWithUrlRequest(org.geosdi.geoplatform.connector.geoserver.request.workspaces.coverages.GeoserverLoadCoverageWithUrlRequest) GeoserverLayer(org.geosdi.geoplatform.connector.geoserver.model.layers.GeoserverLayer) LayerPublishAction(org.geosdi.geoplatform.gui.shared.publisher.LayerPublishAction) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPGeoserverCoverageInfo(org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo) FactoryException(org.opengis.referencing.FactoryException) DataSourceException(org.geotools.data.DataSourceException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 5 with GPGeoserverCoverageInfo

use of org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo in project geo-platform by geosdi.

the class GPGeoserverCreateCoverageRequest method prepareHttpEntity.

/**
 * @return {@link HttpEntity}
 */
@Override
protected HttpEntity prepareHttpEntity() throws Exception {
    GPGeoserverCoverageInfo coverageBody = this.coverageBody.get();
    checkArgument(coverageBody != null, "The coverageBody must not be null.");
    String workspaceBodyString = jacksonSupport.getDefaultMapper().writeValueAsString(coverageBody);
    logger.debug("#############################COVERAGE_BODY : \n{}\n", workspaceBodyString);
    return new StringEntity(workspaceBodyString, APPLICATION_JSON);
}
Also used : StringEntity(org.apache.hc.core5.http.io.entity.StringEntity) GPGeoserverCoverageInfo(org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo)

Aggregations

GPGeoserverCoverageInfo (org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo)13 Test (org.junit.Test)9 GeoserverConnectorTest (org.geosdi.geoplatform.geoserver.GeoserverConnectorTest)5 File (java.io.File)4 RESTCoverage (it.geosolutions.geoserver.rest.decoder.RESTCoverage)2 RESTLayer (it.geosolutions.geoserver.rest.decoder.RESTLayer)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 StringEntity (org.apache.hc.core5.http.io.entity.StringEntity)2 GeoserverLayer (org.geosdi.geoplatform.connector.geoserver.model.layers.GeoserverLayer)2 GeoserverRasterLayer (org.geosdi.geoplatform.connector.geoserver.model.layers.raster.GeoserverRasterLayer)2 GPGeoserverStyle (org.geosdi.geoplatform.connector.geoserver.model.styles.GPGeoserverStyle)2 GeoserverLoadCoverageStoreRequest (org.geosdi.geoplatform.connector.geoserver.request.coveragestores.GeoserverLoadCoverageStoreRequest)2 GeoserverLoadCoverageWithUrlRequest (org.geosdi.geoplatform.connector.geoserver.request.workspaces.coverages.GeoserverLoadCoverageWithUrlRequest)2 Ignore (org.junit.Ignore)2 File.separator (java.io.File.separator)1 StringReader (java.io.StringReader)1 TRUE (java.lang.Boolean.TRUE)1 Collectors.joining (java.util.stream.Collectors.joining)1 Collectors.toList (java.util.stream.Collectors.toList)1