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

Java JtsGeometry类代码示例

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

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



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

示例1: toDoc

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

  ODocument doc = new ODocument(getName());
  MultiPolygon multiPolygon = (MultiPolygon) shape.getGeom();
  List<List<List<List<Double>>>> polyCoordinates = new ArrayList<List<List<List<Double>>>>();
  int n = multiPolygon.getNumGeometries();

  for (int i = 0; i < n; i++) {
    Geometry geom = multiPolygon.getGeometryN(i);
    polyCoordinates.add(coordinatesFromPolygon((Polygon) geom));
  }

  doc.field(COORDINATES, polyCoordinates);
  return doc;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:17,代码来源:OMultiPolygonShapeBuilder.java


示例2: createMultiPolygon

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
protected JtsGeometry createMultiPolygon(ShapeCollection<Shape> geometries) {

    Polygon[] polygons = new Polygon[geometries.size()];

    int i = 0;

    for (Shape geometry : geometries) {
      if (geometry instanceof JtsGeometry) {
        polygons[i] = (Polygon) ((JtsGeometry) geometry).getGeom();
      } else {
        Rectangle rectangle = (Rectangle) geometry;
        Geometry geometryFrom = SPATIAL_CONTEXT.getGeometryFrom(rectangle);
        polygons[i] = (Polygon) geometryFrom;
      }

      i++;
    }

    MultiPolygon multiPolygon = GEOMETRY_FACTORY.createMultiPolygon(polygons);

    return SPATIAL_CONTEXT.makeShape(multiPolygon);
  }
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:23,代码来源:OComplexShapeBuilder.java


示例3: parse

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
@Override
public Mapper parse(ParseContext context) throws IOException {
    try {
        Shape shape = context.parseExternalValue(Shape.class);
        if (shape == null) {
            ShapeBuilder shapeBuilder = ShapeBuilder.parse(context.parser(), this);
            if (shapeBuilder == null) {
                return null;
            }
            shape = shapeBuilder.build();
        }
        if (fieldType().pointsOnly() && !(shape instanceof Point)) {
            throw new MapperParsingException("[{" + fieldType().names().fullName() + "}] is configured for points only but a " +
                    ((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass()) + " was found");
        }
        Field[] fields = fieldType().defaultStrategy().createIndexableFields(shape);
        if (fields == null || fields.length == 0) {
            return null;
        }
        for (Field field : fields) {
            if (!customBoost()) {
                field.setBoost(fieldType().boost());
            }
            context.doc().add(field);
        }
    } catch (Exception e) {
        throw new MapperParsingException("failed to parse [" + fieldType().names().fullName() + "]", e);
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:31,代码来源:GeoShapeFieldMapper.java


示例4: fromDoc

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
@Override
public JtsGeometry fromDoc(ODocument document) {
  validate(document);
  List<List<List<List<Number>>>> coordinates = document.field("coordinates");

  Polygon[] polygons = new Polygon[coordinates.size()];
  int i = 0;
  for (List<List<List<Number>>> coordinate : coordinates) {
    polygons[i] = createPolygon(coordinate);
    i++;
  }
  return toShape(GEOMETRY_FACTORY.createMultiPolygon(polygons));
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:14,代码来源:OMultiPolygonShapeBuilder.java


示例5: fromDoc

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
@Override
public JtsGeometry fromDoc(ODocument document) {
  validate(document);
  List<List<Number>> coordinates = document.field(COORDINATES);
  Coordinate[] coords = new Coordinate[coordinates.size()];
  int i = 0;
  for (List<Number> coordinate : coordinates) {
    coords[i] = new Coordinate(coordinate.get(0).doubleValue(), coordinate.get(1).doubleValue());
    i++;
  }
  return toShape(GEOMETRY_FACTORY.createMultiPoint(coords));
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:13,代码来源:OMultiPointShapeBuilder.java


示例6: toDoc

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
@Override
public ODocument toDoc(final JtsGeometry shape) {
  final MultiPoint geom = (MultiPoint) shape.getGeom();

  ODocument doc = new ODocument(getName());
  doc.field(COORDINATES, new ArrayList<List<Double>>() {
    {
      Coordinate[] coordinates = geom.getCoordinates();
      for (Coordinate coordinate : coordinates) {
        add(Arrays.asList(coordinate.x, coordinate.y));
      }
    }
  });
  return doc;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:16,代码来源:OMultiPointShapeBuilder.java


示例7: isLineString

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
private boolean isLineString(Shape shape) {
  if (shape instanceof JtsGeometry) {
    Geometry geom = ((JtsGeometry) shape).getGeom();
    return geom instanceof LineString;
  }
  return false;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:8,代码来源:OComplexShapeBuilder.java


示例8: isPolygon

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
protected boolean isPolygon(Shape shape) {

    if (shape instanceof JtsGeometry) {
      Geometry geom = ((JtsGeometry) shape).getGeom();
      return geom instanceof Polygon;
    }
    if (shape instanceof Rectangle) {
      return true;
    }
    return false;
  }
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:12,代码来源:OComplexShapeBuilder.java


示例9: fromDoc

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
@Override
public JtsGeometry fromDoc(ODocument document) {

  validate(document);
  List<List<Number>> coordinates = document.field(COORDINATES);

  Coordinate[] coords = new Coordinate[coordinates.size()];
  int i = 0;
  for (List<Number> coordinate : coordinates) {
    coords[i] = new Coordinate(coordinate.get(0).doubleValue(), coordinate.get(1).doubleValue());
    i++;
  }
  return toShape(GEOMETRY_FACTORY.createLineString(coords));
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:15,代码来源:OLineStringShapeBuilder.java


示例10: toDoc

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
@Override
public ODocument toDoc(JtsGeometry shape) {
  ODocument doc = new ODocument(getName());
  LineString lineString = (LineString) shape.getGeom();
  doc.field(COORDINATES, coordinatesFromLineString(lineString));
  return doc;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:8,代码来源:OLineStringShapeBuilder.java


示例11: fromDoc

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
@Override
public JtsGeometry fromDoc(ODocument document) {
  validate(document);
  List<List<List<Number>>> coordinates = document.field(COORDINATES);
  LineString[] multiLine = new LineString[coordinates.size()];
  int j = 0;
  for (List<List<Number>> coordinate : coordinates) {
    multiLine[j] = createLineString(coordinate);
    j++;
  }
  return toShape(GEOMETRY_FACTORY.createMultiLineString(multiLine));
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:13,代码来源:OMultiLineStringShapeBuilder.java


示例12: toDoc

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
@Override
public ODocument toDoc(JtsGeometry shape) {
  final MultiLineString geom = (MultiLineString) shape.getGeom();

  List<List<List<Double>>> coordinates = new ArrayList<List<List<Double>>>();
  ODocument doc = new ODocument(getName());
  for (int i = 0; i < geom.getNumGeometries(); i++) {
    final LineString lineString = (LineString) geom.getGeometryN(i);
    coordinates.add(coordinatesFromLineString(lineString));
  }

  doc.field(COORDINATES, coordinates);
  return doc;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:15,代码来源:OMultiLineStringShapeBuilder.java


示例13: fromDoc

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
@Override
public JtsGeometry fromDoc(ODocument document) {
  validate(document);
  List<List<List<Number>>> coordinates = document.field("coordinates");

  return toShape(createPolygon(coordinates));
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:8,代码来源:OPolygonShapeBuilder.java


示例14: toDoc

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

  ODocument doc = new ODocument(getName());
  Polygon polygon = (Polygon) shape.getGeom();
  List<List<List<Double>>> polyCoordinates = coordinatesFromPolygon(polygon);
  doc.field(COORDINATES, polyCoordinates);
  return doc;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:10,代码来源:OPolygonShapeBuilder.java


示例15: toDoc

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的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


示例16: testMultiLineStringIO

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
@Test
public void testMultiLineStringIO() {

  ODocument doc = new ODocument("OMultiLineString");
  doc.field("coordinates", new ArrayList<List<List<Double>>>() {
    {
      add(new ArrayList<List<Double>>() {
        {
          add(Arrays.asList(-71.160281, 42.258729));
          add(Arrays.asList(-71.160837, 42.259113));
          add(Arrays.asList(-71.161144, 42.25932));
        }
      });
    }
  });

  OMultiLineStringShapeBuilder builder = new OMultiLineStringShapeBuilder();
  String multiLineString = builder.asText(doc);

  Shape shape = context.makeLineString(new ArrayList<Point>() {
    {
      add(context.makePoint(-71.160281, 42.258729));
      add(context.makePoint(-71.160837, 42.259113));
      add(context.makePoint(-71.161144, 42.25932));
    }
  });

  JtsGeometry geometry = (JtsGeometry) shape;

  LineString lineString = (LineString) geometry.getGeom();
  MultiLineString multiLineString2 = geometryFactory.createMultiLineString(new LineString[] { lineString });
  String multiLineString1 = multiLineString2.toText();

  Assert.assertEquals(multiLineString1, multiLineString);
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:36,代码来源:LuceneSpatialIOTest.java


示例17: writeShape

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
void writeShape(Shape shape, JsonGenerator gen) throws IOException {
    if (shape instanceof Point) {
        write((Point) shape, gen);
    } else if (shape instanceof Circle) {
        write((Circle) shape, gen);
    } else if (shape instanceof Rectangle) {
        write((Rectangle) shape, gen);
    } else if (shape instanceof ShapeCollection<?>) {
        write((ShapeCollection<?>) shape, gen);
    } else if (shape instanceof JtsGeometry) {
        write((JtsGeometry) shape, gen);
    } else {
        throw new RuntimeException("Unsupported Geometry type");
    }
}
 
开发者ID:scaleset,项目名称:scaleset-geo,代码行数:16,代码来源:ShapeSerializer.java


示例18: toShape

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
public JtsGeometry toShape(Geometry geometry) {
  return SPATIAL_CONTEXT.makeShape(geometry);
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:4,代码来源:OShapeBuilder.java


示例19: write

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
void write(JtsGeometry jtsGeometry, JsonGenerator gen) throws IOException {
    Geometry geometry = jtsGeometry.getGeom();
    jtsSerializer.writeGeometry(geometry, gen);
}
 
开发者ID:scaleset,项目名称:scaleset-geo,代码行数:5,代码来源:ShapeSerializer.java


示例20: cutOnPoles

import com.spatial4j.core.shape.jts.JtsGeometry; //导入依赖的package包/类
/**
 * Cut given polygon on poles (89 and -89)
 */
private static String cutOnPoles(String polygonWKT) throws Exception
{
   JtsSpatialContextFactory noCheckFactory = new JtsSpatialContextFactory();
   noCheckFactory.datelineRule = DatelineRule.none;
   noCheckFactory.validationRule = ValidationRule.none;
   JtsSpatialContext noCheckContext = noCheckFactory.newSpatialContext();
   JtsWKTReaderShapeParser noCheckParser =
         new JtsWKTReaderShapeParser(noCheckContext, noCheckFactory);

   JtsGeometry polygon = (JtsGeometry) noCheckParser.parse(polygonWKT);
   JtsGeometry northPole =
         (JtsGeometry) noCheckParser.parse("LINESTRING(180 89, 0 89, -180 89)");
   JtsGeometry southPole =
         (JtsGeometry) noCheckParser.parse("LINESTRING(180 -89, 0 -89, -180 -89)");

   LineMerger lm = new LineMerger();
   lm.add(polygon.getGeom());
   lm.add(northPole.getGeom());
   lm.add(southPole.getGeom());

   Geometry geometry = UnaryUnionOp.union(lm.getMergedLineStrings());

   Polygonizer polygonizer = new Polygonizer();
   polygonizer.add(geometry);

   List<Polygon> foundPolygons = (List<Polygon>) polygonizer.getPolygons();
   List<Polygon> filteredPolygons = new ArrayList<>();
   for (Polygon p: foundPolygons)
   {
      // removing polygons over the poles
      if (p.getCentroid().getCoordinate().y < 89 && p.getCentroid().getCoordinate().y > -89)
      {
         filteredPolygons.add(p);
      }
   }

   Geometry res = null;

   if (!filteredPolygons.isEmpty())
   {
      res = filteredPolygons.get(0);
   }
   if (filteredPolygons.size() > 1)
   {
      // Should not happen...
      LOGGER.error("A Multipolygon was found, instead of a single polygon. Only the first one is retained.");
   }

   WKTWriter wkw = new WKTWriter();
   return wkw.write(res);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:55,代码来源:JTSFootprintParser.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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