1 | <?php |
||
15 | class Circle extends \Maps\Elements\BaseFillableElement { |
||
16 | |||
17 | private $circleCentre; |
||
18 | private $circleRadius; |
||
19 | |||
20 | 7 | public function __construct( LatLongValue $circleCentre, float $circleRadius ) { |
|
21 | 7 | if ( !is_float( $circleRadius ) && !is_int( $circleRadius ) ) { |
|
22 | throw new InvalidArgumentException( '$circleRadius must be a float or int' ); |
||
23 | } |
||
24 | |||
25 | 7 | if ( $circleRadius <= 0 ) { |
|
26 | 2 | throw new InvalidArgumentException( '$circleRadius must be greater than zero' ); |
|
27 | } |
||
28 | |||
29 | 5 | $this->setCircleCentre( $circleCentre ); |
|
30 | 5 | $this->setCircleRadius( $circleRadius ); |
|
31 | 5 | } |
|
32 | |||
33 | 1 | public function getJSONObject( string $defText = '', string $defTitle = '' ): array { |
|
34 | 1 | return array_merge( |
|
35 | 1 | parent::getJSONObject( $defText, $defTitle ), |
|
36 | [ |
||
37 | 'centre' => [ |
||
38 | 1 | 'lon' => $this->getCircleCentre()->getLongitude(), |
|
39 | 1 | 'lat' => $this->getCircleCentre()->getLatitude() |
|
40 | ], |
||
41 | 1 | 'radius' => intval( $this->getCircleRadius() ), |
|
42 | ] |
||
43 | ); |
||
44 | } |
||
45 | |||
46 | 5 | public function getCircleCentre(): LatLongValue { |
|
49 | |||
50 | 5 | public function setCircleCentre( LatLongValue $circleCentre ) { |
|
51 | 5 | $this->circleCentre = $circleCentre; |
|
53 | |||
54 | 5 | public function getCircleRadius(): float { |
|
57 | |||
58 | 5 | public function setCircleRadius( float $circleRadius ) { |
|
61 | |||
62 | } |
||
63 |