/**
  * @param double|S2Point $radians_or_x
  * @param S2Point $y
  * Return the angle between two points, which is also equal to the distance
  * between these points on the unit sphere. The points do not need to be
  * normalized.
  */
 public function __construct($radians_or_x = null, $y = null)
 {
     if ($radians_or_x instanceof S2Point && $y instanceof S2Point) {
         $this->radians = $radians_or_x->angle($y);
     } else {
         $this->radians = $radians_or_x === null ? 0 : $radians_or_x;
     }
 }
Ejemplo n.º 2
0
 /**
  * Define o tipo da celula
  * 
  * @param type $type
  * @return \ZendT_Report_Cell 
  */
 public function setType($type)
 {
     $this->_type = ucfirst(strtolower($type));
     if ($this->_value instanceof ZendT_Type_Date && !in_array($this->_type, array('Date', 'Datetime', 'Time'))) {
         $this->_type = $this->_value->getType();
     }
     $this->_addStyleName('type', $this->_type);
     return $this;
 }
 /**
  * This is internal to avoid ambiguity about which units are expected.
  * @param double|S1Angle $latRadians
  * @param double|S1Angle $lngRadians
  */
 public function __construct($latRadians = null, $lngRadians = null)
 {
     if ($latRadians instanceof S1Angle && $lngRadians instanceof S1Angle) {
         $this->latRadians = $latRadians->radians();
         $this->lngRadians = $lngRadians->radians();
     } else {
         if ($lngRadians === null && $latRadians instanceof S2Point) {
             $this->latRadians = atan2($latRadians->z, sqrt($latRadians->x * $latRadians->x + $latRadians->y * $latRadians->y));
             $this->lngRadians = atan2($latRadians->y, $latRadians->x);
         } else {
             if ($latRadians === null && $lngRadians === null) {
                 $this->latRadians = 0;
                 $this->lngRadians = 0;
             } else {
                 $this->latRadians = $latRadians;
                 $this->lngRadians = $lngRadians;
             }
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @return bool|string
  */
 function getXml()
 {
     // Return XML for this value
     switch ($this->type) {
         case 'boolean':
             return '<boolean>' . ($this->data ? '1' : '0') . '</boolean>';
             break;
         case 'int':
             return '<int>' . $this->data . '</int>';
             break;
         case 'double':
             return '<double>' . $this->data . '</double>';
             break;
         case 'string':
             return '<string>' . htmlspecialchars($this->data) . '</string>';
             break;
         case 'array':
             $return = '<array><data>' . "\n";
             foreach ($this->data as $item) {
                 $return .= '  <value>' . $item->getXml() . "</value>\n";
             }
             $return .= '</data></array>';
             return $return;
             break;
         case 'struct':
             $return = '<struct>' . "\n";
             foreach ($this->data as $name => $value) {
                 $return .= "  <member><name>{$name}</name><value>";
                 $return .= $value->getXml() . "</value></member>\n";
             }
             $return .= '</struct>';
             return $return;
             break;
         case 'date':
         case 'base64':
             return $this->data->getXml();
             break;
     }
     return false;
 }
Ejemplo n.º 5
0
 /**
  * {@inheritDoc}
  * 
  * @return string
  */
 public function toString()
 {
     $result = '[';
     $result .= get_class($this);
     $result .= ": count=";
     $result .= $this->count;
     $result .= ",bias=";
     if ($this->hasBias()) {
         $result .= $this->biasActivation->toString();
     } else {
         $result .= "false";
     }
     if ($this->contextFedBy != null) {
         $result .= ",contextFed=";
         if ($this->contextFedBy == this) {
             $result .= "itself";
         } else {
             $result .= $this->contextFedBy;
         }
     }
     $result .= "]";
     return $result;
 }
Ejemplo n.º 6
0
 /**
  * Converts a latitude + longitude to UTM format.
  *
  * @param  string  $ellipsoid e.g. 'WGS-84' use one of the \Beluga\Gps\Ext\Ellipsoid::TYPE_* constants
  * @param  \Beluga\GIS\AbstractElement|double $lat The latitude
  * @param  \Beluga\GIS\AbstractElement|double $long The longitude.
  * @return string|FALSE
  */
 public static function LL2Utm(string $ellipsoid, $lat, $long)
 {
     if (!isset(Ellipsoid::$Ellipsoid[$ellipsoid])) {
         // The defined ellipsoid does not exist.
         return false;
     }
     // Get the longitude decimal value
     $ln = $long instanceof AbstractElement ? $long->getDecimalValue() : (\is_double($long) ? $long : \doubleval($long));
     // Get the latitude decimal value
     $lt = $lat instanceof AbstractElement ? $lat->getDecimalValue() : (\is_double($lat) ? $lat : \doubleval($lat));
     // Init some required parameters
     $longOrigin = null;
     $eccPrimeSquared = null;
     $longOriginRad = null;
     $k0 = 0.9996;
     // Doing the calculation
     $a = Ellipsoid::$Ellipsoid[$ellipsoid][0];
     $eccSquared = Ellipsoid::$Ellipsoid[$ellipsoid][1];
     $N = null;
     $T = null;
     $C = null;
     $A = null;
     $M = null;
     $longTemp = $ln + 180.0 - \intval(($ln + 180) / 360) * 360 - 180;
     $latRad = $lt * self::DEG2RAD;
     $longRad = $longTemp * self::DEG2RAD;
     $zoneNumber = \intval(($longTemp + 180) / 6) + 1;
     if ($lt >= 56.0 && $lt < 64.0 && $longTemp >= 3.0 && $longTemp < 12.0) {
         $zoneNumber = 32;
     }
     if ($lt >= 72.0 && $lt < 84.0) {
         if ($longTemp >= 0.0 && $longTemp < 9.0) {
             $zoneNumber = 31;
         } else {
             if ($longTemp >= 9.0 && $longTemp < 22.0) {
                 $zoneNumber = 33;
             } else {
                 if ($longTemp >= 22.0 && $longTemp < 33.0) {
                     $zoneNumber = 35;
                 } else {
                     if ($longTemp >= 33.0 && $longTemp < 42.0) {
                         $zoneNumber = 37;
                     }
                 }
             }
         }
     }
     $longOrigin = ($zoneNumber - 1) * 6 - 180 + 3;
     $longOriginRad = $longOrigin * self::DEG2RAD;
     $UTMZone = \sprintf('%d%s', $zoneNumber, self::UTMLetterDesignator($lt));
     $eccPrimeSquared = $eccSquared / (1 - $eccSquared);
     $N = $a / \sqrt(1 - $eccSquared * \sin($latRad) * \sin($latRad));
     $T = \tan($latRad) * \tan($latRad);
     $C = $eccPrimeSquared * \cos($latRad) * \cos($latRad);
     $A = \cos($latRad) * ($longRad - $longOriginRad);
     $M = $a * ((1 - $eccSquared / 4 - 3 * $eccSquared * $eccSquared / 64 - 5 * $eccSquared * $eccSquared * $eccSquared / 256) * $latRad - (3 * $eccSquared / 8 + 3 * $eccSquared * $eccSquared / 32 + 45 * $eccSquared * $eccSquared * $eccSquared / 1024) * \sin(2 * $latRad) + (15 * $eccSquared * $eccSquared / 256 + 45 * $eccSquared * $eccSquared * $eccSquared / 1024) * \sin(4 * $latRad) - 35 * $eccSquared * $eccSquared * $eccSquared / 3072 * \sin(6 * $latRad));
     $UTMEasting = (double) ($k0 * $N * ($A + (1 - $T + $C) * $A * $A * $A / 6 + (5 - 18 * $T + $T * $T + 72 * $C - 58 * $eccPrimeSquared) * $A * $A * $A * $A * $A / 120) + 500000.0);
     $UTMEasting = \round($UTMEasting, 0);
     $UTMNorthing = (double) ($k0 * ($M + $N * \tan($latRad) * ($A * $A / 2 + (5 - $T + 9 * $C + 4 * $C * $C) * $A * $A * $A * $A / 24 + (61 - 58 * $T + $T * $T + 600 * $C - 330 * $eccPrimeSquared) * $A * $A * $A * $A * $A * $A / 720)));
     if ($lt < 0) {
         $UTMNorthing += 10000000.0;
     }
     $UTMNorthing = \round($UTMNorthing, 0);
     return "{$UTMZone} E {$UTMEasting} N {$UTMNorthing}";
 }
Ejemplo n.º 7
0
 /**
  * Loads delivery set data, checks if it has payments assigned. If active delivery set id
  * is passed - checks if it can be used, if not - takes first ship set id from list which
  * fits. For active ship set collects payment list info. Returns array containing:
  *   1. all ship sets that has payment (array)
  *   2. active ship set id (string)
  *   3. payment list for active ship set (array)
  *
  * @param string $sShipSet current ship set id (can be null if not set yet)
  * @param oxUser $oUser    active user
  * @param double $oBasket  basket object
  *
  * @return array
  */
 public function getDeliverySetData($sShipSet, $oUser, $oBasket)
 {
     $sActShipSet = null;
     $aActSets = array();
     $aActPaymentList = array();
     if (!$oUser) {
         return;
     }
     $this->_getList($oUser, $oUser->getActiveCountry());
     // if there are no shipping sets we don't need to load payments
     if ($this->count()) {
         // one selected ?
         if ($sShipSet && !isset($this->_aArray[$sShipSet])) {
             $sShipSet = null;
         }
         $oPayList = oxRegistry::get("oxPaymentList");
         $oDelList = oxRegistry::get("oxDeliveryList");
         $oCur = $this->getConfig()->getActShopCurrencyObject();
         $dBasketPrice = $oBasket->getPriceForPayment() / $oCur->rate;
         // checking if these ship sets available (number of possible payment methods > 0)
         foreach ($this as $sShipSetId => $oShipSet) {
             $aPaymentList = $oPayList->getPaymentList($sShipSetId, $dBasketPrice, $oUser);
             if (count($aPaymentList)) {
                 // now checking for deliveries
                 if ($oDelList->hasDeliveries($oBasket, $oUser, $oUser->getActiveCountry(), $sShipSetId)) {
                     $aActSets[$sShipSetId] = $oShipSet;
                     if (!$sShipSet || $sShipSetId == $sShipSet) {
                         $sActShipSet = $sShipSet = $sShipSetId;
                         $aActPaymentList = $aPaymentList;
                         $oShipSet->blSelected = true;
                     }
                 }
             }
         }
     }
     return array($aActSets, $sActShipSet, $aActPaymentList);
 }