2 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
9 private $imgpath = null;
10 private $title = null;
11 private $description = null;
13 const err_lonlat_invalid = 1;
15 function __construct ($id, $lon, $lat, $imgpath, $title, $description) {
16 $this->imgpath = $imgpath;
24 $this->title = $title;
27 $this->description = $description;
30 if (!isset ($lon) || !is_numeric ($lon) ||
31 ($lon < -180) || ($lon > 180)) {
32 throw new Exception ($this->err_lonlat_invalid);
37 if (!isset ($lat) || !is_numeric ($lat) ||
38 ($lat < -90) || ($lat > 90)) {
39 throw new Exception ($this->err_lonlat_invalid);
44 public function __get ($attr) {
45 if (isset ($this->$attr)) return $this->$attr;
46 else throw new Exception ('Unknow attribute '.$attr);
49 public function __set ($attr,$value) {
50 throw new Exception ('properties can only be set in constructor');
55 interface anydbConnection {
56 const err_driver_unavailable = 1;
57 const err_connection = 2;
58 const err_unknown_database = 3;
62 * connect to database; That method may be called multiple times.
64 public function connect($host, $user, $pwd, $dbname, $dbprefix);
67 * return true if users table already exists
69 public function users_table_exists();
73 * throws an err_query error in case users table already exists.
75 public function create_users_table();
78 * return true if items table already exists
80 public function items_table_exists();
84 * throws an err_query error in case items table already exists.
86 public function create_items_table();
89 * set password $pwd for user $usrname. If $usrname does not exist, create
92 public function setpwd($usrname, $pwd);
95 * check that $pwd_md5 is md5 for $username password.
97 public function checkpwdmd5($usrname, $pwd_md5);
100 * saves feature in database. If feature has an id, feature will be updated
101 * in database; otherwise it will be created. Returns saved feature
103 public function save_feature($feature);
106 * delete feature from database. Returns true in case of success, even if
107 * image was not referenced in the database.
109 public function delete_feature($feature);
112 * Returns feature with given id. If none exists, returns null.
114 public function getfeature($id);
117 * returns an array of available features
119 public function listfeatures();
122 * returns true if a feature with imgpath exists
124 public function imgpath_exists($imgpath);
127 * returns Minimum Bounding Rectangle containing all feature locations.
128 * That function must return a result even if database is not functional.
129 * Minimum Bounding Rectangle is presented as an Array:
130 * [bottom, left, top, right]
132 public function mbr();
135 * get name of database backend
137 public function getdbname();