History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GEOT-670
Type: Improvement Improvement
Status: In Progress In Progress
Priority: Major Major
Assignee: Simone Giannecchini
Reporter: Alessio Fabiani
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
GeoTools

Let the GeoTIFFFormat accept input from URLs

Created: 22/Aug/05 07:47 AM   Updated: 22/Oct/07 08:19 AM
Component/s: gc geotiff
Affects Version/s: 2.2.M0, 2.4.0, 2.5-M1, 2.3.5, 2.5.0
Fix Version/s: None


 Description  « Hide
With a simple modification we can pass to 'org.geotools.gce.geotiff.GeoTiffFormat' even URLs as sources.
We can change the method 'public GridCoverageReader getReader(Object source)' as follow:

...
import java.net.URL;
import java.net.URLDecoder;
...

public GridCoverageReader getReader(Object source) {
if (source instanceof CatalogEntry) { source = ((CatalogEntry) source).resource(); }

GridCoverageReader reader = null;

if (accepts(source)) {
if (source instanceof URL) {
URL url = (URL) source;

try { final String pathname = URLDecoder.decode(url.getFile(),"UTF-8"); reader = new GeoTiffReader(this, new File(pathname), null); } catch (Exception e) { reader = null; }
} else { reader = new GeoTiffReader(this, source, null); }
}

return reader;
}

And the method 'public boolean accepts(Object o)' as follow:

public boolean accepts(Object o) {
boolean goodfile = false;

if (o instanceof CatalogEntry) { o = ((CatalogEntry) o).resource(); }

goodfile = o instanceof File;

if (goodfile) { goodfile = GeoTiffReader.isGeoTiffFile((File) o); } else if (o instanceof URL) {
URL url = (URL) o;

try { final String pathname = URLDecoder.decode(url.getFile(),"UTF-8"); goodfile = GeoTiffReader.isGeoTiffFile(new File(pathname)); } catch (Exception e) { goodfile = false; }
}

return goodfile;
}



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Simone Giannecchini - 17/Dec/06 10:02 AM
The issue is fixed on 2.3.x, next week I will port to trunk.