static Point2d [ ] decodeCoordinates ( String str ) { if ( str . startsWith ( "|(" ) ) { int end = str . indexOf ( ' ' , 2 ) ; if ( end < 0 ) return new Point2d [ 0 ] ; String [ ] strs = str . substring ( 2 , end ) . split ( ";" ) ; Point2d [ ] points = new Point2d [ strs . length ] ; for ( int i = 0 ; i < strs . length ; i ++ ) { String coord = strs [ i ] ; int first = coord . indexOf ( ' ' ) ; int second = coord . indexOf ( ' ' , first + 1 ) ; points [ i ] = new Point2d ( Double . parseDouble ( coord . substring ( 0 , first ) ) , Double . parseDouble ( coord . substring ( first + 1 , second ) ) ) ; } return points ; } else { String [ ] strs = str . split ( ", " ) ; Point2d [ ] points = new Point2d [ strs . length / 2 ] ; for ( int i = 0 ; i < strs . length ; i += 2 ) { points [ i / 2 ] = new Point2d ( Double . parseDouble ( strs [ i ] ) , Double . parseDouble ( strs [ i + 1 ] ) ) ; } return points ; } }
Decode coordinates that have been placed in a byte buffer .