public boolean isValid ( ) { if ( isEmpty ( ) ) { return true ; } if ( ! isClosed ( ) ) { return false ; } Coordinate [ ] coordinates = getCoordinates ( ) ; if ( coordinates . length < 4 ) { return false ; } for ( int i = 0 ; i < coordinates . length - 1 ; i ++ ) { for ( int j = 0 ; j < coordinates . length - 1 ; j ++ ) { if ( Mathlib . lineIntersects ( coordinates [ i ] , coordinates [ i + 1 ] , coordinates [ j ] , coordinates [ j + 1 ] ) ) { return false ; } } } return true ; }
An empty LinearRing is valid . Furthermore this object must be closed and must not self - intersect .