private boolean isAlone ( Geometry geometryN ) { Coordinate [ ] coordinates = geometryN . getCoordinates ( ) ; if ( coordinates . length > 1 ) { Coordinate first = coordinates [ 0 ] ; Coordinate last = coordinates [ coordinates . length - 1 ] ; for ( SimpleFeature line : linesList ) { Geometry lineGeom = ( Geometry ) line . getDefaultGeometry ( ) ; int numGeometries = lineGeom . getNumGeometries ( ) ; for ( int i = 0 ; i < numGeometries ; i ++ ) { Geometry subGeom = lineGeom . getGeometryN ( i ) ; Coordinate [ ] lineCoordinates = subGeom . getCoordinates ( ) ; if ( lineCoordinates . length < 2 ) { continue ; } else { Coordinate tmpFirst = lineCoordinates [ 0 ] ; Coordinate tmpLast = lineCoordinates [ lineCoordinates . length - 1 ] ; if ( tmpFirst . distance ( first ) < SAMEPOINTTHRESHOLD || tmpFirst . distance ( last ) < SAMEPOINTTHRESHOLD || tmpLast . distance ( first ) < SAMEPOINTTHRESHOLD || tmpLast . distance ( last ) < SAMEPOINTTHRESHOLD ) { return false ; } } } } } // 1 point line or no connection, mark it as alone for removal return true ; }
Checks if the given geometry is connected to any other line .