*/
public synchronized static JGrassMapGeoResource addMapToCatalog( String locationPath, String mapsetName, String mapName,
String mapType ) {
// URL mapsetId = JGrassMapsetGeoResource.createId(locationPath, mapsetName);
JGrassMapsetGeoResource mapset = null;
try {
File locationFile = new File(locationPath);
ID locationId = new ID(locationFile.toURI().toURL());
URL mapsetUrl = JGrassMapsetGeoResource.createId(locationFile.getAbsolutePath(), mapsetName);
ID mapsetId = new ID(mapsetUrl);
ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();
mapset = localCatalog.getById(JGrassMapsetGeoResource.class, mapsetId, ProgressManager.instance().get());
if (mapset == null) {
// try with the service
// URL locationId = JGrassService.createId(locationPath);
JGrassService locationService = localCatalog.getById(JGrassService.class, locationId, ProgressManager.instance()
.get());
mapset = locationService.getMapsetGeoresourceByName(mapsetName);
}
} catch (MalformedURLException e) {
e.printStackTrace();
String message = "An error occurred while adding the map to the catalog";
ExceptionDetailsDialog.openError(null, message, IStatus.ERROR, JGrassPlugin.PLUGIN_ID, e);
}
if (mapset == null)
return null;
return mapset.addMap(mapName, mapType);
}