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

Java ShapeRelation类代码示例

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

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



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

示例1: GeoShapeQueryBuilder

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
/**
 * Read from a stream.
 */
public GeoShapeQueryBuilder(StreamInput in) throws IOException {
    super(in);
    fieldName = in.readString();
    if (in.readBoolean()) {
        shape = in.readNamedWriteable(ShapeBuilder.class);
        indexedShapeId = null;
        indexedShapeType = null;
    } else {
        shape = null;
        indexedShapeId = in.readOptionalString();
        indexedShapeType = in.readOptionalString();
        indexedShapeIndex = in.readOptionalString();
        indexedShapePath = in.readOptionalString();
    }
    relation = ShapeRelation.readFromStream(in);
    strategy = in.readOptionalWriteable(SpatialStrategy::readFromStream);
    ignoreUnmapped = in.readBoolean();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:GeoShapeQueryBuilder.java


示例2: RangeQueryBuilder

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
/**
 * Read from a stream.
 */
public RangeQueryBuilder(StreamInput in) throws IOException {
    super(in);
    fieldName = in.readString();
    from = in.readGenericValue();
    to = in.readGenericValue();
    includeLower = in.readBoolean();
    includeUpper = in.readBoolean();
    timeZone = in.readOptionalTimeZone();
    String formatString = in.readOptionalString();
    if (formatString != null) {
        format = Joda.forPattern(formatString);
    }
    if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
        String relationString = in.readOptionalString();
        if (relationString != null) {
            relation = ShapeRelation.getRelationByName(relationString);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:RangeQueryBuilder.java


示例3: rangeQuery

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
@Override
public Query rangeQuery(String field, Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper,
                        ShapeRelation relation, @Nullable DateTimeZone timeZone, @Nullable DateMathParser parser,
                        QueryShardContext context) {
    DateTimeZone zone = (timeZone == null) ? DateTimeZone.UTC : timeZone;
    DateMathParser dateMathParser = (parser == null) ?
        new DateMathParser(DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER) : parser;
    Long low = lowerTerm == null ? Long.MIN_VALUE :
        dateMathParser.parse(lowerTerm instanceof BytesRef ? ((BytesRef) lowerTerm).utf8ToString() : lowerTerm.toString(),
            context::nowInMillis, false, zone);
    Long high = upperTerm == null ? Long.MAX_VALUE :
        dateMathParser.parse(upperTerm instanceof BytesRef ? ((BytesRef) upperTerm).utf8ToString() : upperTerm.toString(),
            context::nowInMillis, false, zone);

    return super.rangeQuery(field, low, high, includeLower, includeUpper, relation, zone, dateMathParser, context);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:RangeFieldMapper.java


示例4: testShapeFilterWithRandomGeoCollection

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
public void testShapeFilterWithRandomGeoCollection() throws Exception {
    // Create a random geometry collection.
    GeometryCollectionBuilder gcb = RandomShapeGenerator.createGeometryCollection(random());

    logger.info("Created Random GeometryCollection containing {} shapes", gcb.numShapes());

    client().admin().indices().prepareCreate("test").addMapping("type", "location", "type=geo_shape,tree=quadtree")
            .execute().actionGet();

    XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("location"), null).endObject();
    client().prepareIndex("test", "type", "1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get();

    ShapeBuilder filterShape = (gcb.getShapeAt(randomIntBetween(0, gcb.numShapes() - 1)));

    GeoShapeQueryBuilder filter = QueryBuilders.geoShapeQuery("location", filterShape);
    filter.relation(ShapeRelation.INTERSECTS);
    SearchResponse result = client().prepareSearch("test").setTypes("type").setQuery(QueryBuilders.matchAllQuery())
            .setPostFilter(filter).get();
    assertSearchResponse(result);
    assertHitCount(result, 1);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:GeoShapeQueryTests.java


示例5: testContainsShapeQuery

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
public void testContainsShapeQuery() throws Exception {
    // Create a random geometry collection.
    Rectangle mbr = xRandomRectangle(random(), xRandomPoint(random()), true);
    GeometryCollectionBuilder gcb = createGeometryCollectionWithin(random(), mbr);

    client().admin().indices().prepareCreate("test").addMapping("type", "location", "type=geo_shape,tree=quadtree" )
            .execute().actionGet();

    XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("location"), null).endObject();
    client().prepareIndex("test", "type", "1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get();

    // index the mbr of the collection
    EnvelopeBuilder env = new EnvelopeBuilder(new Coordinate(mbr.getMinX(), mbr.getMaxY()), new Coordinate(mbr.getMaxX(), mbr.getMinY()));
    docSource = env.toXContent(jsonBuilder().startObject().field("location"), null).endObject();
    client().prepareIndex("test", "type", "2").setSource(docSource).setRefreshPolicy(IMMEDIATE).get();

    ShapeBuilder filterShape = (gcb.getShapeAt(randomIntBetween(0, gcb.numShapes() - 1)));
    GeoShapeQueryBuilder filter = QueryBuilders.geoShapeQuery("location", filterShape)
            .relation(ShapeRelation.CONTAINS);
    SearchResponse response = client().prepareSearch("test").setTypes("type").setQuery(QueryBuilders.matchAllQuery())
            .setPostFilter(filter).get();
    assertSearchResponse(response);

    assertThat(response.getHits().getTotalHits(), greaterThan(0L));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:GeoShapeQueryTests.java


示例6: testGeoShape

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
public void testGeoShape() throws IOException {
    GeoShapeQueryBuilder qb = geoShapeQuery(
            "pin.location",
            ShapeBuilders.newMultiPoint(
                    new CoordinatesBuilder()
                .coordinate(0, 0)
                .coordinate(0, 10)
                .coordinate(10, 10)
                .coordinate(10, 0)
                .coordinate(0, 0)
                .build()));
    qb.relation(ShapeRelation.WITHIN);

    qb = geoShapeQuery(
                "pin.location",
                "DEU",
                "countries");
    qb.relation(ShapeRelation.WITHIN)
        .indexedShapeIndex("shapes")
        .indexedShapePath("location");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:QueryDSLDocumentationTests.java


示例7: testRangeQuery

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
public void testRangeQuery() throws Exception {
    Settings indexSettings = Settings.builder()
        .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
    IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAsciiOfLengthBetween(1, 10), indexSettings);
    QueryShardContext context = new QueryShardContext(0, idxSettings, null, null, null, null, null, xContentRegistry(),
            null, null, () -> nowInMillis);
    RangeFieldMapper.RangeFieldType ft = new RangeFieldMapper.RangeFieldType(type);
    ft.setName(FIELDNAME);
    ft.setIndexOptions(IndexOptions.DOCS);

    ShapeRelation relation = RandomPicks.randomFrom(random(), ShapeRelation.values());
    boolean includeLower = random().nextBoolean();
    boolean includeUpper = random().nextBoolean();
    Object from = nextFrom();
    Object to = nextTo(from);

    assertEquals(getExpectedRangeQuery(relation, from, to, includeLower, includeUpper),
        ft.rangeQuery(from, to, includeLower, includeUpper, relation, context));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:RangeFieldTypeTests.java


示例8: testSimple

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
/**
 * Create a simple heatmap over the indexed docs and verify that no cell has
 * more than that number of docs
 */
public void testSimple() throws Exception {

    EnvelopeBuilder env = new EnvelopeBuilder(new Coordinate(mbr.getMinX(), mbr.getMaxY()),
            new Coordinate(mbr.getMaxX(), mbr.getMinY()));
    GeoShapeQueryBuilder geo = QueryBuilders.geoShapeQuery("location", env).relation(ShapeRelation.WITHIN);

    SearchResponse response2 = client().prepareSearch("idx")
            .addAggregation(heatmap("heatmap1").geom(geo).field("location").gridLevel(7).maxCells(100)).execute().actionGet();

    GeoHeatmap filter2 = response2.getAggregations().get("heatmap1");
    assertThat(filter2, notNullValue());
    assertThat(filter2.getName(), equalTo("heatmap1"));

    int maxHeatmapValue = 0;
    for (int i = 0; i < filter2.getCounts().length; i++) {
        maxHeatmapValue = Math.max(maxHeatmapValue, filter2.getCounts()[i]);
    }
    assertTrue(maxHeatmapValue <= numTag1Docs);
}
 
开发者ID:boundlessgeo,项目名称:elasticsearch-heatmap,代码行数:24,代码来源:GeoHeatmapAggregationTests.java


示例9: getArgs

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
public static SpatialArgs getArgs(ShapeBuilder shape, ShapeRelation relation) {
    switch (relation) {
    case DISJOINT:
        return new SpatialArgs(SpatialOperation.IsDisjointTo, shape.build());
    case INTERSECTS:
        return new SpatialArgs(SpatialOperation.Intersects, shape.build());
    case WITHIN:
        return new SpatialArgs(SpatialOperation.IsWithin, shape.build());
    case CONTAINS:
        return new SpatialArgs(SpatialOperation.Contains, shape.build());
    default:
        throw new IllegalArgumentException("invalid relation [" + relation + "]");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:GeoShapeQueryBuilder.java


示例10: testInvalidRelation

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
public void testInvalidRelation() throws IOException {
    ShapeBuilder shape = RandomShapeGenerator.createShapeWithin(random(), null);
    GeoShapeQueryBuilder builder = new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, shape);
    builder.strategy(SpatialStrategy.TERM);
    expectThrows(IllegalArgumentException.class, () -> builder.relation(randomFrom(ShapeRelation.DISJOINT, ShapeRelation.WITHIN)));
    GeoShapeQueryBuilder builder2 = new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, shape);
    builder2.relation(randomFrom(ShapeRelation.DISJOINT, ShapeRelation.WITHIN));
    expectThrows(IllegalArgumentException.class, () -> builder2.strategy(SpatialStrategy.TERM));
    GeoShapeQueryBuilder builder3 = new GeoShapeQueryBuilder(GEO_SHAPE_FIELD_NAME, shape);
    builder3.strategy(SpatialStrategy.TERM);
    expectThrows(IllegalArgumentException.class, () -> builder3.relation(randomFrom(ShapeRelation.DISJOINT, ShapeRelation.WITHIN)));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:GeoShapeQueryBuilderTests.java


示例11: getExpectedRangeQuery

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
private Query getExpectedRangeQuery(ShapeRelation relation, Object from, Object to, boolean includeLower, boolean includeUpper) {
    switch (type) {
        case DATE:
            return getDateRangeQuery(relation, (DateTime)from, (DateTime)to, includeLower, includeUpper);
        case INTEGER:
            return getIntRangeQuery(relation, (int)from, (int)to, includeLower, includeUpper);
        case LONG:
            return getLongRangeQuery(relation, (long)from, (long)to, includeLower, includeUpper);
        case DOUBLE:
            return getDoubleRangeQuery(relation, (double)from, (double)to, includeLower, includeUpper);
        default:
            return getFloatRangeQuery(relation, (float)from, (float)to, includeLower, includeUpper);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:RangeFieldTypeTests.java


示例12: getIntRangeQuery

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
private Query getIntRangeQuery(ShapeRelation relation, int from, int to, boolean includeLower, boolean includeUpper) {
    int[] lower = new int[] {from + (includeLower ? 0 : 1)};
    int[] upper = new int[] {to - (includeUpper ? 0 : 1)};
    if (relation == ShapeRelation.WITHIN) {
        return IntRangeField.newWithinQuery(FIELDNAME, lower, upper);
    } else if (relation == ShapeRelation.CONTAINS) {
        return IntRangeField.newContainsQuery(FIELDNAME, lower, upper);
    }
    return IntRangeField.newIntersectsQuery(FIELDNAME, lower, upper);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:RangeFieldTypeTests.java


示例13: getLongRangeQuery

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
private Query getLongRangeQuery(ShapeRelation relation, long from, long to, boolean includeLower, boolean includeUpper) {
    long[] lower = new long[] {from + (includeLower ? 0 : 1)};
    long[] upper = new long[] {to - (includeUpper ? 0 : 1)};
    if (relation == ShapeRelation.WITHIN) {
        return LongRangeField.newWithinQuery(FIELDNAME, lower, upper);
    } else if (relation == ShapeRelation.CONTAINS) {
        return LongRangeField.newContainsQuery(FIELDNAME, lower, upper);
    }
    return LongRangeField.newIntersectsQuery(FIELDNAME, lower, upper);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:RangeFieldTypeTests.java


示例14: getFloatRangeQuery

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
private Query getFloatRangeQuery(ShapeRelation relation, float from, float to, boolean includeLower, boolean includeUpper) {
    float[] lower = new float[] {includeLower ? from : Math.nextUp(from)};
    float[] upper = new float[] {includeUpper ? to : Math.nextDown(to)};
    if (relation == ShapeRelation.WITHIN) {
        return FloatRangeField.newWithinQuery(FIELDNAME, lower, upper);
    } else if (relation == ShapeRelation.CONTAINS) {
        return FloatRangeField.newContainsQuery(FIELDNAME, lower, upper);
    }
    return FloatRangeField.newIntersectsQuery(FIELDNAME, lower, upper);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:RangeFieldTypeTests.java


示例15: getDoubleRangeQuery

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
private Query getDoubleRangeQuery(ShapeRelation relation, double from, double to, boolean includeLower, boolean includeUpper) {
    double[] lower = new double[] {includeLower ? from : Math.nextUp(from)};
    double[] upper = new double[] {includeUpper ? to : Math.nextDown(to)};
    if (relation == ShapeRelation.WITHIN) {
        return DoubleRangeField.newWithinQuery(FIELDNAME, lower, upper);
    } else if (relation == ShapeRelation.CONTAINS) {
        return DoubleRangeField.newContainsQuery(FIELDNAME, lower, upper);
    }
    return DoubleRangeField.newIntersectsQuery(FIELDNAME, lower, upper);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:RangeFieldTypeTests.java


示例16: getArgs

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
private SpatialArgs getArgs(Shape shape, ShapeRelation relation) {
    switch (relation) {
        case INTERSECTS:
            return new SpatialArgs(SpatialOperation.Intersects, shape);
        case DISJOINT:
            return new SpatialArgs(SpatialOperation.IsDisjointTo, shape);
        case WITHIN:
            return new SpatialArgs(SpatialOperation.IsWithin, shape);
    }
    throw invalidMatchType(relation.getRelationName());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:LuceneQueryBuilder.java


示例17: GeoShapeQueryBuilder

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
private GeoShapeQueryBuilder(String name, ShapeBuilder shape, String indexedShapeId, String indexedShapeType, ShapeRelation relation) {
    this.name = name;
    this.shape = shape;
    this.indexedShapeId = indexedShapeId;
    this.relation = relation;
    this.indexedShapeType = indexedShapeType;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:GeoShapeQueryBuilder.java


示例18: getArgs

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
public static SpatialArgs getArgs(ShapeBuilder shape, ShapeRelation relation) {
    switch(relation) {
    case DISJOINT:
        return new SpatialArgs(SpatialOperation.IsDisjointTo, shape.build());
    case INTERSECTS:
        return new SpatialArgs(SpatialOperation.Intersects, shape.build());
    case WITHIN:
        return new SpatialArgs(SpatialOperation.IsWithin, shape.build());
    case CONTAINS:
        return new SpatialArgs(SpatialOperation.Contains, shape.build());
    default:
        throw new IllegalArgumentException("");

    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:GeoShapeQueryParser.java


示例19: t_queryByEsQueryDo2

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
@org.junit.Test
public void t_queryByEsQueryDo2()throws Exception {
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    QueryBuilder qb = QueryBuilders.matchAllQuery();
    searchSourceBuilder.query(qb);
    ShapeBuilder shapeBuilder = ShapeBuilder.newPoint(new Coordinate(116.402257, 39.914548));
    QueryBuilder qb2 = QueryBuilders.geoShapeQuery("geometry", shapeBuilder, ShapeRelation.CONTAINS);

    QueryBuilder qb3 = QueryBuilders.boolQuery().must(qb).filter(qb2);
    searchSourceBuilder.query(qb3);
   iEsQueryDao.query(searchSourceBuilder,"twitter","user","user2");
    /*logger.info(JSON.toJSONString(es));
    Assert.assertNotEquals("1", es.getStatus());*/
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:15,代码来源:T_IEsQueryDao.java


示例20: testSpecificShapes

import org.elasticsearch.common.geo.ShapeRelation; //导入依赖的package包/类
public void testSpecificShapes() throws Exception {
    createPrecalculatedIndex();
    ShapeBuilder query = ShapeBuilders.newEnvelope(new Coordinate(50, 90), new Coordinate(180, 20));
    GeoShapeQueryBuilder geo = QueryBuilders.geoShapeQuery("location", query).relation(ShapeRelation.WITHIN);
    
    String expected = "\"aggregations\":{\"heatmap1\":{\"grid_level\":4,\"rows\":7,\"columns\":6,\"min_x\":45.0,\"min_y\":11.25,"+
         "\"max_x\":180.0,\"max_y\":90.0,\"counts\":[[0,0,2,1,0,0],[0,0,1,1,0,0],[0,1,1,1,0,0],[0,0,1,1,0,0],[0,0,1,1,0,0],[],[]]}}}";

    assertHeatmapContents(geo, expected, 4, "test");
}
 
开发者ID:boundlessgeo,项目名称:elasticsearch-heatmap,代码行数:11,代码来源:GeoHeatmapTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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