Hi Simone, Mike, wasn't aware of that weekness in the plugin. Please open a JIra and assign it to me. I am working abroad this week, so I probably won't be able to fix it right now. It will be the first thing when I am back.
Andrea On Mon, Aug 1, 2011 at 10:44 PM, Simone Giannecchini <[email protected]> wrote: > Dear Mike, > easy fix is to remove the grass binay raster plugin from your path. > > I would also ask you to open a Jira since this seems like a bad > behavior from the above mentioned plugin. Checking the code it looks > like that the accept method of the GrassCoverageFormat is too week > and accepts things, like a geotiff while it should not therefore > returning a wrong reader for the provided source, see below: > > public boolean accepts( final Object o, Hints hints ) { > File fileToUse; > > if (o instanceof File) { > fileToUse = (File) o; > } else if (o instanceof URL) { > fileToUse = DataUtilities.urlToFile((URL) o); > } else if (o instanceof String) { > fileToUse = new File((String) o); > } else { > return false; > } > if (!fileToUse.exists()) { > return false; > } > return true; > } > > Noticed that GridFormatFinder.findFormat( rasterFile ) relies exactly > on that call. > > Regards, > Simone Giannecchini > ------------------------------------------------------- > Ing. Simone Giannecchini > GeoSolutions S.A.S. > Founder > > Via Poggio alle Viti 1187 > 55054 Massarosa (LU) > Italy > > phone: +39 0584 962313 > fax: +39 0584 962313 > mob: +39 333 8128928 > > http://www.geo-solutions.it > http://geo-solutions.blogspot.com/ > http://www.youtube.com/user/GeoSolutionsIT > http://www.linkedin.com/in/simonegiannecchini > http://twitter.com/simogeo > > ------------------------------------------------------- > > > > On Mon, Aug 1, 2011 at 10:13 PM, Mike O'Toole <[email protected]> wrote: >> Hi All, >> >> I've been working on updating my code to use 2.8. When creating a >> GridCoverage2D the file path to my tif seems to get corrupted. The >> "sample_data" part of the path turns into "cellhd". Below is the code and >> error. You can see I output the filename. >> >> Thanks for your help with this. >> >> Mike O'Toole >> >> Code: >> >> GridCoverage2D grid = null; >> >> System.out.println("rasterFile: " + rasterFile); >> AbstractGridFormat format = GridFormatFinder.findFormat( rasterFile ); >> reader = format.getReader(rasterFile); >> >> grid = reader.read(null); // RasterImportExtension.java:158 >> >> Output and error. >> >> rasterFile: >> /home/mike/workspace/RM_GT_AgriD_Extensions/sample_data/elevation-ned10m46118b2.tif >> java.io.IOException: >> /home/mike/workspace/RM_GT_AgriD_Extensions/cellhd/elevation-ned10m46118b2.tif >> (No such file or directory) >> at >> org.geotools.gce.grassraster.core.GrassBinaryRasterReadHandler.parseHeaderAndAccessoryFiles(GrassBinaryRasterReadHandler.java:669) >> at >> org.geotools.gce.grassraster.GrassBinaryImageReader.ensureOpen(GrassBinaryImageReader.java:176) >> at >> org.geotools.gce.grassraster.GrassBinaryImageReader.getImageMetadata(GrassBinaryImageReader.java:224) >> at >> org.geotools.gce.grassraster.GrassCoverageReader.readRaster(GrassCoverageReader.java:196) >> at >> org.geotools.gce.grassraster.GrassCoverageReader.read(GrassCoverageReader.java:748) >> at >> edu.agrid.reader.raster.RasterImportExtension.work(RasterImportExtension.java:158) >> ------------------------------------------------------------------------------ >> BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA >> The must-attend event for mobile developers. Connect with experts. >> Get tools for creating Super Apps. See the latest technologies. >> Sessions, hands-on labs, demos & much more. Register early & save! >> http://p.sf.net/sfu/rim-blackberry-1 >> _______________________________________________ >> Geotools-gt2-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> > ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1 _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
