diff options
Diffstat (limited to 'pictures')
-rw-r--r-- | pictures/index.php | 28 |
1 files 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) { |