import { Pipe , PipeTransform } from '@angular/core' ; @ Pipe ( { name : 'sharedGetMapBounds' } ) export class GetMapBoundsPipe implements PipeTransform { param product param zoom return transform ( product , zoom = false ) { if ( ! product || ! product . properties ) { return null ; } let minLat = parseFloat ( product . properties [ 'minimum-latitude' ] ) ; let maxLat = parseFloat ( product . properties [ 'maximum-latitude' ] ) ; let minLon = parseFloat ( product . properties [ 'minimum-longitude' ] ) ; const maxLon = parseFloat ( product . properties [ 'maximum-longitude' ] ) ; if ( isNaN ( minLat ) || isNaN ( minLon ) || isNaN ( maxLat ) || isNaN ( maxLon ) ) { return null ; } if ( maxLon < minLon && ( minLon - maxLon ) > 180 ) { minLon -= 360 ; } if ( zoom ) { const absMaxLat = Math . max ( Math . abs ( maxLat ) , Math . abs ( minLat ) ) ; const latFactor = absMaxLat > 75 ? .1 : absMaxLat > 70 ? .05 : absMaxLat > 65 ? .01 : absMaxLat > 60 ? .001 : absMaxLat > 50 ? .0005 : 0 ; const latAdjust = absMaxLat * latFactor ; minLat = minLat + latAdjust ; maxLat = maxLat - latAdjust ; } return [ [ minLat , minLon ] , [ maxLat , maxLon ] ] ; } }