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

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

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

Geometry.intersects介绍

[英]Tests whether this geometry intersects the argument geometry.

The intersects predicate has the following equivalent definitions:

  • The two geometries have at least one point in common

  • The DE-9IM Intersection Matrix for the two geometries matches at least one of the patterns

  • [T********]

    • [*T*******]
    • [***T*****]
    • [****T****]
  • ! g.disjoint(this) = true
    (intersects is the inverse of disjoint)
    [中]测试此几何图形是否与参数几何图形相交。
    intersects谓词具有以下等效定义:
    *这两种几何图形至少有一个共同点
    *两种几何图形的DE-9IM相交矩阵至少与其中一种图案匹配

  • [T********]

  • [*T*******]

  • [***T*****]

  • [****T****]

  • ! g.disjoint(this) = true
    intersectsdisjoint的倒数)

代码示例

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

  1. Geometry coverageBounds =
  2. JTS.toGeometry((Envelope) new ReferencedEnvelope(grid.getEnvelope2D()));
  3. if (coverageBounds.intersects(rasterFilter)) {
  4. final ParameterValueGroup param = cropParams.clone();
  5. param.parameter("source").setValue(grid);

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

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

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

  1. public boolean intersects(Geometry g) {
  2. return geometry.intersects(g);
  3. }

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

  1. /**
  2. * Tests if the interior of the <code>Shape</code> intersects the interior of a specified <code>
  3. * Rectangle2D</code>. This method might conservatively return <code>true</code> when:
  4. *
  5. * <ul>
  6. * <li>there is a high probability that the <code>Rectangle2D</code> and the <code>Shape
  7. * </code> intersect, but
  8. * <li>the calculations to accurately determine this intersection are prohibitively expensive.
  9. * </ul>
  10. *
  11. * This means that this method might return <code>true</code> even though the <code>Rectangle2D
  12. * </code> does not intersect the <code>Shape</code>.
  13. *
  14. * @param r the specified <code>Rectangle2D</code>
  15. * @return <code>true</code> if the interior of the <code>Shape</code> and the interior of the
  16. * specified <code>Rectangle2D</code> intersect, or are both highly likely to intersect and
  17. * intersection calculations would be too expensive to perform; <code>false</code>
  18. * otherwise.
  19. * @see #intersects(double, double, double, double)
  20. */
  21. public boolean intersects(Rectangle2D r) {
  22. Geometry rect = rectangleToGeometry(r);
  23. return geometry.intersects(rect);
  24. }

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

  1. /**
  2. * Tests if the interior of the <code>Shape</code> intersects the interior of a specified <code>
  3. * Rectangle2D</code>. This method might conservatively return <code>true</code> when:
  4. *
  5. * <ul>
  6. * <li>there is a high probability that the <code>Rectangle2D</code> and the <code>Shape
  7. * </code> intersect, but
  8. * <li>the calculations to accurately determine this intersection are prohibitively expensive.
  9. * </ul>
  10. *
  11. * This means that this method might return <code>true</code> even though the <code>Rectangle2D
  12. * </code> does not intersect the <code>Shape</code>.
  13. *
  14. * @param r the specified <code>Rectangle2D</code>
  15. * @return <code>true</code> if the interior of the <code>Shape</code> and the interior of the
  16. * specified <code>Rectangle2D</code> intersect, or are both highly likely to intersect and
  17. * intersection calculations would be too expensive to perform; <code>false</code>
  18. * otherwise.
  19. * @see #intersects(double, double, double, double)
  20. */
  21. public boolean intersects(Rectangle2D r) {
  22. Geometry rect = rectangleToGeometry(r);
  23. return geometry.intersects(rect);
  24. }

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

  1. Geometry rect = createRectangle(x, y, w, h);
  2. return geometry.intersects(rect);

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

  1. /** Helper method for {@link #intersects(Geometry, Geometry) intersects(Geometry, Geometry)} */
  2. private static boolean intersects(GeometryCollection gc, Geometry g) {
  3. final int size = gc.getNumGeometries();
  4. for (int i = 0; i < size; i++) {
  5. Geometry g1 = gc.getGeometryN(i);
  6. if (g1.intersects(g)) return true;
  7. }
  8. return false;
  9. }

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

  1. Geometry rect = createRectangle(x, y, w, h);
  2. return geometry.intersects(rect);

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

  1. protected boolean basicEvaluate(Geometry left, Geometry right) {
  2. Envelope envLeft = left.getEnvelopeInternal();
  3. Envelope envRight = right.getEnvelopeInternal();
  4. if (envRight.intersects(envLeft)) {
  5. return left.intersects(right);
  6. } else {
  7. return false;
  8. }
  9. // Note that this is a pretty permissive logic
  10. // if the type has somehow been mis-set (can't happen externally)
  11. // then true is returned in all cases
  12. }

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

  1. protected final boolean basicEvaluate(Geometry left, Geometry right) {
  2. Envelope envLeft = left.getEnvelopeInternal();
  3. Envelope envRight = right.getEnvelopeInternal();
  4. return envRight.intersects(envLeft) && left.intersects(right);
  5. }
  6. }

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

  1. @Override
  2. public boolean checkAndReserve(List<AffineTransform2D> transforms)
  3. throws MismatchedDimensionException, TransformException {
  4. List<Geometry> transformedConflictBounds = new ArrayList<Geometry>();
  5. boolean conflict = false;
  6. for (AffineTransform2D tx2d : transforms) {
  7. if (conflict) {
  8. break;
  9. }
  10. Geometry cbTransformed = JTS.transform(conflictBounds, tx2d);
  11. transformedConflictBounds.add(cbTransformed);
  12. List results = qt.query(cbTransformed.getEnvelopeInternal());
  13. for (Iterator it = results.iterator(); it.hasNext(); ) {
  14. Geometry candidate = (Geometry) it.next();
  15. if (candidate.intersects(cbTransformed)) {
  16. // location conflict
  17. conflict = true;
  18. break;
  19. }
  20. }
  21. }
  22. // reserve the area if no conflict
  23. if (!conflict) {
  24. for (Geometry tcb : transformedConflictBounds) {
  25. qt.insert(tcb.getEnvelopeInternal(), tcb);
  26. }
  27. }
  28. return !conflict;
  29. }

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

  1. if (geometry.intersects(extentGeometry)) {

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

  1. @DescribeProcess(title = "Intersects Test", description = "Tests if two geometries intersect.")
  2. @DescribeResult(description = "True if the inputs intersect")
  3. public static boolean intersects(
  4. @DescribeParameter(name = "a", description = "First input geometry") Geometry a,
  5. @DescribeParameter(name = "b", description = "Second input geometry") Geometry b) {
  6. return a.intersects(b);
  7. }

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

  1. for (int l = bbox[0].getY(); l <= bbox[1].getY(); l++) {
  2. Geometry bboxGeometry = tileToJTSGeometry(k, l, baseZoomLevel, enlargementInMeter);
  3. if (bboxGeometry.intersects(wayGeometry)) {
  4. matchedTiles.add(new TileCoordinate(k, l, baseZoomLevel));

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

  1. /**
  2. * Tests whether the two geometries intersect.
  3. *
  4. * <p>This method relies completely on {@link Geometry#intersects(Geometry)} but also tries to
  5. * unroll <TT>GeometryCollection</TT>s.
  6. *
  7. * @param g1
  8. * @param g2
  9. * @return true if the two geometries intersect.
  10. */
  11. public static boolean intersects(Geometry g1, Geometry g2) {
  12. Utilities.ensureNonNull("g1", g1);
  13. Utilities.ensureNonNull("g2", g2);
  14. if (g1 instanceof GeometryCollection) {
  15. if (g2 instanceof GeometryCollection) {
  16. return intersects((GeometryCollection) g1, (GeometryCollection) g2);
  17. } else {
  18. return intersects((GeometryCollection) g1, g2);
  19. }
  20. } else {
  21. if (g2 instanceof GeometryCollection) {
  22. return intersects((GeometryCollection) g2, g1);
  23. } else {
  24. return g1.intersects(g2);
  25. }
  26. }
  27. }

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

  1. /**
  2. * A tile on zoom level <i>z</i> has exactly 16 sub tiles on zoom level <i>z+2</i>. For each of these 16 sub tiles
  3. * it is analyzed if the given way needs to be included. The result is represented as a 16 bit short value. Each bit
  4. * represents one of the 16 sub tiles. A bit is set to 1 if the sub tile needs to include the way. Representation is
  5. * row-wise.
  6. *
  7. * @param geometry the geometry which is analyzed
  8. * @param tile the tile which is split into 16 sub tiles
  9. * @param enlargementInMeter amount of pixels that is used to enlarge the bounding box of the way and the tiles in the mapping
  10. * process
  11. * @return a 16 bit short value that represents the information which of the sub tiles needs to include the way
  12. */
  13. public static short computeBitmask(final Geometry geometry, final TileCoordinate tile, final int enlargementInMeter) {
  14. List<TileCoordinate> subtiles = tile
  15. .translateToZoomLevel((byte) (tile.getZoomlevel() + SUBTILE_ZOOMLEVEL_DIFFERENCE));
  16. short bitmask = 0;
  17. int tileCounter = 0;
  18. for (TileCoordinate subtile : subtiles) {
  19. Geometry bbox = tileToJTSGeometry(subtile.getX(), subtile.getY(), subtile.getZoomlevel(),
  20. enlargementInMeter);
  21. if (bbox.intersects(geometry)) {
  22. bitmask |= TILE_BITMASK_VALUES[tileCounter];
  23. }
  24. tileCounter++;
  25. }
  26. return bitmask;
  27. }

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

  1. intersects = inclusionGeometry.intersects(bb);
  2. } catch (FactoryException | MismatchedDimensionException | TransformException e) {
  3. intersects = inclusionGeometry.intersects(bb);

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

  1. if (envelope.contains(rLineGeom.getEnvelopeInternal())) {
  2. if (LineString.class.isAssignableFrom(rLineGeom.getClass())) {
  3. if (lineGeom.intersects(rLineGeom)) {
  4. if (!hasPair(
  5. ((LineString) lineGeom).getCoordinateSequence(),

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

  1. if (currentGeom
  2. .getEnvelope()
  3. .intersects(((Geometry) second.getDefaultGeometry()))) {

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

  1. if (g1.intersects(g2) != expected) {
  2. results.error(
  3. f1,

相关文章