]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffTileInterface.java
Add SCL interface for District Elevation server
[simantics/district.git] / org.simantics.maps.elevation.server / src / org / simantics / maps / elevation / server / TiffTileInterface.java
index d6f1910e7057efce2c19b6f64e77d64de0c4df2b..b85f234c72d935ef4121877e8d9cc299d73b3fed 100644 (file)
@@ -121,16 +121,19 @@ public class TiffTileInterface {
     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