Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorchewbears
    • CommentTimeOct 15th 2008
     
    Sid I sent you an e-mail on this topic but I think I would like to see what others think, and potentially are doing.

    Currently I am geotagging all my images with exifutils. I currently have no method of using plogger to add these points to a map, but instead have to house my images in 2 places on two separate databases to get this effect. I am just wondering if anyone else is interested in having a piece of plogger with a map showing where pictures have been taking.

    More specifically to Sid, is there any potential for plogger to do what flickr is moving in the direction towards and Picasa (sp.) is doing with googlemaps? I am very interested in this as all my photos are survery photos and people browsing have a HUGE interest in the spatial location of the particular photos they are interested in.

    thanks for any and all responses.
    • CommentAuthorkokuda
    • CommentTimeOct 15th 2008
     
    I too am interested in this. I've been carrying a GPS with me for years when taking photos, but haven't really made any practical use of it.

    I've written a Javascript GPX viewer using google maps (http://notions.okuda.ca/geotagging/projects-im-working-on/gpx-viewer/), I'm writing my own geotagger in C# that uses Google Maps (http://code.google.com/p/geotagger/), and some code for my previous gallery (mg2) to read the GPS data from photos (http://notions.okuda.ca/mg2-hacks/exif-parser/), but have never got around to putting any of these things together.

    It would be very easy to add a couple of fields for the coordinates of photos that could either be extracted from the images when they are uploaded (using the php exif library) , or edited in the admin interface. It would be easy to get the coordinates from clicking on a Google Map (see my geotagger project, as it uses a Javascript interface with Google Maps for that purpose, with dragging and dropping markers).

    Once you have the data in the database, then getting it out in a readable format should be straight forward. A list of photos and coordinates, either XML (GPX?), JSON, or some other format, should be easy to parse and display in a Google Map (see my GPX viewer).

    I would be interested in helping out with this (when I have the time) or feel free to use the code I've published around this to make it happen. I would love to see it happen.
    • CommentAuthorchewbears
    • CommentTimeOct 16th 2008
     
    Kokuda,

    Sidtheduck on these forums helped me do the missing piece you have addressed above. He has written a bit of a php mod that allows you apon upload to extract the gps-latitude and gps-longitude of the photos, create a mysql field for them and then store that information. In terms of adding the exif information gps-lat and gps-long into the photos I use a ~40 dollar tool called exifutils which I have written a series of automated .bat files which updates about ~24 exif fields. I have done this for thousands of photos. Then apon uploading them with sids .php the tables in the mysql are populated and the information for the 24 fields is then stored. Anyways I am looking now at your site to see how we can pull these two pieces together.
    • CommentAuthorchewbears
    • CommentTimeDec 8th 2008 edited
     
    KOkuda,

    If you are still around I am dying to know how you did http://okuda.ca/gallery/index.php?id=70 on your site with the link to the google maps on the GPS section. I have been working for about a week now trying to do exactly that. My problem is on plogger when I get to the picture view that displays all the field (same place your picture is at in the above link), I can not tell plogger to send that pictures Lat Long to google maps to link me to the location. If you are around and can help send me an email at mstreubert AT hotmail dot com

    EDIT: TO be more specific I need to know how to put the below into the exif picture.php

    function MakeMapURL($exif)
    {
    if (isset($exif['GPSVersion']))
    {
    echo "<a href=\"http://maps.google.com/maps?q=";
    echo $exif['GPSLatitudeRef'];
    echo $exif['GPSLatitude'];
    echo ",+";
    echo $exif['GPSLongitudeRef' ];
    echo $exif['GPSLongitude'];
    echo "&spn=0.0,0.0&t=h&hl=en\" target=\"_blank\">View location in Google Maps</a>";
    }
    }


    I have made mine to represent my fields in my DB so the naming is changed a bit

    function MakeMapURL($exif)
    {
    if (isset($exif['GPSVersion']))
    {
    echo "<a href=\"http://maps.google.com/maps?q=";
    echo $exif['EXIF_lat_ref'];
    echo $exif['EXIF_lat'];
    echo ",+";
    echo $exif['EXIF_long_ref' ];
    echo $exif['EXIF_long'];
    echo "&spn=0.0,0.0&t=h&hl=en\" target=\"_blank\">View location in Google Maps</a>";
    }
    }



    I think I have to change if (isset($exif['GPSVersion'])) but I do not know what it is : P Is GPSVerision your field on your details? So for plogger I need to put this function in plog-functions, but again I do not know exactly where and I do not know how to use the GPSVersion. Most of my photos have Lat Long.

    Also I am hoping that plogger will allow this function to reside in plog-functions.php as well I need to figure out how to fit the new field which you are linking to google maps into the function generate_exif_table, as that is where I want the hyperlink to be displayed.

    I am testing in the exif table like this

    <tr>
    <td><strong>GPS</strong></td>
    <td><? echo MakeMapURL($exif_data) ?></td>
    </tr>

    but that is not working... because I do not know how to tell it how to populate the field with the result of the function


    Thanks
    •  
      CommentAuthorsidtheduck
    • CommentTimeDec 8th 2008
     
    chewbears,

    Try changing:
    if (isset($exif['GPSVersion']))
    to:
    if (!empty($exif['EXIF_lat']))
    I think that should work for you.

    Also, if you are adding new functions, it may be best to create your own function file in the theme you are using and call it with a PHP include function in the head.php file. That way, if/when you do upgrade, it will be a little easier (so you don't have to integrate your new functions into the new plog-functions.php file before uploading).
    • CommentAuthorchewbears
    • CommentTimeDec 8th 2008 edited
     
    Sid,

    Thanks for the advice on creating my own functions. I have done so now the problem I have run into is incorporating the result of that function into the table

    $table_data = '<div id="exif_table">';
    $table_data .= '
    <table id="exif_data_visible">
    <tr>
    <td><strong>GPS</strong></td>
    <td><MakeMapURL($exif_data)></td>
    </tr>
    <tr>
    <td><strong>Subject</strong></td>
    <td>'.$row["EXIF_subj_ref"].'</td>
    </tr>
    <tr>
    <td><strong>Date/Time</strong></td>
    <td>'.$row["EXIF_date_time_orig"].'</td>
    </tr>
    <tr>
    <td><strong>Latitude</strong></td>
    <td>'.$row["EXIF_lat"].' '.$row["EXIF_lat_ref"].'</td>
    </tr>
    <tr>
    <td><strong>Longitude</strong></td>
    <td>'.$row["EXIF_long"].' '.$row["EXIF_long_ref"].'</td>
    </tr>
    </table>';

    If you recall that is the table you helped me make for my visible exif data. In its current form the GPS html will not display. Any thoughts on how to make that link display on my picture.php

    <td><? echo "GPS" ?></td>
    <td><? echo MakeMapURL($exif_data) ?></td>

    was the suggestion on KOkuda's website, but that will not work either.

    thanks
    •  
      CommentAuthorsidtheduck
    • CommentTimeDec 8th 2008 edited
     
    Does this work?
    <td><strong>GPS</strong></td>
    <td>'.MakeMapURL($exif_data).'</td>
    • CommentAuthorchewbears
    • CommentTimeDec 8th 2008
     
    function MakeMapURL($exif)
    {
    if (!empty($exif['EXIF_lat']))
    {
    echo "<a href=\"http://maps.google.com/maps?q=";
    echo $exif['EXIF_lat_ref'];
    echo $exif['EXIF_lat'];
    echo ",+";
    echo $exif['EXIF_long_ref' ];
    echo $exif['EXIF_long'];
    echo "&spn=0.0,0.0&t=h&hl=en\" target=\"_blank\">View location in Google Maps</a>";
    }
    }

    with that as my function it returns <>
    •  
      CommentAuthorsidtheduck
    • CommentTimeDec 8th 2008
     
    Try this.
    function MakeMapURL($exif)
    {
    if (!empty($exif['EXIF_lat']))
    {
    return "<a href=\"http://maps.google.com/maps?q=".$exif['EXIF_lat_ref'].$exif['EXIF_lat'].",+".$exif['EXIF_long_ref' ].$exif['EXIF_long']."&spn=0.0,0.0&t=h&hl=en\" target=\"_blank\">View location in Google Maps</a>";
    }
    }

    and:
    $exif_map_link = MakeMapURL($exif_data);
    $table_data = '<div id="exif_table">';
    $table_data .= '
    <table id="exif_data_visible">
    <tr>
    <td><strong>GPS</strong></td>
    <td>'.$exif_map_link.'</td>>
    • CommentAuthorkokuda
    • CommentTimeDec 8th 2008 edited
     
    One problem I see is that there is a mixing of styles. Your html is being built as a string in php, while my examples assume that the php is being escaped briefly in the html. You are building a string, so you need to close the string before calling any php functions.

    You are starting the string here...
    $table_data .= '

    So the following will not call any functions, only generate MakeMapURL as part of the html.
    <td><MakeMapURL($exif_data)></td>

    You need to close the string, call the function, and then open it again. Hence the suggestion of <td><'.MakeMapURL(...).'></td>

    However, this assumes that the MakeMapURL function will return a string. I'm not sure if the echo calls within that function will do the trick (it will probably cause the output to be out of order). You should make both parts of the code follow the same format. Either echo each line of output, or generate a single string that you echo at the end.

    I suggest you add the '. and .' around the MakeMapURL call and change the function to build and return a string, like you are doing with $table_data.

    edit: Sorry, the formatting was all lost as html
    edit2: What sidtheduck said.
    •  
      CommentAuthorsidtheduck
    • CommentTimeDec 8th 2008
     
    kokuda is correct (and no fault of his/her original script). It looks to be just an issue of function vs. string vs. output and how they are formatted and escaped. I *think* the code I posted above should work, but you'll need to try it and let us know. :D
    • CommentAuthorchewbears
    • CommentTimeDec 8th 2008 edited
     
    function generate_exif_table($id, $condensed = 0){
    global $config;
    $query = "SELECT * FROM `".TABLE_PREFIX."pictures` WHERE `id`=".intval($id);
    $result = run_query($query);
    if (mysql_num_rows($result) > 0){
    $row = mysql_fetch_assoc($result);
    foreach($row as $key => $val) if (trim($row[$key]) == '') $row[$key] = '&nbsp;';
    $exif_map_link = MakeMapURL($exif_data);
    $table_data = '<div id="exif_table">';
    $table_data .= '
    <table id="exif_data_visible">
    <tr>
    <td><strong>GPS</strong></td>
    <td>'.$exif_map_link.'</td>

    with the function

    function MakeMapURL($exif)
    {
    if (!empty($exif['EXIF_lat']))
    {
    return "<a href=\"http://maps.google.com/maps?q=".$exif['EXIF_lat_ref'].$exif['EXIF_lat'].",+".$exif['EXIF_long_ref' ].$exif['EXIF_long']."&spn=0.0,0.0&t=h&hl=en\" target=\"_blank\">View location in Google Maps</a>";
    }
    }

    Now leaves the area after GPS blank. I dunno why but also tried it with $exif_map_link = MakeMapURL($exif); instead of $exif_data
    • CommentAuthorchewbears
    • CommentTimeDec 8th 2008 edited
     
    Removed {
    if (!empty($exif['EXIF_lat']))
    }

    and it linked me to google maps but there was no coordinate present.

    I think the if needs to be reverse like if nothing then do not show. The way it was written was if empty then show, but if there is nothing then there is nothing to show

    Now to get the coordinates to actually work. THis is the googlemaps return : http://maps.google.com/maps?q=,+&spn=0.0,0.0&t=h&hl=en
    •  
      CommentAuthorsidtheduck
    • CommentTimeDec 8th 2008
     
    DOH! You need to do:
    $exif_map_link = MakeMapURL($row);
    • CommentAuthorchewbears
    • CommentTimeDec 8th 2008 edited
     
    Getting closer Sid : P

    That returns http://maps.google.com/maps?q=N30°%2021'%2039 which is only the Lat : P It also allows to exist once more. I think the ,+ is stopping it for some reason playing around with it as we speak.

    EDIT : Double checked the field names etc then reversed lat and long and still only read the first 2 ref and long
    EDIT2 : Reverted back to the original way in the function and it still only read the first 2. Starting to wonder about the line being limited.
    EDIT3 : Just as an update I believe I have figured out that it will not except 2 numbered fields in the format dd mm ss. I can put any number and combo of fields from my database into it but as soon as I put 2 lats 2 longs or a lat and a long only 1 is visible. Any thoughts?
    •  
      CommentAuthorsidtheduck
    • CommentTimeDec 8th 2008
     
    How about this (with single quotes instead of doubles)? It *shouldn't* matter, but maybe it does.
    return '<a href="http://maps.google.com/maps?q='.$exif['EXIF_lat_ref'].$exif['EXIF_lat'].',+'.$exif['EXIF_long_ref'].$exif['EXIF_long'].'&spn=0.0,0.0&t=h&hl=en" target="_blank">View location in Google Maps</a>';
    • CommentAuthorchewbears
    • CommentTimeDec 8th 2008
     
    Yeah Sid I think I tried every combo. I am assuming it has to do with the fact that in the DB lat for example is named 30#139; to make th ascii sign for the degree or something. My plan of attack is to dupe the EXIF_lat field to another field named lat_new and populate it with a find and replace to remove all that extra stuff and then try. I even went as far as to do like EXIF_keyword and such to make sure it worked in the q="" part. It did but the EXIF_lat or long would fail if they both existed.

    So basically the ',+' is not the problem. THe problem is with how google interprets the stuff after say the 30. I am thinking of just making that new field in the DB convert to Decimal Degree for simplicity. Anyways I think this will work and I will keep you posted. If you think of anything based on this idea, put it up there as I would love to not have to mod the DB like this as a work around.
    • CommentAuthorchewbears
    • CommentTimeDec 9th 2008
     
    UPDATE:

    I did this as my work around

    function MakeMapURL($exif)
    {
    if (!empty($exif['EXIF_lat']))
    {
    $long=substr($exif['EXIF_long'], 0, -1);
    $lat=substr($exif['EXIF_lat'], 0, -1);
    return "<a href=\"http://maps.google.com/maps?q=".$exif['EXIF_lat_ref'].$lat.",".$exif['EXIF_long_ref' ].$long."&spn=0.0.,.0.0&t=h&hl=en\" target=\"_blank\">View location in Google Maps</a>";
    }
    }

    Basically the " in the database were ending the google map search so I used the substr php to elimate that quotation mark.

    Works very good

    Final question if anyone can help me with is I would like a better means to stop photo's without the lat and long from having the google map link. I do not want the user to be able to click or see the google map link if no lat exists. How can I do that?
    • CommentAuthorchewbears
    • CommentTimeDec 9th 2008
     
    One other cool thing I noted to add a little bit of neatness to this concept is fir you add &z=X
    where X is a number between 0-20 it will create a static zoom. 0 is all the way out 20 all the way in.

    So for example my code is now

    return "<a href=\"http://maps.google.com/maps?q=".$exif['EXIF_lat_ref'].$lat.",".$exif['EXIF_long_ref' ].$long."&z=5"."&spn=0.0.,.0.0&t=h&hl=en\" target=\"_blank\">View location in Google Maps</a>";
    }
    notice the ,"&z=5" = P

    pretty neat stuff !!!