Projet

Général

Profil

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

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

1
<?php
2
require_once(dirname(__FILE__).'/../constants.inc.php');
3

    
4
//
5
class RefPoint {
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->lon = $values[0];
15
    $this->lat = $values[1];
16
    $this->ele = $values[2];
17
  }
18

    
19
  public static function load_if_needed() {
20
    if (!isset(self::$all_ref_points_cache)) {
21
      if (file_exists(REF_POINTS_PATH)) {
22
        require(REF_POINTS_PATH);
23
        self::$all_ref_points_cache = $ref_points;
24
        return $ref_points;
25
      } else {
26
        return array();
27
      }
28
    }
29
   return self::$all_ref_points_cache;
30
  }
31

    
32
  public static function get_all() {
33
    self::load_if_needed();
34
    $ref_points_objs = array();
35
    foreach (self::$all_ref_points_cache as $name => $vals) {
36
      $ref_points_objs[] = new RefPoint($name, $vals);
37
    }
38
    return $ref_points_objs;
39
  }
40

    
41
  public static function get($name) {
42
    self::load_if_needed();
43
    $values = self::$all_ref_points_cache[$name];
44
    return new RefPoint($name, $values);
45
  }
46

    
47
}
48
?>