Note some new features in the changelog, add modulus operation

This commit is contained in:
Tom MacWright 2012-06-26 12:37:05 -04:00
parent 28ab872e72
commit bdfcd7aa6d
7 changed files with 83 additions and 3 deletions

View File

@ -1,5 +1,10 @@
## Changelog
## 0.9.0
* Adds the modulus operator `%` as an option
* Adds a new field-type like `[FIELD]` instead of "[FIELD"
### 0.8.0
* Supports function syntax for transforms, optionally with variables and arguments.

View File

@ -463,7 +463,7 @@ carto.Parser = function Parser(env) {
call: function() {
var name, args;
if (! (name = /^([\w-]+|%)\(/.exec(chunks[j]))) return;
if (! (name = /^([\w\-]+|%)\(/.exec(chunks[j]))) return;
name = name[1].toLowerCase();
@ -776,10 +776,9 @@ carto.Parser = function Parser(env) {
multiplication: function() {
var m, a, op, operation;
if (m = $(this.operand)) {
while ((op = ($('/') || $('*'))) && (a = $(this.operand))) {
while ((op = ($('/') || $('*') || $('%'))) && (a = $(this.operand))) {
operation = new tree.Operation(op, [operation || m, a], memo);
}
console.log(m);
return operation || m;
}
},

View File

@ -53,6 +53,7 @@ tree.operate = function(op, a, b) {
case '+': return a + b;
case '-': return a - b;
case '*': return a * b;
case '%': return a % b;
case '/': return a / b;
}
};

View File

@ -0,0 +1,23 @@
<?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">
<FontSet name="fontset-0">
<Font face-name="Georgia Regular"/>
<Font face-name="Arial Italic"/>
</FontSet>
<Style name="world" filter-mode="first" >
<Rule>
<TextSymbolizer size="11" fontset-name="fontset-0" ><![CDATA[hello [NAME]]]></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>

View File

@ -0,0 +1,23 @@
{
"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": [
"modulus.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"
}
},
{
"class": "new",
"name": "countries",
"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-name: "hello ";
text-size: 11 % 2;
text-face-name: "Georgia Regular", "Arial Italic";
}

View File

@ -0,0 +1,23 @@
<?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">
<FontSet name="fontset-0">
<Font face-name="Georgia Regular"/>
<Font face-name="Arial Italic"/>
</FontSet>
<Style name="world" filter-mode="first" >
<Rule>
<TextSymbolizer size="1" fontset-name="fontset-0" ><![CDATA[hello ]]></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>