Displaying a GridCoverage2D in JMapPane causes an error

Description

Reported by Mike O'Toole on the user list. Code such as this:

MapContext map = new MapContext();
map.addLayer( myGridCoverage, myStyle );
JMapFrame.showMap(map);

...will provoke the following error:

Error:
2011-04-28 16:09:54 SEVERE: org.geotools.feature.simple.SimpleFeatureImpl cannot be cast to org.geotools.coverage.grid.GridCoverage2D (StreamingRenderer.fireErrorEvent())
java.lang.ClassCastException: org.geotools.feature.simple.SimpleFeatureImpl cannot be cast to org.geotools.coverage.grid.GridCoverage2D
org.geotools.renderer.lite.StreamingRenderer.processSymbolizers(StreamingRenderer.java:2219)
org.geotools.renderer.lite.StreamingRenderer.process(StreamingRenderer.java:2158)
org.geotools.renderer.lite.StreamingRenderer.drawPlain(StreamingRenderer.java:2014)
org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1934)
org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:766)
org.geotools.swing.RenderingExecutor$Task.call(RenderingExecutor.java:149)
org.geotools.swing.RenderingExecutor$Task.call(RenderingExecutor.java:105)
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
java.util.concurrent.FutureTask.run(FutureTask.java:166)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
java.lang.Thread.run(Thread.java:636)

Environment

None

Activity

Show:
codehaus
April 10, 2015, 3:16 PM

CodeHaus Comment From: mbedward - Time: Mon, 2 May 2011 02:02:58 -0500
---------------------
The attached file DisplayGridCoverage.java demonstrates the problem that Mike reported. Also attached is a one line patch against trunk which I think fixes the problem.

codehaus
April 10, 2015, 3:16 PM

CodeHaus Comment From: mbedward - Time: Mon, 2 May 2011 02:10:48 -0500
---------------------
problem with last patch - new copy attached

codehaus
April 10, 2015, 3:16 PM

CodeHaus Comment From: aaime - Time: Mon, 2 May 2011 03:40:24 -0500
---------------------
Yep, the patch makes sense. The DisplayGridCoverage could be turned into a unit test, just make sure it does not bomb out? (and prevent future regressions on this topic)

If you have time to do that just go ahead and commit once done.

codehaus
April 10, 2015, 3:16 PM

CodeHaus Comment From: mbedward - Time: Mon, 2 May 2011 05:39:10 -0500
---------------------
Test class is ready. I'll commit when subversion is working again.

codehaus
April 10, 2015, 3:16 PM

CodeHaus Comment From: mbedward - Time: Mon, 2 May 2011 21:22:42 -0500
---------------------
Fix and unit test committed to trunk (r37051) and 2.7.x branch (r37052)

Fixed

Assignee

Unassigned

Reporter

codehaus

Triage

None

Fix versions

Affects versions

Priority

Medium
Configure