Projet

Général

Profil

Paste
Télécharger (1,35 ko) Statistiques
| Branche: | Révision:

root / class / RefPoint.class.php @ 6bf61e20

1
<?php
2
require_once(dirname(__FILE__).'/../constants.inc.php');
3
require_once(dirname(__FILE__).'/GeoPoint.class.php');
4
//
5
class RefPoint extends GeoPoint {
6
  static $all_ref_points_cache;
7
  public $name;
8
  public $lon;
9
  public $lat;
10
  public $ele;
11

    
12
  public function __construct($name, $values) {
13
    $this->name = $name;
14
    $this->lat = $values[0];
15
    $this->lon = $values[1];
16
    $this->ele = $values[2];
17
  }
18

    
19
  public function get_lat() {
20
    return $this->lat;
21
  }
22

    
23
  public function get_name() {
24
    return $this->name;
25
  }
26

    
27
  public function get_lon() {
28
    return $this->lon;
29
  }
30

    
31
  public static function load_if_needed() {
32
    if (!isset(self::$all_ref_points_cache)) {
33
      if (file_exists(REF_POINTS_PATH)) {
34
        $ref_points = array();
35
        require(REF_POINTS_PATH);
36
        self::$all_ref_points_cache = $ref_points;
37
        return $ref_points;
38
      } else {
39
        return array();
40
      }
41
    }
42
   return self::$all_ref_points_cache;
43
  }
44

    
45
  public static function get_all() {
46
    self::load_if_needed();
47
    $ref_points_objs = array();
48
    foreach (self::$all_ref_points_cache as $name => $vals) {
49
      $ref_points_objs[] = new RefPoint($name, $vals);
50
    }
51
    return $ref_points_objs;
52
  }
53

    
54
  public static function get($name) {
55
    self::load_if_needed();
56
    $values = self::$all_ref_points_cache[$name];
57
    return new RefPoint($name, $values);
58
  }
59

    
60
}
61
?>