aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-03-16 22:06:03 -0700
committerfriendica <info@friendica.com>2015-03-16 22:06:03 -0700
commitbc22df9057198018f9cc490d0e3e013692f52b90 (patch)
treeb7a9bb4470297e85d07317135d8f6c7bd5553c0c /include
parent7c194c37b891f122740de52d154db0af612e0074 (diff)
downloadvolse-hubzilla-bc22df9057198018f9cc490d0e3e013692f52b90.tar.gz
volse-hubzilla-bc22df9057198018f9cc490d0e3e013692f52b90.tar.bz2
volse-hubzilla-bc22df9057198018f9cc490d0e3e013692f52b90.zip
display a map for photos if allowed. Note: there is a bug in that if the map div starts with display:none one needs to reload the frame or zoom in or they end up at minimum resolution. Still trying to sort this out.
Diffstat (limited to 'include')
-rw-r--r--include/photos.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/photos.php b/include/photos.php
index 4b7809fc1..4785e47c4 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -205,6 +205,17 @@ function photo_upload($channel, $observer, $args) {
// Create item container
+ $lat = $lon = null;
+
+ if($exif && $exif['GPS']) {
+ if(get_pconfig($channel_id,'system','allow_photo_location')) {
+ $lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPSLatitudeRef']);
+ $lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPSLongitudeRef']);
+ }
+ }
+
+
+
$item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
$item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
$title = '';
@@ -212,6 +223,9 @@ function photo_upload($channel, $observer, $args) {
$arr = array();
+ if($lat && $lon)
+ $arr['coord'] = $lat . ' ' . $lon;
+
$arr['aid'] = $account_id;
$arr['uid'] = $channel_id;
$arr['mid'] = $mid;
@@ -481,3 +495,30 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
return $item_id;
}
+
+
+function getGps($exifCoord, $hemi) {
+
+ $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
+ $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;
+ $seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0;
+
+ $flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1;
+
+ return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600)));
+
+}
+
+function gps2Num($coordPart) {
+
+ $parts = explode('/', $coordPart);
+
+ if (count($parts) <= 0)
+ return 0;
+
+ if (count($parts) == 1)
+ return $parts[0];
+
+ return floatval($parts[0]) / floatval($parts[1]);
+}
+