public static boolean intersects ( Geometry one , Geometry two ) { if ( one == null || two == null || isEmpty ( one ) || isEmpty ( two ) ) { return false ; } if ( Geometry . POINT . equals ( one . getGeometryType ( ) ) ) { return intersectsPoint ( one , two ) ; } else if ( Geometry . LINE_STRING . equals ( one . getGeometryType ( ) ) ) { return intersectsLineString ( one , two ) ; } else if ( Geometry . MULTI_POINT . equals ( one . getGeometryType ( ) ) || Geometry . MULTI_LINE_STRING . equals ( one . getGeometryType ( ) ) ) { return intersectsMultiSomething ( one , two ) ; } List < Coordinate > coords1 = new ArrayList < Coordinate > ( ) ; List < Coordinate > coords2 = new ArrayList < Coordinate > ( ) ; getAllCoordinates ( one , coords1 ) ; getAllCoordinates ( two , coords2 ) ; for ( int i = 0 ; i < coords1 . size ( ) - 1 ; i ++ ) { for ( int j = 0 ; j < coords2 . size ( ) - 1 ; j ++ ) { if ( MathService . intersectsLineSegment ( coords1 . get ( i ) , coords1 . get ( i + 1 ) , coords2 . get ( j ) , coords2 . get ( j + 1 ) ) ) { return true ; } } } return false ; }
Calculate whether or not two given geometries intersect each other .