1
내 MongoDB의 수집에 다음과 같이 기록을 데가 반환됩니다
/* 1 */
{
"_id" : ObjectId("58ecf141624bc0798ee5882d"),
"username" : "user.sthlm",
"location" : [
18.0686,
59.3293
]
}
/* 2 */
{
"_id" : ObjectId("58ecf141624bc0798ee5882e"),
"username" : "user.malmo",
"location" : [
13.0038,
55.605
]
}
/* 3 */
{
"_id" : ObjectId("58ecf141624bc0798ee5882f"),
"username" : "user.la",
"location" : [
-118.2437,
34.0522
]
}
"위치"는 "2dsphere"유형과 순서에 [경도, 위도]
는 지금은 = 특정 시점
(스톡홀름 좌표) 경도 = 18.0686 위도 사이의 거리를 검색하기 위해 아래와 같이 pymongo 쿼리를 사용하고 59.3293
012 스톡홀름와 LA 사이의 거리가 1.393869662777678로 재선되는 쿼리 응답{
"distance": 0,
"username": "user.sthlm"
},
{
"distance": 0.08048218816530191,
"username": "user.malmo"
},
{
"distance": 1.393869662777678,
"username": "user.la"
}
다음과 같이 3,516,
for doc in self.users.aggregate([{"$geoNear": {"near": [longitude, latitude],
"distanceField":"distance",
"distanceMultiplier": 1.0,
"num": int(count),
"spherical": True}}]):
결과이다. 어느 유닛에 있는지 잘 모르겠습니다.
Google지도에서 좌표 사이의 거리는 8,875 킬로미터 (5,515 마일)이고 1.3938은 어느 쪽의 법안에도 맞지 않습니다. mongoDB 설명서에서, 결과가 라디안으로 반환되지 않습니다 참조하십시오. 그래서 내 쿼리 응답에서 무엇을 참조해야하는지 궁금합니다.
감사
작동합니다. 6371에 어떻게 도착했는지 알아? – slysid
https://www.google.com/search?q=convert+radians+to+kilometers –