Merging package. Supporting variables in filters

This commit is contained in:
Tom MacWright 2011-05-17 13:54:44 -04:00
parent f22e0f5f1d
commit 4c30131e4f
5 changed files with 55 additions and 41 deletions

View File

@ -806,7 +806,7 @@ carto.Parser = function Parser(env) {
if (! $('[')) return;
if (key = $(/^[a-zA-Z0-9-_]+/) || $(this.entities.quoted)) {
if ((op = $(this.entities.comparison)) &&
(val = $(this.entities.quoted) || $(/^[\w-\.]+/))) {
(val = $(this.entities.quoted) || $(this.entities.variable) || $(/^[\w-\.]+/))) {
if (! $(']')) return;
return new tree.Filter(key, op, val, memo);
}

View File

@ -41,6 +41,7 @@ var opXML = {
};
tree.Filter.prototype.toXML = function(env) {
if (this.val.eval) this._val = this.val.eval(env);
if (this._key) var key = this._key.toString(this._key.is == 'string');
if (this._val) var val = this._val.toString(this._val.is == 'string');

View File

@ -10,8 +10,8 @@ tree.Layer = function Layer(obj) {
tree.Layer.prototype.toXML = function() {
var dsoptions = [];
for (var i in this.datasource) {
dsoptions.push('<Parameter name="' + i + '">' +
this.datasource[i] + '</Parameter>');
dsoptions.push('<Parameter name="' + i + '"><![CDATA[' +
this.datasource[i] + ']]></Parameter>');
}
return '<Layer\n ' +
' name="' + this.name + '"\n' +

View File

@ -1,89 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs">
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
<Style name="world" filter-mode="first">
<Rule>
<MinScaleDenominator>50000000</MinScaleDenominator>
<PolygonSymbolizer fill="#ffff00"/>
<PolygonSymbolizer fill="#ffff00" />
</Rule>
<Rule>
<MaxScaleDenominator>1500000</MaxScaleDenominator><MinScaleDenominator>750000</MinScaleDenominator>
<PolygonSymbolizer fill="#000000"/>
<MaxScaleDenominator>1500000</MaxScaleDenominator>
<MinScaleDenominator>750000</MinScaleDenominator>
<PolygonSymbolizer fill="#000000" />
</Rule>
</Style>
<Layer
name="world"
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs">
name="world"
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
<StyleName>world</StyleName>
<Datasource>
<Parameter name="file">[absolute path]</Parameter>
<Parameter name="type">shape</Parameter>
<Parameter name="file"><![CDATA[[absolute path]]]></Parameter>
<Parameter name="type"><![CDATA[shape]]></Parameter>
</Datasource>
</Layer>
<Style name="countries" filter-mode="first">
<Rule>
<MaxScaleDenominator>100000</MaxScaleDenominator>
<LineSymbolizer stroke-width="0.25"/>
<LineSymbolizer stroke-width="0.25" />
</Rule>
<Rule>
<MaxScaleDenominator>200000</MaxScaleDenominator><MinScaleDenominator>100000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.3"/>
<MaxScaleDenominator>200000</MaxScaleDenominator>
<MinScaleDenominator>100000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.3" />
</Rule>
<Rule>
<MaxScaleDenominator>400000</MaxScaleDenominator><MinScaleDenominator>200000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.4"/>
<MaxScaleDenominator>400000</MaxScaleDenominator>
<MinScaleDenominator>200000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.4" />
</Rule>
<Rule>
<MaxScaleDenominator>750000</MaxScaleDenominator><MinScaleDenominator>400000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.5"/>
<MaxScaleDenominator>750000</MaxScaleDenominator>
<MinScaleDenominator>400000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.5" />
</Rule>
<Rule>
<MaxScaleDenominator>1500000</MaxScaleDenominator><MinScaleDenominator>750000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.6"/>
<MaxScaleDenominator>1500000</MaxScaleDenominator>
<MinScaleDenominator>750000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.6" />
</Rule>
<Rule>
<MaxScaleDenominator>3000000</MaxScaleDenominator><MinScaleDenominator>1500000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.7"/>
<MaxScaleDenominator>3000000</MaxScaleDenominator>
<MinScaleDenominator>1500000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.7" />
</Rule>
<Rule>
<MaxScaleDenominator>6500000</MaxScaleDenominator><MinScaleDenominator>3000000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.8"/>
<MaxScaleDenominator>6500000</MaxScaleDenominator>
<MinScaleDenominator>3000000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.8" />
</Rule>
<Rule>
<MaxScaleDenominator>12500000</MaxScaleDenominator><MinScaleDenominator>6500000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.9"/>
<MaxScaleDenominator>12500000</MaxScaleDenominator>
<MinScaleDenominator>6500000</MinScaleDenominator>
<LineSymbolizer stroke-width="0.9" />
</Rule>
<Rule>
<MaxScaleDenominator>25000000</MaxScaleDenominator><MinScaleDenominator>12500000</MinScaleDenominator>
<LineSymbolizer stroke-width="1"/>
<MaxScaleDenominator>25000000</MaxScaleDenominator>
<MinScaleDenominator>12500000</MinScaleDenominator>
<LineSymbolizer stroke-width="1" />
</Rule>
<Rule>
<MaxScaleDenominator>100000000</MaxScaleDenominator><MinScaleDenominator>50000000</MinScaleDenominator>
<LineSymbolizer stroke-width="1.25"/>
<MaxScaleDenominator>50000000</MaxScaleDenominator>
<MinScaleDenominator>25000000</MinScaleDenominator>
<LineSymbolizer stroke-width="1.25" />
</Rule>
<Rule>
<MaxScaleDenominator>50000000</MaxScaleDenominator><MinScaleDenominator>25000000</MinScaleDenominator>
<LineSymbolizer stroke-width="1.25"/>
<MaxScaleDenominator>100000000</MaxScaleDenominator>
<MinScaleDenominator>50000000</MinScaleDenominator>
<LineSymbolizer stroke-width="1.25" />
</Rule>
<Rule>
<MaxScaleDenominator>200000000</MaxScaleDenominator><MinScaleDenominator>100000000</MinScaleDenominator>
<LineSymbolizer stroke-width="1.5"/>
<MaxScaleDenominator>200000000</MaxScaleDenominator>
<MinScaleDenominator>100000000</MinScaleDenominator>
<LineSymbolizer stroke-width="1.5" />
</Rule>
<Rule>
<MaxScaleDenominator>500000000</MaxScaleDenominator><MinScaleDenominator>200000000</MinScaleDenominator>
<LineSymbolizer stroke-width="2"/>
<MaxScaleDenominator>500000000</MaxScaleDenominator>
<MinScaleDenominator>200000000</MinScaleDenominator>
<LineSymbolizer stroke-width="2" />
</Rule>
</Style>
<Layer
name="countries"
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs">
name="countries"
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
<StyleName>countries</StyleName>
<Datasource>
<Parameter name="file">[absolute path]</Parameter>
<Parameter name="type">shape</Parameter>
<Parameter name="file"><![CDATA[[absolute path]]]></Parameter>
<Parameter name="type"><![CDATA[shape]]></Parameter>
</Datasource>
</Layer>