php - MongoDB inserts geopoint in the wrong order -
php - MongoDB inserts geopoint in the wrong order -
i'm trying insert location in mongodb. aware location should in longitude , latitude order. php code:
... $coordinates=new coordinates(); $coordinates->setlng($lng); $coordinates->setlat($lat); $hospitals->setcoordinates($coordinates); ...
when flushing error :
insertdocument :: caused :: 16755 can't extract geo keys object, malformed geometry?: { _id: objectid('54510e88211b6f133e8b4573'), coordinates: { lat: 35.72701023223023, lng: 137.094778418541 },
why did coordinates flip order ? set them longitude latitude , why object inverted ? precise when creating object longitude before latitude. help please
the 2d indexing documentation advises using longitude/latitude tuples instead of embedded objects, have improve command on field ordering.
arrays preferred languages not guarantee associative map ordering.
in case, 2d coordinate value best mapped collection type in odm, ensure stored bson array in mongodb.
if using 2dsphere
index geojson values, field best mapped hash, ensure bson object storage. there, can create geojson value in php (my geojson library may helpful). hash-mapped route should more flexible creating embedded documents specific geojson type
, coordinates
fields mapped out (see this twitter conversation give-and-take on subject). ultimately, nice odm back upwards geojson mapped field type (to convert mongodb bson objects to/from geojson classes).
php json mongodb symfony2 doctrine-odm
Comments
Post a Comment