Ciao Gabriella,
I tried to reproduce the erroneous behaviour you are experiencing with
no luck, everything seems to work. I have to point out that I am not
using 2.3.M0 but the source of what is about the become 2.3-RC1.
Here is the code I am using:
//
/////////////////////////////////////////////////////////////////
//
// CREATING A GRID COVERAGE
//
//
// /////////////////////////////////////////////////////////////////
final RenderedImage image = ImageIO.read(TestData.getResource(this,
FILENAME));
final GeneralEnvelope myEnvelope = new GeneralEnvelope(
new Rectangle2D.Double(35, -41, 45, 46));
GridCoverageFactory factory = FactoryFinder
.getGridCoverageFactory(null);
GridCoverage2D gc = factory.create("Map", image, myEnvelope);
// /////////////////////////////////////////////////////////////////
//
// MAP CONTEXT
//
//
// /////////////////////////////////////////////////////////////////
final MapContext context = new DefaultMapContext(
DefaultGeographicCRS.WGS84);
StyleBuilder sb = new StyleBuilder();
RasterSymbolizer rs = sb.createRasterSymbolizer();
final Style style = sb.createStyle(rs);
context.addLayer(gc, style);
// /////////////////////////////////////////////////////////////////
//
// Streaming renderer
//
//
// ///////////////////////////////////////////////////////////////
final StreamingRenderer renderer = new StreamingRenderer();
renderer.setContext(context);
RendererBaseTest.showRender("testGridCoverage", renderer, 1000, context
.getLayerBounds());
This code works fine for me.
Now, I understand you are trying to visualize some georeferenced image
(image+world file). Here you have a couple of suggestions.
1>Always use an appropriate prj file otherwise the plugin for world
images will send a warning to the output and use WGS84 geographic.
2>Use the code that I am providing here below:
// /////////////////////////////////////////////////////////////////
//
// CREATING A GRID COVERAGE
//
//
// /////////////////////////////////////////////////////////////////
WorldImageReader wr = new WorldImageReader(TestData
.file(this, FILENAME));
// /////////////////////////////////////////////////////////////////
//
// MAP CONTEXT
//
//
// /////////////////////////////////////////////////////////////////
final MapContext context = new DefaultMapContext(
DefaultGeographicCRS.WGS84);
StyleBuilder sb = new StyleBuilder();
RasterSymbolizer rs = sb.createRasterSymbolizer();
final Style style = sb.createStyle(rs);
context.addLayer(wr, style);
// /////////////////////////////////////////////////////////////////
//
// Streaming renderer
//
//
// ///////////////////////////////////////////////////////////////
final StreamingRenderer renderer = new StreamingRenderer();
renderer.setContext(context);
The good news about 2.3.x is that you can pass directly a reader to
the renderer so that the the best fitting image will be chose in order
to increase speed and reduce memory usage.
3>Always tell the MapContext which CRS to use.
Try the suggestions I gave you and if you still have problems, please,
send me privately an isolate test case (code+sample coverage) and I
will do my best to solve this issue.
Regards,
Simone.
On 11/13/06, Gabriella Turek <[EMAIL PROTECTED]> wrote:
> I think I found the source of the null point exception:
>
> Nov 13, 2006 2:19:49 PM StreamingRenderer processStylers
> SEVERE: null
> java.lang.NullPointerException
> at com.vividsolutions.jts.geom.Envelope.init(Envelope.java:254)
> at com.vividsolutions.jts.geom.Envelope.<init>(Envelope.java:186)
> at
> org.geotools.geometry.jts.ReferencedEnvelope.<init>(ReferencedEnvelope.ja
> va:112)
> at
> org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.<init>(Gri
> dCoverageRenderer.java:158)
> at StreamingRenderer.renderRaster(StreamingRenderer.java:1731)
> at StreamingRenderer.processSymbolizers(StreamingRenderer.java:1590)
> at StreamingRenderer.process(StreamingRenderer.java:1534)
> at StreamingRenderer.processStylers(StreamingRenderer.java:1476)
> at StreamingRenderer.paint(StreamingRenderer.java:542)
> at StreamingRenderer.paint(StreamingRenderer.java:406)
>
>
>
> that's been driving me crazy (and others it seems) when trying to plot
> georeferenced files with geo tools 2.3, when it workd perfectly fine 2.2
>
> Apparently mapExtent is never passed along so that on line 1715 when
> GridCoverageRenderer is instatiated the mapExtent is null.
> I will try to see how I can fix this, as I *really* would like to use
> 2.3 over 2.2.
> gaby
> --
> ***************************************************************
> ** Gabriella Turek [EMAIL PROTECTED] **
> ** National Institute of Water & Atmospheric Research (NIWA) **
> ** PO Box 8602 Christchurch New Zealand +64-3-348-8987x3724 **
> ***************************************************************
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions
http://www.geo-solutions.it
-------------------------------------------------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users