Search in sources :

Example 1 with GeoserverRasterLayer

use of org.geosdi.geoplatform.connector.geoserver.model.layers.raster.GeoserverRasterLayer in project geo-platform by geosdi.

the class GPPublisherBasicServiceImpl method publishExternalGeoTiff.

/**
 * @param userWorkspace
 * @param fileInTifDir
 * @param fileName
 * @param epsg
 * @param sld
 * @return {@link boolean}
 */
private boolean publishExternalGeoTiff(String userWorkspace, File fileInTifDir, String fileName, String epsg, String sld) throws IllegalArgumentException {
    if (userWorkspace != null && fileInTifDir != null && fileName != null && fileInTifDir != null && epsg != null && sld != null) {
        try {
            GPGeoserverCoverageInfo theGPGeoserverCoverageInfo = new GPGeoserverCoverageInfo();
            theGPGeoserverCoverageInfo.setName(fileName);
            theGPGeoserverCoverageInfo.setTitle(fileName);
            theGPGeoserverCoverageInfo.setSrs(epsg);
            theGPGeoserverCoverageInfo.setEnabled(TRUE);
            theGPGeoserverCoverageInfo.setPolicy(GPProjectionPolicy.FORCE_DECLARED);
            GeoserverLoadCoverageStoreRequest geoserverLoadCoverageStoreRequest = this.geoserverConnectorStore.loadCoverageStoreRequest().withWorkspace(userWorkspace).withStore(fileName);
            this.geoserverConnectorStore.updateCoverageStoreWithStoreName().withWorkspace(userWorkspace).withCoverageName(fileName).withStore(fileName).withUpdate(GPParameterUpdate.OVERWRITE).withConfigure(GPGeoserverParameterConfigure.FIRST).withMethod(GPGeoserverUploadMethod.FILE).withFormat(GPGeoserverCoverageStoreFileExtension.GEOTIFF).withFile(fileInTifDir).getResponse();
            if (!geoserverLoadCoverageStoreRequest.exist()) {
                return FALSE;
            } else if (!this.geoserverConnectorStore.createCoverageRequest().withWorkspace(userWorkspace).withCoverageStore(fileName).withCoverageBody(theGPGeoserverCoverageInfo).getResponse()) {
                logger.error("Unable to create a coverage for the store:" + fileName);
                return FALSE;
            } else {
                GeoserverRasterLayer geoserverRasterLayer = new GeoserverRasterLayer();
                GPGeoserverStyle gpGeoserverStyle = new GPGeoserverStyle();
                gpGeoserverStyle.setName(sld);
                geoserverRasterLayer.setDefaultStyle(gpGeoserverStyle);
                if (this.geoserverConnectorStore.updateLayerRequest().withWorkspaceName(userWorkspace).withLayerName(fileName).withLayerBody(geoserverRasterLayer).getResponse()) {
                    return TRUE;
                }
                return FALSE;
            }
        } catch (Exception e) {
            final String error = "Error to load external GEOTIFF " + e;
            logger.error(error);
            throw new IllegalArgumentException(error);
        }
    } else {
        throw new IllegalArgumentException("Unable to run: null parameter");
    }
}
Also used : IGPGeoserverStyle(org.geosdi.geoplatform.connector.geoserver.model.styles.IGPGeoserverStyle) GPGeoserverStyle(org.geosdi.geoplatform.connector.geoserver.model.styles.GPGeoserverStyle) GeoserverLoadCoverageStoreRequest(org.geosdi.geoplatform.connector.geoserver.request.coveragestores.GeoserverLoadCoverageStoreRequest) GPGeoserverCoverageInfo(org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo) GeoserverRasterLayer(org.geosdi.geoplatform.connector.geoserver.model.layers.raster.GeoserverRasterLayer) FactoryException(org.opengis.referencing.FactoryException) DataSourceException(org.geotools.data.DataSourceException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 2 with GeoserverRasterLayer

use of org.geosdi.geoplatform.connector.geoserver.model.layers.raster.GeoserverRasterLayer in project geo-platform by geosdi.

the class GeoserverConnectorCoverageStoresTest method i_updateLayer.

@Ignore
@Test
public void i_updateLayer() throws Exception {
    GeoserverRasterLayer geoserverRasterLayer = new GeoserverRasterLayer();
    GPGeoserverStyle gpGeoserverStyle = new GPGeoserverStyle();
    gpGeoserverStyle.setName("burg");
    geoserverRasterLayer.setDefaultStyle(gpGeoserverStyle);
    logger.info("###############{}\n", this.geoserverConnectorStore.updateLayerRequest().withWorkspaceName("sf").withLayerName("layer_vito").withLayerBody(geoserverRasterLayer).getResponse());
}
Also used : GPGeoserverStyle(org.geosdi.geoplatform.connector.geoserver.model.styles.GPGeoserverStyle) GeoserverRasterLayer(org.geosdi.geoplatform.connector.geoserver.model.layers.raster.GeoserverRasterLayer) Ignore(org.junit.Ignore) GeoserverConnectorTest(org.geosdi.geoplatform.geoserver.GeoserverConnectorTest) Test(org.junit.Test)

Example 3 with GeoserverRasterLayer

use of org.geosdi.geoplatform.connector.geoserver.model.layers.raster.GeoserverRasterLayer in project geo-platform by geosdi.

the class GeoserverConnectorCoverageStoresTest method l_createCoverage.

@Ignore
@Test
public void l_createCoverage() throws Exception {
    File file = new File(of("src", "test", "resources", "VMI_20210923T1020Z.tif").collect(joining(separator)));
    Assert.assertTrue("#################FILE_EXSIST", file.exists());
    GPGeoserverCoverageInfo theGPGeoserverCoverageInfo = new GPGeoserverCoverageInfo();
    theGPGeoserverCoverageInfo.setName("layer_vito");
    theGPGeoserverCoverageInfo.setTitle("layer_vito");
    theGPGeoserverCoverageInfo.setEnabled(TRUE);
    theGPGeoserverCoverageInfo.setPolicy(GPProjectionPolicy.FORCE_DECLARED);
    theGPGeoserverCoverageInfo.setSrs("EPSG:4326");
    this.geoserverConnectorStore.updateCoverageStoreWithStoreName().withWorkspace("sf").withStore("store_vito").withFormat(GPGeoserverCoverageStoreFileExtension.GEOTIFF).withFile(file).withMethod(GPGeoserverUploadMethod.FILE).withConfigure(GPGeoserverParameterConfigure.FIRST).withCoverageName("layer_vito").withUpdate(GPParameterUpdate.OVERWRITE).getResponse();
    GeoserverLoadCoverageStoreRequest geoserverLoadCoverageStoreRequest = this.geoserverConnectorStore.loadCoverageStoreRequest().withWorkspace("sf").withStore("store_vito");
    if (!geoserverLoadCoverageStoreRequest.exist()) {
        logger.error("");
    } else if (!this.geoserverConnectorStore.createCoverageRequest().withWorkspace("sf").withCoverageStore("store_vito").withCoverageBody(theGPGeoserverCoverageInfo).getResponse()) {
        logger.error("Unable to create a coverage for the store:" + "layer_vito");
    } else {
        GeoserverRasterLayer geoserverRasterLayer = new GeoserverRasterLayer();
        GPGeoserverStyle gpGeoserverStyle = new GPGeoserverStyle();
        gpGeoserverStyle.setName("burg");
        geoserverRasterLayer.setDefaultStyle(gpGeoserverStyle);
        logger.info("##############{}\n", this.geoserverConnectorStore.updateLayerRequest().withWorkspaceName("sf").withLayerName("layer_vito").withLayerBody(geoserverRasterLayer).getResponse());
    }
}
Also used : GPGeoserverStyle(org.geosdi.geoplatform.connector.geoserver.model.styles.GPGeoserverStyle) GeoserverLoadCoverageStoreRequest(org.geosdi.geoplatform.connector.geoserver.request.coveragestores.GeoserverLoadCoverageStoreRequest) GPGeoserverCoverageInfo(org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo) GeoserverRasterLayer(org.geosdi.geoplatform.connector.geoserver.model.layers.raster.GeoserverRasterLayer) File(java.io.File) Ignore(org.junit.Ignore) GeoserverConnectorTest(org.geosdi.geoplatform.geoserver.GeoserverConnectorTest) Test(org.junit.Test)

Aggregations

GeoserverRasterLayer (org.geosdi.geoplatform.connector.geoserver.model.layers.raster.GeoserverRasterLayer)3 GPGeoserverStyle (org.geosdi.geoplatform.connector.geoserver.model.styles.GPGeoserverStyle)3 GPGeoserverCoverageInfo (org.geosdi.geoplatform.connector.geoserver.model.workspace.coverages.GPGeoserverCoverageInfo)2 GeoserverLoadCoverageStoreRequest (org.geosdi.geoplatform.connector.geoserver.request.coveragestores.GeoserverLoadCoverageStoreRequest)2 GeoserverConnectorTest (org.geosdi.geoplatform.geoserver.GeoserverConnectorTest)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 IGPGeoserverStyle (org.geosdi.geoplatform.connector.geoserver.model.styles.IGPGeoserverStyle)1 DataSourceException (org.geotools.data.DataSourceException)1 FactoryException (org.opengis.referencing.FactoryException)1