private static LineString reverse3D ( LineString lineString , String order ) { CoordinateSequence seq = lineString . getCoordinateSequence ( ) ; double startZ = seq . getCoordinate ( 0 ) . z ; double endZ = seq . getCoordinate ( seq . size ( ) - 1 ) . z ; if ( order . equalsIgnoreCase ( "desc" ) ) { if ( ! Double . isNaN ( startZ ) && ! Double . isNaN ( endZ ) && startZ < endZ ) { CoordinateSequences . reverse ( seq ) ; return FACTORY . createLineString ( seq ) ; } } else if ( order . equalsIgnoreCase ( "asc" ) ) { if ( ! Double . isNaN ( startZ ) && ! Double . isNaN ( endZ ) && startZ > endZ ) { CoordinateSequences . reverse ( seq ) ; return FACTORY . createLineString ( seq ) ; } } else { throw new IllegalArgumentException ( "Supported order values are asc or desc." ) ; } return lineString ; }
Reverses a LineString according to the z value . The z of the first point must be lower than the z of the end point .