CoordinatesParser { @NonNull public static GeoPoint parse(@NonNull String input) throws IllegalArgumentException { Result result = parseWithResult(input); return result.coordinates; }  @NonNull static Result parseWithResult(@NonNull String input); @NonNull static GeoPoint parse(@NonNull String input);  }
@Test public void testUtmParser() { double testLatitude = 39.095973; double testLongitude = -94.573414; GeoPoint actual = CoordinatesParser.parse("15N 363936 4328605"); assertEquals("Failed to parse 15N 363936 4328605", testLatitude, actual.getLatitude(), 0.000005); assertEquals("Failed to parse 15N 363936 4328605", testLongitude, actual.getLongitude(), 0.000005); }
@Test public void testMgrsParser() { double testLatitude = 39.095973; double testLongitude = -94.573414; GeoPoint actual = CoordinatesParser.parse("15SUD 63936 28605"); assertEquals("Failed to parse 15SUD 63936 28605", testLatitude, actual.getLatitude(), 0.000005); assertEquals("Failed to parse 15SUD 63936 28605", testLongitude, actual.getLongitude(), 0.000005); actual = CoordinatesParser.parse("15SUD6393628605"); assertEquals("Failed to parse 15SUD6393628605", testLatitude, actual.getLatitude(), 0.000005); assertEquals("Failed to parse 15SUD6393628605", testLongitude, actual.getLongitude(), 0.000005); actual = CoordinatesParser.parse("15S UD 63936 28605"); assertEquals("Failed to parse 15S UD 63936 28605", testLatitude, actual.getLatitude(), 0.000005); assertEquals("Failed to parse 15S UD 63936 28605", testLongitude, actual.getLongitude(), 0.000005); }
@Test public void testNumericParser() { GeoPoint actual = CoordinatesParser.parse("39.095973 -94.573414"); double testLatitude = 39.095973; double testLongitude = -94.573414; assertEquals("Failed to parse 39.095973 -94.573414", testLatitude, actual.getLatitude(), 0.000005); assertEquals("Failed to parse 39.095973 -94.573414", testLongitude, actual.getLongitude(), 0.000005); }
@Test public void testDegreesParser() { GeoPoint actual = CoordinatesParser.parse("39.095973\u00B0 -94.573414\u00B0"); double testLatitude = 39.095973; double testLongitude = -94.573414; assertEquals("Failed to parse 39.095973\u00B0 -94.573414\u00B0", testLatitude, actual.getLatitude(), 0.000005); assertEquals("Failed to parse 39.095973\u00B0 -94.573414\u00B0", testLongitude, actual.getLongitude(), 0.000005); }
@Test public void testMinutesParser() { double testLatitude = 39.095973; double testLongitude = -94.573414; GeoPoint actual = CoordinatesParser.parse("39\u00B0 05.7584' -94\u00B0 34.4048'"); assertEquals("Failed to parse 39\u00B0 05.7584' -94\u00B0 34.4048'", testLatitude, actual.getLatitude(), 0.000005); assertEquals("Failed to parse 39\u00B0 05.7584' -94\u00B0 34.4048'", testLongitude, actual.getLongitude(), 0.000005); }
@Test public void testSecondsParser() { double testLatitude = 39.095973; double testLongitude = -94.573414; GeoPoint actual = CoordinatesParser.parse("39\u00B0 05' 45.503\" -94\u00B0 34' 24.290\""); assertEquals("Failed to parse 39\u00B0 05' 45.503\" -94\u00B0 34' 24.290\"", testLatitude, actual.getLatitude(), 0.000005); assertEquals("Failed to parse 39\u00B0 05' 45.503\" -94\u00B0 34' 24.290\"", testLongitude, actual.getLongitude(), 0.000005); actual = CoordinatesParser.parse("N39\u00B0 05' 45.503\" W94\u00B0 34' 24.290\""); assertEquals("Failed to parse N39\u00B0 05' 45.503\" W94\u00B0 34' 24.290\"", testLatitude, actual.getLatitude(), 0.000005); assertEquals("Failed to parse N39\u00B0 05' 45.503\" W94\u00B0 34' 24.290\"", testLongitude, actual.getLongitude(), 0.000005); actual = CoordinatesParser.parse("39\u00B005'45.503\"N 94\u00B034'24.290\"W"); assertEquals("Failed to parse 39°05'45.503\"N 94°34'24.290\"W", testLatitude, actual.getLatitude(), 0.000005); assertEquals("Failed to parse 39°05'45.503\"N 94°34'24.290\"W", testLongitude, actual.getLongitude(), 0.000005); }