diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-08-20 08:56:26 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-08-20 08:56:34 +0200 |
commit | d6d751d748f83d027d273f3c02c8a371f0a06ce5 (patch) | |
tree | 4a10667d6cdcef11c956f5512131d1650226b9d8 | |
parent | 1944fdaa1999435d635f25fc78e8b4f3fcf87c4f (diff) | |
download | gpx-gallery-d6d751d748f83d027d273f3c02c8a371f0a06ce5.tar.gz gpx-gallery-d6d751d748f83d027d273f3c02c8a371f0a06ce5.tar.bz2 gpx-gallery-d6d751d748f83d027d273f3c02c8a371f0a06ce5.tar.xz gpx-gallery-d6d751d748f83d027d273f3c02c8a371f0a06ce5.zip |
o Fixing orientation code.
-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) { |