sql >> Base de Datos >  >> NoSQL >> MongoDB

Almacenar polígonos GeoJSON en MongoDB

Con MongoDB 2.4, use el índice "2dsphere" para GeoJSON Points, LineStrings y Polygons.

Por ejemplo, puede crear este índice:

db.mycoll.ensureIndex( { loc : "2dsphere" } )

Y almacene este LineString:

{ loc : { type : "LineString" , coordinates : [ [ 1 , 2 ] , [ 3 , 4 ] ] } }

Consulte http://docs.mongodb.org/manual/applications/2dsphere/ .