|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Rawaby88\OpenWeatherMap\Services; |
|
4
|
|
|
|
|
5
|
|
|
use Rawaby88\OpenWeatherMap\Interfaces\CWMultiResultInterface; |
|
6
|
|
|
use Rawaby88\OpenWeatherMap\Traits\CWMultiResultTrait; |
|
7
|
|
|
use Rawaby88\OpenWeatherMap\WeatherFactory; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class CWByRectangleZone. |
|
11
|
|
|
*/ |
|
12
|
|
|
class CWByRectangleZone extends WeatherFactory implements CWMultiResultInterface |
|
13
|
|
|
{ |
|
14
|
|
|
use CWMultiResultTrait; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var float Bounding box lon-left. |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $lonLeft; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var float Bounding box lat-bottom. |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $latBottom; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var float Bounding box lon-right. |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $lonRight; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var float Bounding box lat-top. |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $latTop; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var float Bounding box zoom. |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $zoom; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* CWByRectangleZone constructor. |
|
43
|
|
|
* |
|
44
|
|
|
* returns the data from cities within the defined rectangle specified by the geographic coordinates. |
|
45
|
|
|
* There is a limit of 25 square degrees for Free and Startup plans. |
|
46
|
|
|
* |
|
47
|
|
|
* @param float $lonLeft Bounding box lon-left. |
|
48
|
|
|
* @param float $latBottom Bounding box lat-bottom. |
|
49
|
|
|
* @param float $lonRight Bounding box lon-right. |
|
50
|
|
|
* @param float $latTop Bounding box lat-top. |
|
51
|
|
|
* @param float $zoom Bounding box zoom. |
|
52
|
|
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __construct(float $lonLeft, float $latBottom, float $lonRight, float $latTop, float $zoom) |
|
55
|
|
|
{ |
|
56
|
|
|
parent::__construct(); |
|
57
|
|
|
$this->apiCall = 'box/city'; |
|
58
|
|
|
$this->lonLeft = $lonLeft; |
|
59
|
|
|
$this->latBottom = $latBottom; |
|
60
|
|
|
$this->lonRight = $lonRight; |
|
61
|
|
|
$this->latTop = $latTop; |
|
62
|
|
|
$this->zoom = $zoom; |
|
63
|
|
|
$this->params = $this->paramsToArray(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Generate query parameters for api call. |
|
68
|
|
|
* @return array |
|
69
|
|
|
*/ |
|
70
|
|
|
private function paramsToArray(): array |
|
71
|
|
|
{ |
|
72
|
|
|
$box = $this->lonLeft.','.$this->latBottom.','.$this->lonRight.','.$this->latTop.','.$this->zoom; |
|
73
|
|
|
|
|
74
|
|
|
return ['bbox' => $box]; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|