diff --git a/modules/exif_gps/helpers/exif_gps.php b/modules/exif_gps/helpers/exif_gps.php index a03670a8..c136f787 100644 --- a/modules/exif_gps/helpers/exif_gps.php +++ b/modules/exif_gps/helpers/exif_gps.php @@ -51,6 +51,7 @@ class exif_gps_Core { $record->item_id = $item->id; $record->latitude = $keys["Latitude"]; $record->longitude = $keys["Longitude"]; + // Represent N/S/E/W as postive and negative numbers if ($keys["Latitude Reference"] == "S") { $record->latitude = "-" . $record->latitude; } @@ -62,6 +63,7 @@ class exif_gps_Core { } private static function _keys() { + // EXIF fields to extract. if (!isset(self::$exif_keys)) { self::$exif_keys = array( "Latitude Reference" => array("GPS", "Latitude Reference", t("GPS: Latitude Reference"), ), diff --git a/modules/exif_gps/helpers/exif_gps_block.php b/modules/exif_gps/helpers/exif_gps_block.php index c7cf1d6e..087dbf0c 100644 --- a/modules/exif_gps/helpers/exif_gps_block.php +++ b/modules/exif_gps/helpers/exif_gps_block.php @@ -32,6 +32,7 @@ class exif_gps_block_Core { switch ($block_id) { case "exif_gps_map": + // Check and see if the item has exif coordinates associated with it. $record = ORM::factory("exif_coordinate")->where("item_id", "=", $theme->item->id)->find(); if ($record->loaded()) { $block = new Block(); @@ -41,6 +42,7 @@ class exif_gps_block_Core { $block->content->latitude = $record->latitude; $block->content->longitude = $record->longitude; } elseif (module::is_active("tagsmap") && module::is_active("tag")) { + // If there are no exif coordinates, check for tagsmap coordinates instead. $tagsItem = ORM::factory("tag") ->join("items_tags", "tags.id", "items_tags.tag_id") ->where("items_tags.item_id", "=", $theme->item->id) @@ -55,7 +57,7 @@ class exif_gps_block_Core { $block->content = new View("exif_gps_sidebar.html"); $block->content->latitude = $tagsGPS->latitude; $block->content->longitude = $tagsGPS->longitude; - break; + break; } } } diff --git a/modules/exif_gps/helpers/exif_gps_task.php b/modules/exif_gps/helpers/exif_gps_task.php index 6158bc69..3eef7079 100644 --- a/modules/exif_gps/helpers/exif_gps_task.php +++ b/modules/exif_gps/helpers/exif_gps_task.php @@ -38,21 +38,25 @@ class exif_gps_task_Core { static function update_gps_index($task) { $start = microtime(true); + // Figure out the total number of photos in the database. + // If this is the first run, also set last_id and completed to 0. $total = $task->get("total"); if (empty($total)) { $task->set("total", $total = count(ORM::factory("item")->where("type", "=", "photo")->find_all())); $task->set("last_id", 0); $task->set("completed", 0); } - $last_id = $task->get("last_id"); $completed = $task->get("completed"); + // Generate an array of the next 100 photos to check. $all_photos = ORM::factory("item") ->where("id", ">", $last_id) ->where("type", "=", "photo") ->find_all(100); + // Check each photo in the array to see if it already has exif gps data associated with it. + // If it doesn't, attempt to extract gps coordinates. foreach (ORM::factory("item") ->where("id", ">", $last_id) ->where("type", "=", "photo")