Projet

Général

Profil

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

root / class / RefPoint.class.php @ 7096d2f9

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

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

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

    
27
  public static function load_if_needed() {
28
    if (!isset(self::$all_ref_points_cache)) {
29
      if (file_exists(REF_POINTS_PATH)) {
30
        require(REF_POINTS_PATH);
31
        self::$all_ref_points_cache = $ref_points;
32
        return $ref_points;
33
      } else {
34
        return array();
35
      }
36
    }
37
   return self::$all_ref_points_cache;
38
  }
39

    
40
  public static function get_all() {
41
    self::load_if_needed();
42
    $ref_points_objs = array();
43
    foreach (self::$all_ref_points_cache as $name => $vals) {
44
      $ref_points_objs[] = new RefPoint($name, $vals);
45
    }
46
    return $ref_points_objs;
47
  }
48

    
49
  public static function get($name) {
50
    self::load_if_needed();
51
    $values = self::$all_ref_points_cache[$name];
52
    return new RefPoint($name, $values);
53
  }
54

    
55
}
56
?>