Beispiel #1
0
 /**
  * Get location object for the object
  *
  * @return org_routamc_positioning_location_dba
  */
 function seek_location_object()
 {
     $qb = org_routamc_positioning_location_dba::new_query_builder();
     $qb->add_constraint('parent', '=', $this->_object->guid);
     $qb->begin_group('OR');
     $qb->add_constraint('relation', '=', ORG_ROUTAMC_POSITIONING_RELATION_IN);
     $qb->add_constraint('relation', '=', ORG_ROUTAMC_POSITIONING_RELATION_LOCATED);
     $qb->end_group('OR');
     $qb->add_order('metadata.published', 'DESC');
     $matches = $qb->execute();
     if (count($matches) > 0) {
         return $matches[0];
     }
     return null;
 }
Beispiel #2
0
 private function _claim_location_entries()
 {
     $previous = $this->get_previous();
     if (is_object($previous)) {
         $qb = org_routamc_positioning_location_dba::new_query_builder();
         // Find locations reported to previous log but after
         // this log's date
         $qb->add_constraint('log', '=', $previous->id);
         $qb->add_constraint('date', '>=', $this->date);
         $matches = $qb->execute();
         if (count($matches) > 0) {
             foreach ($matches as $location) {
                 // Switch the location to point to this log
                 $location->log = $this->id;
                 $location->latitude = $this->latitude;
                 $location->longitude = $this->longitude;
                 $location->altitude = $this->altitude;
                 $location->update();
             }
         }
     }
 }