示例#1
0
 /**
  * Factory method to create an instance and extract the data from the given JSON object
  *
  * @param   object     $json  The item JSON
  * @param   Location   $obj    An object or null to create it
  * @return  Location           The created instance
  */
 public static function createFromJson($json, Location $obj = null)
 {
     if (!is_object($obj)) {
         throw new \InvalidArgumentException('Argument must be an object');
     }
     if ($json->name) {
         $obj->name = html_entity_decode($json->name, null, 'UTF-8');
     }
     $obj->coordinate = Coordinate::createFromJson($json);
     return $obj;
 }
示例#2
0
 /**
  * {@inheritDoc}
  */
 public function toXml(\SimpleXMLElement $parent = null)
 {
     if (null !== $parent) {
         $xml = $parent->addChild('Address');
     } else {
         $xml = new \SimpleXMLElement('<Address />');
     }
     $xml['name'] = $this->name;
     // x and y inverted for HAFAS
     if ($this->coordinate->x) {
         $xml['y'] = Coordinate::floatToInt($this->coordinate->x);
     }
     if ($this->coordinate->y) {
         $xml['x'] = Coordinate::floatToInt($this->coordinate->y);
     }
     return $xml;
 }
示例#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)];
 }
示例#4
0
 /**
  * @dataProvider provider
  */
 public function testIntToFloat($source, $int, $float)
 {
     $this->assertEquals($float, Coordinate::intToFloat($int));
 }
示例#5
0
 public function toArray()
 {
     return array('performLocating' => '2', 'tpl' => 'stop2json', 'look_maxno' => $this->limit, 'look_stopclass' => 1023, 'look_maxdist' => 5000, 'look_y' => Coordinate::floatToInt($this->lat), 'look_x' => Coordinate::floatToInt($this->lon));
 }