[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| Re: [udig-devel] add GeoTifff Image | 
I’m only new to this so forgive me if I’m barking up the wrong 
tree, I was digging around in the 
CatalogPlugin plugin and think that’s what you’re looking for.
 
You can manually create your service 
and add it to the catalog like so.
 
IServiceFactory 
serviceFactory = CatalogPlugin.getDefault().getServiceFactory();
IService 
service = 
serviceFactory.createService(new URL("file://"+path)); 
 
try {
    IServiceInfo info = 
service.getInfo( null );  // try connecting to make sure the service 
works
 
    if (info != null) 
{
         
CatalogPlugin.getDefault().getLocalCatalog().add( service ); // add 
service
    
} 
}catch (IOException couldNotConnect ){
     service.dispose(new 
NullProgressMonitor());
}
 
However the catalog provides the 
acquire method that will do all the work for you. 
 
IService service = 
CatalogPlugin.getDefault().getLocalCatalog().acquire(new URL("file://"+path), new 
NullProgressMonitor()); 
 
Simply call this from your menu 
contribution and provide the path to your GeoTiff.
 
One thing to note is that the acquire 
method douse not guarantee that a geotiff service will be used to render your 
layer. If it I important that your layer use a geotiff render you will have to use the 
manual service creation method. 
 
  
  Hi,
I wuold like to add a geoTiff image on a 2D map simply 
  pressing a button.
The functionality is the same as "right click on a 
  map" -> "add files" -> "and select a GeoTiff image"
but I don't know 
  which classes I should use and in which 
way.
Thanks.
Alberto
 
+----------------------------------------------------------------+
Think B4U Print
1 ream of paper = 6% of a tree and 5.4kg CO2 in the atmosphere
3 sheets of A4 paper = 1 litre of water
+----------------------------------------------------------------+