org.locationtech.jts.geom.Geometry.getGeometryType()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(251)

本文整理了Java中org.locationtech.jts.geom.Geometry.getGeometryType()方法的一些代码示例,展示了Geometry.getGeometryType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.getGeometryType()方法的具体详情如下:
包路径:org.locationtech.jts.geom.Geometry
类名称:Geometry
方法名:getGeometryType

Geometry.getGeometryType介绍

[英]Returns the name of this Geometry's actual class.
[中]返回此几何体的实际类的名称。

代码示例

代码示例来源:origin: JanusGraph/janusgraph

  1. @SuppressWarnings("unchecked")
  2. public Geoshape.Type getType(Shape shape) {
  3. final Geoshape.Type type;
  4. if (JtsGeometry.class.isAssignableFrom(shape.getClass()) && "LineString".equals(((JtsGeometry) shape).getGeom().getGeometryType())) {
  5. type = Geoshape.Type.LINE;
  6. } else if (JtsGeometry.class.isAssignableFrom(shape.getClass())) {
  7. try {
  8. type = Geoshape.Type.fromGson((((JtsGeometry) shape).getGeom().getGeometryType()));
  9. } catch (IllegalArgumentException e) {
  10. throw new IllegalStateException("Unrecognized shape type");

代码示例来源:origin: prestodb/presto

  1. private static void writeGeometry(Geometry geometry, DynamicSliceOutput output)
  2. {
  3. switch (geometry.getGeometryType()) {
  4. case "Point":
  5. writePoint((Point) geometry, output);
  6. break;
  7. case "MultiPoint":
  8. writeMultiPoint((MultiPoint) geometry, output);
  9. break;
  10. case "LineString":
  11. writePolyline(geometry, output, false);
  12. break;
  13. case "MultiLineString":
  14. writePolyline(geometry, output, true);
  15. break;
  16. case "Polygon":
  17. writePolygon(geometry, output, false);
  18. break;
  19. case "MultiPolygon":
  20. writePolygon(geometry, output, true);
  21. break;
  22. case "GeometryCollection":
  23. writeGeometryCollection(geometry, output);
  24. break;
  25. default:
  26. throw new IllegalArgumentException("Unsupported geometry type : " + geometry.getGeometryType());
  27. }
  28. }

代码示例来源:origin: prestodb/presto

  1. @SqlNullable
  2. @Description("Returns a float between 0 and 1 representing the location of the closest point on the LineString to the given Point, as a fraction of total 2d line length.")
  3. @ScalarFunction("line_locate_point")
  4. @SqlType(DOUBLE)
  5. public static Double lineLocatePoint(@SqlType(GEOMETRY_TYPE_NAME) Slice lineSlice, @SqlType(GEOMETRY_TYPE_NAME) Slice pointSlice)
  6. {
  7. Geometry line = JtsGeometrySerde.deserialize(lineSlice);
  8. Geometry point = JtsGeometrySerde.deserialize(pointSlice);
  9. if (line.isEmpty() || point.isEmpty()) {
  10. return null;
  11. }
  12. GeometryType lineType = GeometryType.getForJtsGeometryType(line.getGeometryType());
  13. if (lineType != GeometryType.LINE_STRING && lineType != GeometryType.MULTI_LINE_STRING) {
  14. throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("First argument to line_locate_point must be a LineString or a MultiLineString. Got: %s", line.getGeometryType()));
  15. }
  16. GeometryType pointType = GeometryType.getForJtsGeometryType(point.getGeometryType());
  17. if (pointType != GeometryType.POINT) {
  18. throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Second argument to line_locate_point must be a Point. Got: %s", point.getGeometryType()));
  19. }
  20. return new LengthIndexedLine(line).indexOf(point.getCoordinate()) / line.getLength();
  21. }

代码示例来源:origin: hibernate/hibernate-orm

  1. protected boolean testTypeAndVertexEquality(Geometry geom1, Geometry geom2) {
  2. if ( !geom1.getGeometryType().equals( geom2.getGeometryType() ) ) {
  3. return false;
  4. }
  5. if ( geom1.getNumGeometries() != geom2.getNumGeometries() ) {
  6. return false;
  7. }
  8. if ( geom1.getNumPoints() != geom2.getNumPoints() ) {
  9. return false;
  10. }
  11. Coordinate[] coordinates1 = geom1.getCoordinates();
  12. Coordinate[] coordinates2 = geom2.getCoordinates();
  13. for ( int i = 0; i < coordinates1.length; i++ ) {
  14. Coordinate c1 = coordinates1[i];
  15. Coordinate c2 = coordinates2[i];
  16. if ( !testCoordinateEquality( c1, c2 ) ) {
  17. return false;
  18. }
  19. }
  20. return true;
  21. }

代码示例来源:origin: geotools/geotools

  1. public static String geometryType(Geometry arg0) {
  2. if (arg0 == null) return null;
  3. Geometry _this = arg0;
  4. return _this.getGeometryType();
  5. }

代码示例来源:origin: geotools/geotools

  1. public String getGeometryType() {
  2. return geometry.getGeometryType();
  3. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Returns the type of the geometry as a string. Eg: 'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.
  3. *
  4. * <p>This method returns <code>null</code> when <tt>wkb</tt> is <code>null</code>.
  5. *
  6. * @param wkb The geometry.
  7. */
  8. public static String GeometryType(byte[] wkb) {
  9. if (wkb == null) {
  10. return null;
  11. }
  12. Geometry g = fromWKB(wkb);
  13. return g != null ? g.getGeometryType().toUpperCase() : null;
  14. }

代码示例来源:origin: geotools/geotools

  1. + geom.getGeometryType()
  2. + " as SDO_GTYPE "
  3. + "(Limitied to Point, Line, Polygon, GeometryCollection, MultiPoint,"

代码示例来源:origin: geotools/geotools

  1. @Override
  2. public void filter(Geometry gmtr) {
  3. if (MultiPolygon.class.isAssignableFrom(binding)) {
  4. if (gmtr.getArea() != 0.0d && gmtr.getGeometryType().equals("Polygon")) {
  5. collection.add(gmtr);
  6. }
  7. }
  8. if (MultiLineString.class.isAssignableFrom(binding)) {
  9. if (gmtr.getLength() != 0.0d && gmtr.getGeometryType().equals("LineString")) {
  10. collection.add(gmtr);
  11. }
  12. }
  13. if (MultiPoint.class.isAssignableFrom(binding)) {
  14. if (gmtr.getNumGeometries() > 0 && gmtr.getGeometryType().equals("Point")) {
  15. collection.add(gmtr);
  16. }
  17. }
  18. if (Point.class.isAssignableFrom(binding)) {
  19. if (gmtr.getGeometryType().equals("Point")) {
  20. collection.add(gmtr);
  21. }
  22. }
  23. }

代码示例来源:origin: geotools/geotools

  1. static Object[] distanceBufferOpProperty(Expression e) {
  2. if (e instanceof PropertyName) {
  3. return new Object[] {FES.ValueReference, e};
  4. } else if (e instanceof Literal) {
  5. Literal l = (Literal) e;
  6. if (l.getValue() instanceof Geometry) {
  7. Geometry g = (Geometry) l.getValue();
  8. return new Object[] {new QName(GML.NAMESPACE, g.getGeometryType()), g};
  9. }
  10. return new Object[] {FES.Literal, e};
  11. } else if (e instanceof Function) {
  12. return new Object[] {FES.Function, e};
  13. } else {
  14. return new Object[] {FES.expression, e};
  15. }
  16. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Construct a geometry from the WKT representation of a geometry
  3. *
  4. * @param geom the constructor for the geometry.
  5. */
  6. public String db2Geom(Geometry geom) {
  7. String geomType = geom.getGeometryType();
  8. String g1 = geom.toText();
  9. String g2 = "db2gse.ST_" + geomType + "('" + g1 + "'," + getSRID() + ")";
  10. return g2;
  11. }

代码示例来源:origin: geotools/geotools

  1. @DescribeProcess(
  2. title = "Geometry Type",
  3. description =
  4. "Returns the name of a geometry's type. Values are one of POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION."
  5. )
  6. @DescribeResult(description = "The name of the geometry type")
  7. public static String geometryType(
  8. @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) {
  9. return geom.getGeometryType();
  10. }

代码示例来源:origin: geotools/geotools

  1. + geom.getGeometryType()
  2. + " as "
  3. + "SDO_ORDINATRES (Limitied to Point, Line, Polygon, "

代码示例来源:origin: geotools/geotools

  1. if (geo.getGeometryType().equals(geometryType)) {
  2. geoms.add(geo);

代码示例来源:origin: geotools/geotools

  1. private static Geometry smooth(
  2. final Geometry geom,
  3. final double fit,
  4. final GeometryFactory factory,
  5. GeometrySmoother smoother) {
  6. switch (Geometries.get(geom)) {
  7. case POINT:
  8. case MULTIPOINT:
  9. // For points, just return the input geometry
  10. return geom;
  11. case LINESTRING:
  12. // This handles open and closed lines (LinearRings)
  13. return smoothLineString(factory, smoother, geom, fit);
  14. case MULTILINESTRING:
  15. return smoothMultiLineString(factory, smoother, geom, fit);
  16. case POLYGON:
  17. return smoother.smooth((Polygon) geom, fit);
  18. case MULTIPOLYGON:
  19. return smoothMultiPolygon(factory, smoother, geom, fit);
  20. case GEOMETRYCOLLECTION:
  21. return smoothGeometryCollection(factory, smoother, geom, fit);
  22. default:
  23. throw new UnsupportedOperationException(
  24. "No smoothing method available for " + geom.getGeometryType());
  25. }
  26. }

代码示例来源:origin: geotools/geotools

  1. + geom.getGeometryType()
  2. + " as SDO_ELEM_INFO "
  3. + "(Limitied to Point, Line, Polygon, GeometryCollection, MultiPoint,"

代码示例来源:origin: geotools/geotools

  1. + geom.getGeometryType()
  2. + " as "
  3. + "SDO_ORDINATRES (Limitied to Point, Line, Polygon, "

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. } else if (shape instanceof Point == false) {
  2. throw new MapperParsingException("[{" + fieldType().name() + "}] is configured for points only but a "
  3. + ((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass())
  4. + " was found");

代码示例来源:origin: geotools/geotools

  1. @Test
  2. public void testDecimateCollection() throws Exception {
  3. WKTReader2 reader = new WKTReader2();
  4. MultiLineString origin =
  5. (MultiLineString)
  6. reader.read("MULTICURVE((0 0, 5 5),CIRCULARSTRING(4 0, 4 4, 8 4))");
  7. Decimator d = new Decimator(0.1, 0.1);
  8. MultiLineString simplified =
  9. (MultiLineString) d.decimateTransformGeneralize(origin, identity);
  10. assertEquals(origin.getGeometryN(0), simplified.getGeometryN(0));
  11. assertNotEquals(origin.getGeometryN(1), simplified.getGeometryN(1));
  12. assertEquals("CircularString", origin.getGeometryN(1).getGeometryType());
  13. assertEquals("LineString", simplified.getGeometryN(1).getGeometryType());
  14. }
  15. }

代码示例来源:origin: geotools/geotools

  1. throw new IllegalArgumentException("Unknown geometry type: " + geom.getGeometryType());

相关文章