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

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

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

Geometry.isEmpty介绍

[英]Tests whether the set of points covered by this Geometry is empty.
[中]测试此Geometry覆盖的点集是否为空。

代码示例

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

  1. @Override
  2. public boolean test(Geometry geom1, Geometry geom2) {
  3. if ( geom1 != null && geom1.isEmpty() ) {
  4. return geom2 == null || geom2.isEmpty();
  5. }
  6. return super.test( geom1, geom2 );
  7. }

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

  1. @Override
  2. public boolean test(Geometry geom1, Geometry geom2) {
  3. if ( geom1 != null && geom1.isEmpty() ) {
  4. return geom2 == null || geom2.isEmpty();
  5. }
  6. return super.test( geom1, geom2 );
  7. }

代码示例来源: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: prestodb/presto

  1. private static void writeEnvelope(Geometry geometry, SliceOutput output)
  2. {
  3. if (geometry.isEmpty()) {
  4. for (int i = 0; i < 4; i++) {
  5. output.writeDouble(NaN);
  6. }
  7. return;
  8. }
  9. Envelope envelope = geometry.getEnvelopeInternal();
  10. output.writeDouble(envelope.getMinX());
  11. output.writeDouble(envelope.getMinY());
  12. output.writeDouble(envelope.getMaxX());
  13. output.writeDouble(envelope.getMaxY());
  14. }

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

  1. @Override
  2. public boolean test(Geometry geom1, Geometry geom2) {
  3. if ( geom1 == null ) {
  4. return geom2 == null;
  5. }
  6. if ( geom1.isEmpty() ) {
  7. return geom2.isEmpty();
  8. }
  9. if ( !equalSRID( geom1, geom2 ) ) {
  10. return false;
  11. }
  12. if ( geom1 instanceof GeometryCollection ) {
  13. if ( !( geom2 instanceof GeometryCollection ) ) {
  14. return false;
  15. }
  16. GeometryCollection expectedCollection = (GeometryCollection) geom1;
  17. GeometryCollection receivedCollection = (GeometryCollection) geom2;
  18. for ( int partIndex = 0; partIndex < expectedCollection.getNumGeometries(); partIndex++ ) {
  19. Geometry partExpected = expectedCollection.getGeometryN( partIndex );
  20. Geometry partReceived = receivedCollection.getGeometryN( partIndex );
  21. if ( !test( partExpected, partReceived ) ) {
  22. return false;
  23. }
  24. }
  25. return true;
  26. }
  27. else {
  28. return testSimpleGeometryEquality( geom1, geom2 );
  29. }
  30. }

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

  1. public static boolean isEmpty(Geometry arg0) {
  2. if (arg0 == null) return false;
  3. Geometry _this = arg0;
  4. return _this.isEmpty();
  5. }

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

  1. public boolean isEmpty() {
  2. return geometry.isEmpty();
  3. }

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

  1. public MultiLevelROIGeometryOverviews(
  2. Geometry footprint,
  3. List<Geometry> multilevelFootprints,
  4. boolean overviewsInRasterSpace,
  5. Hints hints) {
  6. this.originalFootprint = footprint;
  7. this.multilevelFootprints = multilevelFootprints;
  8. this.numOverviews = multilevelFootprints != null ? multilevelFootprints.size() : 0;
  9. this.overviewsRoiInRasterSpace = overviewsInRasterSpace;
  10. this.empty = originalFootprint.isEmpty();
  11. this.hints = hints;
  12. }

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

  1. @Override
  2. public void setGeometryValue(
  3. Geometry g, int dimension, int srid, Class binding, PreparedStatement ps, int column)
  4. throws SQLException {
  5. if (g == null || g.isEmpty()) {
  6. ps.setNull(column, Types.BLOB);
  7. return;
  8. }
  9. ps.setBytes(column, GeoDB.gToWKB(g));
  10. }

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

  1. @Override
  2. public void filter(Geometry geom) {
  3. if (!(geom instanceof GeometryCollection)
  4. && geom.getDimension() == targetDimension
  5. && !geom.isEmpty()) {
  6. geometries.add(geom);
  7. }
  8. }

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

  1. public Object getProperty(Object object, QName name) {
  2. // hack for xlink stuff
  3. Geometry geometry = (Geometry) object;
  4. if (geometry.isEmpty()) {
  5. return null;
  6. }
  7. if ("pos".equals(name.getLocalPart())) {
  8. Point point = (Point) object;
  9. return point.getCoordinateSequence();
  10. }
  11. return null;
  12. }
  13. }

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

  1. /**
  2. * Returns true if the geometry is fully empty
  3. *
  4. * @param geometry
  5. * @return
  6. */
  7. private boolean isEmpty(Literal geometry) {
  8. if (geometry != null) {
  9. Geometry g = geometry.evaluate(null, Geometry.class);
  10. return g == null || g.isEmpty();
  11. }
  12. return false;
  13. }

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

  1. public void encodeGeometryValue(Geometry value, int srid, StringBuffer sql) throws IOException {
  2. if (value == null || value.isEmpty()) {
  3. sql.append("ST_GeomFromText ('");
  4. sql.append(new WKTWriter().write(value));
  5. sql.append("',");
  6. sql.append(srid);
  7. sql.append(")");
  8. } else {
  9. sql.append("NULL");
  10. }
  11. }

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

  1. @Override
  2. public void setGeometryValue(
  3. Geometry g, int dimension, int srid, Class binding, PreparedStatement ps, int column)
  4. throws SQLException {
  5. if (g == null || g.isEmpty()) {
  6. // ps.setNull(column, Types.OTHER);
  7. ps.setBytes(column, null);
  8. return;
  9. }
  10. DB2WKBWriter w = new DB2WKBWriter(dimension, getDb2DialectInfo().isHasOGCWkbZTyps());
  11. byte[] bytes = w.write(g);
  12. ps.setBytes(column, bytes);
  13. }

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

  1. private static void addCoordinates(List list, MultiPoint points) {
  2. for (int i = 0; i < points.getNumGeometries(); i++) {
  3. Geometry geometryN = points.getGeometryN(i);
  4. if (geometryN != null && !geometryN.isEmpty()) addCoordinates(list, (Point) geometryN);
  5. }
  6. }

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

  1. private static void addCoordinates(List list, MultiLineString lines) {
  2. for (int i = 0; i < lines.getNumGeometries(); i++) {
  3. Geometry geometryN = lines.getGeometryN(i);
  4. if (geometryN != null && !geometryN.isEmpty())
  5. addCoordinates(list, (LineString) geometryN);
  6. }
  7. }

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

  1. @DescribeProcess(
  2. title = "Empty Test",
  3. description = "Tests if a geometry contains no vertices."
  4. )
  5. @DescribeResult(description = "True if the input is empty")
  6. public static boolean isEmpty(
  7. @DescribeParameter(name = "geom", description = "Input geometry") Geometry geom) {
  8. return geom.isEmpty();
  9. }

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

  1. private static void addCoordinates(List list, MultiPolygon polys) {
  2. for (int i = 0; i < polys.getNumGeometries(); i++) {
  3. Geometry geometryN = polys.getGeometryN(i);
  4. if (geometryN != null && !geometryN.isEmpty())
  5. addCoordinates(list, (Polygon) geometryN);
  6. }
  7. }

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

  1. /**
  2. * Writes a Geometry instance as GeoJSON.
  3. *
  4. * @param geometry The geometry.
  5. * @param output The output. See {@link GeoJSONUtil#toWriter(Object)} for details.
  6. */
  7. public void write(Geometry geometry, Object output) throws IOException {
  8. if (geometry == null || geometry.isEmpty()) {
  9. GeoJSONUtil.encode("null", output);
  10. } else {
  11. GeoJSONUtil.encode(create(geometry), output);
  12. }
  13. }

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

  1. @Test
  2. public void testGeotXYWZ() throws Exception {
  3. clipper = new GeometryClipper(new Envelope(-11, 761, -11, 611));
  4. Geometry g =
  5. wkt.read(
  6. "POLYGON((367 -13, 459 105, 653 -42, 611 -96, 562 -60, 514 -124, 367 -13))");
  7. // System.out.println(g.getNumPoints());
  8. Geometry clipped = clipper.clip(g, false);
  9. assertNotNull(clipped);
  10. assertTrue(!clipped.isEmpty());
  11. // System.out.println(clipped);
  12. }

相关文章