question: public static Point parsePoint ( String str , SpatialContext ctx ) throws InvalidShapeException { try { double x , y ; str = str . trim ( ) ; int commaIdx = str . indexOf ( ',' ) ; if ( commaIdx == - 1 ) { int spaceIdx = str . indexOf ( ' ' ) ; if ( spaceIdx == - 1 ) throw new InvalidShapeException ( "Point must be in 'lat, lon' or 'x y' format: " + str ) ; int middleEndIdx = findIndexNotSpace ( str , spaceIdx + 1 , + 1 ) ; x = Double . parseDouble ( str . substring ( 0 , spaceIdx ) ) ; y = Double . parseDouble ( str . substring ( middleEndIdx ) ) ; } else { int middleStartIdx = findIndexNotSpace ( str , commaIdx - 1 , - 1 ) ; int middleEndIdx = findIndexNotSpace ( str , commaIdx + 1 , + 1 ) ; y = Double . parseDouble ( str . substring ( 0 , middleStartIdx + 1 ) ) ; x = Double . parseDouble ( str . substring ( middleEndIdx ) ) ; } x = ctx . normX ( x ) ; y = ctx . normY ( y ) ; return ctx . makePoint ( x , y ) ; } catch ( InvalidShapeException e ) { throw e ; } catch ( Exception e ) { throw new InvalidShapeException ( e . toString ( ) , e ) ; } }
target:  Parses either "lat, lon" (spaces optional on either comma side) or "x y" style formats. Spaces can be basically anywhere.  And not any whitespace, just the space char.