1 package org.simantics.maps.elevation.server;
3 import java.io.IOException;
4 import java.nio.file.Files;
5 import java.nio.file.Path;
6 import java.nio.file.Paths;
8 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory;
11 public class SingletonTiffTileInterface {
13 private static final Logger LOGGER = LoggerFactory.getLogger(SingletonTiffTileInterface.class);
15 private static final String TIFS_FOLDER = System.getProperty("tifsFolder");
17 private static SingletonTiffTileInterface instance = new SingletonTiffTileInterface();
19 private TiffTileInterface tileInterface;
21 private SingletonTiffTileInterface() {
23 Activator.registerSpis();
24 Path tilesFolder = Paths.get("tifsFolder");
25 if (TIFS_FOLDER != null) {
26 Path potTilesFolder = Paths.get(TIFS_FOLDER);
27 if (!Files.exists(potTilesFolder)) {
28 // use default from working directory
29 tilesFolder = potTilesFolder;
33 Files.createDirectories(tilesFolder);
34 } catch (IOException e) {
35 LOGGER.error("Could not create directories {}", tilesFolder.toAbsolutePath(), e);
37 tileInterface = new TiffTileInterface(tilesFolder);
40 public static Number lookup(double x, double y) {
41 return instance.tileInterface.lookup(x, y);