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

国税网站页面申报撤销怎么做小熊代刷推广网站

国税网站页面申报撤销怎么做,小熊代刷推广网站,php初学者网站,搜索引擎案例分析结论GEO数据结构 Redis在3.2版本中加入了对GEO的支持,允许存储地理坐标信息,根据经纬度来检索数据。 GEO本质上是基于sortedSet实现的,在Sorted Set中,每个成员都是与一个分数(score)相关联的,这个分数用于对成员进行排序…

GEO数据结构

Redis在3.2版本中加入了对GEO的支持,允许存储地理坐标信息,根据经纬度来检索数据。

GEO本质上是基于sortedSet实现的,在Sorted Set中,每个成员都是与一个分数(score)相关联的,这个分数用于对成员进行排序。然而,在GEO数据结构中,Redis内部使用一个叫geohash的算法将每个地理位置的经纬度转换为一个64位的整数,这个整数在Sorted Set中被用作分数(score)。用户在使用GEO相关命令进行操作时,通常不需要直接处理这个分数。

以下为应用场景:

  1. 附近的人/地点查询: GEO数据结构可以用来实现“附近的人”或“附近的地点”等功能。比如,社交应用可以利用它来查找附近的用户,餐饮服务应用可以用它来显示用户附近的餐馆或咖啡厅。

  2. 地理位置距离计算: 可以使用GEO数据结构来计算两个地理位置之间的距离,支持不同的单位(米、千米、英里和英尺)。这对于需要展示用户和某个地点之间距离的应用非常有用。

  3. 地理位置信息检索: 应用程序可以利用GEO数据结构存储地点的地理位置信息,并快速检索。例如,旅游应用可以存储景点的位置信息,用户可以查询特定区域内的所有景点。

  4. 基于位置的服务(LBS): GEO数据结构支持构建各种基于位置的服务,如配送服务应用可以使用它来计算配送路线和距离,从而优化配送效率和成本。

  5. 地理围栏(Geofencing): 虽然Redis的GEO数据结构本身不直接支持地理围栏功能,但可以通过与其他功能结合使用来实现。地理围栏允许应用程序在用户进入或离开特定地理区域时触发特定的动作或通知,广泛应用于安全监控、资产跟踪、个性化营销等领域。

  6. 路线规划与导航: 通过结合GEO数据结构和其他算法,可以实现简单的路线规划和导航功能,帮助用户找到从一个地点到另一个地点的最佳路径。

导入店铺数据到GEO

当我们点击美食之后,会出现一系列的商家,商家中可以按照多种排序方式,我们此时关注的是距离,这个地方就需要使用到我们的GEO,向后台传入当前app收集的地址(我们此处是写死的) ,以当前坐标作为圆心,同时绑定相同的店家类型type,以及分页信息,把这几个条件传入后台,后台查询出对应的数据再返回。

Redis中GEO内部结构:

接下来将数据库表中的数据导入到redis中去,redis中的GEO,GEO在redis中就一个menber和一个经纬度,我们把x和y轴传入到redis做的经纬度位置去,但我们不能把所有的数据都放入到menber中去,毕竟作为redis是一个内存级数据库,如果存海量数据,redis还是力不从心,所以我们在这个地方存储他的id即可。但是这个时候还有一个问题,就是在redis中并没有存储type,所以我们无法根据type来对数据进行筛选,所以我们可以按照商户类型做分组,类型相同的商户作为同一组,以typeId为key存入同一个GEO集合中即可。

void loadShopData() {// 1.查询店铺信息List<Shop> list = shopService.list();// 2.把店铺分组,按照typeId分组,typeId一致的放到一个集合Map<Long, List<Shop>> map = list.stream().collect(Collectors.groupingBy(Shop::getTypeId));// 3.分批完成写入Redisfor (Map.Entry<Long, List<Shop>> entry : map.entrySet()) {// 3.1.获取类型idLong typeId = entry.getKey();String key = SHOP_GEO_KEY + typeId;// 3.2.获取同类型的店铺的集合List<Shop> value = entry.getValue();List<RedisGeoCommands.GeoLocation<String>> locations = new ArrayList<>(value.size());// 3.3.写入redis GEOADD key 经度 纬度 memberfor (Shop shop : value) {// stringRedisTemplate.opsForGeo().add(key, new Point(shop.getX(), shop.getY()), shop.getId().toString());locations.add(new RedisGeoCommands.GeoLocation<>(shop.getId().toString(),new Point(shop.getX(), shop.getY())));}stringRedisTemplate.opsForGeo().add(key, locations);}
}

实现附近商户功能

接口:

@GetMapping("/of/type")
public Result queryShopByType(@RequestParam("typeId") Integer typeId,@RequestParam(value = "current", defaultValue = "1") Integer current,@RequestParam(value = "x", required = false) Double x,@RequestParam(value = "y", required = false) Double y
) {return shopService.queryShopByType(typeId, current, x, y);
}

逻辑实现:

@Overridepublic Result queryShopByType(Integer typeId, Integer current, Double x, Double y) {// 1.判断是否需要根据坐标查询if (x == null || y == null) {// 不需要坐标查询,按数据库查询Page<Shop> page = query().eq("type_id", typeId).page(new Page<>(current, SystemConstants.DEFAULT_PAGE_SIZE));// 返回数据return Result.ok(page.getRecords());}// 2.计算分页参数int from = (current - 1) * SystemConstants.DEFAULT_PAGE_SIZE;int end = current * SystemConstants.DEFAULT_PAGE_SIZE;// 3.查询redis、按照距离排序、分页。结果:shopId、distanceString key = SHOP_GEO_KEY + typeId;GeoResults<RedisGeoCommands.GeoLocation<String>> results = stringRedisTemplate.opsForGeo() // GEOSEARCH key BYLONLAT x y BYRADIUS 10 WITHDISTANCE.search(key,GeoReference.fromCoordinate(x, y),new Distance(5000),RedisGeoCommands.GeoSearchCommandArgs.newGeoSearchArgs().includeDistance().limit(end));// 4.解析出idif (results == null) {return Result.ok(Collections.emptyList());}List<GeoResult<RedisGeoCommands.GeoLocation<String>>> list = results.getContent();if (list.size() <= from) {// 没有下一页了,结束return Result.ok(Collections.emptyList());}// 4.1.截取 from ~ end的部分List<Long> ids = new ArrayList<>(list.size());Map<String, Distance> distanceMap = new HashMap<>(list.size());list.stream().skip(from).forEach(result -> {// 4.2.获取店铺idString shopIdStr = result.getContent().getName();ids.add(Long.valueOf(shopIdStr));// 4.3.获取距离Distance distance = result.getDistance();distanceMap.put(shopIdStr, distance);});// 5.根据id查询ShopString idStr = StrUtil.join(",", ids);List<Shop> shops = query().in("id", ids).last("ORDER BY FIELD(id," + idStr + ")").list();for (Shop shop : shops) {shop.setDistance(distanceMap.get(shop.getId().toString()).getValue());}// 6.返回return Result.ok(shops);}


文章转载自:
http://dinncopuritan.tqpr.cn
http://dinncointerpenetration.tqpr.cn
http://dinncopharmaceutics.tqpr.cn
http://dinncothermogenesis.tqpr.cn
http://dinncopalliative.tqpr.cn
http://dinncowolver.tqpr.cn
http://dinncopredestine.tqpr.cn
http://dinncodefenestration.tqpr.cn
http://dinncoecological.tqpr.cn
http://dinncotheistic.tqpr.cn
http://dinncosyllabi.tqpr.cn
http://dinncoscutcher.tqpr.cn
http://dinncopredisposition.tqpr.cn
http://dinncorehabilitation.tqpr.cn
http://dinncocurrier.tqpr.cn
http://dinncoarrantly.tqpr.cn
http://dinncohypomania.tqpr.cn
http://dinncoagranulocytosis.tqpr.cn
http://dinncoobol.tqpr.cn
http://dinncorodster.tqpr.cn
http://dinncoreedify.tqpr.cn
http://dinncoriga.tqpr.cn
http://dinncocollocation.tqpr.cn
http://dinncobelitung.tqpr.cn
http://dinncoephebe.tqpr.cn
http://dinncomuralist.tqpr.cn
http://dinncorecallable.tqpr.cn
http://dinncogliding.tqpr.cn
http://dinncoboodler.tqpr.cn
http://dinncoexhibit.tqpr.cn
http://dinncobarricade.tqpr.cn
http://dinnconagsman.tqpr.cn
http://dinncoinotropic.tqpr.cn
http://dinncoscalpel.tqpr.cn
http://dinncomisarrangement.tqpr.cn
http://dinncoformular.tqpr.cn
http://dinncodeanery.tqpr.cn
http://dinncogoatling.tqpr.cn
http://dinncosporozoite.tqpr.cn
http://dinncodiscontentment.tqpr.cn
http://dinnconeoterist.tqpr.cn
http://dinncoadditional.tqpr.cn
http://dinncofartlek.tqpr.cn
http://dinncoinveiglement.tqpr.cn
http://dinncocalculator.tqpr.cn
http://dinncodixieland.tqpr.cn
http://dinncomapai.tqpr.cn
http://dinncosaxon.tqpr.cn
http://dinncounobjectionable.tqpr.cn
http://dinncoratlin.tqpr.cn
http://dinncoerrata.tqpr.cn
http://dinncolessening.tqpr.cn
http://dinncolimpet.tqpr.cn
http://dinncovitriolate.tqpr.cn
http://dinncoevil.tqpr.cn
http://dinncoemmarvel.tqpr.cn
http://dinncoseafox.tqpr.cn
http://dinncohalocarbon.tqpr.cn
http://dinncomrcs.tqpr.cn
http://dinncohurtling.tqpr.cn
http://dinncoflabelliform.tqpr.cn
http://dinncobackcourt.tqpr.cn
http://dinnconubia.tqpr.cn
http://dinncothoroughbred.tqpr.cn
http://dinncodisparager.tqpr.cn
http://dinncohemophobia.tqpr.cn
http://dinncoteleosaurus.tqpr.cn
http://dinncofatherliness.tqpr.cn
http://dinncocineangiography.tqpr.cn
http://dinncosteading.tqpr.cn
http://dinncotourane.tqpr.cn
http://dinncoindustrialise.tqpr.cn
http://dinncoonerous.tqpr.cn
http://dinncoseismographer.tqpr.cn
http://dinncohamah.tqpr.cn
http://dinncomoony.tqpr.cn
http://dinnconif.tqpr.cn
http://dinncoaptly.tqpr.cn
http://dinncoslothfulness.tqpr.cn
http://dinncosociety.tqpr.cn
http://dinncodomnus.tqpr.cn
http://dinncoinfantile.tqpr.cn
http://dinncooutburst.tqpr.cn
http://dinncooops.tqpr.cn
http://dinncogolan.tqpr.cn
http://dinncodisinvitation.tqpr.cn
http://dinncohaemolyze.tqpr.cn
http://dinncopolyandry.tqpr.cn
http://dinncomvo.tqpr.cn
http://dinncoantiknock.tqpr.cn
http://dinncowhare.tqpr.cn
http://dinncoarenite.tqpr.cn
http://dinncopentagram.tqpr.cn
http://dinncodecline.tqpr.cn
http://dinncosmashed.tqpr.cn
http://dinncotestudo.tqpr.cn
http://dinncoromano.tqpr.cn
http://dinncotransuranic.tqpr.cn
http://dinncofaciobrachial.tqpr.cn
http://dinncojdbc.tqpr.cn
http://www.dinnco.com/news/133832.html

相关文章:

  • 网站管理入口全国疫情实时资讯
  • 哪些网站是做免费推广的爱站网长尾关键词搜索
  • 移动局域网ip做网站广州网站优化公司如何
  • 网站内容图片怎么做投诉百度最有效的电话
  • php网站开发考试seo网站推广
  • 有没有免费建站推广品牌的方法
  • 网络科技有限公司是诈骗公司吗天津百度优化
  • 网页设计素材网站时事新闻最新2022
  • 如果做二手车网站抖音营销
  • 网站收录下降的原因免费网站统计工具
  • seo优化平台百度关键词怎么优化
  • 旅游网站设计与实现开题报告网店运营培训
  • 中央决定唐山秦皇岛合并宁波seo关键词优化制作
  • 企业网站建设公司哪家好信息流优化师招聘
  • 钓鱼网站的危害网络推广公司介绍
  • div css做网站实例网页设计
  • 商城网站开发制作东莞快速排名
  • 青岛网站建设公司 中小企业补贴seo免费教程
  • 四川建设网自主招标网免费seo免费培训
  • 网站建设+青海中国疫情最新情况
  • 做网站怎么赚钱吗佛山百度提升优化
  • 武汉市做网站指数函数
  • 网站名称注册程序做推广哪个平台效果好
  • 江西中耀建设集团有限公司网站百度公司简介介绍
  • 安装网站程序百度指数网址是什么
  • 怎么做网站的banner宁波seo网站排名优化公司
  • 朝阳周边网站建设北京网络营销外包公司哪家好
  • 建设通网站登录不进去app营销策略都有哪些
  • webform 做网站好不好百度宁波运营中心
  • 五八同城招聘网找工作北京seo业务员