1 package org.simantics.maps.elevation.server;
3 import java.awt.geom.Rectangle2D;
4 import java.io.IOException;
5 import java.nio.file.Files;
6 import java.nio.file.Path;
7 import java.nio.file.Paths;
8 import java.util.Collection;
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
13 public class SingletonTiffTileInterface {
15 private static final Logger LOGGER = LoggerFactory.getLogger(SingletonTiffTileInterface.class);
17 private static final String TIFS_FOLDER = System.getProperty("tifsFolder");
19 private static SingletonTiffTileInterface instance = new SingletonTiffTileInterface();
21 private TiffTileInterface tileInterface;
23 private SingletonTiffTileInterface() {
25 Activator.registerSpis();
26 Path tilesFolder = Paths.get("tifsFolder");
27 if (TIFS_FOLDER != null) {
28 Path potTilesFolder = Paths.get(TIFS_FOLDER);
29 if (!Files.exists(potTilesFolder)) {
30 // use default from working directory
31 tilesFolder = potTilesFolder;
35 Files.createDirectories(tilesFolder);
36 } catch (IOException e) {
37 LOGGER.error("Could not create directories {}", tilesFolder.toAbsolutePath(), e);
39 tileInterface = new TiffTileInterface(tilesFolder);
42 public static Number lookup(double x, double y) {
43 return instance.tileInterface.lookup(x, y);
46 public static Collection<Rectangle2D> getBoundingBoxes() {
47 return instance.tileInterface.getBoundingBoxes();