Your SlideShare is downloading. ×
MongoDBと位置情報 ~地理空間インデックスの紹介
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

MongoDBと位置情報 ~地理空間インデックスの紹介

10,276

Published on

Published in: Technology
0 Comments
20 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
10,276
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
62
Comments
0
Likes
20
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. db.shopinfo.ensureIndex({ loc : "2d"});db.shopinfo.ensureIndex({ loc : "2d", category: 1 });
  • 2. var lon = 139;var lat = 35;db.shopinfo.save({ name: 喫茶もんご, category: [喫茶店], loc: [lon, lat]});
  • 3. db.shopinfo.find({ loc: [139, 35]});
  • 4. db.shopinfo.find({ loc : { $near : [139.4, 35.4] }});
  • 5. db.shopinfo.find({ loc : { $near : [139.4, 35.4], $maxDistance : 2 }});
  • 6. db.shopinfo.find({ loc : { $near : [139.4, 35.4], $maxDistance : 2 }, category: 喫茶店});
  • 7. db.runCommand({ geoNear: "shopinfo", near: [139.4, 35.4], maxDistance: 2, query: {category: 喫茶店}});
  • 8. { "ns" : "test.shopinfo", "near" : "1110100101001011000011000101000010111011111111011110", "results" : [{ "dis" : 0.5656861498877501, "obj" : { "_id" : ObjectId("4d01f5616919cb54afce6a77"), "name" : "喫茶もんご", "category" : ["喫茶店"], "loc" : [139, 35] } }], "stats" : { "time" : 0, "btreelocs" : 0, "nscanned" : 1, "objectsLoaded" : 1, "avgDistance" : 0.5656861498877501, "maxDistance" : 0.5656861498877501 }, "ok" : 1}
  • 9. db.shopinfo.find({ loc : { $within : { $box : [[130, 30], [140, 35]] } }});db.shopinfo.find({ loc : { $within : { $center : [[135, 35], 4] } }});
  • 10. db.shopinfo.find({ loc : { $nearSphere : [139.4, 35.4] }});db.shopinfo.find({ loc : { $within : { $centerSphere : [[135, 35], 0.1] } }});
  • 11. 1 = 6371 km
  • 12. db.runCommand({ geoNear: "shopinfo", near: [135, 35], query: {category: 喫茶店}, spherical: true});"results" : [{ "dis" : 0.05718377899700883, "obj" : { "loc" : [139, 35] }}],

×