gpt4 book ai didi

org.geotools.geometry.util.XRectangle2D.intersect()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 14:07:05 26 4
gpt4 key购买 nike

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

XRectangle2D.intersect介绍

[英]Tests if the interior of the Shape intersects the interior of a specified rectangle. This method might conservatively return true when there is a high probability that the rectangle and the shape intersect, but the calculations to accurately determine this intersection are prohibitively expensive. This is similar to Shape#intersects(Rectangle2D), except that this method tests also rectangle with zero Rectangle2D#getWidth or Rectangle2D#getHeight (which are Rectangle2D#isEmpty according Shape contract). However, rectangle with negative width or height are still considered as empty.

This method is said inclusive because it try to mimic #intersectInclusive(Rectangle2D,Rectangle2D) behavior, at least for rectangle with zero width or height.
[中]测试形状的内部是否与指定矩形的内部相交。当矩形和形状相交的概率很高时,此方法可能会保守地返回true,但精确确定此相交的计算代价高昂。这与形状#相交(矩形2D)类似,只是该方法也测试矩形为零的矩形2D#getWidth或矩形2D#getHeight(根据形状契约,它们是矩形2D#isEmpty)。但是,宽度或高度为负的矩形仍被视为空。
这种方法之所以被称为包容,是因为它试图模仿#intersectInclusive(Rectangle2D,Rectangle2D)行为,至少对于宽度或高度为零的矩形是如此。

代码示例

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

private Rectangle createQueryGridEnvelope(DirectPosition pos) {
    final GridCoverage2DReader reader = sourceRef.get();
    try {
      MathTransform worldToGridTransform =
          reader.getOriginalGridToWorld(PixelInCell.CELL_CORNER).inverse();

      DirectPosition midPos = worldToGridTransform.transform(pos, null);
      int x = (int) midPos.getOrdinate(0);
      int y = (int) midPos.getOrdinate(1);
      int halfWidth = CACHED_RASTER_WIDTH / 2;

      final Rectangle queryRect =
          new Rectangle(
              x - halfWidth, y - halfWidth, CACHED_RASTER_WIDTH, CACHED_RASTER_WIDTH);

      GridEnvelope gridEnv = reader.getOriginalGridRange();
      Rectangle rect =
          new Rectangle(
              gridEnv.getLow(0), gridEnv.getLow(1),
              gridEnv.getSpan(0), gridEnv.getSpan(1));

      XRectangle2D.intersect(queryRect, rect, queryRect);
      return queryRect;

    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }
}

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

private Rectangle computeRasterArea(
    ReferencedEnvelope computedBBox, MathTransform2D requestedWorldToGrid)
    throws TransformException, FactoryException {
  final ReferencedEnvelope cropBBOXInRequestCRS =
      Utils.reprojectEnvelope(computedBBox, requestCRS, requestedBBox);
  // make sure it falls within the requested envelope
  cropBBOXInRequestCRS.intersection((org.locationtech.jts.geom.Envelope) requestedBBox);
  // now go back to raster space
  Rectangle computedRasterArea =
      new GeneralGridEnvelope(
              CRS.transform(requestedWorldToGrid, cropBBOXInRequestCRS),
              PixelInCell.CELL_CORNER,
              false)
          .toRectangle();
  // intersect with the original requested raster space to be sure that we stay within
  // the requested raster area
  XRectangle2D.intersect(computedRasterArea, requestedRasterArea, computedRasterArea);
  return computedRasterArea;
}

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

XRectangle2D.intersect(
    coverageRequestedRasterArea,
    coverageRasterArea,

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

final Rectangle tempRect = finalRange.toRectangle();
  XRectangle2D.intersect(tempRect, requestedDim, tempRect);
  requestedDim.setRect(tempRect);
} catch (TransformException te) {

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

.toRectangle2D()
        .getBounds();
XRectangle2D.intersect(
    sourceArea,
    selectedlevel.rasterDimensions,

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

sourceArea.grow(2, 2);
XRectangle2D.intersect(
    sourceArea,
    selectedlevel.rasterDimensions,

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

/**
 * This method is responsible for computing the raster bounds of the final mosaic.
 *
 * @throws TransformException In case transformation fails during the process.
 */
private void initRasterBounds() throws TransformException {
  final GeneralEnvelope tempRasterBounds = CRS.transform(finalWorldToGridCorner, mosaicBBox);
  rasterBounds = tempRasterBounds.toRectangle2D().getBounds();
  // SG using the above may lead to problems since the reason is that may be a little (1 px)
  // bigger
  // than what we need. The code below is a bit better since it uses a proper logic (see
  // GridEnvelope
  // Javadoc)
  rasterBounds =
      new GridEnvelope2D(new Envelope2D(tempRasterBounds), PixelInCell.CELL_CORNER);
  if (rasterBounds.width == 0) rasterBounds.width++;
  if (rasterBounds.height == 0) rasterBounds.height++;
  if (oversampledRequest) rasterBounds.grow(2, 2);
  // make sure the expanded bounds are still within the reach of the granule bounds, not
  // larger
  // (the above expansion might have made them so)
  final GeneralEnvelope levelRasterArea_ =
      CRS.transform(
          finalWorldToGridCorner, request.spatialRequestHelper.getCoverageBBox());
  final GridEnvelope2D levelRasterArea =
      new GridEnvelope2D(new Envelope2D(levelRasterArea_), PixelInCell.CELL_CORNER);
  XRectangle2D.intersect(levelRasterArea, rasterBounds, rasterBounds);
}

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

XRectangle2D.intersect(
      destinationRasterArea, requestedRasterArea, destinationRasterArea);
} catch (NoninvertibleTransformException e) {

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

XRectangle2D.intersect(
      destinationRasterArea, requestedRasterArea, destinationRasterArea);
} catch (NoninvertibleTransformException e) {

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

XRectangle2D.intersect(
    imageBounds,
    rasterLayerResponse.getRasterBounds(),

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com