/**
  * Finds the closest image available for a given time and datasource
  *
  * @return JSON meta information for matching image
  *
  * TODO: Combine with getJP2Image? (e.g. "&display=true")
  */
 public function getClosestImage()
 {
     include_once HV_ROOT_DIR . '/../src/Database/ImgIndex.php';
     $imgIndex = new Database_ImgIndex();
     $image = $imgIndex->getDataFromDatabase($this->_params['date'], $this->_params['sourceId']);
     // Read JPEG 2000 header
     $file = HV_JP2_DIR . $image['filepath'] . '/' . $image['filename'];
     $xmlBox = $imgIndex->extractJP2MetaInfo($file);
     // Prepare cache for tiles
     $this->_createTileCacheDir($image['filepath']);
     // Return date and id
     $response = array_merge(array('id' => $image['id'], 'date' => $image['date']), $xmlBox);
     // Print result
     $this->_printJSON(json_encode($response));
 }