org.springframework.data.mongodb.core.query.Criteria.within()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(209)

本文整理了Java中org.springframework.data.mongodb.core.query.Criteria.within()方法的一些代码示例,展示了Criteria.within()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Criteria.within()方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.query.Criteria
类名称:Criteria
方法名:within

Criteria.within介绍

[英]Creates a geospatial criterion using a $geoWithin operation.
[中]使用$GEOIN操作创建地理空间标准。

代码示例

代码示例来源:origin: spring-projects/spring-data-mongodb

return criteria.within((Shape) parameter);
case SIMPLE_PROPERTY:

代码示例来源:origin: org.springframework.data/spring-data-mongodb

return criteria.within((Shape) parameter);
case SIMPLE_PROPERTY:

代码示例来源:origin: sentilo/sentilo

public SearchFilterResult<Component> geoSpatialSearch(final SearchFilter filter) {
 if (SentiloUtils.arrayIsEmpty(filter.getBounds())) {
  return super.search(filter);
 }
 // bounds = [lat_lo_left,lng_lo_left,lat_hi_west,lng_hi_west]
 final String[] mapBounds = filter.getBounds();
 final double[] lowerLeft = {Double.parseDouble(mapBounds[1]), Double.parseDouble(mapBounds[0])};
 final double[] upperRight = {Double.parseDouble(mapBounds[3]), Double.parseDouble(mapBounds[2])};
 final Box mapBox = new Box(lowerLeft, upperRight);
 final Criteria geoSpatialCriteria = Criteria.where("location.centroid").within(mapBox);
 final Query query = buildQuery(filter, false, geoSpatialCriteria);
 LOGGER.debug("GeoSpatial Search - query: {}", query);
 final List<Component> content = getMongoOps().find(query, Component.class);
 return new SearchFilterResult<Component>(content, filter, content.size());
}

相关文章