public static Location fromCoordinates ( String coordinates ) { if ( coordinates == null ) { throw new IllegalArgumentException ( "Cannot create Location from null input." ) ; } Matcher m = P . matcher ( coordinates ) ; if ( ! m . matches ( ) ) { throw new IllegalArgumentException ( coordinates + " must be on the pattern (longitude,latitude,altitude) : " + P . pattern ( ) ) ; } try { Double longitude = Double . valueOf ( m . group ( 1 ) ) ; Double latitude = Double . valueOf ( m . group ( 2 ) ) ; Integer altitude = 0 ; if ( m . group ( 3 ) != null ) { altitude = Integer . valueOf ( m . group ( 3 ) . substring ( 1 ) ) ; } return new Location ( longitude , latitude , altitude , "" ) ; } catch ( NumberFormatException e ) { throw new IllegalArgumentException ( coordinates + " must be on the pattern (longitude,latitude,altitude) : " + P . pattern ( ) ) ; } }
Create an untitled Location from coordinate string .