public Number lookup(double x, double y) {
LOGGER.info("Looking up x={} y={}", x, y);
DirectPosition p = new DirectPosition2D(c4326, x, y);
- List<Path> tifFile = (List<Path>) index.query(new Envelope(new Coordinate(x, y)));
- if (!tifFile.isEmpty()) {
- TiffInterface tifInterface = openTifInterface(tifFile.get(0));
- try {
- return tifInterface.lookup(p);
- } finally {
- tifInterface.close();
+ List<Path> tifFiles = (List<Path>) index.query(new Envelope(new Coordinate(x, y)));
+ for (Path tifFile : tifFiles) {
+ TiffInterface tifInterface = openTifInterface(tifFile);
+ if (tifInterface.contains(p)) {
+ try {
+ return tifInterface.lookup(p);
+ } finally {
+ tifInterface.close();
+ }
+ } else {
+ System.out.println("not found");
}
- } else {
- return new Double(0); // use 0 by default for now
}
+ return new Double(0); // use 0 by default for now
}
}
\ No newline at end of file