|
|
|
| Вот информация об этих файлах:
https://en.wikipedia.org/wiki/Geotagging
Вот слова моего клиента, которые вкратце описывают файлы такого типа:
When people shoot photos with their phones or other modern cameras they have the ability to save gps coordinates (where the picture was taken) in the image file.
These data (gps coordinates) need to be read from the file when you upload the image so the google map pins it automatically.
Умеет ли php доставать информацию (gps-координаты) из таких файлов? Кто-нибудь может дать мне пример такого файла? | |
|
|
|
|
|
|
|
для: Лена
(15.11.2015 в 11:37)
| | Посмотрите в сторону exif_read_data(), только скорее всего расширение придется ставить. Или возможно есть какой-то компонент для этого. | |
|
|
|
|
23.2 Кб |
|
|
для: Лена
(15.11.2015 в 11:37)
| | вот пример фотки
Данные хранятся так, как будто формат выбирал какой-нибудь Жюль-верновский герой.
[GPSVersion] =>
[GPSLatitudeRef] => N
[GPSLatitude] => Array
(
[0] => 59/1
[1] => 53/1
[2] => 285021/10000
)
[GPSLongitudeRef] => E
[GPSLongitude] => Array
(
[0] => 30/1
[1] => 28/1
[2] => 336062/10000
)
[GPSAltitudeRef] =>
[GPSAltitude] => -67/1
[GPSTimeStamp] => Array
(
[0] => 12/1
[1] => 20/1
[2] => 28/1
)
|
Но пересчитать можно во что угодно. | |
|
|
|
|
|
|
|
для: Trianon
(15.11.2015 в 15:36)
| | Спасибо.
Подключила расширение exif.
$name = isset($_FILES['uploadfile']['name']) ? $_FILES['uploadfile']['name'] : '';
$exif = exif_read_data($name);
$lon = getGps($exif["GPSLongitude"], $exif['GPSLongitudeRef']);
$lat = getGps($exif["GPSLatitude"], $exif['GPSLatitudeRef']);
var_dump($lat, $lon);
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 $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]);
}
|
Ваша фотка дала результат:
float(59.891250583333)
float(30.476001722222)
что очень похоже на ваше местоположение. | |
|
|
|