From c01e5c96c815c53695b7d80923a51cd235edd841 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 19 Aug 2015 19:06:56 +0200 Subject: wip --- pictures/index.php | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 pictures/index.php (limited to 'pictures') diff --git a/pictures/index.php b/pictures/index.php new file mode 100644 index 0000000..0bee830 --- /dev/null +++ b/pictures/index.php @@ -0,0 +1,128 @@ + "Feature", "id" => $filename]; + + foreach ($exif as $key => $section) { + foreach ($section as $name => $val) { + switch("$key.$name") { + case "FILE.FileSize": $filesize_bytes = $val; break; + case "COMPUTED.Height": $height = $val; break; + case "COMPUTED.Width": $width = $val; break; + case "GPS.GPSLongitude": $lon = parseDeg($val); break; + case "GPS.GPSLatitude": $lat = parseDeg($val); break; + case "IFD0.Orientation": $orientation = $val; break; + case "EXIF.MakerNote": + case "EXIF.ComponentsConfiguration": + case "GPS.GPSVersion": + case "GPS.GPSAltitudeRef": + break; + default: +// echo "$key.$name=$val\n"; + } + } + } + + if (isset($lon) && isset($lat)) { + $json["geometry"] = [ + "type" => "Point", + "coordinates" => [$lon, $lat] + ]; + } + + $properties = [ + ]; + if (isset($filesize_bytes)) { + $properties["filesize_bytes"] = $filesize_bytes; + } + if (isset($height)) { + $properties["height_px"] = $height; + } + if (isset($width)) { + $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; + } + } + $json["properties"] = $properties; + + $s = json_encode($json); + file_put_contents($cacheFile, $s); + + return $json; + } + + if (!isset($_GET["file"])) { + $d = dir("."); + $features = []; + while (false !== ($entry = $d->read())) { + if(!isValidFilename($entry)) { + continue; + } + array_push($features, processFile($entry)); + } + $json = ["type" => "FeatureCollection", "features" => $features]; + } else { + $filename = $_GET["file"]; + $json = processFile($filename); + } + + header('Content-Type: application/vnd.geo+json'); + echo json_encode($json, JSON_PRETTY_PRINT); + echo "\n"; +} catch(InvalidArgumentException $e) { + header('HTTP/1.1 400 bad request'); +} +?> -- cgit v1.2.3