MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / flatten

Method flatten

src/common/style/CartoCSS.js:4374–4454  ·  view source on GitHub ↗
(result, parents, env)

Source from the content-addressed store, hash-verified

4372 }
4373
4374 flatten(result, parents, env) {
4375 var selectors = [], i, j;
4376 if (this.selectors.length === 0) {
4377 env.frames = env.frames.concat(this.rules);
4378 }
4379 // evaluate zoom variables on this object.
4380 this.evZooms(env);
4381 for (i = 0; i < this.selectors.length; i++) {
4382 var child = this.selectors[i];
4383
4384 if (!child.filters) {
4385 // This is an invalid filterset.
4386 continue;
4387 }
4388
4389 if (parents.length) {
4390 for (j = 0; j < parents.length; j++) {
4391 var parent = parents[j];
4392
4393 var mergedFilters = parent.filters.cloneWith(child.filters);
4394 if (mergedFilters === null) {
4395 // Filters could be added, but they didn't change the
4396 // filters. This means that we only have to clone when
4397 // the zoom levels or the attachment is different too.
4398 if (parent.zoom === child.zoom &&
4399 parent.attachment === child.attachment &&
4400 parent.elements.join() === child.elements.join()) {
4401 selectors.push(parent);
4402 continue;
4403 } else {
4404 mergedFilters = parent.filters;
4405 }
4406 } else if (!mergedFilters) {
4407 // The merged filters are invalid, that means we don't
4408 // have to clone.
4409 continue;
4410 }
4411
4412 var clone = Object.create(CartoCSS.Tree.Selector.prototype);
4413 clone.filters = mergedFilters;
4414 clone.zoom = child.zoom;
4415 clone.elements = parent.elements.concat(child.elements);
4416 if (parent.attachment && child.attachment) {
4417 clone.attachment = parent.attachment + '/' + child.attachment;
4418 } else {clone.attachment = child.attachment || parent.attachment;}
4419 clone.conditions = parent.conditions + child.conditions;
4420 clone.index = child.index;
4421 selectors.push(clone);
4422 }
4423 } else {
4424 selectors.push(child);
4425 }
4426 }
4427
4428 var rules = [];
4429 for (i = 0; i < this.rules.length; i++) {
4430 var rule = this.rules[i];
4431

Callers 4

getParserMethod · 0.80
mapv.min.jsFile · 0.80
draw$4Function · 0.80
WFunction · 0.80

Calls 4

evZoomsMethod · 0.95
cloneWithMethod · 0.80
pushMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected