本文整理了Java中org.locationtech.jts.geom.Geometry.isEmpty()
方法的一些代码示例,展示了Geometry.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.isEmpty()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Geometry
类名称:Geometry
方法名:isEmpty
[英]Tests whether the set of points covered by this Geometry
is empty.
[中]测试此Geometry
覆盖的点集是否为空。
代码示例来源:origin: hibernate/hibernate-orm
@Override
public boolean test(Geometry geom1, Geometry geom2) {
if ( geom1 != null && geom1.isEmpty() ) {
return geom2 == null || geom2.isEmpty();
}
return super.test( geom1, geom2 );
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public boolean test(Geometry geom1, Geometry geom2) {
if ( geom1 != null && geom1.isEmpty() ) {
return geom2 == null || geom2.isEmpty();
}
return super.test( geom1, geom2 );
}
代码示例来源: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: prestodb/presto
private static void writeEnvelope(Geometry geometry, SliceOutput output)
{
if (geometry.isEmpty()) {
for (int i = 0; i < 4; i++) {
output.writeDouble(NaN);
}
return;
}
Envelope envelope = geometry.getEnvelopeInternal();
output.writeDouble(envelope.getMinX());
output.writeDouble(envelope.getMinY());
output.writeDouble(envelope.getMaxX());
output.writeDouble(envelope.getMaxY());
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public boolean test(Geometry geom1, Geometry geom2) {
if ( geom1 == null ) {
return geom2 == null;
}
if ( geom1.isEmpty() ) {
return geom2.isEmpty();
}
if ( !equalSRID( geom1, geom2 ) ) {
return false;
}
if ( geom1 instanceof GeometryCollection ) {
if ( !( geom2 instanceof GeometryCollection ) ) {
return false;
}
GeometryCollection expectedCollection = (GeometryCollection) geom1;
GeometryCollection receivedCollection = (GeometryCollection) geom2;
for ( int partIndex = 0; partIndex < expectedCollection.getNumGeometries(); partIndex++ ) {
Geometry partExpected = expectedCollection.getGeometryN( partIndex );
Geometry partReceived = receivedCollection.getGeometryN( partIndex );
if ( !test( partExpected, partReceived ) ) {
return false;
}
}
return true;
}
else {
return testSimpleGeometryEquality( geom1, geom2 );
}
}
代码示例来源:origin: geotools/geotools
public static boolean isEmpty(Geometry arg0) {
if (arg0 == null) return false;
Geometry _this = arg0;
return _this.isEmpty();
}
代码示例来源:origin: geotools/geotools
public boolean isEmpty() {
return geometry.isEmpty();
}
代码示例来源:origin: geotools/geotools
public MultiLevelROIGeometryOverviews(
Geometry footprint,
List<Geometry> multilevelFootprints,
boolean overviewsInRasterSpace,
Hints hints) {
this.originalFootprint = footprint;
this.multilevelFootprints = multilevelFootprints;
this.numOverviews = multilevelFootprints != null ? multilevelFootprints.size() : 0;
this.overviewsRoiInRasterSpace = overviewsInRasterSpace;
this.empty = originalFootprint.isEmpty();
this.hints = hints;
}
代码示例来源:origin: geotools/geotools
@Override
public void setGeometryValue(
Geometry g, int dimension, int srid, Class binding, PreparedStatement ps, int column)
throws SQLException {
if (g == null || g.isEmpty()) {
ps.setNull(column, Types.BLOB);
return;
}
ps.setBytes(column, GeoDB.gToWKB(g));
}
代码示例来源:origin: geotools/geotools
@Override
public void filter(Geometry geom) {
if (!(geom instanceof GeometryCollection)
&& geom.getDimension() == targetDimension
&& !geom.isEmpty()) {
geometries.add(geom);
}
}
代码示例来源:origin: geotools/geotools
public Object getProperty(Object object, QName name) {
// hack for xlink stuff
Geometry geometry = (Geometry) object;
if (geometry.isEmpty()) {
return null;
}
if ("pos".equals(name.getLocalPart())) {
Point point = (Point) object;
return point.getCoordinateSequence();
}
return null;
}
}
代码示例来源:origin: geotools/geotools
/**
* Returns true if the geometry is fully empty
*
* @param geometry
* @return
*/
private boolean isEmpty(Literal geometry) {
if (geometry != null) {
Geometry g = geometry.evaluate(null, Geometry.class);
return g == null || g.isEmpty();
}
return false;
}
代码示例来源:origin: geotools/geotools
public void encodeGeometryValue(Geometry value, int srid, StringBuffer sql) throws IOException {
if (value == null || value.isEmpty()) {
sql.append("ST_GeomFromText ('");
sql.append(new WKTWriter().write(value));
sql.append("',");
sql.append(srid);
sql.append(")");
} else {
sql.append("NULL");
}
}
代码示例来源:origin: geotools/geotools
@Override
public void setGeometryValue(
Geometry g, int dimension, int srid, Class binding, PreparedStatement ps, int column)
throws SQLException {
if (g == null || g.isEmpty()) {
// ps.setNull(column, Types.OTHER);
ps.setBytes(column, null);
return;
}
DB2WKBWriter w = new DB2WKBWriter(dimension, getDb2DialectInfo().isHasOGCWkbZTyps());
byte[] bytes = w.write(g);
ps.setBytes(column, bytes);
}
代码示例来源:origin: geotools/geotools
private static void addCoordinates(List list, MultiPoint points) {
for (int i = 0; i < points.getNumGeometries(); i++) {
Geometry geometryN = points.getGeometryN(i);
if (geometryN != null && !geometryN.isEmpty()) addCoordinates(list, (Point) geometryN);
}
}
代码示例来源:origin: geotools/geotools
private static void addCoordinates(List list, MultiLineString lines) {
for (int i = 0; i < lines.getNumGeometries(); i++) {
Geometry geometryN = lines.getGeometryN(i);
if (geometryN != null && !geometryN.isEmpty())
addCoordinates(list, (LineString) geometryN);
}
}
代码示例来源:origin: geotools/geotools
@DescribeProcess(
title = "Empty Test",
description = "Tests if a geometry contains no vertices."
)
@DescribeResult(description = "True if the input is empty")
public static boolean isEmpty(
@DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) {
return geom.isEmpty();
}
代码示例来源:origin: geotools/geotools
private static void addCoordinates(List list, MultiPolygon polys) {
for (int i = 0; i < polys.getNumGeometries(); i++) {
Geometry geometryN = polys.getGeometryN(i);
if (geometryN != null && !geometryN.isEmpty())
addCoordinates(list, (Polygon) geometryN);
}
}
代码示例来源:origin: geotools/geotools
/**
* Writes a Geometry instance as GeoJSON.
*
* @param geometry The geometry.
* @param output The output. See {@link GeoJSONUtil#toWriter(Object)} for details.
*/
public void write(Geometry geometry, Object output) throws IOException {
if (geometry == null || geometry.isEmpty()) {
GeoJSONUtil.encode("null", output);
} else {
GeoJSONUtil.encode(create(geometry), output);
}
}
代码示例来源:origin: geotools/geotools
@Test
public void testGeotXYWZ() throws Exception {
clipper = new GeometryClipper(new Envelope(-11, 761, -11, 611));
Geometry g =
wkt.read(
"POLYGON((367 -13, 459 105, 653 -42, 611 -96, 562 -60, 514 -124, 367 -13))");
// System.out.println(g.getNumPoints());
Geometry clipped = clipper.clip(g, false);
assertNotNull(clipped);
assertTrue(!clipped.isEmpty());
// System.out.println(clipped);
}
内容来源于网络,如有侵权,请联系作者删除!