]> git.mxchange.org Git - friendica.git/blob - include/photos.php
Merge pull request #2112 from rabuzarus/2811_group_side
[friendica.git] / include / photos.php
1 <?php
2 /**
3  * @file include/photos.php
4  * @brief Functions related to photo handling.
5  */
6
7 function getGps($exifCoord, $hemi) {
8         $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
9         $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;
10         $seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0;
11
12         $flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1;
13
14         return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600)));
15 }
16
17 function gps2Num($coordPart) {
18         $parts = explode('/', $coordPart);
19
20         if (count($parts) <= 0)
21                 return 0;
22
23         if (count($parts) == 1)
24                 return $parts[0];
25
26         return floatval($parts[0]) / floatval($parts[1]);
27 }