@@ -388,6 +388,41 @@ def test_geometry_collection_get_bounds():
388388 assert folium .GeoJson (geojson_data ).get_bounds () == [[0 , - 3 ], [4 , 2 ]]
389389
390390
391+ @pytest .mark .parametrize ("container" , ["geometry" , "feature" , "feature_collection" ])
392+ @pytest .mark .parametrize ("collection" , ["multiple" , "nested" , "empty" ])
393+ def test_geometry_collection_bounds_all_members (container , collection ):
394+ geometries = [
395+ {"type" : "Point" , "coordinates" : [2 , 1 ]},
396+ {"type" : "LineString" , "coordinates" : [[- 3 , 4 ], [40 , 30 ]]},
397+ ]
398+ expected = [[1 , - 3 ], [30 , 40 ]]
399+ if collection == "nested" :
400+ geometries = [
401+ {"type" : "GeometryCollection" , "geometries" : []},
402+ {"type" : "GeometryCollection" , "geometries" : geometries },
403+ ]
404+ elif collection == "empty" :
405+ geometries = []
406+ expected = [[None , None ], [None , None ]]
407+
408+ data = {"type" : "GeometryCollection" , "geometries" : geometries }
409+ if container != "geometry" :
410+ data = {"type" : "Feature" , "properties" : {}, "geometry" : data }
411+ if container == "feature_collection" :
412+ data = {
413+ "type" : "FeatureCollection" ,
414+ "features" : [
415+ {"type" : "Feature" , "properties" : {}, "geometry" : None },
416+ data ,
417+ ],
418+ }
419+
420+ m = folium .Map ()
421+ layer = folium .GeoJson (data ).add_to (m )
422+ assert layer .get_bounds () == expected
423+ assert m .get_bounds () == expected
424+
425+
391426def test_choropleth_get_by_key ():
392427 geojson_data = {
393428 "id" : "0" ,
0 commit comments