GeometryCollection implements Geometry { public static GeometryCollection fromGeometries(@NonNull List<Geometry> geometries) { return new GeometryCollection(TYPE, null, geometries); } GeometryCollection(String type, @Nullable BoundingBox bbox, List<Geometry> geometries); static GeometryCollection fromJson(String json); static GeometryCollection fromGeometries(@NonNull List<Geometry> geometries); static GeometryCollection fromGeometries(@NonNull List<Geometry> geometries,
                                                  @Nullable BoundingBox bbox); static GeometryCollection fromGeometry(@NonNull Geometry geometry); static GeometryCollection fromGeometry(@NonNull Geometry geometry,
                                                @Nullable BoundingBox bbox); @NonNull @Override String type(); @Nullable @Override BoundingBox bbox(); @NonNull List<Geometry> geometries(); @Override String toJson(); static TypeAdapter<GeometryCollection> typeAdapter(Gson gson); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void sanity() throws Exception { List<Point> points = new ArrayList<>(); points.add(Point.fromLngLat(1.0, 2.0)); points.add(Point.fromLngLat(2.0, 3.0)); LineString lineString = LineString.fromLngLats(points); List<Geometry> geometries = new ArrayList<>(); geometries.add(points.get(0)); geometries.add(lineString); GeometryCollection geometryCollection = GeometryCollection.fromGeometries(geometries); assertNotNull(geometryCollection); }
@Test public void testSerializable() throws Exception { List<Point> points = new ArrayList<>(); points.add(Point.fromLngLat(1.0, 2.0)); points.add(Point.fromLngLat(2.0, 3.0)); LineString lineString = LineString.fromLngLats(points); List<Geometry> geometries = new ArrayList<>(); geometries.add(points.get(0)); geometries.add(lineString); BoundingBox bbox = BoundingBox.fromLngLats(1.0, 2.0, 3.0, 4.0); GeometryCollection geometryCollection = GeometryCollection.fromGeometries(geometries, bbox); byte[] bytes = serialize(geometryCollection); assertEquals(geometryCollection, deserialize(bytes, GeometryCollection.class)); }