Skip to content

Commit

Permalink
Code cleanup and comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
rWatcher committed Mar 4, 2010
1 parent 29a1d7e commit f862f89
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions modules/exif_gps/helpers/exif_gps.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static function extract($item) {
$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;
}
Expand All @@ -62,6 +63,7 @@ static function extract($item) {
}

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"), ),
Expand Down
4 changes: 3 additions & 1 deletion modules/exif_gps/helpers/exif_gps_block.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static function get($block_id, $theme) {

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();
Expand All @@ -41,6 +42,7 @@ static function get($block_id, $theme) {
$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)
Expand All @@ -55,7 +57,7 @@ static function get($block_id, $theme) {
$block->content = new View("exif_gps_sidebar.html");
$block->content->latitude = $tagsGPS->latitude;
$block->content->longitude = $tagsGPS->longitude;
break;
break;
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion modules/exif_gps/helpers/exif_gps_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,25 @@ static function available_tasks() {
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")
Expand Down

0 comments on commit f862f89

Please sign in to comment.