123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace App\Yr\Forecast\Tabular\Time;
- /**
- * Wind direction
- *
- * @author Joachim M. Giæver (joachim[]giaever.org)
- */
- class WindDirection extends AbstractUnit{
- const DEFAULT_VARIANCE = 22.5;
- private $name;
- /**
- * @param \SimpleXMLElement $xml XML element containing the wind direction
- */
- public function __construct(\SimpleXMLElement $xml) {
- parent::__construct(
- (float)$xml['deg'],
- (string)$xml['code']
- );
- $this->name = (string)$xml['name'];
- }
- /**
- * Returns the wind direction in full,
- * e.g «Northeast».
- *
- * @return string
- */
- public function getName(): string {
- return $this->name;
- }
- /**
- * {@inheritDoc}
- */
- public function diff(DiffInterface $d): int {
- if ($diff = parent::diff($d))
- return $diff > static::DEFAULT_VARIANCE ? 1 : 0;
- return 0;
- }
- }
|