Ejemplo n.º 1
0
 public function toXml()
 {
     if ($this->isArrivalTime == false) {
         $forwardCount = $this->limit;
         $backwardCount = 0;
     } else {
         $forwardCount = 0;
         $backwardCount = $this->limit;
     }
     $transportationsBinary = Transportations::reduceTransportations($this->transportations);
     $request = $this->createRequest();
     $con = $request->addChild('ConReq');
     $start = $con->addChild('Start');
     $this->srcLocation->toXml($start);
     $prod = $start->addChild('Prod');
     $prod['prod'] = $transportationsBinary;
     if ($this->direct) {
         $prod['direct'] = 1;
     }
     if ($this->sleeper) {
         $prod['sleeper'] = 1;
     }
     if ($this->couchette) {
         $prod['couchette'] = 1;
     }
     if ($this->bike) {
         $filterList = $con->addChild('FilterList');
         $attrFilter = $filterList->addChild('ConReqAttrFilter');
         $attrFilter['mode'] = '1';
         $attrFilter['type'] = 'EXC';
         $attrFilter['value'] = 'VN:VX';
     }
     $dest = $con->addChild('Dest');
     $this->dstLocation->toXml($dest);
     foreach ($this->viaLocations as $location) {
         $via = $con->addChild('Via');
         $location->toXml($via);
         $prod = $via->addChild('Prod');
         $prod['prod'] = $transportationsBinary;
     }
     $reqt = $con->addChild('ReqT');
     if ($this->isArrivalTime) {
         $reqt['a'] = 1;
     } else {
         $reqt['a'] = 0;
     }
     $reqt['date'] = date('Ymd', strtotime($this->date));
     $reqt['time'] = date('H:i', strtotime($this->time));
     $rflags = $con->addChild('RFlags');
     $rflags['b'] = $backwardCount;
     $rflags['f'] = $forwardCount;
     $rflags['sMode'] = $this->searchMode;
     if ($this->changeCount >= 0) {
         $rflags['nrChanges'] = $this->changeCount;
     }
     if ($this->changeExtensionPercent > 0) {
         $rflags['chExtension'] = $this->changeExtensionPercent;
     }
     return $request->asXML();
 }
Ejemplo n.º 2
0
 public function toXml()
 {
     $request = $this->createRequest('STBReq');
     $board = $request->addChild('STBReq');
     $board->addAttribute('boardType', $this->boardType);
     $board->addAttribute('maxJourneys', $this->maxJourneys);
     $board->addChild('Time', $this->date->format('H:i'));
     $period = $board->addChild('Period');
     $dateBegin = $period->addChild('DateBegin');
     $dateBegin->addChild('Date', $this->date->format('Ymd'));
     $dateEnd = $period->addChild('DateEnd');
     $dateEnd->addChild('Date', $this->date->format('Ymd'));
     $tableStation = $board->addChild('TableStation');
     $tableStation->addAttribute('externalId', $this->station->id);
     $board->addChild('ProductFilter', Transportations::reduceTransportations($this->transportations));
     return $request->asXML();
 }
Ejemplo n.º 3
0
 public function toArray()
 {
     return ['performLocating' => '2', 'tpl' => 'stop2json', 'look_maxno' => $this->limit, 'look_stopclass' => Transportations::reduceTransportationsDec($this->transportations, 10), 'look_maxdist' => 5000, 'look_y' => Coordinate::floatToInt($this->lat), 'look_x' => Coordinate::floatToInt($this->lon)];
 }
Ejemplo n.º 4
0
 public function testReduceTransportations()
 {
     $transportations = array('bus', 'ship');
     $this->assertSame('0000101000000000', Transportations::reduceTransportations($transportations));
 }