use of org.polymap.core.project.IMap in project polymap4-core by Polymap4.
the class DeleteLayerOperation method doWithCommit.
@Override
public IStatus doWithCommit(IProgressMonitor monitor, IAdaptable info) throws Exception {
assert layer.get().belongsTo(uow.get());
monitor.beginTask(getLabel(), 2);
register(uow.get());
IMap map = layer.get().parentMap.get();
// if (!map.layers.remove( layer.get() )) {
// throw new IllegalStateException( "Unable to remove layer from map." );
// }
// force commit (https://github.com/Polymap4/polymap4-model/issues/6)
map.label.set(map.label.get());
uow.get().removeEntity(layer.get());
assert !map.layers.contains(layer.get());
monitor.worked(1);
uow.get().commit();
monitor.done();
return Status.OK_STATUS;
}
use of org.polymap.core.project.IMap in project polymap4-core by Polymap4.
the class GeoServerLoader method loadGeoServer.
protected void loadGeoServer(GeoServerServlet service) {
IMap map = service.map;
log.info("Loading GeoServer...");
GeoServerInfoImpl gsInfo = new GeoServerInfoImpl(geoserver);
gsInfo.setTitle("GeoServer powered by mapzone.io");
gsInfo.setId(simpleName(map.id()) + "-gs");
// XXX alias is added by ArenaConfig when running in mapzone (see comment there)
String proxyBaseUrl = GeoServerPlugin.instance().baseUrl.map(s -> !s.contains(service.alias) ? s + service.alias : s).get();
gsInfo.setProxyBaseUrl(proxyBaseUrl);
log.info("Proxy base URL: " + gsInfo.getProxyBaseUrl());
gsInfo.setVerbose(true);
gsInfo.setVerboseExceptions(true);
geoserver.setGlobal(gsInfo);
log.info("GeoServer: " + gsInfo);
createWMSInfo(map);
createWFSInfo(map);
}
use of org.polymap.core.project.IMap in project polymap4-core by Polymap4.
the class GeoServerLoader method loadCatalog.
protected void loadCatalog(Catalog catalog, GeoServerServlet service) throws Exception {
log.info("Loading catalog...");
IMap map = service.map;
// workspace
WorkspaceInfoImpl wsInfo = new WorkspaceInfoImpl();
wsInfo.setId(simpleName(map.id()) + "-ws");
wsInfo.setDefault(true);
// simpleName( GeoServerPlugin.instance().baseName.orElse( map.label.get() ) ) );
wsInfo.setName("the-one-and-only");
// catalog.add( MapInfo );
log.info("Workspace: " + wsInfo);
catalog.add(GeoServerUtils.defaultNsInfo.get());
log.info("Namespace: " + GeoServerUtils.defaultNsInfo.get());
for (ILayer layer : map.layers) {
try {
// Features
P4DataStoreInfo dsInfo = P4DataStoreInfo.canHandle(catalog, layer);
if (dsInfo != null) {
dsInfo.setWorkspace(wsInfo);
if (dsInfo.getFeatureSource().getSchema().getGeometryDescriptor() != null) {
P4FeatureTypeInfo ftInfo = new P4FeatureTypeInfo(catalog, dsInfo);
catalog.add(ftInfo);
P4LayerInfo layerInfo = new P4LayerInfo(catalog, layer, ftInfo, PublishedType.VECTOR);
layerInfo.createFeatureStyleInfo(service.createSLD(layer), resourceLoader);
catalog.add(layerInfo);
}
continue;
}
// WMS
P4ImageStoreInfo imInfo = P4ImageStoreInfo.canHandle(catalog, layer);
if (imInfo != null) {
imInfo.setWorkspace(wsInfo);
P4ImageResourceInfo resInfo = new P4ImageResourceInfo(catalog, imInfo);
catalog.add(resInfo);
P4LayerInfo layerInfo = new P4LayerInfo(catalog, layer, resInfo, PublishedType.WMS);
layerInfo.createFeatureStyleInfo(service.createSLD(layer), resourceLoader);
catalog.add(layerInfo);
continue;
}
// XXX GridCoverage is not handled yet
} catch (Exception e) {
// don't break entire GeoServer if upstream WMS/WFS or else fails
log.warn("Error loading layer: " + layer, e);
}
}
catalog.add(wsInfo);
}
Aggregations