Only one small detail; making a URL from a File is super scary (when you get 
into things like windows network shares and so on). There is a DataUtilities 
method to do the conversion for you...

http://docs.geotools.org/latest/userguide/library/main/data.html#url-and-file

-- 
Jody Garnett


On Thursday, 23 June 2011 at 9:24 AM, Putna Levi wrote:

> 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 
> (file://%22+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. 
> 
> > From: [email protected] 
> > [mailto:[email protected]] On Behalf Of Alberto 
> > Debiasi
> > Sent: Wednesday, 22 June 2011 5:52 PM
> > To: ML udig-users; User-friendly Desktop Internet GIS
> > Subject: [udig-devel] add GeoTifff Image
> > 
> >  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
> +----------------------------------------------------------------+
> 
> 
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to