import turfBbox from '@turf/bbox' ; import { FeatureCollection } from 'geojson' ; import { MapExtent } from '../../../common/descriptor_types' ; import { FEATURE_VISIBLE_PROPERTY_NAME } from '../../../common/constants' ; export function getFeatureCollectionBounds ( featureCollection , hasJoins ) { if ( ! featureCollection ) { return null ; } const visibleFeatures = hasJoins ? featureCollection . features . filter ( ( feature ) => { return feature . properties && feature . properties [ FEATURE_VISIBLE_PROPERTY_NAME ] ; } ) : featureCollection . features ; if ( visibleFeatures . length === 0 ) { return null ; } const bbox = turfBbox ( { type : 'FeatureCollection' , features : visibleFeatures , } ) ; return { minLon : bbox [ 0 ] , minLat : bbox [ 1 ] , maxLon : bbox [ 2 ] , maxLat : bbox [ 3 ] , } ; }