import { BaseMapSourceProvider , IBaseMapSourceProviderConstructor , IMAGERY_MAP_SOURCE_PROVIDERS } from '../model/base-map-source-provider' ; import { FactoryProvider , Provider } from '@angular/core' ; export interface IImageryMapSources { [ mapType ] : { [ sourceType ] : BaseMapSourceProvider ; } ; } description export function BaseMapSourceProviderFactory ( mapSourceProviders ) { return mapSourceProviders . reduce ( ( a , mapSourceProvider ) => [ ... a , ... mapSourceProvider ] , [ ] ) . reduce ( ( obj , item ) => { item . supported . forEach ( ( support ) => { obj [ support . prototype . mapType ] = { ... obj [ support . prototype . mapType ] , [ item . sourceType ] : item } ; } ) ; return { ... obj } ; } , { } ) ; } description export function MapSourceProvidersFactory ( ... mapSourceProviders ) { return mapSourceProviders ; } description export function createMapSourceProviders ( mapSourceProviders ) { return [ mapSourceProviders , { provide : IMAGERY_MAP_SOURCE_PROVIDERS , useFactory : MapSourceProvidersFactory , deps : mapSourceProviders , multi : true } ] ; } export const BaseMapSourceProviderProvider = { provide : BaseMapSourceProvider , useFactory : BaseMapSourceProviderFactory , deps : [ IMAGERY_MAP_SOURCE_PROVIDERS ] } ;