Dear all,
I hope you are all doing fine. This is my first posting and I'm not that 
familiar with GIS in general so please, be indulgent ;).
I have been using Geotools library for the past month, looking through the 
userguide, this mailing list and some other websites but I have reached a dead 
end. I'm using Geotools 13.0 with Maven through Eclipse and GDAL/OGR 1.11.1
My issue : I can't manage to display a NITF file as a layer of my mapcontent.
I have added the gt-imageio-ext-gdal jar to my pom.xml and succeeded in 
displaying the gridcoverage. Here's my source code:
File file = JFileDataStoreChooser.showOpenFile("", null);GridCoverage2DReader 
reader = new NITFReader(file);AbstractGridFormat format = 
GridFormatFinder.findFormat( file );GridCoverage2DReader reader = 
format.getReader(file);GridCoverage2D gc = (GridCoverage2D) 
reader.read(null);gc.show();
(This code is working and it displays the NITF file in a default viewer, so it 
means that my gdal importation should be fine. Besides, I get "GDAL Native 
Library loaded (version: 1.11.1)" in the stack trace)
However, when I try to build a layer and add it too a mapContent as it is 
explained in the imageLab, I get either nothing, or a nullPointerException 
depending of the way of building the layer. Here is my source code:
File file = JFileDataStoreChooser.showOpenFile("", null);AbstractGridFormat 
format = GridFormatFinder.findFormat( file );        GridCoverage2DReader 
reader = format.getReader(file);GridCoverage2D gc = (GridCoverage2D) 
reader.read(null);
//creating a default raster styleStyleBuilder sb = new 
StyleBuilder();RasterSymbolizer raster = sb.createRasterSymbolizer();Style 
rasterStyle = sb.createStyle(raster);
final MapContent map = new MapContent();Layer rasterLayer = new 
GridReaderLayer(reader, 
rasterStyle);map.addLayer(rasterLayer);JMapFrame.showMap(map);
With this code, my JMapFrame is displayed but remains blank. I have checked the 
corners coordinates with gdalinfo to be sure to get the right envelope. I 
didn't get any error in the stack trace and the NITF file has everything( CRS, 
Color table (Gray))
Another method was to create the layer through this way : Layer rasterLayer = 
new GridCoverageLayer(gc, rasterStyle);In this case, I get this error:
avr. 20, 2015 10:27:55 PM it.geosolutions.imageio.gdalframework.GDALUtilities 
loadGDALINFOS: GDAL Native Library loaded (version: 
1.11.1)2015-04-20T22:27:57.803+0200  WARNING  
nulljava.lang.NullPointerException      at 
org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.renderImage(GridCoverageRenderer.java:386)
    at 
org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:962)
  at 
org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:924)
  at 
org.geotools.renderer.lite.StreamingRenderer$RenderRasterRequest.execute(StreamingRenderer.java:3485)
        at 
org.geotools.renderer.lite.StreamingRenderer$PainterThread.run(StreamingRenderer.java:3654)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)    
  at java.util.concurrent.FutureTask.run(FutureTask.java:262)     at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
     at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
     at java.lang.Thread.run(Thread.java:745)
2015-04-20T22:27:57.803+0200  SEVERE  nulljava.lang.NullPointerException        
at 
org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.renderImage(GridCoverageRenderer.java:386)
    at 
org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:962)
  at 
org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:924)
  at 
org.geotools.renderer.lite.StreamingRenderer$RenderRasterRequest.execute(StreamingRenderer.java:3485)
        at 
org.geotools.renderer.lite.StreamingRenderer$PainterThread.run(StreamingRenderer.java:3654)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)    
  at java.util.concurrent.FutureTask.run(FutureTask.java:262)     at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
     at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
     at java.lang.Thread.run(Thread.java:745)
This method lead me to think that the layer building wasn't right. I though 
that it could come from the style and I have tried it with the styles presented 
in the tutorial : createGreyScale and createRGBStyle but nothing changed.
I tried another way of displaying it by saving the map in a jpeg file as it is 
shown here : http://docs.codehaus.org/display/GEOTDOC/01+GTRenderer (it worked 
with a geotiff file but not with my NITF file)
I would be so grateful if you could help me to figure out this problem. The 
NITF sample can be found here : 
http://www.gwg.nga.mil/ntb/baseline/software/testfile/Nitfv2_1/scen_2_1.html   
(it is the i_3001a.ntf file)
I would like to keep the layer-adding pattern to display it because it would 
allow me to draw features layer on it.
Guillaume
                                          
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to