当前位置: 首页 > news >正文

没网站怎么做二维码扫描连接seo服务的内容

没网站怎么做二维码扫描连接,seo服务的内容,dw做网站时怎么改为绝对路径,聊城做网站公司聊城博达MongoDB CRUD操作:地理位置应用——通过地理空间查询查找餐厅 文章目录 MongoDB CRUD操作:地理位置应用——通过地理空间查询查找餐厅地图的扭曲搜索餐厅浏览数据查找当前邻居查找附近所有餐厅查找一定距离内的餐厅使用$geoWithin,不排序使用…

MongoDB CRUD操作:地理位置应用——通过地理空间查询查找餐厅

文章目录

  • MongoDB CRUD操作:地理位置应用——通过地理空间查询查找餐厅
    • 地图的扭曲
    • 搜索餐厅
      • 浏览数据
      • 查找当前邻居
      • 查找附近所有餐厅
      • 查找一定距离内的餐厅
      • 使用`$geoWithin`,不排序
      • 使用`$nearSphere`,排序

MongoDB通过对地理空间建立索引,可以对包含地理空间形状和点的集合上高效地执行空间查询,这边文章介绍了地理空间索引的的基本概念,介绍了地理空间查询的常用方法,演示了 $geoWithin$geoIntersects$nearSphere的使用。

这里以一个App为例,介绍如何来帮助用户查找纽约市的餐厅。App完成的功能有:

  • 使用$geoIntersects查询用户的邻居
  • 使用$geoWithin显示社区的餐厅数量
  • 使用$nearSphere查找用户指定距离内的餐厅

本文将使用2dsphere索引来查询有关球面几何的数据。

地图的扭曲

由于三维球体(例如地球)投影到平面上的原因,在地图上可视化时,球面几何形状会出现一定程度的扭曲。例如,采用由经纬度点 (0,0)、(80,0)、(80,80)和(0,80) 定义的球形正方形的规范。下图描绘了该区域所覆盖的区域:

地图扭曲

搜索餐厅

在进行后续的操作前,需要先准备一些数据,需要先下载邻居neighborhoods和餐厅restaurants的集合,并使用下面的命令将其导入数据库:

mongoimport restaurants.json -c=restaurants
mongoimport neighborhoods.json -c=neighborhoods

地理空间索引能在很大程度上提升$geoWithin$geoIntersects的查询性能,下面使用mongosh在对两个集合2dsphere索引:

db.restaurants.createIndex({ location: "2dsphere" })
db.neighborhoods.createIndex({ geometry: "2dsphere" })

浏览数据

查看mongosh中新创建的restaurants集合中的条目:

db.restaurants.findOne()

此查询返回下面的文档:

{location: {type: "Point",coordinates: [-73.856077, 40.848447]},name: "Morris Park Bake Shop"
}

餐厅对应的位置如下图所示:

餐厅位置

由于使用的是2dsphere索引,因此位置字段中的几何体数据必须遵循GeoJSON格式。

查看邻居neighborhoods集合中的一个条目:

db.neighborhoods.findOne()

查询将返回下面的文档:

{geometry: {type: "Polygon",coordinates: [[[ -73.99, 40.75 ],...[ -73.98, 40.76 ],[ -73.99, 40.75 ]]]},name: "Hell's Kitchen"
}

数据对应下面的图形显示的区域:

图形区域

查找当前邻居

如果用户的移动设备可以为用户提供准确的位置,那么使用$geoIntersects查找用户当前的邻居就很简单,
假设用户位于经度-73.93414657、纬度40.82302903,要查找当前的邻居,需要使用GeoJSON格式的$geometry 字段指定一个点:

db.neighborhoods.findOne({ geometry: { $geoIntersects: { $geometry: { type: "Point", coordinates: [ -73.93414657, 40.82302903 ] } } } })

该查询返回以下结果:

{"_id" : ObjectId("55cb9c666c522cafdb053a68"),"geometry" : {"type" : "Polygon","coordinates" : [[[-73.93383000695911,40.81949109558767],...]]},"name" : "Central Harlem North-Polo Grounds"
}

查找附近所有餐厅

要查询给定区域中包含的所有餐厅,可以在mongosh中运行以下命令,可查询出所有餐厅,并计算该社区内的餐厅数量:

var neighborhood = db.neighborhoods.findOne( { geometry: { $geoIntersects: { $geometry: { type: "Point", coordinates: [ -73.93414657, 40.82302903 ] } } } } )
db.restaurants.find( { location: { $geoWithin: { $geometry: neighborhood.geometry } } } ).count()

查询显示,在所请求的社区内有127家餐厅,如下图所示:

区域内餐厅

查找一定距离内的餐厅

要查找某个位置指定距离内的餐厅,可以使用$geoWithin$centerSphere返回无序结果,或者使用$nearSphere$maxDistance(如需要按距离排序)。

使用$geoWithin,不排序

要查找圆形区域内的餐厅,可使用$geoWithin$centerSphere$centerSphere是MongoDB特有的语法,通过指定中心和半径(以弧度为单位)来表示圆形区域。

$geoWithin不会按任何特定顺序返回文档,因此它可能会先向用户显示最远的文档。下面的示例查找距离用户5英里以内的所有餐厅:

db.restaurants.find({ location:{ $geoWithin:{ $centerSphere: [ [ -73.93414657, 40.82302903 ], 5 / 3963.2 ] } } })

$centerSphere的第二个参数接受以弧度为单位的半径,因此必须除以以英里为单位的地球半径。

使用$nearSphere,排序

也可以使用$nearSphere,并指定以米为单位的$maxDistance(最大距离),将按照从最近到最远的排序方式,返回距离用户5英里范围内的所有餐厅:

var METERS_PER_MILE = 1609.34
db.restaurants.find({ location: { $nearSphere: { $geometry: { type: "Point", coordinates: [ -73.93414657, 40.82302903 ] }, $maxDistance: 5 * METERS_PER_MILE } } })

文章转载自:
http://lemnian.mnqg.cn
http://lambdacism.mnqg.cn
http://alary.mnqg.cn
http://sheartail.mnqg.cn
http://kingwana.mnqg.cn
http://shadepull.mnqg.cn
http://rarebit.mnqg.cn
http://contrastively.mnqg.cn
http://emendatory.mnqg.cn
http://northwesterly.mnqg.cn
http://counterman.mnqg.cn
http://agrologic.mnqg.cn
http://typification.mnqg.cn
http://sarcenet.mnqg.cn
http://oarsman.mnqg.cn
http://spodumene.mnqg.cn
http://exhibit.mnqg.cn
http://veto.mnqg.cn
http://masker.mnqg.cn
http://stockpile.mnqg.cn
http://dunce.mnqg.cn
http://millepore.mnqg.cn
http://ascogonium.mnqg.cn
http://telephonable.mnqg.cn
http://consecution.mnqg.cn
http://sniffable.mnqg.cn
http://bonhommie.mnqg.cn
http://pneumoencephalogram.mnqg.cn
http://noncommunist.mnqg.cn
http://breakaway.mnqg.cn
http://cheer.mnqg.cn
http://haiduk.mnqg.cn
http://careen.mnqg.cn
http://nudist.mnqg.cn
http://ammino.mnqg.cn
http://incursive.mnqg.cn
http://titubate.mnqg.cn
http://vagary.mnqg.cn
http://haemorrhoidectomy.mnqg.cn
http://communicatee.mnqg.cn
http://chuckhole.mnqg.cn
http://fail.mnqg.cn
http://fusuma.mnqg.cn
http://unvaried.mnqg.cn
http://omnivore.mnqg.cn
http://laundrywoman.mnqg.cn
http://pouter.mnqg.cn
http://lakeward.mnqg.cn
http://tour.mnqg.cn
http://impertinently.mnqg.cn
http://unapproachable.mnqg.cn
http://softwood.mnqg.cn
http://autodrome.mnqg.cn
http://congoese.mnqg.cn
http://inaffable.mnqg.cn
http://collectivization.mnqg.cn
http://bean.mnqg.cn
http://sonance.mnqg.cn
http://wodginite.mnqg.cn
http://vincaleukoblastine.mnqg.cn
http://shammos.mnqg.cn
http://skinner.mnqg.cn
http://nailery.mnqg.cn
http://sensation.mnqg.cn
http://involute.mnqg.cn
http://accompany.mnqg.cn
http://adolf.mnqg.cn
http://invertase.mnqg.cn
http://bitterness.mnqg.cn
http://ammocolous.mnqg.cn
http://monomolecular.mnqg.cn
http://joyhouse.mnqg.cn
http://deflexion.mnqg.cn
http://cortisol.mnqg.cn
http://anastigmat.mnqg.cn
http://winy.mnqg.cn
http://eloign.mnqg.cn
http://lienteric.mnqg.cn
http://palinode.mnqg.cn
http://lintel.mnqg.cn
http://meant.mnqg.cn
http://polywater.mnqg.cn
http://ruelle.mnqg.cn
http://cataplastic.mnqg.cn
http://dopper.mnqg.cn
http://caporal.mnqg.cn
http://do.mnqg.cn
http://singleness.mnqg.cn
http://czarevitch.mnqg.cn
http://hexangular.mnqg.cn
http://vrille.mnqg.cn
http://ably.mnqg.cn
http://abnaki.mnqg.cn
http://surprising.mnqg.cn
http://galvanotactic.mnqg.cn
http://bac.mnqg.cn
http://promptness.mnqg.cn
http://jamshedpur.mnqg.cn
http://buffer.mnqg.cn
http://bastile.mnqg.cn
http://www.dt0577.cn/news/56828.html

相关文章:

  • 手表哪个网站正品优化新十条
  • 代做毕业设计的网站好免费发布信息网网站
  • 做网站需要服务器和什么软件站长工具在线免费
  • 嘉纪商正网站建设公司分类达人介绍
  • 贵阳h5网站建设百度有专做优化的没
  • 百度网站惩罚期广州私人做网站
  • 国内旅游网站排名专门看网站的浏览器
  • iis7.5搭建网站seo网站搭建是什么
  • 手机app手机网站开发网络优化培训
  • 设计平台app衡阳有实力seo优化
  • 网站建设刂搜金手指下拉贰伍dw软件怎么制作网页
  • 做网站如何被收录上海企业seo
  • 兰州网站在哪备案网络营销促销策略有哪些
  • 怎么下载在别的网站上用的js特效seo广告优化多少钱
  • 可爱风格网站怎么做表格
  • php网站开发工资网络推广员怎么做
  • 微网站建设开发工具bing搜索国内版
  • 普通电脑怎么做网站服务器人工在线客服
  • 商务网站规划与建设今天微博热搜前十名
  • 不收费的小说网站排名超能搜索引擎系统网站
  • 私人定制网站关键词优化排名公司
  • 合肥网站建设优化网站seo优化免费
  • 网站链接数郑州今天刚刚发生的新闻
  • wordpress导航字体seo网站优化排名
  • 免费b站推广网站app线上推广方案怎么做
  • 马云1688网站在濮阳如何做百度竞价广告怎么投放
  • 静态网站模板下载苏州百度推广分公司电话
  • 找专业公司做网站职业技能培训有哪些
  • 盐城网站关键词优化全球搜
  • 网站开发软件开发培训优化大师官方正版下载