From d6d751d748f83d027d273f3c02c8a371f0a06ce5 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 20 Aug 2015 08:56:26 +0200 Subject: o Fixing orientation code. --- pictures/index.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/pictures/index.php b/pictures/index.php index 0bee830..7865a53 100644 --- a/pictures/index.php +++ b/pictures/index.php @@ -32,10 +32,16 @@ try { throw new InvalidArgumentException("Invalid file name: $filename"); } - if (false && is_readable($cacheFile)) { + if (is_readable($cacheFile)) { $s = file_get_contents($cacheFile); + // echo "cacheFile=$cacheFile, s=$s\n"; if ($s !== false) { - return json_decode($s); + $j = json_decode($s); + if ($j !== null) { + return $j; + } else { + // echo "Could not decode JSON\n"; + } } } @@ -85,15 +91,14 @@ try { $properties["width_px"] = $width; } if (isset($orientation)) { - switch ($orientation) { - case 1: - $properties["orientation"] = 0; - case 3: - $properties["orientation"] = -180; - case 6: - $properties["orientation"] = 90; - case 8: - $properties["orientation"] = -90; + if($orientation == 1) { + $properties["orientation"] = 0; + } else if($orientation == 3) { + $properties["orientation"] = -180; + } else if($orientation == 6) { + $properties["orientation"] = 90; + } else if($orientation == 8) { + $properties["orientation"] = -90; } } $json["properties"] = $properties; @@ -120,6 +125,7 @@ try { } header('Content-Type: application/vnd.geo+json'); + header('Access-Control-Allow-Origin: *'); echo json_encode($json, JSON_PRETTY_PRINT); echo "\n"; } catch(InvalidArgumentException $e) { -- cgit v1.2.3