当前位置: 首页>>代码示例>>Java>>正文


Java ShapeCollection类代码示例

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


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

示例1: shape2Map

import com.spatial4j.core.shape.ShapeCollection; //导入依赖的package包/类
public static Map<String, Object> shape2Map(Shape shape) {
    if (shape instanceof ShapeCollection) {
        ShapeCollection<?> shapeCollection = (ShapeCollection<?>)shape;
        List<Map<String, Object>> geometries = new ArrayList<>(shapeCollection.size());
        for(Shape collShape : shapeCollection) {
            geometries.add(shape2Map(collShape));
        }
        return ImmutableMap.of(
                TYPE_FIELD, GEOMETRY_COLLECTION,
                GEOMETRIES_FIELD, geometries
                );
    } else {
        try {
            return GEOJSON_CONVERTER.convert(JtsSpatialContext.GEO.getGeometryFrom(shape));
        } catch (InvalidShapeException e) {
            throw new IllegalArgumentException(
                    String.format(Locale.ENGLISH, "Cannot convert shape %s to Map", shape), e);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:GeoJSONUtils.java

示例2: gridSnap

import com.spatial4j.core.shape.ShapeCollection; //导入依赖的package包/类
protected Shape gridSnap(Shape snapMe) {
  if (snapMe == null)
    return null;
  if (snapMe instanceof ShapePair) {
    ShapePair me = (ShapePair) snapMe;
    return new ShapePair(gridSnap(me.shape1), gridSnap(me.shape2), me.biasContainsThenWithin);
  }
  if (snapMe instanceof Point) {
    snapMe = snapMe.getBoundingBox();
  }
  //The next 4 lines mimic PrefixTreeStrategy.createIndexableFields()
  double distErrPct = ((PrefixTreeStrategy) strategy).getDistErrPct();
  double distErr = SpatialArgs.calcDistanceFromErrPct(snapMe, distErrPct, ctx);
  int detailLevel = grid.getLevelForDistance(distErr);
  List<Cell> cells = grid.getCells(snapMe, detailLevel, false, true);

  //calc bounding box of cells.
  List<Shape> cellShapes = new ArrayList<>(cells.size());
  for (Cell cell : cells) {
    cellShapes.add(cell.getShape());
  }
  return new ShapeCollection<>(cellShapes, ctx).getBoundingBox();
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:SpatialOpRecursivePrefixTreeTest.java

示例3: gridSnap

import com.spatial4j.core.shape.ShapeCollection; //导入依赖的package包/类
protected Shape gridSnap(Shape snapMe) {
  if (snapMe == null)
    return null;
  if (snapMe instanceof ShapePair) {
    ShapePair me = (ShapePair) snapMe;
    return new ShapePair(gridSnap(me.shape1), gridSnap(me.shape2), me.biasContainsThenWithin);
  }
  if (snapMe instanceof Point) {
    snapMe = snapMe.getBoundingBox();
  }
  //The next 4 lines mimic PrefixTreeStrategy.createIndexableFields()
  double distErrPct = ((PrefixTreeStrategy) strategy).getDistErrPct();
  double distErr = SpatialArgs.calcDistanceFromErrPct(snapMe, distErrPct, ctx);
  int detailLevel = grid.getLevelForDistance(distErr);
  Iterator<Cell> cells = grid.getCells(snapMe, detailLevel, false, false).iterator();

  //calc bounding box of cells.
  List<Shape> cellShapes = new ArrayList<>(1024);
  while (cells.hasNext()) {
    Cell cell = cells.next();
    if (!cell.isLeaf())
      continue;
    cellShapes.add(cell.getShape());
  }
  return new ShapeCollection<>(cellShapes, ctx).getBoundingBox();
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:RandomSpatialOpFuzzyPrefixTreeTest.java

示例4: fromDoc

import com.spatial4j.core.shape.ShapeCollection; //导入依赖的package包/类
@Override
public ShapeCollection<Shape> fromDoc(ODocument doc) {

  List<ODocument> geometries = doc.field("geometries");

  List<Shape> shapes = new ArrayList<Shape>();

  Geometry[] geoms = new Geometry[geometries.size()];
  for (ODocument geometry : geometries) {
    Shape shape = shapeFactory.fromDoc(geometry);
    shapes.add(shape);
  }

  return new ShapeCollection(shapes, SPATIAL_CONTEXT);
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:16,代码来源:OGeometryCollectionShapeBuilder.java

示例5: asText

import com.spatial4j.core.shape.ShapeCollection; //导入依赖的package包/类
@Override
public String asText(ShapeCollection<Shape> shapes) {

  Geometry[] geometries = new Geometry[shapes.size()];
  int i = 0;
  for (Shape shape : shapes) {
    geometries[i] = SPATIAL_CONTEXT.getGeometryFrom(shape);
    i++;
  }
  return GEOMETRY_FACTORY.createGeometryCollection(geometries).toText();
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:12,代码来源:OGeometryCollectionShapeBuilder.java

示例6: toDoc

import com.spatial4j.core.shape.ShapeCollection; //导入依赖的package包/类
@Override
public ODocument toDoc(ShapeCollection<Shape> shapes) {

  ODocument doc = new ODocument(getName());
  List<ODocument> geometries = new ArrayList<ODocument>(shapes.size());
  for (Shape s : shapes) {
    geometries.add(shapeFactory.toDoc(s));
  }
  doc.field("geometries", geometries);
  return doc;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:12,代码来源:OGeometryCollectionShapeBuilder.java

示例7: toDoc

import com.spatial4j.core.shape.ShapeCollection; //导入依赖的package包/类
@Override
public ODocument toDoc(Shape shape) {

  // TODO REFACTOR
  ODocument doc = null;
  if (Point.class.isAssignableFrom(shape.getClass())) {
    doc = factories.get(OPointShapeBuilder.NAME).toDoc(shape);
  } else if (Rectangle.class.isAssignableFrom(shape.getClass())) {
    doc = factories.get(ORectangleShapeBuilder.NAME).toDoc(shape);
  } else if (JtsGeometry.class.isAssignableFrom(shape.getClass())) {
    JtsGeometry geometry = (JtsGeometry) shape;
    Geometry geom = geometry.getGeom();
    doc = factories.get("O" + geom.getClass().getSimpleName()).toDoc(shape);

  } else if (ShapeCollection.class.isAssignableFrom(shape.getClass())) {
    ShapeCollection collection = (ShapeCollection) shape;

    if (isMultiPolygon(collection)) {
      doc = factories.get("OMultiPolygon").toDoc(createMultiPolygon(collection));
    } else if (isMultiPoint(collection)) {
      doc = factories.get("OMultiPoint").toDoc(createMultiPoint(collection));
    } else if (isMultiLine(collection)) {
      doc = factories.get("OMultiLineString").toDoc(createMultiLine(collection));
    } else {
      doc = factories.get("OGeometryCollection").toDoc(shape);
    }
  }
  return doc;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:30,代码来源:OShapeFactory.java


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