Modify

Opened 2 years ago

Last modified 16 months ago

#12108 new defect

It is not possible to open GeoTiff image

Reported by: kendzi Owned by: team
Priority: major Milestone:
Component: Plugin importimage Version:
Keywords: template_report geotiff geotools Cc:

Description (last modified by Don-vip)

What steps will reproduce the problem?

  1. Install Import Image plugin
  2. Open GeoTiff image with elevation from ASTER

What is the expected result?

Image is opened.

What happens instead?

Console show an error. It looks that it is internal error of geotools. The class MaskOverviewProvider$SpiHelper is intentionally converting path into URL and past it to
FileImageInputStreamSpi.createInputStreamInstance
But java 7 is expecting file there:

        if (input instanceof File) {
            try {
                return new FileImageInputStream((File)input);
            } catch (Exception e) {
                return null;
            }
        } else {
            throw new IllegalArgumentException();
        }

Console stacktrace:

Nov 16, 2015 7:53:37 PM org.geotools.coverage.grid.io.imageio.MaskOverviewProvider$SpiHelper <init>
WARNING: Unable to create a Reader for File: /home/kendzi/Desktop/wycieczka piatek/new.tiff
java.lang.IllegalArgumentException
	at com.sun.imageio.spi.FileImageInputStreamSpi.createInputStreamInstance(FileImageInputStreamSpi.java:60)
	at org.geotools.coverage.grid.io.imageio.MaskOverviewProvider$SpiHelper.<init>(MaskOverviewProvider.java:720)
	at org.geotools.coverage.grid.io.imageio.MaskOverviewProvider.<init>(MaskOverviewProvider.java:106)
	at org.geotools.coverage.grid.io.imageio.MaskOverviewProvider.<init>(MaskOverviewProvider.java:101)
	at org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:357)
	at org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:249)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.PluginOperations.readGeoTiff(PluginOperations.java:349)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.PluginOperations.createGridFromFile(PluginOperations.java:120)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.ImageLayer.createImage(ImageLayer.java:92)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.ImageLayer.<init>(ImageLayer.java:76)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.LoadImageAction.actionPerformed(LoadImageAction.java:47)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
	at java.awt.Component.processMouseEvent(Component.java:6505)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
	at java.awt.Component.processEvent(Component.java:6270)
	at java.awt.Container.processEvent(Container.java:2229)
	at java.awt.Component.dispatchEventImpl(Component.java:4861)
	at java.awt.Container.dispatchEventImpl(Container.java:2287)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
	at java.awt.Container.dispatchEventImpl(Container.java:2273)
	at java.awt.Window.dispatchEventImpl(Window.java:2719)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:694)
	at java.awt.EventQueue$3.run(EventQueue.java:692)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:708)
	at java.awt.EventQueue$4.run(EventQueue.java:706)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

org.geotools.data.DataSourceException: java.lang.IllegalArgumentException
	at org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:262)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.PluginOperations.readGeoTiff(PluginOperations.java:349)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.PluginOperations.createGridFromFile(PluginOperations.java:120)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.ImageLayer.createImage(ImageLayer.java:92)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.ImageLayer.<init>(ImageLayer.java:76)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.LoadImageAction.actionPerformed(LoadImageAction.java:47)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
	at java.awt.Component.processMouseEvent(Component.java:6505)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
	at java.awt.Component.processEvent(Component.java:6270)
	at java.awt.Container.processEvent(Container.java:2229)
	at java.awt.Component.dispatchEventImpl(Component.java:4861)
	at java.awt.Container.dispatchEventImpl(Container.java:2287)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
	at java.awt.Container.dispatchEventImpl(Container.java:2273)
	at java.awt.Window.dispatchEventImpl(Window.java:2719)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:694)
	at java.awt.EventQueue$3.run(EventQueue.java:692)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:708)
	at java.awt.EventQueue$4.run(EventQueue.java:706)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: org.geotools.data.DataSourceException: java.lang.IllegalArgumentException
	at org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:487)
	at org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:249)
	... 44 more
Caused by: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException
	at org.geotools.coverage.grid.io.imageio.MaskOverviewProvider$SpiHelper.<init>(MaskOverviewProvider.java:729)
	at org.geotools.coverage.grid.io.imageio.MaskOverviewProvider.<init>(MaskOverviewProvider.java:106)
	at org.geotools.coverage.grid.io.imageio.MaskOverviewProvider.<init>(MaskOverviewProvider.java:101)
	at org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:357)
	... 45 more
Caused by: java.lang.IllegalArgumentException
	at com.sun.imageio.spi.FileImageInputStreamSpi.createInputStreamInstance(FileImageInputStreamSpi.java:60)
	at org.geotools.coverage.grid.io.imageio.MaskOverviewProvider$SpiHelper.<init>(MaskOverviewProvider.java:720)
	... 48 more

Please provide any additional information below. Attach a screenshot if possible.

Build-Date: 2015-11-16 19:50:45
Revision: 9013
Is-Local-Build: true

Identification: JOSM/1.5 (9013 SVN en) Linux Ubuntu 15.10
Memory Usage: 982 MB / 5376 MB (677 MB allocated, but free)
Java version: 1.7.0_51, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
VM arguments: [-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:37775, -Djosm.home=/home/kendzi/josm_dev/, -Dsun.java2d.noddraw=true, -D_jogl.debug.GraphicsConfiguration=true, -Dkendzi3d.opengl.sampleBuffers=true, -Dkendzi3d.opengl.zbuffer=16, -Djogl.debug=false, -Dfile.encoding=UTF-8]
Program arguments: [--language=en, /home/kendzi/josm_dev/test.osm]
Dataset consistency test: No problems found

Plugins:
- ImportImagePlugin (31746)
- ShowInGoogleMaps (7)
- geotools (31744)
- jts (31603)
- kendzi3d-jogl (41)
- kendzi3d-resources (0.0.1)
- log4j (31603)

Attachments (1)

ASTGTM2.zip (2.3 MB) - added by kendzi 2 years ago.
Example file

Change History (8)

Changed 2 years ago by kendzi

Attachment: ASTGTM2.zip added

Example file

comment:1 Changed 2 years ago by kendzi

When I'm running it locally the method MaskOverviewProvider.getInputStreamSPIFromURL(...) is returning
URLImageInputStreamSpi from imageio-ext-streams-1.1.12-sources.jar, but when I'm debbuging JOSM I get differnt class there InputStreamImageInputStreamSpi from JDK.

The class is chosen here:

ImageIOExt l: 221:

 iter = IIORegistry.getDefaultInstance().getServiceProviders(ImageInputStreamSpi.class,
                    true);

getDefaultInstance() take context from current thread and as it was called from menu (thread AWT-EventQueue) don't have context filled with that external providers. I have checked when GeoToolsPlugin is starting, and there everythink is fine (as thread is different).

So in short in AWT thread the IIORegistry is not initiated and URLImageInputStreamSpi provider is missing there...

Honestly I don't have idea how to fix that :/

Last edited 2 years ago by kendzi (previous) (diff)

comment:2 Changed 2 years ago by Don-vip

Description: modified (diff)
Keywords: geotiff geotools added

comment:3 Changed 2 years ago by Don-vip

I don't face this error. I have tried to launch JOSM both from Eclipse and with java -jar josm-latest.jar and the file is opened:

Build-Date:2015-11-21 12:10:23
Revision:9042
Is-Local-Build:true

Identification: JOSM/1.5 (9042 SVN en) Windows 7 64-Bit
Memory Usage: 724 MB / 2708 MB (367 MB allocated, but free)
Java version: 1.8.0_66, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
VM arguments: [-Dfile.encoding=UTF-8]

Plugins:
- ImportImagePlugin (31772)
- apache-commons (31772)
- ejml (31772)
- geotools (31774)
- imagery-xml-bounds (31772)
- jts (31772)
- log4j (31772)
- opendata (31772)
- utilsplugin2 (31772)

However the image is not displayed correctly, there is another error:

java.lang.ArrayIndexOutOfBoundsException: -1
	at java.awt.image.ComponentColorModel.getRGBComponent(ComponentColorModel.java:903)
	at java.awt.image.ComponentColorModel.getRed(ComponentColorModel.java:944)
	at java.awt.image.ComponentColorModel.getRGB(ComponentColorModel.java:1135)
	at sun.java2d.loops.OpaqueCopyAnyToArgb.Blit(CustomComponent.java:145)
	at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:560)
	at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:541)
	at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:189)
	at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Blit.java:204)
	at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:959)
	at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:577)
	at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:86)
	at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1030)
	at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:196)
	at sun.java2d.SunGraphics2D.copyImage(SunGraphics2D.java:3229)
	at sun.java2d.pipe.DrawImage.makeBufferedImage(DrawImage.java:357)
	at sun.java2d.pipe.DrawImage.renderImageXform(DrawImage.java:462)
	at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:264)
	at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:76)
	at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1014)
	at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:186)
	at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3318)
	at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3296)
	at org.openstreetmap.josm.plugins.ImportImagePlugin.ImageLayer.paint(ImageLayer.java:209)
	at org.openstreetmap.josm.gui.MapView.paintLayer(MapView.java:637)
	at org.openstreetmap.josm.gui.MapView.paint(MapView.java:721)

comment:4 Changed 2 years ago by kendzi

I try to use GeoTool directly to load some GeoTiff files and I get exactly the same problem with index. The difference between that file and regular tiff files is that they contain some "special" values. E.g. in case of aster value "-1" mean no height data. In some other GeoTiff files I had download there was some different "special" values. I seems GeoTools completely ignore that fact, and treats that files as regular RGB Tiffs. This mean it try to convert value into RGB (range 0-255 per color).

About my problem I suspect that is connected with linux. I will try at week to setup virtual machine with ubutnu and check if it is possible to reproduce my problem on clean setup.

comment:5 Changed 2 years ago by anonymous

After some of yours last changes the first problem has been fixed. Now I get ArrayIndexOutOfBoundsException too. So good job :)

To solve ArrayIndexOutOfBoundsException plugin has to manage colors pallet. Do you have any plans to do that?

comment:6 in reply to:  5 Changed 2 years ago by Don-vip

Replying to anonymous:

Do you have any plans to do that?

I'd like to but I have no idea how to do it. Any lead?

comment:7 Changed 16 months ago by cmppri@…

What about manually registering a URL SPI?

IIORegistry.getDefaultInstance().registerServiceProvider(new URLImageInputStreamSpi());

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set.
to The owner will be changed from team to the specified user.
The owner will change to kendzi
as duplicate The resolution will be set to duplicate.The specified ticket will be cross-referenced with this ticket
The owner will be changed from team to anonymous.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.