Kirjautuminen

Haku

Tehtävät

Keskustelu: Nettisivujen teko: EXIF-koordinaatit

taky [25.05.2008 12:16:39]

#

Serveri.....

- Apache Version Apache/2.2.8 (Win32) PHP/5.2.6

jossa EXIF paikkatiedolla varustettuja valokuvia ja niitä
PHP:llä linkiksi, esimerkki kts....
http://basepath.com/index-real.php?url=blogentry/2007-05-27.htm

<?php
/*
    To use this PHP script:

    1. Get access to a web server running PHP with EXIF support enabled (compiled with --enable-exif).
       The PHP on Mac OS X seems to come that way, but it isn't configured by default to run in the Apache
       web server that comes with OS X. You'll have to do that yourself.
    2. Put GPS tagged JPEGs in a directory on your Web server named "images".
    3. Put this file in the parent directory of the "images" directory.
    4. Get a free Google Maps API key from www.google.com/apis/maps/signup.html.
    5. Replace the key below with your key (use a text editor).
    6. Run this script.

    What's needed is a way to do this without PHP or any other scripting approach that requires installation
    and configuration. I'm working on that.

    Copyright 2007 by Marc J. Rochkind. All rights reserved, except that this script may be used under
    the BSD license posted at basepath.com/aup/copyright.html.

*/

mapit(scandir("images"));

function sexagesimal_to_float($x) {
    eval('$f = ' . $x[0] . "+" . $x[1] . " / 60 + "  . $x[2] . " / 3600;");
    return $f;
}

function mapit($files) {
    echo <<<EOT
        <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>Google Photo Map (from www.basepath.com)</title>
        <!--
            ****** Change the key below to your personal Google Maps API key.
            ****** You can get a free key from www.google.com/apis/maps/signup.html
            ****** Carefully replace the letters replace_this_with_your_key with your key.
        -->
        <script src="http://maps.google.com/maps?file=api&v=2&key=replace_this_with_your_key"
          type="text/javascript"></script>
        <script type="text/javascript">
        //<![CDATA[

        var images = new Array(
EOT;
    // UFPs (Unidentified Flying Photos) are moved to Area 51.
    $lat_area51 = 37.405;
    $lon_area51 = -116.24;
    $first = true;
    $centerOnArea51 = false;
    for ($i = 0; $i < count($files); $i++) {
        if ($files[$i][0] == '.')
            continue;
        $photo = "images/$files[$i]";
        $exif = exif_read_data($photo);
        $exif_lat = $exif["GPSLatitude"];
        $exif_lon = $exif["GPSLongitude"];
        if (empty($exif_lat) || empty($exif_lon)) {
            $centerOnArea51 = true;
            $lat = $lat_area51;
            $lon = $lon_area51;
        }
        else {
            $lat = sexagesimal_to_float($exif_lat);
            if ($exif["GPSLatitudeRef"][0] == "S")
                $lat = -$lat;
            $lon = sexagesimal_to_float($exif_lon);
            if ($exif["GPSLongitudeRef"][0] == "W")
                $lon = -$lon;
        }
        if ($first)
            $first = false;
        else
            echo ",";
        echo "\n";
        echo <<<EOT
            new Array("$photo", $lat, $lon)
EOT;
    }
    echo <<<EOT
        );
        var area51 = null;

EOT;
        if ($centerOnArea51)
            echo <<<EOT
                area51 = new GLatLng($lat_area51, $lon_area51);

EOT;
    echo <<<EOT
        function load() {
            if (GBrowserIsCompatible()) {
                var map = new GMap2(document.getElementById("map"));
                map.addControl(new GSmallMapControl());
                map.addControl(new GMapTypeControl());
                for (i = 0; i < images.length; i++) {
                    p = new GLatLng(images[i][1], images[i][2]);
                    if (i == 0)
                        if (area51 == null)
                            map.setCenter(p, 15);
                        else
                            map.setCenter(area51, 13);
                    m = new GMarker(p);
                    m.image = images[i][0];
                    map.addOverlay(m);
                }
                map.setMapType(G_HYBRID_TYPE);

EOT;
    echo <<<EOT
                GEvent.addListener(map, "click", function(marker, point) {
                    marker.openInfoWindowHtml(
                      marker.getPoint().toString() +
                      "<p><a target=_blank href='" + marker.image + "'><img src='" + marker.image + "' width=200 /></a>");
                });
            }
        }

        //]]>
        </script>
        </head>
        <body onload="load()" onunload="GUnload()">
        <div id="map" style="width: 600; height: 600px"></div>
        </body>
        </html>

EOT;
}
?>

Systeemi toimii muuten mutta EXIF ei ratkaise koordinaatteja kuvista, vaan
ne "tulostuu" kaikki "Area 51":ssä määritettyyn paikkaan, siis

$lat_area51 = 37.405;
$lon_area51 = -116.24;

Serveri ja sen optiot linkissä...

http://kallenkuja3c.dy.fi/phptesti.php

PHP.INI:ssä

extension=php_mbstring.dll
extension=php_exif.dll

Missä mahtaa olla bitti poikittain kun paikkatieto ei kuvista irtoa, se on kuska sama PHP toimii toisella serverillä OK - oletus että PHP/Apachen asetuksissa on jokin disable - mutta mikä?

taky [28.05.2008 11:47:13]

#

Syy selvisi.... testiaineiston JPG kuvat olivat korruptoituneet = paikkatieto niistä hukassa, syy lienee Photo Studio ohjelma http://www.exif.org/programs.html-sivuilta

Vastaus

Aihe on jo aika vanha, joten et voi enää vastata siihen.

Tietoa sivustosta