Returns <code>true</code> if the specified bounding box is intersects
with the given polygon.
438997
function(polygon, bbox) {
        var clip = this.getClippingPolygon(bbox);
        var result = this.clipPolygon(polygon, clip);
        return !!result.length;
    }
426239
public boolean intersects(Interval1D<V> other) {
    if (other.hi.compareTo(this.lo) < 0) {
      return false;
    }
    if (this.hi.compareTo(other.lo) < 0) {
      return false;
    }

    return true;
  }
82080
public static boolean isPointInBoundingBox(Point point,
			BoundingBox boundingBox, double maxLongitude) {
		BoundingBox pointBoundingbox = new BoundingBox(point.getX(),
				point.getY(), point.getX(), point.getY());
		BoundingBox overlap = overlap(boundingBox, pointBoundingbox,
				maxLongitude, true);
		return overlap != null;
	}
895826
public static boolean intersect(long[] x, long[] y) {
    final int min = (x.length < y.length) ? x.length : y.length;
    for(int i = 0; i < min; i++) {
      if((x[i] & y[i]) != 0L) {
        return true;
      }
    }
    return false;
  }
751094
static boolean polygonContainsPolygon_(Polygon polygon_a, Polygon polygon_b, double tolerance, ProgressTracker progress_tracker)
    {
        assert(!polygon_a.isEmpty());
        assert(!polygon_b.isEmpty());

        RelationalOperationsMatrix relOps = new RelationalOperationsMatrix();
        relOps.resetMatrix_();
        relOps.setPredicates_("T*****F**");
        relOps.setAreaAreaPredicates_();

        Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
        polygon_a.queryEnvelope2D(env_a);
        polygon_b.queryEnvelope2D(env_b);

        boolean bRelationKnown = false;
        boolean b_disjoint = RelationalOperations.envelopeDisjointEnvelope_(env_a, env_b, tolerance, progress_tracker);

        if (b_disjoint)
        {
            relOps.areaAreaDisjointPredicates_(polygon_a, polygon_b);
            bRelationKnown = true;
        }

        if (!bRelationKnown)
        {
            // Quick rasterize test to see whether the the geometries are disjoint, or if one is contained in the other.
            int relation = RelationalOperations.tryRasterizedContainsOrDisjoint_(polygon_a, polygon_b, tolerance, false);

            if (relation == RelationalOperations.Relation.disjoint)
            {
                relOps.areaAreaDisjointPredicates_(polygon_a, polygon_b);
                bRelationKnown = true;
            }
            else if (relation == RelationalOperations.Relation.contains)
            {
                relOps.areaAreaContainsPredicates_(polygon_b);
                bRelationKnown = true;
            }
            else if (relation == RelationalOperations.Relation.within)
            {
                relOps.areaAreaWithinPredicates_(polygon_a);
                bRelationKnown = true;
            }
        }

        if (bRelationKnown)
        {
            boolean bContains = relationCompare_(relOps.m_matrix, relOps.m_scl);
            return bContains;
        }

        EditShape edit_shape = new EditShape();
        int geom_a = edit_shape.addGeometry(polygon_a);
        int geom_b = edit_shape.addGeometry(polygon_b);

        CrackAndCluster.execute(edit_shape, tolerance, progress_tracker, false);
        Polyline boundary_b = (Polyline)edit_shape.getGeometry(geom_b).getBoundary();
        edit_shape.filterClosePoints(0, true, true);
        Simplificator.execute(edit_shape, geom_a, -1, false, progress_tracker);

        // Make sure Polygon A has exterior
        // If the simplified Polygon A does not have interior, then it cannot contain anything.
        if (edit_shape.getPointCount(geom_a) == 0)
            return false;

        Simplificator.execute(edit_shape, geom_b, -1, false, progress_tracker);

        relOps.setEditShape_(edit_shape, progress_tracker);

        // We see if the simplified Polygon A contains the simplified Polygon B.

        boolean b_empty = edit_shape.getPointCount(geom_b) == 0;

        if (!b_empty)
        {//geom_b has interior
            relOps.computeMatrixTopoGraphHalfEdges_(geom_a, geom_b);
            relOps.m_topo_graph.removeShape();
            boolean bContains = relationCompare_(relOps.m_matrix, relOps.m_scl);

            if (!bContains)
                return bContains;
        }

        Polygon polygon_simple_a = (Polygon)edit_shape.getGeometry(geom_a);
        edit_shape = new EditShape();
        geom_a = edit_shape.addGeometry(polygon_simple_a);
        geom_b = edit_shape.addGeometry(boundary_b);
        relOps.setEditShape_(edit_shape, progress_tracker);

        // Check no interior lines of the boundary intersect the exterior
        relOps.m_predicate_count = 0;
        relOps.resetMatrix_();
        relOps.setPredicates_(b_empty ? "T*****F**" : "******F**");
        relOps.setAreaLinePredicates_();

        relOps.computeMatrixTopoGraphHalfEdges_(geom_a, geom_b);
        relOps.m_topo_graph.removeShape();
        boolean bContains = relationCompare_(relOps.m_matrix, relOps.m_scl);
        return bContains;
    }
303430
public static boolean contains(double[][] polygon, double x, double y) {
        if (polygon.length <= 2) {
            return false;
        }

        int hits = 0;

        int n = polygon.length;
        double lastx = polygon[n - 1][0];
        double lasty = polygon[n - 1][1];
        double curx, cury;

        // Walk the edges of the polygon
        for (int i = 0; i < n; lastx = curx, lasty = cury, i++) {
            curx = polygon[i][0];
            cury = polygon[i][1];

            if (cury == lasty) {
                continue;
            }

            double leftx;
            if (curx < lastx) {
                if (x >= lastx) {
                    continue;
                }
                leftx = curx;
            } else {
                if (x >= curx) {
                    continue;
                }
                leftx = lastx;
            }

            double test1, test2;
            if (cury < lasty) {
                if (y < cury || y >= lasty) {
                    continue;
                }
                if (x < leftx) {
                    hits++;
                    continue;
                }
                test1 = x - curx;
                test2 = y - cury;
            } else {
                if (y < lasty || y >= cury) {
                    continue;
                }
                if (x < leftx) {
                    hits++;
                    continue;
                }
                test1 = x - lastx;
                test2 = y - lasty;
            }

            if (test1 < (test2 / (lasty - cury) * (lastx - curx))) {
                hits++;
            }
        }

        return ((hits & 1) != 0);
    }
976874
public static <E> boolean intersects(Set<E> s1, Set<E> s2) {
    // loop over whichever set is smaller
    if (s1.size() < s2.size()) {
      for (E element1 : s1) {
        if (s2.contains(element1)) {
          return true;
        }
      }
    } else {
      for (E element2 : s2) {
        if (s1.contains(element2)) {
          return true;
        }
      }
    }
    
    return false;
  }
436827
public boolean isWithinBoundingBox(int x, int y, int zoom) {
        boolean withinBounds = true;

        // If a bounding box is set, check if it overlaps with the request
        if (webMercatorBoundingBox != null) {

            // Get the bounding box of the requested tile
            BoundingBox tileWebMercatorBoundingBox = TileBoundingBoxUtils
                    .getWebMercatorBoundingBox(x, y, zoom);

            // Adjust the bounding box if needed
            BoundingBox adjustedWebMercatorBoundingBox = getWebMercatorBoundingBox(tileWebMercatorBoundingBox);

            // Check if the request overlaps
            withinBounds = adjustedWebMercatorBoundingBox.intersects(
                    tileWebMercatorBoundingBox, true);
        }

        return withinBounds;
    }
1096843
private static boolean polygonContainsMultiPoint_(Polygon polygon_a,
			MultiPoint multipoint_b, double tolerance,
			ProgressTracker progress_tracker) {
		Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
		polygon_a.queryEnvelope2D(env_a);
		multipoint_b.queryEnvelope2D(env_b);

		// Quick envelope rejection test for false equality.
		if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance))
			return false;

		// Quick rasterize test to see whether the the geometries are disjoint,
		// or if one is contained in the other.
		int relation = tryRasterizedContainsOrDisjoint_(polygon_a,
				multipoint_b, tolerance, false);

		if (relation == Relation.disjoint)
			return false;

		if (relation == Relation.contains)
			return true;

        boolean b_interior = false;
        Point2D ptB;

        MultiPathImpl polygon_a_impl = (MultiPathImpl)polygon_a._getImpl();

        Polygon pa = null;
        Polygon p_polygon_a = polygon_a;

        boolean b_checked_polygon_a_quad_tree = false;

        for (int i = 0; i < multipoint_b.getPointCount(); i++)
        {
            ptB = multipoint_b.getXY(i);

            if (!env_a.contains(ptB))
                return false;

            PolygonUtils.PiPResult result = PolygonUtils.isPointInPolygon2D(p_polygon_a, ptB, tolerance);

            if (result == PolygonUtils.PiPResult.PiPInside)
                b_interior = true;
            else if (result == PolygonUtils.PiPResult.PiPOutside)
                return false;

            if (!b_checked_polygon_a_quad_tree) {
                if (PointInPolygonHelper.quadTreeWillHelp(polygon_a, multipoint_b.getPointCount() - 1) && (polygon_a_impl._getAccelerators() == null || polygon_a_impl._getAccelerators().getQuadTree() == null)) {
                    pa = new Polygon();
                    polygon_a.copyTo(pa);
                    ((MultiPathImpl) pa._getImpl())._buildQuadTreeAccelerator(Geometry.GeometryAccelerationDegree.enumMedium);
                    p_polygon_a = pa;
                } else {
                    p_polygon_a = polygon_a;
                }

                b_checked_polygon_a_quad_tree = true;
            }
        }

        return b_interior;
	}
1185974
public boolean intersects(Geometry geometry) {
		if (isEmpty()) {
			return false;
		}
		if (exteriorRing.intersects(geometry)) {
			return true;
		}
		if (interiorRings != null) {
			for (LinearRing interiorRing : interiorRings) {
				if (interiorRing.intersects(geometry)) {
					return true;
				}
			}
		}
		return false;
	}
994043
private static boolean polygonTouchesMultiPoint_(Polygon polygon_a,
			MultiPoint multipoint_b, double tolerance,
			ProgressTracker progress_tracker) {
		// Quick rasterize test to see whether the the geometries are disjoint,
		// or if one is contained in the other.
		int relation = tryRasterizedContainsOrDisjoint_(polygon_a,
				multipoint_b, tolerance, false);

		if (relation == Relation.disjoint || relation == Relation.contains)
			return false;

        Envelope2D env_a_inflated = new Envelope2D();
        polygon_a.queryEnvelope2D(env_a_inflated);
        env_a_inflated.inflate(tolerance, tolerance);

        Point2D ptB;
        boolean b_boundary = false;

        MultiPathImpl polygon_a_impl = (MultiPathImpl)polygon_a._getImpl();

        Polygon pa = null;
        Polygon p_polygon_a = polygon_a;

        boolean b_checked_polygon_a_quad_tree = false;

        for (int i = 0; i < multipoint_b.getPointCount(); i++)
        {
            ptB = multipoint_b.getXY(i);

            if (env_a_inflated.contains(ptB)) {

                PolygonUtils.PiPResult result = PolygonUtils.isPointInPolygon2D(p_polygon_a, ptB, tolerance);

                if (result == PolygonUtils.PiPResult.PiPBoundary)
                    b_boundary = true;
                else if (result == PolygonUtils.PiPResult.PiPInside)
                    return false;
            }

            if (!b_checked_polygon_a_quad_tree) {
                if (PointInPolygonHelper.quadTreeWillHelp(polygon_a, multipoint_b.getPointCount() - 1) && (polygon_a_impl._getAccelerators() == null || polygon_a_impl._getAccelerators().getQuadTree() == null)) {
                    pa = new Polygon();
                    polygon_a.copyTo(pa);
                    ((MultiPathImpl) pa._getImpl())._buildQuadTreeAccelerator(Geometry.GeometryAccelerationDegree.enumMedium);
                    p_polygon_a = pa;
                } else {
                    p_polygon_a = polygon_a;
                }

                b_checked_polygon_a_quad_tree = true;
            }
        }

        if (b_boundary)
            return true;

        return false;
	}
351248
private static boolean polygonDisjointPolyline_(Polygon polygon_a,
			Polyline polyline_b, double tolerance,
			ProgressTracker progress_tracker) {
		// Quick rasterize test to see whether the the geometries are disjoint,
		// or if one is contained in the other.
		int relation = tryRasterizedContainsOrDisjoint_(polygon_a, polyline_b,
				tolerance, true);

		if (relation == Relation.disjoint)
			return true;

		if (relation == Relation.contains || relation == Relation.intersects)
			return false;

		return polygonDisjointMultiPath_(polygon_a, polyline_b, tolerance,
				progress_tracker);
	}
1198425
public boolean intersects( Geometry geometry, boolean usePrepared ) {
        if (!getEnvelope().intersects(geometry.getEnvelopeInternal())) {
            return false;
        }
        if (usePrepared) {
            if (preparedGeometry == null) {
                preparedGeometry = PreparedGeometryFactory.prepare(getGeometry());
            }
            return preparedGeometry.intersects(geometry);
        } else {
            return getGeometry().intersects(geometry);
        }
    }
206200
@Pure
	private static boolean intersectsCoplanarTriangle(
			int i0, int i1, int con, double[] s1, double[] s2, double[] u1, double[] u2, double[] u3) {
		double Ax,Ay;

		Ax = s2[i0] - s1[i0];
		Ay = s2[i1] - s1[i1];

		// test edge U0,U1 against V0,V1
		if (intersectEdgeEdge(i0, i1, con, Ax, Ay, s1, u1, u2)) return true;
		// test edge U1,U2 against V0,V1
		if (intersectEdgeEdge(i0, i1, con, Ax, Ay, s1, u2, u3)) return true;
		// test edge U2,U1 against V0,V1
		if (intersectEdgeEdge(i0, i1, con, Ax, Ay, s1, u3, u1)) return true;

		return false;
	}
1181095
function polygonCanSee2(polygon, a,b) {
    // for each edge
    for (var i = 0; i !== polygon.length; ++i) {
        // ignore incident edges
        if (i === a || i === b || (i + 1) % polygon.length === a || (i + 1) % polygon.length === b){
            continue;
        }
        if( lineSegmentsIntersect(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i), polygonAt(polygon, i+1)) ){
            return false;
        }
    }
    return true;
}
1335040
private static boolean intersectsPoint(Geometry point, Geometry geometry) {
		if (geometry.getGeometries() != null) {
			for (Geometry child : geometry.getGeometries()) {
				if (intersectsPoint(point, child)) {
					return true;
				}
			}
		}
		if (geometry.getCoordinates() != null) {
			Coordinate coordinate = point.getCoordinates()[0];
			if (geometry.getCoordinates().length == 1) {
				return coordinate.equals(geometry.getCoordinates()[0]);
			} else {
				for (int i = 0; i < geometry.getCoordinates().length - 1; i++) {
					double distance = MathService.distance(geometry.getCoordinates()[i],
							geometry.getCoordinates()[i + 1], coordinate);
					if (distance < DEFAULT_DOUBLE_DELTA) {
						return true;
					}
				}
			}
		}
		return false;
	}
1116350
@Override
  public boolean intersects(IVersionRange yourRange)
  {
    // The set has explicit versions, so just check these against the supplied range
    for (IVersion version : set) {
      if (yourRange.contains(version)) {
        return true;
      }
    }
    return false;
  }