Example #1
0
 /**
  * Get log object based on creation time and creator of the object
  *
  * @return org_routamc_positioning_log
  */
 function seek_log_object($person = null, $time = null)
 {
     if (is_integer($person) || is_string($person)) {
         $person_guid = $person;
     } elseif (is_null($person)) {
         $person_guid = $this->object->metadata->creator;
         // TODO: Use metadata.authors?
     } else {
         $person_guid = $person->guid;
     }
     if (is_null($time)) {
         $time = $this->object->metadata->published;
     }
     $person = new midgard_person($person_guid);
     $qb = org_routamc_positioning_log::new_query_builder();
     $qb->add_constraint('person', '=', $person->id);
     $qb->add_constraint('date', '<=', $time);
     $qb->add_order('date', 'DESC');
     $qb->set_limit(1);
     $matches = $qb->execute();
     if (count($matches) > 0) {
         return $matches[0];
     }
     return null;
 }
Example #2
0
 /**
  * Checks after location cache creation
  */
 public function _on_created()
 {
     if (!$this->log && $this->relation == ORG_ROUTAMC_POSITIONING_RELATION_IN) {
         // This location entry is defined as being made in a location,
         // but is stored to object directly without corresponding log,
         // create one.
         // This situation can happen for example when importing images
         // that have EXIF geo tags set
         $object = $this->get_parent();
         $log = new org_routamc_positioning_log();
         $log->date = $this->date;
         // TODO: Use 1.8 metadata authors instead?
         $log->person = $object->metadata->creator;
         $log->latitude = $this->latitude;
         $log->longitude = $this->longitude;
         $log->altitude = $this->altitude;
         $log->importer = 'objectlocation';
         // Usually the positions based on objects are manual, except in
         // case of GPS-equipped cameras etc. We still need to figure
         // out how to handle those.
         $log->accuracy = ORG_ROUTAMC_POSITIONING_ACCURACY_MANUAL;
         $log->create();
     }
 }