Add unsigned support and test code

This commit is contained in:
Tom MacWright 2012-09-04 12:57:25 -04:00
parent f4132221d6
commit 829fe84baf
5 changed files with 52 additions and 1 deletions

View File

@ -24,6 +24,10 @@ tree.Dimension.prototype = {
toColor: function() {
return new tree.Color([this.value, this.value, this.value]);
},
round: function() {
this.value = Math.round(this.value);
return this;
},
toString: function() {
return this.value.toString();
},

View File

@ -173,8 +173,15 @@ tree.Reference.validValue = function(env, selector, value) {
}
return true;
}
} else if (tree.Reference.selector(selector).type == 'expression') {
} else if (tree.Reference.selector(selector).type === 'expression') {
return true;
} else if (tree.Reference.selector(selector).type === 'unsigned') {
if (value.value[0].is === 'float') {
value.value[0].round();
return true;
} else {
return false;
}
} else {
if (tree.Reference.selector(selector).validate) {
var valid = false;

View 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": [
"unsigned.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"
}
}]
}

View File

@ -0,0 +1,6 @@
#world {
text-size:10.5;
text-spacing:12.1;
text-name:[FOO];
text-face-name:'Foo';
}

View File

@ -0,0 +1,20 @@
<?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" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">
<Style name="world" filter-mode="first" >
<Rule>
<TextSymbolizer size="11" spacing="12" face-name="Foo" ><![CDATA[[FOO]]]></TextSymbolizer>
</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>