• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get GPS Data from Picture in PHP

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an urgent project & I have to print latitude & longitude of a picture location. I'm stuck at getting them. Here's the code:

   $exif = exif_read_data($picture_link, 0, true);

   echo "Latitude REF: " .$exif['GPS']['GPSLatitudeRef']
       ."<br>Latitude: " .print_r($exif['GPS']['GPSLatitude']) .
       ."<br>Longitude REF: " .$exif['GPS']['GPSLongitudeRef']
       ."<br>Longitude: " .print_r($exif['GPS']['GPSLongitude']);

And here's what I get back:

Latitude REF: N
Latitude: Array ( [0] => 44/1 [1] => 29/1 [2] => 5581/100 )
Longitude REF: E
Longitude: Array ( [0] => 11/1 [1] => 5/1 [2] => 401/100 )
How can I elaborate this data? Is there a better way to build a GPS?
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like your GPS co-ordinates are degrees/minutes/seconds. As upposed to degrees with decimal places.

So you should be able to print something like this:

Note that minutes is indicates by a single quote and seconds by a double quote. I may be mis-using the quotes around those quotes, since I can never remember which language handles quotes which way.

If you prefer decimals, divide minutes by 60, seconds by 3600, and add them to degrees.
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The third value doesn't look like seconds since it ranges from 0 to 59. Perhaps is it decimal places for minutes:  44 deg, 29.5581 min
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:The third value doesn't look like seconds since it ranges from 0 to 59. Perhaps is it decimal places for minutes:  44 deg, 29.5581 min



There are 60 minutes to a degree and  60 seconds to a minute. Did I miss something?
 
Norm Radder
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whoops, Sorry.  Looks like I missed the divisor  /100 which would put the seconds in range.

N 44 29 5.581 E 11 5 0.401
That puts the mark on a building at
4 Via S. Antonio
Emilia-Romagna
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get a spot on the road right in the middle of the vineyards. But close enough.

My apologies to Bologna. I tried making Ragù Bolognese for the first time last week and I can now say definitively that no matter what celebrity chefs say otherwise, the soffritto and the meat should NOT be cooked in the same pot.

But aside from the burnt vegetables, it did actually cook very nicely. So live and learn...
 
reply
    Bookmark Topic Watch Topic
  • New Topic