-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathclass.rectangle.php
More file actions
88 lines (70 loc) · 1.79 KB
/
class.rectangle.php
File metadata and controls
88 lines (70 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace WPGMZA;
if(!defined('ABSPATH'))
return;
class Rectangle extends Feature
{
private $_cornerA;
private $_cornerB;
public function __construct($id_or_fields=-1, $read_mode=Crud::SINGLE_READ)
{
global $wpdb;
global $WPGMZA_TABLE_NAME_RECTANGLES;
$this->_cornerA = new LatLng();
$this->_cornerB = new LatLng();
Crud::__construct($WPGMZA_TABLE_NAME_RECTANGLES, $id_or_fields, $read_mode);
}
protected function get_column_parameter($name)
{
switch($name)
{
case "cornerA":
case "cornerB":
return "POINT(" . floatval($this->{"_$name"}->lat) . " " . floatval($this->{"_$name"}->lng) . ")";
break;
default:
break;
}
return Crud::get_column_parameter($name);
}
public function __get($name)
{
switch($name) {
case "cornerA":
case "cornerB":
return $this->{"_$name"};
break;
default:
break;
}
return Feature::__get($name);
}
public function __set($name, $value)
{
switch($name) {
case "cornerA":
case "cornerB":
$this->{"_$name"} = new LatLng($value);
break;
default:
Feature::__set($name, $value);
break;
}
}
public function set($arg, $val=null)
{
if(is_array($arg) && isset($arg['cornerA']))
$arg['cornerA'] = $this->_cornerA = new LatLng($arg['cornerA']);
else if(is_object($arg) && isset($arg->cornerA))
$arg->cornerA = $this->_cornerA = new LatLng($arg->cornerA);
if(is_array($arg) && isset($arg['cornerB']))
$arg['cornerB'] = $this->_cornerB = new LatLng($arg['cornerB']);
else if(is_object($arg) && isset($arg->cornerB))
$arg->cornerB = $this->_cornerB = new LatLng($arg->cornerB);
Crud::set($arg, $val);
}
public static function get_table_name_static() {
global $WPGMZA_TABLE_NAME_RECTANGLES;
return $WPGMZA_TABLE_NAME_RECTANGLES;
}
}