plepe / pgmapcss

PGMapCSS is a library for PostgreSQL/PostGIS which works between an osm2pgsql based database and Mapnik (and maybe other renderers). It processes database (usually OpenStreetMap) objects according to MapCSS rules and calculates resulting colors, widths and other properties for Symbolizers, even geometric modifications.
GNU Affero General Public License v3.0
35 stars 8 forks source link

Optimize eval functions with fixed result #112

Open plepe opened 9 years ago

plepe commented 9 years ago

When eval functions have a fixed result (e.g. 2+2), pgmapcss uses this fixed result, just like as if the final value would have been given.

E.g.:

node {
  foo: 2+2;
  foo: 4;
}

will both compile into

current['properties']['foo'] = '4'

When using a property where the value is checked/modified before assigning, the check/modification could be done at compile time.

E.g.

way {
  color: red;
  color: concat('r', 'e', 'd');
}

will compile into

current['properties']['color'] = '#ff0000';
current['properties']['color'] = check_color('red');

Therefore, for every map feature which matches this rule the check_color() function will be called, which is not necessary.