@Test public void testInvariantGeojsonType4() { String json = "{ type: 'Point', coordinates: [0, 0] }"; TurfAssertions.geojsonType(Point.fromJson(json), "Point", "myfn"); }
@Test public void fromJson_coordinatesPresent() throws Exception { thrown.expect(NullPointerException.class); Point.fromJson("{\"type\":\"Point\",\"coordinates\":null}"); } }
@Test public void bboxDeserializer_deserializeTwoDimensionalArray() { String fixtureJson = "{\"type\":\"Point\",\"bbox\":[1,2,3,4],\"coordinates\":[100,0]}"; Point point = Point.fromJson(fixtureJson); compareJson(fixtureJson, point.toJson()); } }
@Test public void coordAllPoint() throws TurfException { String jsonPoint = "{type: 'Point', coordinates: [0, 0]}"; Point pointGeometry = Point.fromJson(jsonPoint); List<Point> resultList = TurfMeta.coordAll(pointGeometry); assertEquals(resultList.size(), 1, DELTA); assertEquals(resultList.get(0), Point.fromLngLat(0, 0)); }
@Test public void toJson() throws IOException { final String json = loadJsonFixture(SAMPLE_POINT); Point geo = Point.fromJson(json); compareJson(json, geo.toJson()); }
@Test public void bboxDeserializer_handlesOnlyOneAltitudeCorrectly() throws Exception { thrown.expect(GeoJsonException.class); thrown.expectMessage("The value of the bbox member MUST be an array of length"); String fixtureJson = "{\"type\":\"Point\",\"bbox\":[1.0,2.0,3.0,4.0,5.0],\"coordinates\":[100,0]}"; Point point = Point.fromJson(fixtureJson); compareJson(fixtureJson, point.toJson()); }
@Test public void testInvariantGeojsonType3() throws TurfException { String json = "{ type: 'Point', coordinates: [0, 0] }"; thrown.expect(TurfException.class); thrown.expectMessage(startsWith("Invalid input to myfn: must be a Polygon, given Point")); TurfAssertions.geojsonType(Point.fromJson(json), "Polygon", "myfn"); }
@Test public void point_fromJson() throws Exception { // set shifter CoordinateShifterManager.setCoordinateShifter(new TestCoordinateShifter()); Point point1 = Point.fromLngLat(1.0, 2.0); String jsonString = "{\"type\":\"Point\",\"coordinates\":[1.0, 2.0]}"; Point point2 = Point.fromJson(jsonString); assertEquals(point1, point2); CoordinateShifterManager.setCoordinateShifter(null); }
@Test public void point_toJson() throws Exception { // set shifter CoordinateShifterManager.setCoordinateShifter(new TestCoordinateShifter()); Point point1 = Point.fromLngLat(2.0, 3.0); String point1JsonString = point1.toJson(); Point point2 = Point.fromJson(point1JsonString); assertEquals(point1, point2); CoordinateShifterManager.setCoordinateShifter(null); }
@Test public void fromJson() throws IOException { final String json = loadJsonFixture(SAMPLE_POINT); Point geo = Point.fromJson(json); assertEquals(geo.type(), "Point"); assertEquals(geo.longitude(), 100.0, DELTA); assertEquals(geo.latitude(), 0.0, DELTA); assertEquals(geo.altitude(), Double.NaN, DELTA); assertEquals(geo.coordinates().get(0), 100.0, DELTA); assertEquals(geo.coordinates().get(1), 0.0, DELTA); assertEquals(geo.coordinates().size(), 2); assertFalse(geo.hasAltitude()); }