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

Java Metrics类代码示例

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

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



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

示例1: exposesGeoSpatialFunctionality

import org.springframework.data.geo.Metrics; //导入依赖的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: extractDistanceString

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
/**
 * extract the distance string from a {@link org.springframework.data.geo.Distance} object.
 *
 * @param distance distance object to extract string from
 * @param sb StringBuilder to build the distance string
 */
private void extractDistanceString(Distance distance, StringBuilder sb) {
	// handle Distance object
	sb.append((int) distance.getValue());

	Metrics metric = (Metrics) distance.getMetric();

	switch (metric) {
		case KILOMETERS:
			sb.append("km");
			break;
		case MILES:
			sb.append("mi");
			break;
	}
}
 
开发者ID:VanRoy,项目名称:spring-data-jest,代码行数:22,代码来源:CriteriaFilterProcessor.java


示例3: searchByDistance

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
@Test
public void searchByDistance() {

	Raptor raptor = Utils.createNewAdminInstance();

	log.debug("Search by distance");

	Device dev = createDevice(raptor);
	Stream s = dev.stream("test");

	int qt = 10;
	pushRecords(raptor, s, qt);

	DataQuery q = new DataQuery();
	q.distance(new GeoJsonPoint(11.45, 45.11), 10000, Metrics.KILOMETERS);
	ResultSet results = raptor.Stream().search(s, q);

	log.debug("Found {} records", results.size());
	Assert.assertEquals(qt, results.size());
}
 
开发者ID:raptorbox,项目名称:raptor,代码行数:21,代码来源:DataStreamTest.java


示例4: testGeoLocationWithDistanceInMiles

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
@Test
public void testGeoLocationWithDistanceInMiles() {
	ExampleSolrBean searchableBeanInBuffalow = createExampleBeanWithId("1");
	searchableBeanInBuffalow.setStore("45.17614,-93.87341");

	ExampleSolrBean searchableBeanInNYC = createExampleBeanWithId("2");
	searchableBeanInNYC.setStore("40.7143,-74.006");

	solrTemplate.saveBeans(Arrays.asList(searchableBeanInBuffalow, searchableBeanInNYC));
	solrTemplate.commit();

	Page<ExampleSolrBean> result = solrTemplate.queryForPage(
			new SimpleQuery(new Criteria("store").near(new Point(45.15, -93.85), new Distance(3.106856, Metrics.MILES))),
			ExampleSolrBean.class);

	Assert.assertEquals(1, result.getContent().size());
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:18,代码来源:ITestCriteriaExecution.java


示例5: findByGeoLocationProperty

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
/**
 * Find entity by a {@link GeoIndexed} property on an embedded entity.
 */
@Test
public void findByGeoLocationProperty() {

	Address winterfell = new Address();
	winterfell.setCountry("the north");
	winterfell.setCity("winterfell");
	winterfell.setLocation(new Point(52.9541053, -1.2401016));

	eddard.setAddress(winterfell);

	Address casterlystein = new Address();
	casterlystein.setCountry("Westerland");
	casterlystein.setCity("Casterlystein");
	casterlystein.setLocation(new Point(51.5287352, -0.3817819));

	robb.setAddress(casterlystein);

	flushTestUsers();

	Circle innerCircle = new Circle(new Point(51.8911912, -0.4979756), new Distance(50, Metrics.KILOMETERS));
	List<Person> eddardStark = repository.findByAddress_LocationWithin(innerCircle);

	assertThat(eddardStark, hasItem(robb));
	assertThat(eddardStark, hasSize(1));

	Circle biggerCircle = new Circle(new Point(51.8911912, -0.4979756), new Distance(200, Metrics.KILOMETERS));
	List<Person> eddardAndRobbStark = repository.findByAddress_LocationWithin(biggerCircle);

	assertThat(eddardAndRobbStark, hasItems(robb, eddard));
	assertThat(eddardAndRobbStark, hasSize(2));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:35,代码来源:PersonRepositoryTests.java


示例6: findsStoresByLocation

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
@Test
public void findsStoresByLocation() {

	Point location = new Point(-73.995146, 40.740337);
	Store store = new Store("Foo", new Address("street", "city", "zip", location));

	store = repository.save(store);

	Page<Store> stores = repository.findByAddressLocationNear(location, new Distance(1.0, Metrics.KILOMETERS),
			new PageRequest(0, 10));

	assertThat(stores.getContent(), hasSize(1));
	assertThat(stores.getContent(), hasItem(store));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:15,代码来源:StoreRepositoryIntegrationTests.java


示例7: toKm

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
public static double toKm(Distance distance) {
    Metric metric = distance.getMetric();
    if (Metrics.KILOMETERS.equals(metric)) {
        return distance.getValue();
    } else if (Metrics.MILES.equals(metric)) {
        return distance.getValue() * 1.609344;
    } else {
        throw new IllegalArgumentException("Unknown metric: " + metric);
    }
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:11,代码来源:AbstractCriteriaConverter.java


示例8: findsVenuesWithRegularAnnotations

import org.springframework.data.geo.Metrics; //导入依赖的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


示例9: findsVenuesWithComposedAnnotations

import org.springframework.data.geo.Metrics; //导入依赖的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


示例10: convert

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
@Override
public String convert(org.springframework.data.geo.Distance source) {
	if (source == null) {
		return null;
	}
	double value = source.getValue();
	if (source.getMetric() == Metrics.MILES) {
		value = source.getValue() * 1.609344D;
	}
	return String.format(java.util.Locale.ENGLISH, "%s", value);
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:12,代码来源:GeoConverters.java


示例11: testWithGeoLocationPropertyWhereDistanceIsInMiles

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
@Test
public void testWithGeoLocationPropertyWhereDistanceIsInMiles() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByLocationNear", Point.class, Distance.class);
	SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadataMock, entityInformationCreatorMock);

	StringBasedSolrQuery solrQuery = new StringBasedSolrQuery(queryMethod, solrOperationsMock);

	org.springframework.data.solr.core.query.Query query = solrQuery.createQuery(new SolrParametersParameterAccessor(
			queryMethod, new Object[] { new Point(48.303056, 14.290556), new Distance(1, Metrics.MILES) }));

	Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=store d=1.609344}", queryParser.getQueryString(query));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:13,代码来源:StringBasedSolrQueryTests.java


示例12: testCreateQueryWithNearWhereUnitIsMiles

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
@Test
public void testCreateQueryWithNearWhereUnitIsMiles() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByLocationNear", Point.class, Distance.class);

	Query query = createQueryForMethodWithArgs(method, new Object[] { new Point(48.303056, 14.290556),
			new Distance(1, Metrics.MILES) });
	Assert.assertEquals("{!bbox pt=48.303056,14.290556 sfield=store d=1.609344}", queryParser.getQueryString(query));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:9,代码来源:SolrQueryCreatorTests.java


示例13: testCreateQueryWithWithinWhereUnitIsMiles

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
@Test
public void testCreateQueryWithWithinWhereUnitIsMiles() throws NoSuchMethodException, SecurityException {
	Method method = SampleRepository.class.getMethod("findByLocationWithin", Point.class, Distance.class);

	Query query = createQueryForMethodWithArgs(method, new Object[] { new Point(48.303056, 14.290556),
			new Distance(1, Metrics.MILES) });
	Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=store d=1.609344}", queryParser.getQueryString(query));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:9,代码来源:SolrQueryCreatorTests.java


示例14: testNearWithDistanceUnitKilometers

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
@Test
public void testNearWithDistanceUnitKilometers() {
	Criteria criteria = new Criteria("field_1").near(new Point(48.303056, 14.290556), new Distance(1,
			Metrics.KILOMETERS));
	Assert.assertEquals("{!bbox pt=48.303056,14.290556 sfield=field_1 d=1.0}",
			queryParser.createQueryStringFromCriteria(criteria));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:8,代码来源:DefaultQueryParserTests.java


示例15: testWithinWithDistanceUnitKilometers

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
@Test
public void testWithinWithDistanceUnitKilometers() {
	Criteria criteria = new Criteria("field_1").within(new Point(48.303056, 14.290556), new Distance(1,
			Metrics.KILOMETERS));
	Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=field_1 d=1.0}",
			queryParser.createQueryStringFromCriteria(criteria));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:8,代码来源:DefaultQueryParserTests.java


示例16: testWithinCircleWorksCorrectly

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
/**
 * @see DATASOLR-142
 */
@Test
public void testWithinCircleWorksCorrectly() {
	Criteria criteria = new Criteria("field_1").within(new Circle(new Point(48.303056, 14.290556), new Distance(1,
			Metrics.KILOMETERS)));
	Assert.assertEquals("{!geofilt pt=48.303056,14.290556 sfield=field_1 d=1.0}",
			queryParser.createQueryStringFromCriteria(criteria));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:11,代码来源:DefaultQueryParserTests.java


示例17: queryLocation

import org.springframework.data.geo.Metrics; //导入依赖的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


示例18: near

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
@GetMapping(value = "near", produces = MediaType.APPLICATION_JSON_VALUE)
public Mensa near(@RequestParam("longitude") Double longitude, @RequestParam("latitude") Double latitude) {
    return repo.findByPointNear(new Point(longitude, latitude), new Distance(1000, Metrics.KILOMETERS)).stream().findFirst().orElseThrow(() -> new ResourceNotFoundException("Could not find any mensa near to you"));
}
 
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:5,代码来源:MensaController.java


示例19: distance

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
public DataQuery distance(GeoJsonPoint center, double radius, Metrics unit) {
    this.location.distance(center, radius, unit);
    return this;
}
 
开发者ID:raptorbox,项目名称:raptor,代码行数:5,代码来源:DataQuery.java


示例20: distance

import org.springframework.data.geo.Metrics; //导入依赖的package包/类
public GeoQuery distance(GeoJsonPoint center, double radius, Metrics unit) {
    distance.center = center;
    distance.radius = radius;
    distance.unit = unit;
    return this;
}
 
开发者ID:raptorbox,项目名称:raptor,代码行数:7,代码来源:GeoQuery.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java PMatrix类代码示例发布时间:2022-05-22
下一篇:
Java LWCToolkit类代码示例发布时间: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