Merge branch 'master' of github.com:mapbox/carto
This commit is contained in:
commit
3a7f7d4375
@ -19,6 +19,10 @@ tree.Filter = function Filter(key, op, val, index, filename) {
|
|||||||
this.val = val;
|
this.val = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.op !== '=' && this.op !== '!=') {
|
||||||
|
this.val = 1 * this.val;
|
||||||
|
}
|
||||||
|
|
||||||
this.id = this.key + this.op + this.val;
|
this.id = this.key + this.op + this.val;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -34,15 +38,12 @@ var opXML = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
tree.Filter.prototype.toXML = function(env) {
|
tree.Filter.prototype.toXML = function(env) {
|
||||||
if (this.op !== '=' && this.op !== '!=') {
|
if (this.op !== '=' && this.op !== '!=' && isNaN(this.val)) {
|
||||||
this.val = 1 * this.val;
|
env.error({
|
||||||
if (isNaN(this.val)) {
|
message: 'Cannot use operator "' + this.op + '" with value ' + this.val,
|
||||||
env.error({
|
index: this.index,
|
||||||
message: 'Cannot use operator "' + this.op + '" with value ' + this.val,
|
filename: this.filename
|
||||||
index: this.index,
|
});
|
||||||
filename: this.filename
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (this.val.eval) this._val = this.val.eval(env);
|
if (this.val.eval) this._val = this.val.eval(env);
|
||||||
if (this.key.eval) this._key = this.key.eval(env);
|
if (this.key.eval) this._key = this.key.eval(env);
|
||||||
|
@ -23,7 +23,7 @@ helper.files('errorhandling', 'mml', function(file) {
|
|||||||
// @TODO for some reason, fs.readFile includes an additional \n
|
// @TODO for some reason, fs.readFile includes an additional \n
|
||||||
// at the end of read files. Determine why.
|
// at the end of read files. Determine why.
|
||||||
fs.readFile(helper.resultFile(file), 'utf8', function(err, data) {
|
fs.readFile(helper.resultFile(file), 'utf8', function(err, data) {
|
||||||
assert.deepEqual(output, data.substr(0, data.length - 1));
|
if (!err) assert.deepEqual(output, data.substr(0, data.length - 1));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
16
test/errorhandling/multi_stylesheets.mml
Normal file
16
test/errorhandling/multi_stylesheets.mml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"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",
|
||||||
|
"Stylesheet": [
|
||||||
|
"multi_stylesheets_b.mss",
|
||||||
|
"multi_stylesheets_a.mss"
|
||||||
|
],
|
||||||
|
"Layer": [{
|
||||||
|
"id": "world",
|
||||||
|
"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",
|
||||||
|
"Datasource": {
|
||||||
|
"file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip",
|
||||||
|
"type": "shape"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
6
test/errorhandling/multi_stylesheets_a.mss
Normal file
6
test/errorhandling/multi_stylesheets_a.mss
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#world {
|
||||||
|
polygon-opacity: 0.5;
|
||||||
|
line-width:4;
|
||||||
|
line-color:#fff;
|
||||||
|
line-opacity:0.3;
|
||||||
|
}
|
3
test/errorhandling/multi_stylesheets_b.mss
Normal file
3
test/errorhandling/multi_stylesheets_b.mss
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#world {
|
||||||
|
polygonopacity: 0.5;
|
||||||
|
}
|
14
test/rendering/issue_100_filters.mml
Normal file
14
test/rendering/issue_100_filters.mml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
|
||||||
|
"Stylesheet": [
|
||||||
|
"issue_100_filters.mss"
|
||||||
|
],
|
||||||
|
"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.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
|
||||||
|
"Datasource": {
|
||||||
|
"file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip",
|
||||||
|
"type": "shape"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
16
test/rendering/issue_100_filters.mss
Normal file
16
test/rendering/issue_100_filters.mss
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#world[zoom>10][area>16000000],
|
||||||
|
#world[zoom>11][area>4000000],
|
||||||
|
#world[zoom>12][area>1000000],
|
||||||
|
#world[zoom>13][area>500000],
|
||||||
|
#world[zoom>14][area>250000],
|
||||||
|
#world[zoom>15][area>125000],
|
||||||
|
#world[zoom>16][area>62500],
|
||||||
|
#world[zoom>17] {
|
||||||
|
text-name:'[name]';
|
||||||
|
text-face-name:'Helvetica';
|
||||||
|
text-halo-fill:#fff;
|
||||||
|
text-halo-radius:2;
|
||||||
|
text-placement:interior;
|
||||||
|
text-size:11;
|
||||||
|
text-wrap-width:20;
|
||||||
|
}
|
56
test/rendering/issue_100_filters.result
Normal file
56
test/rendering/issue_100_filters.result
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?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.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
|
||||||
|
|
||||||
|
|
||||||
|
<Style name="world" filter-mode="first">
|
||||||
|
<Rule>
|
||||||
|
<MaxScaleDenominator>400000</MaxScaleDenominator>
|
||||||
|
<Filter>([area] > 16000000)</Filter>
|
||||||
|
<TextSymbolizer name="[name]" face-name="Helvetica" halo-fill="#ffffff" halo-radius="2" placement="interior" size="11" wrap-width="20" />
|
||||||
|
</Rule>
|
||||||
|
<Rule>
|
||||||
|
<MaxScaleDenominator>200000</MaxScaleDenominator>
|
||||||
|
<Filter>([area] > 4000000)</Filter>
|
||||||
|
<TextSymbolizer name="[name]" face-name="Helvetica" halo-fill="#ffffff" halo-radius="2" placement="interior" size="11" wrap-width="20" />
|
||||||
|
</Rule>
|
||||||
|
<Rule>
|
||||||
|
<MaxScaleDenominator>100000</MaxScaleDenominator>
|
||||||
|
<Filter>([area] > 1000000)</Filter>
|
||||||
|
<TextSymbolizer name="[name]" face-name="Helvetica" halo-fill="#ffffff" halo-radius="2" placement="interior" size="11" wrap-width="20" />
|
||||||
|
</Rule>
|
||||||
|
<Rule>
|
||||||
|
<MaxScaleDenominator>50000</MaxScaleDenominator>
|
||||||
|
<Filter>([area] > 500000)</Filter>
|
||||||
|
<TextSymbolizer name="[name]" face-name="Helvetica" halo-fill="#ffffff" halo-radius="2" placement="interior" size="11" wrap-width="20" />
|
||||||
|
</Rule>
|
||||||
|
<Rule>
|
||||||
|
<MaxScaleDenominator>25000</MaxScaleDenominator>
|
||||||
|
<Filter>([area] > 250000)</Filter>
|
||||||
|
<TextSymbolizer name="[name]" face-name="Helvetica" halo-fill="#ffffff" halo-radius="2" placement="interior" size="11" wrap-width="20" />
|
||||||
|
</Rule>
|
||||||
|
<Rule>
|
||||||
|
<MaxScaleDenominator>12500</MaxScaleDenominator>
|
||||||
|
<Filter>([area] > 125000)</Filter>
|
||||||
|
<TextSymbolizer name="[name]" face-name="Helvetica" halo-fill="#ffffff" halo-radius="2" placement="interior" size="11" wrap-width="20" />
|
||||||
|
</Rule>
|
||||||
|
<Rule>
|
||||||
|
<MaxScaleDenominator>5000</MaxScaleDenominator>
|
||||||
|
<Filter>([area] > 62500)</Filter>
|
||||||
|
<TextSymbolizer name="[name]" face-name="Helvetica" halo-fill="#ffffff" halo-radius="2" placement="interior" size="11" wrap-width="20" />
|
||||||
|
</Rule>
|
||||||
|
<Rule>
|
||||||
|
<MaxScaleDenominator>2500</MaxScaleDenominator>
|
||||||
|
<TextSymbolizer name="[name]" face-name="Helvetica" halo-fill="#ffffff" halo-radius="2" placement="interior" size="11" wrap-width="20" />
|
||||||
|
</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.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
|
||||||
|
<StyleName>world</StyleName>
|
||||||
|
<Datasource>
|
||||||
|
<Parameter name="file"><![CDATA[[absolute path]]]></Parameter>
|
||||||
|
<Parameter name="type"><![CDATA[shape]]></Parameter>
|
||||||
|
</Datasource>
|
||||||
|
</Layer>
|
||||||
|
|
||||||
|
</Map>
|
14
test/rendering/nominzoom.mml
Normal file
14
test/rendering/nominzoom.mml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"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",
|
||||||
|
"Stylesheet": [
|
||||||
|
"nominzoom.mss"
|
||||||
|
],
|
||||||
|
"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 +wktext +no_defs +over",
|
||||||
|
"Datasource": {
|
||||||
|
"file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip",
|
||||||
|
"type": "shape"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
3
test/rendering/nominzoom.mss
Normal file
3
test/rendering/nominzoom.mss
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#world[zoom < 5] {
|
||||||
|
polygon-fill: #000;
|
||||||
|
}
|
21
test/rendering/nominzoom.result
Normal file
21
test/rendering/nominzoom.result
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?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 +wktext +no_defs +over">
|
||||||
|
|
||||||
|
|
||||||
|
<Style name="world" filter-mode="first">
|
||||||
|
<Rule>
|
||||||
|
<MinScaleDenominator>25000000</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 +wktext +no_defs +over">
|
||||||
|
<StyleName>world</StyleName>
|
||||||
|
<Datasource>
|
||||||
|
<Parameter name="file"><![CDATA[[absolute path]]]></Parameter>
|
||||||
|
<Parameter name="type"><![CDATA[shape]]></Parameter>
|
||||||
|
</Datasource>
|
||||||
|
</Layer>
|
||||||
|
|
||||||
|
</Map>
|
Loading…
Reference in New Issue
Block a user