[geotk] applet to display raster
Martin Desruisseaux
martin.desruisseaux at geomatys.fr
Tue Jan 11 11:05:39 EST 2011
Hello Ramzi
I need to explore this issue more. However in the main time, there is some guess:
1) Could you try to add the following code and check the result in the Applet
viewer please?
Iterator<ImageReaderSpi> it =
IIORegistry.getDefaultInstance().getServiceProviders(ImageReaderSpi.class, true);
while (it.hasNext()) {
System.out.println(it.next());
}
2) If the above does not show any readers in the
"org.geotoolkit.image.io.plugin" namespace, could you try to add the following
before the loop?
ImageIO.scanForPlugins();
3) If the above still don't work, could you try the following (I'm not sure abot
the exact name of GeoTiffImageReader.Spi)?
IIORegistry.getDefaultInstance().registerServiceProvider(new
GeoTiffImageReader.Spi(), ImageReaderSpi.class);
The transformation problem is probably a similar issue; both Image I/O and
referencing use the same META-INF/services registration mechanism. Let see first
if the above make any difference in the Image I/O case...
Regards,
Martin
Le 11/01/11 16:35, Ramzi Oueslati a écrit :
> Hello list,
>
> I'm trying to make an applet display a geotiff coverage. I first tried
> to make the code run as a java application. So far so good. Then I
> changed the code to make it an applet.
> The applet runs fine through appletviewer but fails through the web
> browser. There are 2 errors: one is related to jpeg and the other is
> related to tiff. Here they are:
>
> # display tiff coverage #
>
> org.geotoolkit.coverage.io.CoverageStoreException: Can't read file "world.tiff".
> No suitable image reader for this input.
> at org.geotoolkit.coverage.io.ImageCoverageReader.setInput(ImageCoverageReader.java:398)
> at org.geotoolkit.coverage.io.GridCoverageReaders.createSimpleReader(GridCoverageReaders.java:136)
> at com.spotimage.sdi.applet.OOApplet$1.actionPerformed(OOApplet.java:69)
> at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
> at java.awt.Component.processMouseEvent(Unknown Source)
> at javax.swing.JComponent.processMouseEvent(Unknown Source)
> at java.awt.Component.processEvent(Unknown Source)
> at java.awt.Container.processEvent(Unknown Source)
> at java.awt.Component.dispatchEventImpl(Unknown Source)
> at java.awt.Container.dispatchEventImpl(Unknown Source)
> at java.awt.Component.dispatchEvent(Unknown Source)
> at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> at java.awt.Container.dispatchEventImpl(Unknown Source)
> at java.awt.Component.dispatchEvent(Unknown Source)
> at java.awt.EventQueue.dispatchEvent(Unknown Source)
> at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.run(Unknown Source)
> Caused by: org.geotoolkit.image.io.UnsupportedImageFormatException: No
> suitable image reader for this input.
> at org.geotoolkit.image.io.XImageIO.getReader(XImageIO.java:355)
> at org.geotoolkit.image.io.XImageIO.getReaderBySuffix(XImageIO.java:493)
> at org.geotoolkit.image.io.XImageIO.getReaderBySuffix(XImageIO.java:468)
> at org.geotoolkit.coverage.io.ImageCoverageReader.createImageReader(ImageCoverageReader.java:455)
> at org.geotoolkit.coverage.io.ImageCoverageReader.setInput(ImageCoverageReader.java:332)
> ... 26 more
>
> # display jpeg coverage #
>
> org.opengis.referencing.operation.TransformException: Can't transform envelope.
> at org.geotoolkit.referencing.CRS.transform(CRS.java:1456)
> at org.geotoolkit.display.primitive.AbstractReferencedGraphic2D.setEnvelope(AbstractReferencedGraphic2D.java:174)
> at org.geotoolkit.display2d.container.stateless.AbstractLayerJ2D.<init>(AbstractLayerJ2D.java:70)
> at org.geotoolkit.display2d.container.statefull.StatefullCoverageLayerJ2D.<init>(StatefullCoverageLayerJ2D.java:65)
> at org.geotoolkit.display2d.container.stateless.StatelessContextJ2D.parseLayer(StatelessContextJ2D.java:127)
> at org.geotoolkit.display2d.container.stateless.StatelessContextJ2D.layerChange(StatelessContextJ2D.java:200)
> at org.geotoolkit.map.ContextListener$Weak.layerChange(ContextListener.java:100)
> at org.geotoolkit.map.DefaultMapContext.fireLayerChange(DefaultMapContext.java:231)
> at org.geotoolkit.map.DefaultMapContext$AdapterList.add(DefaultMapContext.java:390)
> at org.geotoolkit.map.DefaultMapContext$AdapterList.add(DefaultMapContext.java:360)
> at java.util.AbstractList.add(Unknown Source)
> at com.spotimage.sdi.applet.OOApplet$1.actionPerformed(OOApplet.java:73)
> at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
> at java.awt.Component.processMouseEvent(Unknown Source)
> at javax.swing.JComponent.processMouseEvent(Unknown Source)
> at java.awt.Component.processEvent(Unknown Source)
> at java.awt.Container.processEvent(Unknown Source)
> at java.awt.Component.dispatchEventImpl(Unknown Source)
> at java.awt.Container.dispatchEventImpl(Unknown Source)
> at java.awt.Component.dispatchEvent(Unknown Source)
> at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> at java.awt.Container.dispatchEventImpl(Unknown Source)
> at java.awt.Component.dispatchEvent(Unknown Source)
> at java.awt.EventQueue.dispatchEvent(Unknown Source)
> at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.run(Unknown Source)
> Caused by: org.opengis.referencing.operation.OperationNotFoundException:
> No transformation available from system "ImageCRS[Grid]" to
> "GeographicCRS[WGS84(DD)]".
> at org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:339)
> at org.geotoolkit.referencing.CRS.transform(CRS.java:1454)
> ... 35 more
> Jan 11, 2011 4:26:47 PM org.geotoolkit.map.DefaultMapContext getBounds
> WARNING: Data source and map context coordinate system differ, yet it
> was not possible to get a projected bounds estimate...
> org.opengis.referencing.operation.TransformException: Can't transform envelope.
> at org.geotoolkit.referencing.CRS.transform(CRS.java:1456)
> at org.geotoolkit.map.DefaultMapContext.getBounds(DefaultMapContext.java:136)
> at com.spotimage.sdi.applet.OOApplet$1.actionPerformed(OOApplet.java:74)
> at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
> at java.awt.Component.processMouseEvent(Unknown Source)
> at javax.swing.JComponent.processMouseEvent(Unknown Source)
> at java.awt.Component.processEvent(Unknown Source)
> at java.awt.Container.processEvent(Unknown Source)
> at java.awt.Component.dispatchEventImpl(Unknown Source)
> at java.awt.Container.dispatchEventImpl(Unknown Source)
> at java.awt.Component.dispatchEvent(Unknown Source)
> at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> at java.awt.Container.dispatchEventImpl(Unknown Source)
> at java.awt.Component.dispatchEvent(Unknown Source)
> at java.awt.EventQueue.dispatchEvent(Unknown Source)
> at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.run(Unknown Source)
> Caused by: org.opengis.referencing.operation.OperationNotFoundException:
> No transformation available from system "ImageCRS[Grid]" to
> "GeographicCRS[WGS84(DD)]".
> at org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:339)
> at org.geotoolkit.referencing.CRS.transform(CRS.java:1454)
> ... 26 more
> Jan 11, 2011 4:26:47 PM org.geotoolkit.map.DefaultMapContext getBounds
> WARNING: Data source and map context coordinate system differ, yet it
> was not possible to get a projected bounds estimate...
> org.opengis.referencing.operation.TransformException: Can't transform envelope.
> at org.geotoolkit.referencing.CRS.transform(CRS.java:1456)
> at org.geotoolkit.map.DefaultMapContext.getBounds(DefaultMapContext.java:136)
> at com.spotimage.sdi.applet.OOApplet$1.actionPerformed(OOApplet.java:74)
> at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
> at java.awt.Component.processMouseEvent(Unknown Source)
> at javax.swing.JComponent.processMouseEvent(Unknown Source)
> at java.awt.Component.processEvent(Unknown Source)
> at java.awt.Container.processEvent(Unknown Source)
> at java.awt.Component.dispatchEventImpl(Unknown Source)
> at java.awt.Container.dispatchEventImpl(Unknown Source)
> at java.awt.Component.dispatchEvent(Unknown Source)
> at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> at java.awt.Container.dispatchEventImpl(Unknown Source)
> at java.awt.Component.dispatchEvent(Unknown Source)
> at java.awt.EventQueue.dispatchEvent(Unknown Source)
> at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.run(Unknown Source)
> Caused by: org.opengis.referencing.operation.OperationNotFoundException:
> No transformation available from system "ImageCRS[Grid]" to
> "GeographicCRS[WGS84(DD)]".
> at org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:339)
> at org.geotoolkit.referencing.CRS.transform(CRS.java:1454)
> ... 26 more
> org.opengis.referencing.operation.TransformException: Can't transform envelope.
> at org.geotoolkit.referencing.CRS.transform(CRS.java:1456)
> at org.geotoolkit.display.canvas.DefaultCanvasController2D.setVisibleArea(DefaultCanvasController2D.java:272)
> at org.geotoolkit.display2d.canvas.J2DCanvasVolatile$DelayedController.setVisibleArea(J2DCanvasVolatile.java:299)
> at com.spotimage.sdi.applet.OOApplet$1.actionPerformed(OOApplet.java:74)
> at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
> at java.awt.Component.processMouseEvent(Unknown Source)
> at javax.swing.JComponent.processMouseEvent(Unknown Source)
> at java.awt.Component.processEvent(Unknown Source)
> at java.awt.Container.processEvent(Unknown Source)
> at java.awt.Component.dispatchEventImpl(Unknown Source)
> at java.awt.Container.dispatchEventImpl(Unknown Source)
> at java.awt.Component.dispatchEvent(Unknown Source)
> at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> at java.awt.Container.dispatchEventImpl(Unknown Source)
> at java.awt.Component.dispatchEvent(Unknown Source)
> at java.awt.EventQueue.dispatchEvent(Unknown Source)
> at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> at java.awt.EventDispatchThread.run(Unknown Source)
> Caused by: org.opengis.referencing.operation.OperationNotFoundException:
> No transformation available from system "ImageCRS[Grid]" to
> "GeographicCRS[WGS84(DD)]".
> at org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:339)
> at org.geotoolkit.referencing.CRS.transform(CRS.java:1454)
> ... 27 more
>
>
> I understand that the first issue seems to be related to the
> imagereader and the second seems to be a transformation issue. But it
> works fine through the appletviewer which makes me think that it is
> probably a missing library issue. Could you please help me ?
>
> Basically the applet allows the user to select a file in the local
> file system (jpeg or tiff). Then it shows the coverage image.
> The applet's jar is signed in order to run outside the security
> sandbox to allow local file system access. I checked that every
> required jar (geotk + extra) is provided with the applet. Every
> dependent jar had to be signed as well. Please let me know if you want
> me to provide the code.
>
> Kind regards,
> Ramzi
More information about the Geotoolkit
mailing list