public static double calc ( String ... coords ) { try { String [ ] array ; switch ( coords . length ) { case 1 : array = Split . split ( ' ' , coords [ 0 ] ) ; if ( array . length != 4 ) return - 1 ; return calc ( Double . parseDouble ( array [ 0 ] ) , Double . parseDouble ( array [ 1 ] ) , Double . parseDouble ( array [ 2 ] ) , Double . parseDouble ( array [ 3 ] ) ) ; case 2 : array = Split . split ( ' ' , coords [ 0 ] ) ; String [ ] array2 = Split . split ( ' ' , coords [ 1 ] ) ; if ( array . length != 2 || array2 . length != 2 ) return - 1 ; return calc ( Double . parseDouble ( array [ 0 ] ) , Double . parseDouble ( array [ 1 ] ) , Double . parseDouble ( array2 [ 0 ] ) , Double . parseDouble ( array2 [ 1 ] ) ) ; case 4 : return calc ( Double . parseDouble ( coords [ 0 ] ) , Double . parseDouble ( coords [ 1 ] ) , Double . parseDouble ( coords [ 2 ] ) , Double . parseDouble ( coords [ 3 ] ) ) ; default : return - 1 ; } } catch ( NumberFormatException e ) { return - 1 ; } }
Convert from Lat Long Lat Long String format Lat Long Lat Long Format or all four entries Lat Long Lat Long