2014-10-30 3 views
1
와 MongoDB를에 GeoJson를 저장하려면 어떻게해야
나는 교리 ODM을 사용하여 MongoDB에 GeoJson 형식의 위치를 ​​저장하기 위해 노력하고있어

: 은 내가 할 것은 :
매핑 :내가 PHP

class Coordinates 
{ 

    /** @MongoDB\String */ 
    protected $type; 

    /** @MongoDB\Hash */ 
    protected $coordinates; 

    public function __construct($type='Point',$coordinates) 
    { 
     $this->setType($type); 
     $this->setCoordinates($coordinates); 
    } 

한 위치를 저장하려고하면 다음과 같이 표시됩니다.

coordinates: { type: "Point", coordinates: { 0: -6.855243444442749, 1: 33.9704221689807 } } 

이것은 GeoJson 형식이 아닙니다. 올바른 형식은

coordinates: { type: "Point", coordinates: [ -6.855243444442749,33.9704221689807 ] } 

이어야합니다. 어떻게해야합니까? 대단히 감사합니다!

편집! 이것은 PHP로 저장하는 방법입니다.

답변

1

예! 트위터에서 내 대답을 얻었습니다 : P 전체 좌표 필드를 해시로 매핑해야합니다.