Exemplo n.º 1
0
 public function testGeoPointType()
 {
     $message = NestedMessage::create();
     $geoJson = '{"type":"Point","coordinates":[102.0,0.5]}';
     $point = GeoPoint::fromArray(json_decode($geoJson, true));
     $message->set('location', $point);
     $this->assertSame($message->get('location')->getLatitude(), 0.5);
     $this->assertSame($message->get('location')->getLongitude(), 102.0);
     $this->assertSame($message->toArray()['location'], $point->toArray());
 }
Exemplo n.º 2
0
 /**
  * @param mixed $value
  * @param Field $field
  *
  * @return GeoPoint
  */
 public function decodeGeoPoint($value, Field $field)
 {
     return GeoPoint::fromArray($value);
 }
Exemplo n.º 3
0
 /**
  * @param GeoPoint $geoPoint
  * @param Field $field
  *
  * @return mixed
  */
 public function encodeGeoPoint(GeoPoint $geoPoint, Field $field)
 {
     return ['M' => ['type' => [self::TYPE_STRING => 'Point'], 'coordinates' => ['L' => [[self::TYPE_NUMBER => (string) $geoPoint->getLongitude()], [self::TYPE_NUMBER => (string) $geoPoint->getLatitude()]]]]];
 }
Exemplo n.º 4
0
 /**
  * @param GeoPoint $geoPoint
  * @param Field $field
  *
  * @return mixed
  */
 public function encodeGeoPoint(GeoPoint $geoPoint, Field $field)
 {
     return [$geoPoint->getLongitude(), $geoPoint->getLatitude()];
 }