ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilGeoLocationCalculator.php
Go to the documentation of this file.
1<?
2
4{
6 protected $geo_repository;
7
8 public function __construct(ilGeoLocationRepository $a_geo_repository)
9 {
10 $this->geo_repository = $a_geo_repository;
11 }
12
13 public function calculateTimeTillNextExpiredGeoLocationAt(float $latitude, float $longitude)
14 {
15 $geo_locations = $this->geo_repository->getGeoLocationsByCoordinates($latitude, $longitude);
16
17 if (count($geo_locations) === 0) {
18 return null;
19 }
20
21 $current = array_shift($geo_locations);
22
23 foreach($geo_locations as $geo_location)
24 {
25 if($current->getExpirationAsTimestamp() >= $geo_location->getExpirationAsTimestamp()) {
26 $current = $geo_location;
27 }
28 }
29
30 return $geo_location;
31 }
32}
__construct(ilGeoLocationRepository $a_geo_repository)
calculateTimeTillNextExpiredGeoLocationAt(float $latitude, float $longitude)
This code is just an example for the Repository Pattern! It is a basic interface to the 'ilGeoLocatio...