赵走x博客
网站访问量:151932
首页
书籍
软件
工具
古诗词
搜索
登录
11、mac使用Django连接Mysql报错:_mysql.cpython-37m-darwin.so Reason: image not found
10、pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
9、Python3 celery requests 中文乱码 UnicodeEncodeError: 'latin-1' codec can't encode characters in position
8、Python3之socket编程--2:基于TCP的套接字
Anaconda 入门
Can't find model 'en'
Jupyter Notebook 简单安装
pycharm运行matplotlib出现ValueError: max() arg is an empty sequence问题
pygmo 找不到安装包问题
1、pycharm 程序一直测试状态下运行
graphviz . NotADirectoryError: [Errno 20] Not a directory: 'dot'
image not found
sklearn无法加载fetch_mldata解决方案
MongoDB 坐标_距离
cv2.imread 总为None
vs code: Class 'Activity' has no 'objects' memberpylint(no-member)
AbortedError: Operation received an exception:Status
1、部署人工智能项目:YangZeyu95
pip安装加速
nltk语料库路径设置
No module named 'pymysql'
linux服务器报错—UnicodeEncodeError 'ascii' codec can't encode characters in position 0-1
DevToolsActivePort file doesn't exist.
linux Message: unknown error: unable to discover open pages
Python爬虫:常用的浏览器请求头User-Agent
ModuleNotFoundError: No module named 'MySQLdb'
mac下解决matplotlib乱码的问题
Flask 运行跨域
mongoengine 判断ObjectID 字段是否存在
python下使用pip freeze >requirements.txt命令迁移模块
Python爬取百度,返回 安全认证
flask-migrate 修改 sqlite的表头,sqlite3.OperationalError: near "DROP": syntax error
pip 安装提示超时
MongoDB 坐标_距离
资源编号:75927
Python 相关Bug
Python
热度:114
获取 距离
# 创建集合 ``` 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" //距离别名 }) ``` # python mongoengine: ``` acs=Activity.objects.aggregate( {'$geoNear':{ 'near':{'type':'Point','coordinates':[x,y]}, 'distanceField':'location', 'maxDistance':max_distance, 'num':19 }} ) for ac in acs: ac['_id']=str(ac['_id']) x=Activity.from_json(json.dumps(ac)) print(type(x)) print(x) ``` 参考:https://blog.csdn.net/forandever/article/details/44751801 参考:http://makaidong.com/xiaoyu411502/1/194475_9677400_2.htm 参考:https://docs.mongodb.org/manual/core/2dsphere/ 参考:https://docs.mongodb.org/manual/reference/geojson/