all files / src/olHelpers/ propertiesZoomStyle.ts

60% Statements 6/10
0% Branches 0/2
33.33% Functions 1/3
60% Lines 6/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                                           
/**
 * Created by gavorhes on 12/14/2015.
 */
 
import provide from '../util/provide';
import * as zoomResolutionConvert from './zoomResolutionConvert';
import ol = require('custom-ol');
const nm = provide('olHelpers');
 
 
/**
 * A style function based on properties and zoom level, wraps normal feature, resolution function
 * @callback propertiesZoomStyle
 * @param {object} properties the feature properties
 * @param {number} zoom level
 *
 */
 
/**
 * wrapper to define a style function by properties and zoom level
 * @param {propertiesZoomStyle|*} styleFunc - style function
 * @returns {function|*} new function
 */
function propertiesZoomStyle(styleFunc) {
    if (styleFunc == undefined){
        return undefined;
    }
 
    return function (feature: ol.Feature, resolution) {
        styleFunc(feature.getProperties(), zoomResolutionConvert.resolutionToZoom(resolution));
    };
}
 
nm.propertiesZoomStyle = propertiesZoomStyle;
export default propertiesZoomStyle;