1 | <?php |
||
8 | class Tree extends Element |
||
9 | { |
||
10 | const DATA_TREE_FILENAME = "index.json"; |
||
11 | const GEO_FEATURE_FILENAME = "geo.json"; |
||
12 | const NONE_TIMEZONE = "none"; |
||
13 | protected $dataTree = null; |
||
14 | protected $dataDirectory; |
||
15 | protected $utils; |
||
16 | |||
17 | /** |
||
18 | * Tree constructor. |
||
19 | * @param $dataDirectory |
||
20 | */ |
||
21 | 25 | public function __construct($dataDirectory=null) |
|
31 | |||
32 | /** |
||
33 | * Data tree is loaded from json file |
||
34 | */ |
||
35 | 25 | public function initializeDataTree() |
|
40 | |||
41 | /** |
||
42 | * Load json features data from a particular geo quadrant path |
||
43 | * @param $quadrantPath |
||
44 | * @return mixed |
||
45 | */ |
||
46 | 7 | protected function loadFeatures($quadrantPath) |
|
53 | |||
54 | /** |
||
55 | * Check if a particular location (latitude, longitude)is IN a particular quadrant |
||
56 | * @param $quadrantPath |
||
57 | * @param $latitude |
||
58 | * @param $longitude |
||
59 | * @return string |
||
60 | */ |
||
61 | 7 | protected function evaluateFeatures($quadrantPath, $latitude, $longitude) |
|
67 | |||
68 | /** |
||
69 | * Get valid timezone |
||
70 | * @param $zoneData |
||
71 | * @param $quadrantPath |
||
72 | * @param $latitude |
||
73 | * @param $longitude |
||
74 | * @return string |
||
75 | * @throws ErrorException |
||
76 | */ |
||
77 | 17 | protected function evaluateQuadrantData($zoneData, $quadrantPath, $latitude, $longitude) |
|
89 | |||
90 | /** |
||
91 | * Check if timezone is valid |
||
92 | * @param $timeZone |
||
93 | * @return bool |
||
94 | */ |
||
95 | 17 | protected function isValidTimeZone($timeZone) |
|
99 | |||
100 | /** |
||
101 | * Main function for looking the timezone associated to a particular location (latitude, longitude) |
||
102 | * @param $latitude |
||
103 | * @param $longitude |
||
104 | * @return string |
||
105 | * @throws ErrorException |
||
106 | */ |
||
107 | 17 | public function lookForTimeZone($latitude, $longitude) |
|
131 | } |
||
132 |