1


我正在尝试使用 Doctrine ODM 在 MongoDb 中以 GeoJson 格式存储位置:我所做的是:
映射:

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 中的方式:

$coordinates=new Coordinates('Point',[$lng,$lat]);
4

1 回答 1

1

是的 !我在推特上得到了答案:PI 应该将整个坐标字段映射为哈希

于 2014-10-30T19:28:45.077 回答