MapUtils { public static LatLng gpsToLatLng(String gps) { String[] gpsSplit = gps.split(","); return new LatLng(Double.parseDouble(gpsSplit[0].trim()), Double.parseDouble(gpsSplit[1].trim())); } private  MapUtils(); static LatLng gpsToLatLng(String gps); static void moveToCurrentLocation(GoogleMap map, List<Marker> markers, Location lastLocation, float zoom); static void moveToMarkerBounds(GoogleMap map, List<Marker> markers); static final float HUE_DEFAULT; }
@Test public void should_split_gps_string_and_convert_it_to_a_LatLng_object() { String gps = "47.383442,0.698555"; LatLng result = MapUtils.gpsToLatLng(gps); assertThat(Double.toString(result.latitude)).isEqualTo("47.383442"); assertThat(Double.toString(result.longitude)).isEqualTo("0.698555"); }
@Test public void should_handle_spaces_when_converting_gps_value() { String gps = " 49.383442 , 0.708555 "; LatLng result = MapUtils.gpsToLatLng(gps); assertThat(Double.toString(result.latitude)).isEqualTo("49.383442"); assertThat(Double.toString(result.longitude)).isEqualTo("0.708555"); }