• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GeoResults类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.data.geo.GeoResults的典型用法代码示例。如果您正苦于以下问题:Java GeoResults类的具体用法?Java GeoResults怎么用?Java GeoResults使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GeoResults类属于org.springframework.data.geo包,在下文中一共展示了GeoResults类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: exposesGeoSpatialFunctionality

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
/**
 * Test case to show the usage of the geo-spatial APIs to lookup people within a given distance of a reference point.
 */
@Test
public void exposesGeoSpatialFunctionality() {

	GeospatialIndex indexDefinition = new GeospatialIndex("address.location");
	indexDefinition.getIndexOptions().put("min", -180);
	indexDefinition.getIndexOptions().put("max", 180);

	operations.indexOps(Customer.class).ensureIndex(indexDefinition);

	Customer ollie = new Customer("Oliver", "Gierke");
	ollie.setAddress(new Address(new Point(52.52548, 13.41477)));
	ollie = repository.save(ollie);

	Point referenceLocation = new Point(52.51790, 13.41239);
	Distance oneKilometer = new Distance(1, Metrics.KILOMETERS);

	GeoResults<Customer> result = repository.findByAddressLocationNear(referenceLocation, oneKilometer);

	assertThat(result.getContent(), hasSize(1));

	Distance distanceToFirstStore = result.getContent().get(0).getDistance();
	assertThat(distanceToFirstStore.getMetric(), is(Metrics.KILOMETERS));
	assertThat(distanceToFirstStore.getValue(), closeTo(0.862, 0.001));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:28,代码来源:CustomerRepositoryIntegrationTest.java


示例2: geoRadiusByMember

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
/**
 * Look up points using a geo-index member as reference.
 */
@Test
public void geoRadiusByMember() {

	GeoResults<GeoLocation<String>> byDistance = geoOperations.geoRadiusByMember("Sicily", "Palermo",
			new Distance(100, DistanceUnit.KILOMETERS));

	assertThat(byDistance).hasSize(2).extracting("content.name").contains("Arigento", "Palermo");

	GeoResults<GeoLocation<String>> greaterDistance = geoOperations.geoRadiusByMember("Sicily", "Palermo",
			new Distance(200, DistanceUnit.KILOMETERS));

	assertThat(greaterDistance).hasSize(3).extracting("content.name").contains("Arigento", "Catania", "Palermo");
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:17,代码来源:GeoOperationsTests.java


示例3: geoRadius

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
/**
 * Lookup points within a circle around coordinates.
 */
@Test
public void geoRadius() {

	Circle circle = new Circle(new Point(13.583333, 37.316667), //
			new Distance(100, DistanceUnit.KILOMETERS));
	GeoResults<GeoLocation<String>> result = geoOperations.geoRadius("Sicily", circle);

	assertThat(result).hasSize(2).extracting("content.name").contains("Arigento", "Palermo");
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:13,代码来源:GeoOperationsTests.java


示例4: findsVenuesWithRegularAnnotations

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
/**
 * Issue a {@code geoNear} query using a 2d legacy index specified by the built-in {@link GeospatialIndex} annotation.
 */
@Test
public void findsVenuesWithRegularAnnotations() {

	GeoResults<Venue> geoResults = operations
			.geoNear(NearQuery.near(jessesHouse.getPoint()).maxDistance(10, Metrics.MILES), Venue.class);

	assertThat(geoResults.getContent(), hasSize(2));

	GeoResult<Venue> geoResult = geoResults.getContent().get(1);

	assertThat(geoResult.getContent(), is(equalTo(theWhiteResidence)));
	assertThat(geoResult.getDistance().getValue(), is(closeTo(7.7, 0.1)));
}
 
开发者ID:SpringOnePlatform2016,项目名称:whats-new-in-spring-data,代码行数:17,代码来源:ComposedAnnotationIntegrationTest.java


示例5: findsVenuesWithComposedAnnotations

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
/**
 * Issue a {@code geoNear} query using a 2d legacy index specified by a custom, composed {@link MyGeoIndexAnnotation}
 * annotation.
 */
@Test
public void findsVenuesWithComposedAnnotations() {

	GeoResults<ImprovedVenue> geoResults = operations
			.geoNear(NearQuery.near(theWhiteResidence.getPoint()).maxDistance(2, Metrics.MILES), ImprovedVenue.class);

	assertThat(geoResults.getContent(), hasSize(2));

	GeoResult<ImprovedVenue> geoResult = geoResults.getContent().get(1);

	assertThat(geoResult.getContent(), is(equalTo(carWash)));
	assertThat(geoResult.getDistance().getValue(), is(closeTo(1.2, 0.1)));
}
 
开发者ID:SpringOnePlatform2016,项目名称:whats-new-in-spring-data,代码行数:18,代码来源:ComposedAnnotationIntegrationTest.java


示例6: queryLocation

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
@Test
public void queryLocation() {
    Point center = new Point(-30.030277, -51.230339);
    Distance radius = new Distance(1, Metrics.KILOMETERS);
    GeoResults<Shape> entities = this.repository.findByLocationNear(center, radius);
    assertThat(entities, is(notNullValue()));
}
 
开发者ID:trein,项目名称:gtfs-java,代码行数:8,代码来源:ShapeRepositoryTest.java


示例7: getNearbyStops

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
@Cacheable(value = "nearby_stops")
public List<StopBean> getNearbyStops(Point point) {
    GeoResults<Stop> stops = this.stopRepository.findByLocationNear(point, DISTANCE);
    List<StopBean> beans = new ArrayList<>();

    for (GeoResult<Stop> geoStop : stops.getContent()) {
        beans.add(StopBean.fromStop(geoStop.getContent()));
    }
    return beans;
}
 
开发者ID:trein,项目名称:gtfs-java,代码行数:11,代码来源:CachedRepository.java


示例8: findByAddressLocationNear

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
/**
 * Show case for a repository query using geo-spatial functionality.
 * 
 * @param point
 * @param distance
 * @return
 */
GeoResults<Customer> findByAddressLocationNear(Point point, Distance distance);
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:9,代码来源:CustomerRepository.java


示例9: findByLocationNear

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
GeoResults<Product> findByLocationNear(Point location, Distance distance); 
开发者ID:kyasar,项目名称:asam,代码行数:2,代码来源:ProductRepository.java


示例10: findByPositionNear

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
GeoResults<Car> findByPositionNear(Point p, Distance d); 
开发者ID:livelessons-spring,项目名称:building-microservices,代码行数:2,代码来源:CarRepository.java


示例11: findByLocationNear

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
GeoResults<Shape> findByLocationNear(Point point, Distance distance); 
开发者ID:trein,项目名称:gtfs-java,代码行数:2,代码来源:ShapeRepository.java


示例12: findByLocationWithin

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
GeoResults<Stop> findByLocationWithin(Circle circle); 
开发者ID:trein,项目名称:gtfs-java,代码行数:2,代码来源:StopRepository.java


示例13: findByLocationNear

import org.springframework.data.geo.GeoResults; //导入依赖的package包/类
GeoResults<Stop> findByLocationNear(Point point, Distance distance); 
开发者ID:trein,项目名称:gtfs-java,代码行数:2,代码来源:StopRepository.java



注:本文中的org.springframework.data.geo.GeoResults类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CounterConstants类代码示例发布时间:2022-05-22
下一篇:
Java HeadphoneFence类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap