コード例 #1
0
ファイル: Longitude.php プロジェクト: sagittariusx/beluga.gis
 /**
  * Extracts a {@see \Beluga\GIS\Longitude} instance from defined value and returns it by reference with the
  * $output parameter. The Method returns TRUE on success, FALSE otherwise.
  *
  * @param  string|double|float|\SimpleXMLElement|\Beluga\GIS\Longitude|\Beluga\GIS\Coordinate $value
  * @param  \Beluga\GIS\Longitude|null &$output Returns the resulting Longitude reference, if the method returns TRUE
  * @return boolean
  */
 public static function TryParse($value, &$output) : bool
 {
     if (\is_null($value)) {
         return false;
     }
     if ($value instanceof Longitude) {
         $output = $value;
         return true;
     }
     if ($value instanceof Coordinate) {
         $output = $value->Longitude;
         return true;
     }
     if (\is_double($value) || \is_float($value)) {
         $data = AbstractElement::_DecToDDMS($value, true);
         try {
             $output = new Longitude($data['DIR'], $data['DEG'], $data['MIN'], $data['SEC']);
         } catch (\Throwable $ex) {
             return false;
         }
         return true;
     }
     $type = new Type($value);
     if (!$type->hasAssociatedString()) {
         return false;
     }
     return self::TryParseString($type->getStringValue(), $output);
 }