MultiPoint implements CoordinateContainer<List<Point>> { public static MultiPoint fromJson(@NonNull String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().fromJson(json, MultiPoint.class); } MultiPoint(String type, @Nullable BoundingBox bbox, List<Point> coordinates); static MultiPoint fromJson(@NonNull String json); static MultiPoint fromLngLats(@NonNull List<Point> points); static MultiPoint fromLngLats(@NonNull List<Point> points, @Nullable BoundingBox bbox); @NonNull @Override String type(); @Nullable @Override BoundingBox bbox(); @NonNull @Override List<Point> coordinates(); @Override String toJson(); static TypeAdapter<MultiPoint> typeAdapter(Gson gson); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void fromJson() throws IOException { final String json = "{ \"type\": \"MultiPoint\"," + "\"coordinates\": [ [100, 0], [101, 1] ] } "; MultiPoint geo = MultiPoint.fromJson(json); assertEquals(geo.type(), "MultiPoint"); assertEquals(geo.coordinates().get(0).longitude(), 100.0, DELTA); assertEquals(geo.coordinates().get(0).latitude(), 0.0, DELTA); assertEquals(geo.coordinates().get(1).longitude(), 101.0, DELTA); assertEquals(geo.coordinates().get(1).latitude(), 1.0, DELTA); assertFalse(geo.coordinates().get(0).hasAltitude()); assertEquals(Double.NaN, geo.coordinates().get(0).altitude(), DELTA); }
@Test public void fromJson_coordinatesPresent() throws Exception { thrown.expect(NullPointerException.class); MultiPoint.fromJson("{\"type\":\"MultiPoint\",\"coordinates\":null}"); }