示例#1
0
 /**
  * @param IPointGlobal $zeroPoint
  * @param IPointGlobal $endPoint
  * @param FieldConfiguration $config
  * @param float $width track width in meters
  */
 public function __construct(IPointGlobal $zeroPoint, IPointGlobal $endPoint, FieldConfiguration $config, $width)
 {
     $this->zeroPoint = $zeroPoint->convertToLocal($config);
     $this->endPoint = $endPoint->convertToLocal($config);
     $diff = $this->endPoint->subtract($this->zeroPoint, $config);
     $this->factor = max(abs($diff->getLatitude()), abs($diff->getLongitude()));
     $this->vector = new LinearVector($diff);
     $absDiff = new LinearVector($endPoint->subtract($zeroPoint));
     $this->cursor = new FieldCursor($this->zeroPoint, $absDiff->getPerpendicular(), $config, $width);
 }
 /**
  * Constructor
  * @param array $config
  * @throws BadParamException
  */
 public function __construct(array $config)
 {
     foreach ($config as $prop => $value) {
         if (property_exists($this, $prop)) {
             $this->{$prop} = $value;
         }
     }
     if (!$this->zeroPoint instanceof IPointGlobal) {
         throw new BadParamException('ZeroPoint must be instance of IPointGlobal');
     }
     if (!$this->endPoint instanceof IPointGlobal) {
         throw new BadParamException('EndPoint must be instance of IPointGlobal');
     }
     if ($this->zeroPoint->equal($this->endPoint, true)) {
         throw new BadParamException("Field Points are equal");
     }
     $offset = $this->endPoint->subtract($this->zeroPoint);
     $this->latOffset = $offset->getLatitude();
     $this->lonOffset = $offset->getLongitude();
     $this->checkPositiveInt($this->latSegments, $this->lonSegments);
     $this->checkPositiveNumber($this->latLength, $this->lonLength);
 }
示例#3
0
 /**
  * Create new Point as a subtraction of the current one and the given
  * @param IPointGlobal $point
  * @return Point
  */
 public function subtract(IPointGlobal $point)
 {
     return new Point($this->latitude - $point->getLatitude(), $this->longitude - $point->getLongitude());
 }