[geotk] Explicit TIFF plugin register

Thys Meintjes sthysel at gmail.com
Mon Jul 11 04:04:34 EDT 2011


Excellent advice, I'll do the same.

Thanks Johann

On Mon, Jul 11, 2011 at 9:07 AM, sorel johann <johann.sorel at geomatys.fr>wrote:

> **
> Hello
>
> I agree It's a problem.
> ImageIO do not use the usual meta-inf/service configuration for discovery
> of new readers. It uses somekind of predecessor.
>
> Here is what I use in Puzzle-GIS for the geotoolkit module (In the
> installer class):
> //force netbeans platform classloader to load image readers.
> Registry.setDefaultCodecPreferences();
> WorldFileImageReader.Spi.registerDefaults(null);
> WorldFileImageWriter.Spi.registerDefaults(null);
> ImageIO.scanForPlugins();
>
> Hints.putSystemDefault(Hints.LENIENT_DATUM_SHIFT, Boolean.TRUE);
>
> //force netbeans platform classloader to load the derby and postgres driver
> //often use for EPSG databases
> try {
>        Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
>        Class.forName("org.postgresql.Driver").newInstance();
> } catch (Exception ex) {
>        Exceptions.printStackTrace(ex);
> }
>
>
> And when I have additional module with image reader/writer I have :
> ImageIO.scanForPlugins();
> GeoTiffImageReader.Spi.registerDefaults(null);
> DimapImageReader.Spi.registerDefaults(null);
>
>
> Perhaps Martin Desruisseaux will give more details on this behavior.
>
>
> johann
>
>
>
>
> On 11/07/2011 08:48, Thys Meintjes wrote:
>
> Hi  All,
>
>  I'm writing a Netbeans RCP based app and had a bad time loading
> GeoTIFF's. After trolling through the mailing list, especially
> this thread:
> http://lists.osgeo.org/pipermail/geotoolkit/2011-January/000466.html, I
> fixed the problem by explicitly registering
> the TIFF readers as follows:
>
>      private void explicitRegisterTIFF() {
>         ImageIO.scanForPlugins();
>         IIORegistry.getDefaultInstance().registerServiceProvider(new
> com.sun.media.imageioimpl.plugins.tiff.TIFFImageReaderSpi(),
> ImageReaderSpi.class);
>         IIORegistry.getDefaultInstance().registerServiceProvider(new
> GeoTiffImageReader.Spi("TIFF"), ImageReaderSpi.class);
>     }
>
>
>  While this works I'm concerned that it point to a deeper problem within
> the app. I would like the service discovery mechanism to work
> as intended. Especially if I ever needed any other readers to work "out of
> the box".
>
>  Any thought on this ?
>
>  thanks and regards
>
> --
> Thys Meintjes
>
>
>
> _______________________________________________
> Geotoolkit mailing listGeotoolkit at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/geotoolkit
>
>
>
> _______________________________________________
> Geotoolkit mailing list
> Geotoolkit at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geotoolkit
>
>


-- 
Thys Meintjes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geotoolkit/attachments/20110711/a4205d20/attachment.html


More information about the Geotoolkit mailing list