import {IGeoTransformStrategy} from './geo-transform-strategy.interface'; import {OwsKmlTransformStrategy} from './ows-kml-transform-strategy'; import { GeoJsonTransformStrategy } from './geojson-transform-strategy'; export class ResolveGeoTransformStrategy { static strategyMap: {[name: string]: IGeoTransformStrategy} = { owsKml: new OwsKmlTransformStrategy(), getOwnReference: new GeoJsonTransformStrategy() }; /** * Resolve a transform strategy from its string representation. * @param type * @returns {IGeoTransformStrategy} */ static resolveStrategy(type: string): IGeoTransformStrategy { const strategy = ResolveGeoTransformStrategy.strategyMap[type]; if (!strategy) { throw `Error: No geo transformation strategy for type ${type}`; } return strategy; } /** * Exports strategy as a string for persistence. * @param type * @returns {string} */ static exportStrategy(strategy: any): string { const exported = _.findKey( ResolveGeoTransformStrategy.strategyMap, strat => strat === strategy ); if (!exported) { throw `Unable to export geo transform strategy`; } return exported; } }