首页
网站导航
关于
Search
1
解决Typecho Joe主题访问fastly.jsdelivr.net速度慢的方案 | 快速优化技巧
2,190 阅读
2
解决WSL2内存不释放问题的最佳指南
1,401 阅读
3
如何在 Typecho Joe 主题的文章中增加目录
1,170 阅读
4
GO语言环境的搭建教程 - 完全指南
1,004 阅读
5
如何解决Win11电脑桌面上方显示横线问题 | 窗口11教程
1,004 阅读
默认分类
编程语言
GO语言
PHP
Node
javascript
html
rust
java
Css
Python
资源分享
chrome插件
阅读思考
运维架构
redis
Nginx
linux
memcached
mongodb
mysql
windows
docker
k8s
Mq
apache
CI
Git
swoole
elk
系统设计
thinkPhp
beego
登录
Search
标签搜索
重要
go基础
git 命令
go包
phpstorm
sublime
thinkphp6
mysql问题
软件分享
redis命令
php基础
thinkphp3.2
php第三扩展包
小蚯蚓博客
累计撰写
333
篇文章
累计收到
48
条评论
首页
栏目
默认分类
编程语言
GO语言
PHP
Node
javascript
html
rust
java
Css
Python
资源分享
chrome插件
阅读思考
运维架构
redis
Nginx
linux
memcached
mongodb
mysql
windows
docker
k8s
Mq
apache
CI
Git
swoole
elk
系统设计
thinkPhp
beego
页面
网站导航
关于
搜索到
1
篇与
的结果
2022-06-21
MongoDB中查询指定距离内坐标数据的详细教程
创建数据和索引 创建集合 db.testGps.insert( { "_id" : NumberLong("908531"), "_class" : "com.xxxxx", "loc" : { "type" : "Point", "coordinates" : [ 121.4624, 31.2262 ] } }); 创建2dsphere索引 db.testGps.createIndex( {"loc" : "2dsphere" } ); 距离查询 第一种方式 // 返回单位为 米 db.testGps.aggregate([ { $geoNear: { near: { type: "Point", coordinates: [121.462,31.226 ] },//coordinates: [0,0] 经度,维度 distanceField: "dis.calculated", // maxDistance: 50000, //指定最大距离,不指定则为最大值 query: { "_id":NumberLong("908531") }, //查询条件 // includeLocs: "dist.location", // num: 5, //返回的行数 ,不写:默认返回所有 spherical: true, //2dsphere 必须指定 // distanceMultiplier:63781 // 不需要 } }]) 第二种方式 //若需要距离单位为 米 则指定 // distanceMultiplier: 6378137 //若需要距离单位为 千米 则指定 // distanceMultiplier: 6378 db.runCommand({ "geoNear":"testGps", "near":[121.462,31.226 ] , // "num":10, spherical:true, distanceMultiplier: 6378137, maxDistance:10, distance:"dis" //距离别名 })
2022年06月21日
246 阅读
0 评论
0 点赞