MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / 'ev'

Method 'ev'

src/common/style/CartoCSS.js:3123–3206  ·  view source on GitHub ↗
(env)

Source from the content-addressed store, hash-verified

3121 // we try to pass a variable to a function, like: `saturate(@color)`.
3122 // The function should receive the value, not the variable.
3123 'ev'(env) {
3124 var args = this.args.map(function (a) {
3125 return a.ev(env);
3126 });
3127
3128 for (var i = 0; i < args.length; i++) {
3129 if (args[i].is === 'undefined') {
3130 return {
3131 is: 'undefined',
3132 value: 'undefined'
3133 };
3134 }
3135 }
3136
3137 if (this.name in CartoCSS.Tree.functions) {
3138 if (CartoCSS.Tree.functions[this.name].length <= args.length) {
3139 var val = CartoCSS.Tree.functions[this.name].apply(CartoCSS.Tree.functions, args);
3140 if (val === null) {
3141 env.error({
3142 message: 'incorrect arguments given to ' + this.name + '()',
3143 index: this.index,
3144 type: 'runtime',
3145 filename: this.filename
3146 });
3147 return {is: 'undefined', value: 'undefined'};
3148 }
3149 return val;
3150 } else {
3151 env.error({
3152 message: 'incorrect number of arguments for ' + this.name +
3153 '(). ' + CartoCSS.Tree.functions[this.name].length + ' expected.',
3154 index: this.index,
3155 type: 'runtime',
3156 filename: this.filename
3157 });
3158 return {
3159 is: 'undefined',
3160 value: 'undefined'
3161 };
3162 }
3163 } else {
3164 var fn = CartoCSS.Tree.Reference.mapnikFunctions[this.name];
3165 if (fn === undefined) {
3166 var functions = toPairs(CartoCSS.Tree.Reference.mapnikFunctions);
3167 // cheap closest, needs improvement.
3168 var name = this.name;
3169 var mean = functions.map(function (f) {
3170 return [f[0], CartoCSS.Tree.Reference.editDistance(name, f[0]), f[1]];
3171 }).sort(function (a, b) {
3172 return a[1] - b[1];
3173 });
3174 env.error({
3175 message: 'unknown function ' + this.name + '(), did you mean ' +
3176 mean[0][0] + '(' + mean[0][2] + ')',
3177 index: this.index,
3178 type: 'runtime',
3179 filename: this.filename
3180 });

Callers

nothing calls this directly

Calls 2

mapMethod · 0.80
evMethod · 0.45

Tested by

no test coverage detected