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

做网站烧钱百度seo排名培训优化

做网站烧钱,百度seo排名培训优化,做微信公众号网站,青岛做网站建设的公司一、概念说明 1.1 空间地理数据 MongoDB 中使用 GeoJSON对象 或 坐标对 描述空间地理数据。MongoDB使用 WGS84 参考系进行地理空间数据查询。 1、MongoDB支持空间数据的存储,数据类型需要限制为GeoJSON; 2、MongoDB可以为GeoJSON类型数据建立索引,提升空…

一、概念说明

1.1 空间地理数据


MongoDB 中使用 GeoJSON对象 或 坐标对 描述空间地理数据。MongoDB使用 WGS84 参考系进行地理空间数据查询。
1、MongoDB支持空间数据的存储,数据类型需要限制为GeoJSON;
2、MongoDB可以为GeoJSON类型数据建立索引,提升空间查询的效率;

1.2 GeoJSON对象


GeoJSON 对象格式


<field>: { type: <GeoJSON type> , coordinates: <coordinates> }

GeoJSON 对象有两个filed,分别是 type 和 coordinates.其中,

  • type 指明是哪种空间地理数据类型

  • coordinates: 是描述 Geo对象的坐标数组,经度在前(经度取值范围 -180到 180),纬度在后(纬度取值范围是-90到90

二、功能演示操作

2.1 准备环境与初始数据


2.1.1、使用SpringBoot 和 MongoTemplate操作
增加MongoDB连接配置

spring:data:# MongoDB配置mongodb:uri: mongodb://usr:usrpassword@192.168.xx.xx:27017/database: filedataauthentication-database: admin#自动创建索引auto-index-creation: trueconnections-num-min-size: 5connections-num-max-size: 10

2.1.2、创建GeoData对象存储空间数据

@Data
@ApiModel
@Document(collection = "GEO-DATA")
public class GeoData {@ApiModelProperty(name = "_id",value = "_id")private String _id;@ApiModelProperty(name = "recordId",value = "recordId")private String recordId;@ApiModelProperty(name = "name",value = "名称")private String name;/** 经度 */@ApiModelProperty(name = "lng",value = "经度")private Double lng;/** 维度 */@ApiModelProperty(name = "lat",value = "维度")private Double lat;/*** 位置信息*/@ApiModelProperty(name = "location",value = "位置信息", hidden = true)private GeoJsonPoint location;@ApiModelProperty(name = "time",value = "录入时间")private Long time;
}

2.1.3、增加集合GEO-DATA并创建对应的空间索引

db.getCollection("GEO-DATA").ensureIndex( { location :"2dsphere" } )

2.1.4、创建测试类MongoGeoTest

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class MongoGeoTest {@Autowiredprivate MongoTemplate mongoTemplate;}

2.1.5、增加批量插入数据的方法


/*** 批量插入数据*/
public void batchInsertData() {//准备数据List<GeoData> geoDataList = new ArrayList<>();for (int i = 0; i < 10; i++) {GeoData geoData = new GeoData();geoData.setRecordId(UUID.fastUUID().toString(Boolean.TRUE));geoData.setName(RandomUtil.randomNumbers(12));geoData.setTime(new Date().getTime());//经度double lng = 116.3180D + RandomUtil.randomDouble(0.1d, 1.0d);geoData.setLng(lng);//维度double lat = 39.9857D + RandomUtil.randomDouble(0.1d, 1.0d);geoData.setLat(lat);geoData.setLocation(new GeoJsonPoint(lng, lat));geoDataList.add(geoData);}//保存数据Long start = System.currentTimeMillis();mongoTemplate.insert(geoDataList, "GEO-DATA");log.info("Mongo save documents to GEO-DATA 耗时:{} 毫秒", System.currentTimeMillis() - start);
}

2.2 多边形区域内查询


2.2.1、创建查询参数类MultiPositionPageQueryParam

@Data
@ApiModel
public class MultiPositionPageQueryParam {@ApiModelProperty(name = "positions",value = "位置集合")private List<BDSPosition> positions;@ApiModelProperty(name = "geoType", value = "类型: 1-多点(位置)查询;2-面(区域)查询")private Integer geoType;@NotNull@ApiModelProperty(name = "pageNum",value = "pageNum 起始数字为 0")private Long pageNum;@NotNull@ApiModelProperty(name = "pageSize",value = "pageSize")private Long pageSize;@ApiModelProperty(name = "needCount",value = "是否需要统计总记录数")private Boolean needCount = Boolean.FALSE;
}

2.2.2、增加多边形区域查询方法

/*** 多边形区域内** @param queryParam*/
public void queryGeoDataByMultiPositionPageQueryParam(MultiPositionPageQueryParam queryParam) {Query query = new Query();Criteria criteria = new Criteria();List<Criteria> criteriaList = new LinkedList<>();//过滤字段query.fields().include("recordId", "_id", "name", "time", "lng", "lat", "location");//位置集合过滤if (ObjectUtil.isNotNull(queryParam.getPositions()) && queryParam.getPositions().size() > 0) {// 类型: 1-多点(位置)查询;2-面(区域)查询if (ObjectUtil.isNotNull(queryParam.getGeoType()) && queryParam.getGeoType() == 2 && queryParam.getPositions().size() > 2) {List<Point> pointList = new LinkedList<>();//经纬度获取for (BDSPosition position : queryParam.getPositions()) {Point point = new Point(position.getLng(), position.getLat());pointList.add(point);}pointList.add(pointList.get(0));GeoJsonPolygon geoJsonPolygon = new GeoJsonPolygon(pointList);Criteria areaCriteria = Criteria.where("location").within(geoJsonPolygon);query.addCriteria(areaCriteria);criteriaList.add(areaCriteria);} else {List<Criteria> orCriteriaList = new LinkedList<>();//经纬度判断for (BDSPosition position : queryParam.getPositions()) {orCriteriaList.add(Criteria.where("lng").is(position.getLng()).and("lat").is(position.getLat()));}Criteria orPositionCriteria = new Criteria().orOperator(orCriteriaList);query.addCriteria(orPositionCriteria);criteriaList.add(orPositionCriteria);}}//总记录数统计Long total = null;if (queryParam.getNeedCount()) {total = mongoTemplate.findDistinct(query, "recordId", "GEO-DATA", String.class).stream().count();}//排序List<Sort.Order> orders = new LinkedList<>();orders.add(Sort.Order.desc("time"));AggregationOptions aggregationOptions = AggregationOptions.builder().allowDiskUse(Boolean.TRUE).build();Aggregation aggregation = null;if (criteriaList.size() > 0) {criteria = criteria.andOperator(criteriaList);aggregation = Aggregation.newAggregation(Aggregation.project("recordId", "_id", "name", "time", "lng", "lat", "location"),//查询条件Aggregation.match(criteria),//分组条件Aggregation.group("recordId").max("time").as("time").first("recordId").as("recordId").last("time").as("time"),Aggregation.sort(Sort.by(orders)),//分页条件Aggregation.skip(queryParam.getPageNum()),Aggregation.limit(queryParam.getPageSize())).withOptions(aggregationOptions);} else {aggregation = Aggregation.newAggregation(Aggregation.project("recordId", "_id", "name", "time", "lng", "lat", "location"),//分组条件Aggregation.group("recordId").max("time").as("time").first("recordId").as("recordId").first("time").as("time"),Aggregation.sort(Sort.by(orders)),//分页条件Aggregation.skip(queryParam.getPageNum()),Aggregation.limit(queryParam.getPageSize())).withOptions(aggregationOptions);}List<GeoData> list = mongoTemplate.aggregate(aggregation, "GEO-DATA", GeoData.class).getMappedResults();log.info("Data: {}", list);
}

2.3 圆形区域内查询

2.3.1、创建查询参数类CirclePageQueryParam

@Data
@ApiModel
public class CirclePageQueryParam {@NotNull@ApiModelProperty(name = "lng", value = "经度")private Double lng;@NotNull@ApiModelProperty(name = "lat", value = "维度")private Double lat;@NotNull@ApiModelProperty(name = "radius", value = "半径")private Double radius;@NotNull@ApiModelProperty(name = "pageNum",value = "pageNum 起始数字为 0")private Long pageNum;@NotNull@ApiModelProperty(name = "pageSize",value = "pageSize")private Long pageSize;@ApiModelProperty(name = "needCount",value = "是否需要统计总记录数")private Boolean needCount = Boolean.FALSE;
}

2.3.2、增加圆形区域查询方法

/*** 圆形区域内查询* @param queryParam*/
public void queryGeoDataByCircle(CirclePageQueryParam queryParam) {Query query = new Query();Criteria criteria = new Criteria();List<Criteria> criteriaList = new LinkedList<>();//过滤字段query.fields().include("recordId", "_id", "name", "time", "lng", "lat", "location");//位置集合过滤if (ObjectUtil.isNotNull(queryParam.getLat()) && ObjectUtil.isNotNull(queryParam.getLng())&& ObjectUtil.isNotNull(queryParam.getRadius())) {Point point = new Point(queryParam.getLng(), queryParam.getLat());Distance distance = new Distance(queryParam.getRadius(), Metrics.MILES);Circle circle = new Circle(point, distance);Criteria areaCriteria = Criteria.where("location").withinSphere(circle);query.addCriteria(areaCriteria);criteriaList.add(areaCriteria);}else{log.info("参数有误,必要参数为空。");return;}//总记录数统计Long total = null;if (queryParam.getNeedCount()) {total = mongoTemplate.findDistinct(query, "recordId", "GEO-DATA", String.class).stream().count();}//排序List<Sort.Order> orders = new LinkedList<>();orders.add(Sort.Order.desc("time"));AggregationOptions aggregationOptions = AggregationOptions.builder().allowDiskUse(Boolean.TRUE).build();Aggregation aggregation = null;if (criteriaList.size() > 0) {criteria = criteria.andOperator(criteriaList);aggregation = Aggregation.newAggregation(Aggregation.project("recordId", "_id", "name", "time", "lng", "lat", "location"),//查询条件Aggregation.match(criteria),//分组条件Aggregation.group("recordId").max("time").as("time").first("recordId").as("recordId").last("time").as("time"),Aggregation.sort(Sort.by(orders)),//分页条件Aggregation.skip(queryParam.getPageNum()),Aggregation.limit(queryParam.getPageSize())).withOptions(aggregationOptions);} else {aggregation = Aggregation.newAggregation(Aggregation.project("recordId", "_id", "name", "time", "lng", "lat", "location"),//分组条件Aggregation.group("recordId").max("time").as("time").first("recordId").as("recordId").first("time").as("time"),Aggregation.sort(Sort.by(orders)),//分页条件Aggregation.skip(queryParam.getPageNum()),Aggregation.limit(queryParam.getPageSize())).withOptions(aggregationOptions);}List<GeoData> list = mongoTemplate.aggregate(aggregation, "GEO-DATA", GeoData.class).getMappedResults();log.info("Data: {}", list);
}


文章转载自:
http://dinncocateyed.tqpr.cn
http://dinncoramp.tqpr.cn
http://dinncomote.tqpr.cn
http://dinncocorn.tqpr.cn
http://dinncotoothpick.tqpr.cn
http://dinncolanguishing.tqpr.cn
http://dinncoimpersonalization.tqpr.cn
http://dinncoadsorb.tqpr.cn
http://dinncodeadass.tqpr.cn
http://dinncoamgot.tqpr.cn
http://dinncoxinjiang.tqpr.cn
http://dinncoscorekeeper.tqpr.cn
http://dinncoshaveling.tqpr.cn
http://dinncocapful.tqpr.cn
http://dinncoskink.tqpr.cn
http://dinncoconnotation.tqpr.cn
http://dinncoouter.tqpr.cn
http://dinncoconidiospore.tqpr.cn
http://dinncoegodefense.tqpr.cn
http://dinncoderogative.tqpr.cn
http://dinncomodernise.tqpr.cn
http://dinncobarathea.tqpr.cn
http://dinncoct.tqpr.cn
http://dinncodw.tqpr.cn
http://dinncoduke.tqpr.cn
http://dinncouglification.tqpr.cn
http://dinncomacedon.tqpr.cn
http://dinncorotterdam.tqpr.cn
http://dinncozelig.tqpr.cn
http://dinncooutbrave.tqpr.cn
http://dinncowandy.tqpr.cn
http://dinncolithosphere.tqpr.cn
http://dinncolandsick.tqpr.cn
http://dinncohippalectryon.tqpr.cn
http://dinncodisseizor.tqpr.cn
http://dinncosum.tqpr.cn
http://dinncopartygoer.tqpr.cn
http://dinncocrowdy.tqpr.cn
http://dinncomultibillion.tqpr.cn
http://dinncoexterminative.tqpr.cn
http://dinncosupervenient.tqpr.cn
http://dinncochevron.tqpr.cn
http://dinncoheilungkiang.tqpr.cn
http://dinncooverquantification.tqpr.cn
http://dinncofantast.tqpr.cn
http://dinncobedbound.tqpr.cn
http://dinncotrouty.tqpr.cn
http://dinncowatermark.tqpr.cn
http://dinncocryptoanalysis.tqpr.cn
http://dinncocrissal.tqpr.cn
http://dinncowhenever.tqpr.cn
http://dinncofighting.tqpr.cn
http://dinncoallure.tqpr.cn
http://dinncoeffraction.tqpr.cn
http://dinncorazzia.tqpr.cn
http://dinncotranscriptionist.tqpr.cn
http://dinncothrombocytopenia.tqpr.cn
http://dinncomylonite.tqpr.cn
http://dinncoorionid.tqpr.cn
http://dinncoconcelebrant.tqpr.cn
http://dinncopuglia.tqpr.cn
http://dinncoanon.tqpr.cn
http://dinncostrict.tqpr.cn
http://dinncoroust.tqpr.cn
http://dinncobrewage.tqpr.cn
http://dinncoascent.tqpr.cn
http://dinncotarriance.tqpr.cn
http://dinncoimpartment.tqpr.cn
http://dinncodeconsecrate.tqpr.cn
http://dinncotorsibility.tqpr.cn
http://dinncoxenoantiserum.tqpr.cn
http://dinncovirosis.tqpr.cn
http://dinncosergeant.tqpr.cn
http://dinncocomplied.tqpr.cn
http://dinncocsa.tqpr.cn
http://dinncocobelligerence.tqpr.cn
http://dinncofatherly.tqpr.cn
http://dinncocinchonine.tqpr.cn
http://dinncotailgate.tqpr.cn
http://dinncokiplingesque.tqpr.cn
http://dinncokava.tqpr.cn
http://dinncofissiped.tqpr.cn
http://dinncoinapprehension.tqpr.cn
http://dinncoanonymous.tqpr.cn
http://dinncosatanize.tqpr.cn
http://dinncocothurn.tqpr.cn
http://dinncopossibilist.tqpr.cn
http://dinncodigitation.tqpr.cn
http://dinncorhaetic.tqpr.cn
http://dinncoripplet.tqpr.cn
http://dinnconpf.tqpr.cn
http://dinncopast.tqpr.cn
http://dinncodinge.tqpr.cn
http://dinncoroentgenite.tqpr.cn
http://dinncoemerge.tqpr.cn
http://dinncobandy.tqpr.cn
http://dinncofirmer.tqpr.cn
http://dinncopittance.tqpr.cn
http://dinncosunfall.tqpr.cn
http://dinncogroom.tqpr.cn
http://www.dinnco.com/news/91750.html

相关文章:

  • 怎样查看一个网站是用什么开源程序做的新型网络营销模式
  • 微网站的链接怎么做的网站后端开发
  • 广州专业网站开发google store
  • 宠物网站建设规划书十大营销策划公司排名
  • 做公司网站哪里好福州短视频seo
  • 南京seo网站优化搜索引擎优化的方法
  • 网站流量限制seo企业推广案例
  • 免费舆情网站直接打开网络营销心得体会300字
  • 东阳厂家高端网站设计企业整站推广
  • 网站建设中企动力推荐产品线下推广方式都有哪些
  • 怎样创建设计公司网站广告发布平台
  • 湖南省人民政府官方网站seo优化多少钱
  • 武进建设局网站织梦seo排名优化教程
  • 专业的培训网站建设seo专员是做什么的
  • 深圳有做网站公司企业培训方案
  • 网站会员系统wordpressseo推广外包报价表
  • 做mad的素材网站搜索推广开户
  • wordpress显示选项屏蔽自定义栏目宁波网站建设优化企业
  • 带数据库网站设计青岛seo服务哪家好
  • 企业形象网站开发业务范畴百度快速排名软件下载
  • 肇庆市专注网站建设平台巩义网络推广公司
  • win7做系统网站哪个好网站排名优化查询
  • 企业如何制作网站管理系统个人网页制作教程
  • 做游戏模型挣钱的网站做推广的都是怎么推
  • 清溪仿做网站百度学术论文官网入口
  • 网站建设需要哪些知识长沙关键词优化首选
  • 有没有专门搞网站上线的公司无锡优化网站排名
  • html5手机移动app网站制作教程广州网络推广平台
  • 国内摄影作品网站免费发布产品的网站
  • 怎样做才能让网站帮忙送东西在线数据分析工具