mongodb - Geospatial filtering of documents with locations within a given radius from given point with LoopbackJS -
there requirement query documents within radius given point. if use mongodb database, can following:
- create geospatial 2dsphere index;
- save data in proper format;
- filter documents within distance of 10 miles given location do:
db.location.find({loc: {$geowithin: {$centersphere: [[-110.111111, 30.333333], 10 / 3963.2]}}})
what proper way achieve same using loopback's geopoint
, near
, lt
?
crossposted here well: https://groups.google.com/forum/#!topic/loopbackjs/ncg7ndj-eeq
location.find({where: {loc: {near: [-110.111111, 30.333333], maxdistance: 10}}})
this 'location' model name. 'loc' location field. 'near' specifies center coordinates. , 'maxdistance' specifies area cover.
also, 2d indexes.
Comments
Post a Comment