From: andrea a. <and...@gm...> - 2015-11-10 10:06:07
|
Hi Piero, in your code you seem to try to force a vector layer through a raster layer. i am not sure from the snippet you posted. There is an example application in which the SWT part has been put in action. Please read this part, it should have everything you need: http://docs.geotools.org/latest/userguide/unsupported/swt/rcp.html Hope that helps, Andrea On Tue, Nov 10, 2015 at 10:56 AM, Piero Campalani <pie...@gm...> wrote: > Dear list, > > > I’m having troubles adding a GridCoverage2D layer to a SwtMapPane. The goal > is to avoid the creation of a GeoTiff to display the GridCoverage2D, which > drastically reduces the application performance. > > > Geotools offers the possibility of adding a GridCoverage or a GridCoverage2D > as a layer directly to the SwtMapPane, nevertheless, I always get the > following error: > > > > GRAVE: org.geotools.feature.simple.SimpleFeatureImpl cannot be cast to > org.geotools.coverage.grid.GridCoverage2D > > java.lang.ClassCastException: org.geotools.feature.simple.SimpleFeatureImpl > cannot be cast to org.geotools.coverage.grid.GridCoverage2D > > at > org.geotools.renderer.lite.StreamingRenderer.processSymbolizers(StreamingRenderer.java:2446) > > at > org.geotools.renderer.lite.StreamingRenderer.process(StreamingRenderer.java:2385) > > at > org.geotools.renderer.lite.StreamingRenderer.drawPlain(StreamingRenderer.java:2241) > > at > org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1940) > > at > org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:773) > > at org.geotools.swt.SwtMapPane.handleEvent(SwtMapPane.java:1120) > > at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) > > at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353) > > at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061) > > at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085) > > at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070) > > at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1491) > > at org.eclipse.swt.widgets.Control.windowProc(Control.java:4667) > > at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339) > > at org.eclipse.swt.widgets.Display.windowProc(Display.java:5023) > > at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) > > at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549) > > at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759) > > at > org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151) > > at > org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:331) > > at > org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032) > > at > org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148) > > at > org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:164) > > at > org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) > > at > org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) > > at > org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) > > at > org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380) > > at > org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) > > at java.lang.reflect.Method.invoke(Unknown Source) > > at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648) > > at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603) > > at org.eclipse.equinox.launcher.Main.run(Main.java:1465) > > at org.eclipse.equinox.launcher.Main.main(Main.java:1438) > > > > Here’s the code I’ve used: > > > > final final GridCoverage2D gridCoverage = gcf.create("GridCoverage", > baseImage, mapPane.getDisplayArea()); > > final GridCoverage2D geoGridCoverage = > gridCoverage.view(ViewType.GEOPHYSICS); > > > > Display.getDefault().syncExec(new Runnable() { > > @Override > > public void run() { > > mapPane.getMapContext().addLayer(geoGridCoverage, > style); > > gridCoverage.dispose(true); > > geoGridCoverage.dispose(true); > > } > > }); > > Any advice on the "best practices" for such use-case? > > > In case you want to understand the question's context: I am developing a TMS > client to overlay tiles on a SwtMapPane as they are received from the remote > server. > > > Thanks in advance for any helping hand :) > > > -Piero > > > ------------------------------------------------------------------------------ > > _______________________________________________ > GeoTools-GT2-Users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > |