本文整理了Java中org.locationtech.jts.geom.Geometry.getGeometryType()
方法的一些代码示例,展示了Geometry.getGeometryType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.getGeometryType()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Geometry
类名称:Geometry
方法名:getGeometryType
[英]Returns the name of this Geometry's actual class.
[中]返回此几何体的实际类的名称。
代码示例来源:origin: JanusGraph/janusgraph
@SuppressWarnings("unchecked")
public Geoshape.Type getType(Shape shape) {
final Geoshape.Type type;
if (JtsGeometry.class.isAssignableFrom(shape.getClass()) && "LineString".equals(((JtsGeometry) shape).getGeom().getGeometryType())) {
type = Geoshape.Type.LINE;
} else if (JtsGeometry.class.isAssignableFrom(shape.getClass())) {
try {
type = Geoshape.Type.fromGson((((JtsGeometry) shape).getGeom().getGeometryType()));
} catch (IllegalArgumentException e) {
throw new IllegalStateException("Unrecognized shape type");
代码示例来源:origin: prestodb/presto
private static void writeGeometry(Geometry geometry, DynamicSliceOutput output)
{
switch (geometry.getGeometryType()) {
case "Point":
writePoint((Point) geometry, output);
break;
case "MultiPoint":
writeMultiPoint((MultiPoint) geometry, output);
break;
case "LineString":
writePolyline(geometry, output, false);
break;
case "MultiLineString":
writePolyline(geometry, output, true);
break;
case "Polygon":
writePolygon(geometry, output, false);
break;
case "MultiPolygon":
writePolygon(geometry, output, true);
break;
case "GeometryCollection":
writeGeometryCollection(geometry, output);
break;
default:
throw new IllegalArgumentException("Unsupported geometry type : " + geometry.getGeometryType());
}
}
代码示例来源:origin: prestodb/presto
@SqlNullable
@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.")
@ScalarFunction("line_locate_point")
@SqlType(DOUBLE)
public static Double lineLocatePoint(@SqlType(GEOMETRY_TYPE_NAME) Slice lineSlice, @SqlType(GEOMETRY_TYPE_NAME) Slice pointSlice)
{
Geometry line = JtsGeometrySerde.deserialize(lineSlice);
Geometry point = JtsGeometrySerde.deserialize(pointSlice);
if (line.isEmpty() || point.isEmpty()) {
return null;
}
GeometryType lineType = GeometryType.getForJtsGeometryType(line.getGeometryType());
if (lineType != GeometryType.LINE_STRING && lineType != GeometryType.MULTI_LINE_STRING) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("First argument to line_locate_point must be a LineString or a MultiLineString. Got: %s", line.getGeometryType()));
}
GeometryType pointType = GeometryType.getForJtsGeometryType(point.getGeometryType());
if (pointType != GeometryType.POINT) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Second argument to line_locate_point must be a Point. Got: %s", point.getGeometryType()));
}
return new LengthIndexedLine(line).indexOf(point.getCoordinate()) / line.getLength();
}
代码示例来源:origin: hibernate/hibernate-orm
protected boolean testTypeAndVertexEquality(Geometry geom1, Geometry geom2) {
if ( !geom1.getGeometryType().equals( geom2.getGeometryType() ) ) {
return false;
}
if ( geom1.getNumGeometries() != geom2.getNumGeometries() ) {
return false;
}
if ( geom1.getNumPoints() != geom2.getNumPoints() ) {
return false;
}
Coordinate[] coordinates1 = geom1.getCoordinates();
Coordinate[] coordinates2 = geom2.getCoordinates();
for ( int i = 0; i < coordinates1.length; i++ ) {
Coordinate c1 = coordinates1[i];
Coordinate c2 = coordinates2[i];
if ( !testCoordinateEquality( c1, c2 ) ) {
return false;
}
}
return true;
}
代码示例来源:origin: geotools/geotools
public static String geometryType(Geometry arg0) {
if (arg0 == null) return null;
Geometry _this = arg0;
return _this.getGeometryType();
}
代码示例来源:origin: geotools/geotools
public String getGeometryType() {
return geometry.getGeometryType();
}
代码示例来源:origin: geotools/geotools
/**
* Returns the type of the geometry as a string. Eg: 'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.
*
* <p>This method returns <code>null</code> when <tt>wkb</tt> is <code>null</code>.
*
* @param wkb The geometry.
*/
public static String GeometryType(byte[] wkb) {
if (wkb == null) {
return null;
}
Geometry g = fromWKB(wkb);
return g != null ? g.getGeometryType().toUpperCase() : null;
}
代码示例来源:origin: geotools/geotools
+ geom.getGeometryType()
+ " as SDO_GTYPE "
+ "(Limitied to Point, Line, Polygon, GeometryCollection, MultiPoint,"
代码示例来源:origin: geotools/geotools
@Override
public void filter(Geometry gmtr) {
if (MultiPolygon.class.isAssignableFrom(binding)) {
if (gmtr.getArea() != 0.0d && gmtr.getGeometryType().equals("Polygon")) {
collection.add(gmtr);
}
}
if (MultiLineString.class.isAssignableFrom(binding)) {
if (gmtr.getLength() != 0.0d && gmtr.getGeometryType().equals("LineString")) {
collection.add(gmtr);
}
}
if (MultiPoint.class.isAssignableFrom(binding)) {
if (gmtr.getNumGeometries() > 0 && gmtr.getGeometryType().equals("Point")) {
collection.add(gmtr);
}
}
if (Point.class.isAssignableFrom(binding)) {
if (gmtr.getGeometryType().equals("Point")) {
collection.add(gmtr);
}
}
}
代码示例来源:origin: geotools/geotools
static Object[] distanceBufferOpProperty(Expression e) {
if (e instanceof PropertyName) {
return new Object[] {FES.ValueReference, e};
} else if (e instanceof Literal) {
Literal l = (Literal) e;
if (l.getValue() instanceof Geometry) {
Geometry g = (Geometry) l.getValue();
return new Object[] {new QName(GML.NAMESPACE, g.getGeometryType()), g};
}
return new Object[] {FES.Literal, e};
} else if (e instanceof Function) {
return new Object[] {FES.Function, e};
} else {
return new Object[] {FES.expression, e};
}
}
代码示例来源:origin: geotools/geotools
/**
* Construct a geometry from the WKT representation of a geometry
*
* @param geom the constructor for the geometry.
*/
public String db2Geom(Geometry geom) {
String geomType = geom.getGeometryType();
String g1 = geom.toText();
String g2 = "db2gse.ST_" + geomType + "('" + g1 + "'," + getSRID() + ")";
return g2;
}
代码示例来源:origin: geotools/geotools
@DescribeProcess(
title = "Geometry Type",
description =
"Returns the name of a geometry's type. Values are one of POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION."
)
@DescribeResult(description = "The name of the geometry type")
public static String geometryType(
@DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) {
return geom.getGeometryType();
}
代码示例来源:origin: geotools/geotools
+ geom.getGeometryType()
+ " as "
+ "SDO_ORDINATRES (Limitied to Point, Line, Polygon, "
代码示例来源:origin: geotools/geotools
if (geo.getGeometryType().equals(geometryType)) {
geoms.add(geo);
代码示例来源:origin: geotools/geotools
private static Geometry smooth(
final Geometry geom,
final double fit,
final GeometryFactory factory,
GeometrySmoother smoother) {
switch (Geometries.get(geom)) {
case POINT:
case MULTIPOINT:
// For points, just return the input geometry
return geom;
case LINESTRING:
// This handles open and closed lines (LinearRings)
return smoothLineString(factory, smoother, geom, fit);
case MULTILINESTRING:
return smoothMultiLineString(factory, smoother, geom, fit);
case POLYGON:
return smoother.smooth((Polygon) geom, fit);
case MULTIPOLYGON:
return smoothMultiPolygon(factory, smoother, geom, fit);
case GEOMETRYCOLLECTION:
return smoothGeometryCollection(factory, smoother, geom, fit);
default:
throw new UnsupportedOperationException(
"No smoothing method available for " + geom.getGeometryType());
}
}
代码示例来源:origin: geotools/geotools
+ geom.getGeometryType()
+ " as SDO_ELEM_INFO "
+ "(Limitied to Point, Line, Polygon, GeometryCollection, MultiPoint,"
代码示例来源:origin: geotools/geotools
+ geom.getGeometryType()
+ " as "
+ "SDO_ORDINATRES (Limitied to Point, Line, Polygon, "
代码示例来源:origin: org.elasticsearch/elasticsearch
} else if (shape instanceof Point == false) {
throw new MapperParsingException("[{" + fieldType().name() + "}] is configured for points only but a "
+ ((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass())
+ " was found");
代码示例来源:origin: geotools/geotools
@Test
public void testDecimateCollection() throws Exception {
WKTReader2 reader = new WKTReader2();
MultiLineString origin =
(MultiLineString)
reader.read("MULTICURVE((0 0, 5 5),CIRCULARSTRING(4 0, 4 4, 8 4))");
Decimator d = new Decimator(0.1, 0.1);
MultiLineString simplified =
(MultiLineString) d.decimateTransformGeneralize(origin, identity);
assertEquals(origin.getGeometryN(0), simplified.getGeometryN(0));
assertNotEquals(origin.getGeometryN(1), simplified.getGeometryN(1));
assertEquals("CircularString", origin.getGeometryN(1).getGeometryType());
assertEquals("LineString", simplified.getGeometryN(1).getGeometryType());
}
}
代码示例来源:origin: geotools/geotools
throw new IllegalArgumentException("Unknown geometry type: " + geom.getGeometryType());
内容来源于网络,如有侵权,请联系作者删除!