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");
}
}
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());
}
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());
}
}
Aggregations