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

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

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

Geometry.getEnvelopeInternal介绍

[英]Gets an Envelope containing the minimum and maximum x and y values in this Geometry. If the geometry is empty, an empty Envelope is returned.

The returned object is a copy of the one maintained internally, to avoid aliasing issues. For best performance, clients which access this envelope frequently should cache the return value.
[中]获取一个信封,其中包含此Geometry中的最小和最大x和y值。如果几何体为空,则返回空Envelope
返回的对象是内部维护的对象的副本,以避免别名问题。为了获得最佳性能,经常访问此信封的客户端应该缓存返回值。

代码示例

代码示例来源:origin: com.h2database/h2

/**
 * Test if this geometry envelope intersects with the other geometry
 * envelope.
 *
 * @param r the other geometry
 * @return true if the two overlap
 */
public boolean intersectsBoundingBox(ValueGeometry r) {
  // the Geometry object caches the envelope
  return getGeometryNoCopy().getEnvelopeInternal().intersects(
      r.getGeometryNoCopy().getEnvelopeInternal());
}

代码示例来源:origin: com.h2database/h2

/**
 * Get the union.
 *
 * @param r the other geometry
 * @return the union of this geometry envelope and another geometry envelope
 */
public Value getEnvelopeUnion(ValueGeometry r) {
  GeometryFactory gf = new GeometryFactory();
  Envelope mergedEnvelope = new Envelope(getGeometryNoCopy().getEnvelopeInternal());
  mergedEnvelope.expandToInclude(r.getGeometryNoCopy().getEnvelopeInternal());
  return get(gf.toGeometry(mergedEnvelope));
}

代码示例来源: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: com.h2database/h2

private SpatialKey getKey(SearchRow row) {
  if (row == null) {
    return null;
  }
  Value v = row.getValue(columnIds[0]);
  if (v == ValueNull.INSTANCE) {
    return null;
  }
  Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometryNoCopy();
  Envelope env = g.getEnvelopeInternal();
  return new SpatialKey(row.getKey(),
      (float) env.getMinX(), (float) env.getMaxX(),
      (float) env.getMinY(), (float) env.getMaxY());
}

代码示例来源:origin: com.h2database/h2

private SpatialKey getKey(SearchRow row) {
  Value v = row.getValue(columnIds[0]);
  if (v == ValueNull.INSTANCE) {
    return new SpatialKey(row.getKey());
  }
  Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometryNoCopy();
  Envelope env = g.getEnvelopeInternal();
  return new SpatialKey(row.getKey(),
      (float) env.getMinX(), (float) env.getMaxX(),
      (float) env.getMinY(), (float) env.getMaxY());
}

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

@Override
  protected boolean basicEvaluate(Geometry left, Geometry right) {

    Envelope envLeft = left.getEnvelopeInternal();
    Envelope envRight = right.getEnvelopeInternal();

    if (envRight.contains(envLeft)) return left.within(right);
    else return false;
  }
}

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

@Override
protected boolean basicEvaluate(Geometry left, Geometry right) {
  Envelope envLeft = left.getEnvelopeInternal();
  Envelope envRight = right.getEnvelopeInternal();
  if (envRight.intersects(envLeft)) return left.disjoint(right);
  return true;
}

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

@Override
public Envelope decodeGeometryEnvelope(ResultSet rs, int column, Connection cx)
    throws SQLException, IOException {
  Geometry g = geometry(rs.getBytes(column));
  return g != null ? g.getEnvelopeInternal() : null;
}

代码示例来源:origin: locationtech/spatial4j

@Override
public int hashCode() {
 //FYI if geometry.equalsExact(that.geometry), then their envelopes are the same.
 return geom.getEnvelopeInternal().hashCode();
}

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

@Override
public Envelope decodeGeometryEnvelope(ResultSet rs, int column, Connection cx)
    throws SQLException, IOException {
  Geometry geom = readGeometry(rs, column, new GeometryFactory(), cx);
  return geom != null ? geom.getEnvelopeInternal() : null;
}

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

public boolean evaluate(Object feature) {
  if (feature == null) return false;
  Geometry other = (Geometry) property.evaluate(feature);
  if (other == null) return false;
  return other.getEnvelopeInternal().intersects(envelope);
}

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

private SimpleFeatureCollection getCollection(Attributes attrs, ElementValue[] value) {
  String id = "";
  id = attrs.getValue("", "ID");
  if (id == null) id = attrs.getValue(GMLSchema.NAMESPACE.toString(), "ID");
  Object value2 = value[0].getValue();
  Envelope envelopeInternal = ((Geometry) value2).getEnvelopeInternal();
  // bbox slot
  GMLFeatureCollection fc = new GMLFeatureCollection(id, envelopeInternal);
  for (int i = 1; i < value.length; i++) // bbox is slot 0
  fc.add((SimpleFeature) value[i].getValue());
  return fc;
}

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

@Override
public BoundingBox getBounds() {
  ReferencedEnvelope bounds =
      new ReferencedEnvelope(featureType.getCoordinateReferenceSystem());
  Object value = getAttribute(index);
  if (value instanceof Geometry) {
    bounds.init(((Geometry) value).getEnvelopeInternal());
  }
  return bounds;
}

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

@Override
public Envelope decodeGeometryEnvelope(ResultSet rs, int column, Connection cx)
    throws SQLException, IOException {
  Geometry envelope = getWkbReader(null).read(rs, column);
  if (envelope != null) {
    return envelope.getEnvelopeInternal();
  } else {
    // empty one
    return new Envelope();
  }
}

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

protected Envelope extractBboxForSpatialIndexQuery(BinarySpatialOperator filter) {
  org.opengis.filter.expression.Expression leftGeom = filter.getExpression1();
  org.opengis.filter.expression.Expression rightGeom = filter.getExpression2();
  Geometry g;
  if (leftGeom instanceof org.opengis.filter.expression.Literal) {
    g = (Geometry) ((org.opengis.filter.expression.Literal) leftGeom).getValue();
  } else {
    g = (Geometry) ((org.opengis.filter.expression.Literal) rightGeom).getValue();
  }
  return g.getEnvelopeInternal();
}

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

public Envelope getEnvelope() throws IOException {
  if (getHeader().getFlags().getEnvelopeIndicator() == EnvelopeType.NONE) {
    return get().getEnvelopeInternal();
  } else {
    return getHeader().getEnvelope();
  }
}

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

@Override
public ROI intersect(ROI roi) {
  final Geometry geom = getGeometry(roi);
  // is it a rectangle?
  if (geom != null && geom.equalsExact(geom.getEnvelope())) {
    GeometryClipper clipper = new GeometryClipper(geom.getEnvelopeInternal());
    Geometry intersect = clipper.clip(getAsGeometry(), true);
    return new ROIGeometry(intersect);
  } else {
    return super.intersect(roi);
  }
}

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

@Test
public void testHorizontalSegmentPositiveOffset() throws ParseException {
  Geometry offset = simpleOffsetTest("LINESTRING(0 0, 10 0)", 2);
  assertTrue(offset.getEnvelopeInternal().getMinY() == 2);
}

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

@Test
public void testHorizontalSegmentNegativeOffset() throws ParseException {
  Geometry offset = simpleOffsetTest("LINESTRING(0 0, 10 0)", -2);
  assertTrue(offset.getEnvelopeInternal().getMinY() == -2);
}

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

@Test
public void smoothPolygon() {
  Coordinate[] coords = getPolyCoords();
  Polygon poly = factory.createPolygon(factory.createLinearRing(coords), null);
  Geometry smoothed = JTS.smooth(poly, 0);
  assertTrue(smoothed instanceof Polygon);
  CoordList list = new CoordList(smoothed.getCoordinates());
  assertTrue(list.containsAll(coords));
  Envelope polyEnv = poly.getEnvelopeInternal();
  Envelope smoothEnv = smoothed.getEnvelopeInternal();
  assertTrue(smoothEnv.covers(polyEnv));
}

相关文章