boolean hasDegenerateSegments ( double tolerance ) { for ( int geometry = getFirstGeometry ( ) ; geometry != - 1 ; geometry = getNextGeometry ( geometry ) ) { if ( ! Geometry . isMultiPath ( getGeometryType ( geometry ) ) ) continue ; boolean b_polygon = getGeometryType ( geometry ) == Geometry . GeometryType . Polygon ; for ( int path = getFirstPath ( geometry ) ; path != - 1 ; ) { int path_size = getPathSize ( path ) ; if ( b_polygon ? path_size < 3 : path_size < 2 ) return true ; int vertex = getFirstVertex ( path ) ; for ( int index = 0 ; index < path_size ; index ++ ) { int next = getNextVertex ( vertex ) ; if ( next == - 1 ) break ; int vindex = getVertexIndex ( vertex ) ; Segment seg = getSegmentFromIndex_ ( vindex ) ; double length = 0 ; if ( seg != null ) { length = seg . calculateLength2D ( ) ; } else { int vindex_next = getVertexIndex ( next ) ; length = m_vertices . _getShortestDistance ( vindex , vindex_next ) ; } if ( length <= tolerance ) return true ; vertex = next ; } path = getNextPath ( path ) ; } } return false ; }
Checks if there are degenerate segments in any of multipath geometries