hi,

When creating a file of type image, or uploading an attachment of type image, it extracts EXIF data including GPS location into RDF.
Is it somehow possible to get this GPS location also into the location.module for that image node?

In the end I'd like to be able to show image locations on a map - with the locations automatically taken from EXIF.

thanks

CommentFileSizeAuthor
#8 file-editform.png143.84 KBansorg
#8 file-locationsetting.png14.56 KBansorg

Comments

miglius’s picture

The latest fileframework is integrated with a location module. You need to enable a locations on the file node. Then on creating a file node with the image file, if there is a geo data in the image, it will be automatically extracted and passed to the location module.

ansorg’s picture

Ok, I tried again and this time it worked - great :)

The image gets a marker now on the node location (gmap) map. There is just no thumbnail shown. But this is another issue ...

Arto’s picture

Issue tags: +location, +exif
miglius’s picture

Status: Active » Fixed

Closing this issue as the location got extracted.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ansorg’s picture

Status: Closed (fixed) » Active

hello again,

I just restarted the whole site from scratch. Enabled FileFramework and friends, Location module and Gmap.

And again, I do not get the system to automatically fill in location information for my File (Image) Nodes. The images do contain geo exif as I can see in the RDF properties of each image.

Location Module is enabled, On the "File" content type I have set location to "1 minimum", "1 maximum" number of locations.

Is there another configuration step that I am missing in one of the involved modules?

miglius’s picture

Assigned: Unassigned » miglius
Status: Active » Postponed (maintainer needs more info)

Do you upload a file by directly creating a file node at 'node/add/file' or upload it as an attachment or cck file field instead? If you create a file node, do you see the Latitude and Longitude fields in the Location fieldset in the node creation form? Those fields are filled with the extracted geo data on the file node creation.

ansorg’s picture

StatusFileSize
new14.56 KB
new143.84 KB

I use the File content type and it's form directly (node/add/file). See attached screenshot, it shows the edit form again right after an upload. As you can see in the properties the Exif gets parsed and location info is found. But the location fields remain empty.

Second screenshot shows how location module is configured for the "File" content type.

It was working once before - if only I could figure out what I did differently this time - apart from using newer (current) versions of all modules

ansorg’s picture

Hi again,
I tried to "debug" a bit ...

file_image_nodeapi seems to be the place where location data is stored, if available.

I added some output to the function

function file_image_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'insert':
      if (module_exists('location') && $node->type == 'file' && !empty($node->file) && preg_match('/^image\//', $node->file->type) && isset($node->locations) && isset($node->locations[0]['locpick']) && empty($node->locations[0]['locpick']['user_latitude']) && empty($node->locations[0]['locpick']['user_longitude'])) {
        $data = rdf_normalize(rdf_query($node->file->uri, NULL, NULL, array('repository' => FILE_RDF_REPOSITORY)));
        $namespaces = rdf_get_namespaces();
        drupal_set_message(print_r($data[$node->file->uri][rdf_qname_to_uri('geo:lat', $namespaces, FALSE)],true));
        drupal_set_message(print_r($data[$node->file->uri][rdf_qname_to_uri('geo:long', $namespaces, FALSE)],true));
        if (($lat = isset($data[$node->file->uri][rdf_qname_to_uri('geo:lat', $namespaces, FALSE)]) ? $data[$node->file->uri][rdf_qname_to_uri('geo:lat', $namespaces, FALSE)][0] : NULL) && ($long = isset($data[$node->file->uri][rdf_qname_to_uri('geo:long', $namespaces, FALSE)]) ? $data[$node->file->uri][rdf_qname_to_uri('geo:long', $namespaces, FALSE)][0] : NULL)) {
          drupal_set_message("Saving into location ...");
          $node->locations[0]['locpick']['user_latitude'] = $lat;
          $node->locations[0]['locpick']['user_longitude'] = $long;
          drupal_set_message($node->locations[0]['locpick']['user_latitude']);
          drupal_set_message($node->locations[0]['locpick']['user_longitude']);
        }
      }
      break;
  }
}

On file upload I get as result


    * Array ( [0] => 40.382415771389 )
    * Array ( [0] => -105.51425933833 )
    * Saving into location ...
    * 40.382415771389
    * -105.51425933833
    * File myFileName has been created.

Looks ok so far I think. But for some reason the $node-locations data is not stored with the node, is there a call to a save function missing?

hope you can make something out of this

ansorg’s picture

and perhaps a feature request:

would it be possible to run this code not only on node creation (insert) but also on update?

miglius’s picture

This is working on my setup. Could you enter some debugging statements into the location module to track where the coordinates get lost and why they are not saved?

ansorg’s picture

unfortunately I'm away for some time now. Will continue on this when I'm back in june

johanneshahn’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

no activity