| 24 | export class CartoCSS { |
| 25 | |
| 26 | constructor(cartoStr) { |
| 27 | this.env = null; |
| 28 | |
| 29 | /** |
| 30 | * @member CartoCSS.prototype.parser |
| 31 | * @description 解析器。 |
| 32 | */ |
| 33 | this.parser = null; |
| 34 | |
| 35 | /** |
| 36 | * @member CartoCSS.prototype.ruleSet |
| 37 | * @description CartoCSS 规则对象。 |
| 38 | */ |
| 39 | this.ruleSet = null; |
| 40 | |
| 41 | /** |
| 42 | * @member CartoCSS.prototype.cartoStr |
| 43 | * @description CartoCSS 样式表字符串。 |
| 44 | */ |
| 45 | this.cartoStr = ""; |
| 46 | |
| 47 | /** |
| 48 | * @member CartoCSS.prototype.shaders |
| 49 | * @description Carto 着色器集。 |
| 50 | */ |
| 51 | this.shaders = null; |
| 52 | |
| 53 | if (typeof cartoStr === "string") { |
| 54 | this.cartoStr = cartoStr; |
| 55 | this.env = { |
| 56 | frames: [], |
| 57 | errors: [], |
| 58 | error: function (obj) { |
| 59 | this.errors.push(obj); |
| 60 | } |
| 61 | }; |
| 62 | this.parser = this.getParser(this.env); |
| 63 | this.parse(cartoStr); |
| 64 | this.shaders = this.toShaders(); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * @function CartoCSS.prototype.getParser |