當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。