1
0
Fork 0
arangodb/Documentation/Examples/008_collectionNearDistance....

42 lines
887 B
Plaintext

arangosh> db.geo.ensureGeoIndex("loc");
{
"id" : "geo/170718091",
"type" : "geo1",
"fields" : [
"loc"
],
"geoJson" : false,
"constraint" : false,
"unique" : false,
"ignoreNull" : true,
"sparse" : true,
"isNewlyCreated" : true,
"code" : 201
}
arangosh> for (var i = -90; i <= 90; i += 10) { for (var j = -180; j <= 180; j += 10) { db.geo.save({ name : "Name/" + i + "/" + j, loc: [ i, j ] }); } }
arangosh> db.geo.near(0, 0).distance().limit(2).toArray();
[
{
"_id" : "geo/240120715",
"_key" : "240120715",
"_rev" : "240120715",
"name" : "Name/0/0",
"loc" : [
0,
0
],
"distance" : 0
},
{
"_id" : "geo/232846219",
"_key" : "232846219",
"_rev" : "232846219",
"name" : "Name/-10/0",
"loc" : [
-10,
0
],
"distance" : 1111949.2664455874
}
]