Projet

Général

Profil

Paste
Télécharger (904 octets) Statistiques
| Branche: | Révision:

root / class / RefPoint.class.php @ fe12dd81

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
      $ref_points_filename = '../ref_points.local.php';
22
          if (file_exists($ref_points_filename)) {
23
            require($ref_points_filename);
24
        self::$all_ref_points_cache = $ref_points;
25
            return $ref_points;
26
          } else {
27
            return array();
28
      }
29
    }
30
   return self::$all_ref_points_cache;
31
  }
32

    
33
  public static function get($name) {
34
    self::load_if_needed();
35
    $values = self::$all_ref_points_cache[$name];
36
    return new RefPoint($name, $values);
37
  }
38

    
39
}
40
?>