pax_global_header00006660000000000000000000000064122325514750014520gustar00rootroot0000000000000052 comment=5a7429d30d9d5d0860ce1a0c78d4f66cd883ca93 carto-0.9.5/000077500000000000000000000000001223255147500126435ustar00rootroot00000000000000carto-0.9.5/.gitignore000066400000000000000000000001451223255147500146330ustar00rootroot00000000000000/node_modules .DS_Store test/rendering/layers/ test/rendering/cache/ test/rendering-mss/npm-debug.logcarto-0.9.5/.npmignore000066400000000000000000000000311223255147500146340ustar00rootroot00000000000000*.swp npm_modules/ test/ carto-0.9.5/.travis.yml000066400000000000000000000001061223255147500147510ustar00rootroot00000000000000language: node_js node_js: - "0.11" - "0.10" - "0.8" - "0.6" carto-0.9.5/CHANGELOG.md000066400000000000000000000117401223255147500144570ustar00rootroot00000000000000## Changelog ## 0.9.5 * Various speed optimizations to help address #20 (#231) * Fixed support for fields that contain the word `zoom` in them (previous clashed with `zoom` keyword) * Fixed support for a space in front of `zoom` keyword (#288) * Improved error messages when color functions encounter invalid color (#309) * The `carto` command line tool now exits cleanly when millstone is used * The `carto` command line tool now only localized with millstone if requested (#243) * Added man page for `carto` (#257) * Fix repeated comments in selectors. Fixes #260 * Fixed `image-filter` duplication (#270) * Quote all needed XML chars. See #263. * Added higher tolerance for various characters in field names (#230) * Bump `mapnik-reference` dependency to ~5.0.7 (with support for Mapnik v2.2.0) * Adds compatibility with screen units. * Fixed ability to use carto as global module (#236) * Now using 'console' instead of `util` for `stderr` (#217) ## 0.9.4 * Fixes nesting of regex calls ## 0.9.3 * Allows `text-face-name` properties to be unquoted * Detects inline Format XML tags in `text-name` and passes such output straight to XML for advanced text names. * Fixes bugs around concatenation of strings in expressions * Fixes parsing of comments in between selectors * Fixes parsing of whitespace in calls * Improved error messages for unknown properties - advises user on the property name most closely matching the incorrect input. * Improved errors for calls, advises user on number of arguments * Fixes instance inheritance - thanks @gravitystorm! ## 0.9.2 Tagged Sept 6, 2012 * Bump `mapnik-reference` dependency to ~5.0.0 * Better support for unsigned types in certain Mapnik styling properties ## 0.9.1 Tagged Aug 15, 2012 * Improved error handling for different target `mapnik-reference` versions (strk) * Bump `mapnik-reference` dependency to ~4.0.3 * Fixed handling of image-filter syntax as per [Mapnik changes](https://github.com/mapnik/mapnik/issues/1384) ## 0.9.0 * Bump `mapnik-reference` dependency to ~4.0.0 to pull in new properties. * Adapted to `comp-op` rename upstream in `mapnik-reference`. * Adapted to `transform` rename upstream in `mapnik-reference` and Mapnik. ## 0.8.1 * Bump `mapnik-reference` dependency to ~3.1.0 to pull in new properties. ## 0.8.0 * Adds the modulus operator `%` as an option * Adds a new field-type like `[FIELD]` instead of "[FIELD]" * Supports function syntax for transforms, optionally with variables and arguments. ### 0.7.1 * Updated mapnik-reference to `~2.2.1` * Added support for `status` parameter on layers. * Command line `carto` program gained `--nosymlink` option to pass to millstone to use absolute paths instead of symlinking files. * Removed unsupported mixin code. ### 0.7.0 * Updated mapnik-reference to `~2.1.0` * Support an `opacity` property on any style that is a style-level property ### 0.6.0 * Bump `mapnik-reference` dependency to 1.0.0 to allow for using `buffer-size` in the `Map` element. ### 0.5.0 * Now uses the [mapnik-reference](https://github.com/mapnik/mapnik-reference) npm module instead of copying `reference.json` when it's updated * Adds a second parameter to `carto.Renderer` - an object which has a key `mapnik_version` that specifies the version of Mapnik this stylesheet should target. ### 0.4.10 * Updated reference.json ### 0.4.9 * Render TileJSON, Mapnik options to Mapnik XML parameters. ### 0.4.8 * Updated reference.json ### 0.4.7 * Removed deprecation warnings re: sys/util * Updated reference.json * Updated underscore dependency ### 0.4.6 * Node >=v0.6.x compatibility * Dropped cartox * Updated reference.json ### 0.4.5 * Fixes text-name with HTML entities * Fixes function calls with incorrect number of arguments * Fixes invalid code segments not having eval ### 0.4.3 * Fixes serialization bug with invalid selectors. ### 0.4.0 * Switches text-symbolizer syntax to new-style for Mapnik 2.0 ### 0.3.0 * Add "name/" prefix for creating multiple instances of a symbolizer in the same attachment * Only output `` tag when there's at least one style * Sort styles by location of first rule's index * Don't support selectors that are not either `Map`, `.` or `#`-prefixed. ### 0.2.3 * Fixes many bugs * Supports arbitrary properties on layers with the `properties` key in MML * Adds `min-path-length` * Updates `reference.json` ### 0.2.2 * Update `carto` to use `millstone` if available. ### 0.2.1 * Accept valid Map properties directly from input mml object. ### 0.2.0 * Removed all external handling - see http://github.com/mapbox/millstone for localizing/caching MML objects with external references. * All errors are now handled as Error objects. ### 0.1.14 * Optional-file datasources - allows string argument to OGR ### 0.1.9 * Variables in filters. ### 0.1.6 & 0.1.8 * Fixed bug caused by jshint testing ### 0.1.5 * Using npm devDependencies in place of ndistro * Updated package.json format * Fixes tests ### 0.1.4 * Fix bug in which SRS autodetection broke error handling * Update carto carto-0.9.5/DEVELOPING.md000066400000000000000000000012641223255147500146240ustar00rootroot00000000000000## Developing Installing: git clone git@github.com:mapbox/carto.git npm install Test: npm test Running the head binary: ./bin/carto ## Documentation This repository contains auto-generated documentation of the content of Carto that's published on MapBox.com. git fetch origin gh-pages:gh-pages Edit `_docs/package.json` to point to the head version of [mapnik-reference](https://github.com/mapnik/mapnik-reference). cd _docs npm install node generate.js Then run up a directory and run the testing server: cd ../ jekyll serve -p 4000 Test the new site at `localhost:4000/carto` and if things look good then git add your changes and push. carto-0.9.5/LICENSE000066400000000000000000000230441223255147500136530ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS Copyright (c) 2009-2010 Alexis Sellier carto-0.9.5/Makefile000066400000000000000000000005231223255147500143030ustar00rootroot00000000000000# # Run all tests # expresso = ./node_modules/.bin/mocha lint: ./node_modules/.bin/jshint lib/carto/*.js lib/carto/tree/*.js ifndef only test: @NODE_PATH=./lib:$NODE_PATH $(expresso) -R spec -I lib test/*.test.js else test: @NODE_PATH=./lib:$NODE_PATH $(expresso) -R spec -I lib test/${only}.test.js endif check: test .PHONY: test carto-0.9.5/README.md000066400000000000000000000215221223255147500141240ustar00rootroot00000000000000# CartoCSS [![Build Status](https://secure.travis-ci.org/mapbox/carto.png)](http://travis-ci.org/mapbox/carto) Is a stylesheet renderer for Mapnik. It's an evolution of the [Cascadenik](https://github.com/mapnik/Cascadenik) idea and language, with an emphasis on speed and flexibility. ## Reference Documentation * [mapbox.com/carto](http://mapbox.com/carto/) ## MML _incompatibility_ * MML files are assumed to be JSON, not XML. The files are near-identical to the XML files accepted by Cascadenik, just translated into JSON. * CartoCSS will not embed files or download URLs for you. Stylesheets should be embedded directly into your MML JSON and any datasources should be paths (relative or absolute) that would be acceptable in Mapnik XML. The [millstone project](https://github.com/mapbox/millstone) aims to fill this need. CartoCSS MML: { "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": [{"id":"style.mss","data":"Map {\n background-color: #fff;\n}\n\n#world {\n line-color: #ccc;\n line-width: 0.5;\n polygon-fill: #eee;\n}"}], "Layer": [{ "id": "world", "name": "world", "srs": "+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs", "Datasource": { "file": "world_borders", "type": "shape" } }] } Cascadenik MML
<Stylesheet><![CDATA[
    Map {
        map-bgcolor: #69f;
    }

    Layer {
        line-width: 1;
        line-color: #696;
        polygon-fill: #6f9;
    }
]]></Stylesheet>
<Layer srs="+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs">
    <Datasource>
        <Parameter name="type">shape</Parameter>
        <Parameter name="file">world_borders</Parameter>
    </Datasource>
</Layer>
</Map>
## Attachments and Instances _new_ In CSS, a certain object can only have one instance of a property. A `
` has a specific border width and color, rules that match better than others (#id instead of .class) override previous definitions. `CartoCSS` acts the same way normally for the sake of familiarity and organization, but Mapnik itself is more powerful. Layers in Mapnik can have multiple [borders](http://trac.mapnik.org/wiki/LineSymbolizer) and multiple copies of other attributes. This ability is useful in drawing line outlines, like in the case of road borders or 'glow' effects around coasts. `CartoCSS` makes this accessible by allowing attachments to styles: #world { line-color: #fff; line-width: 3; } #world::outline { line-color: #000; line-width: 6; } Attachments are optional: if you don't define them, CartoCSS does overriding of styles just like Cascadenik. This brings us to another _incompatibility_: `line-inline` and `line-outline` have been removed from the language, because attachments are capable of the same trick. While attachments allow creating implicit "layers" with the same data, using **instances** allows you to create multiple symbolizers in the same style/layer: #roads { casing/line-width: 6; casing/line-color: #333; line-width: 4; line-color: #666; } This makes Mapnik first draw the line of color #333 with a width of 6, and then immediately afterwards, it draws the same line again with width 4 and color #666. Contrast that to attachments: Mapnik would first draw all casings before proceeding to the actual lines. ## text-name _incompatibility_ Instead of the name attribute of the [TextSymbolizer](http://trac.mapnik.org/wiki/TextSymbolizer) and [ShieldSymbolizer](http://trac.mapnik.org/wiki/ShieldSymbolizer) being a part of the selector, it is a property of a rule. Thus the evaluation is less complex and one can use expressions in names.
cascadenik CartoCSS
#world NAME {
  text-face-name: "Arial";
}
#world {
  text-name: "NAME";
  text-face-name: "Arial";
}
## Mapnik _new_ CartoCSS is only compatible with Mapnik >= 2.x.x. ## Rasters and Buildings _new_ Rasters are supported in CartoCSS - it knows how to download `.vrt`, `.tiff`, and soon other raster formats, and the properties of the [RasterSymbolizer](http://trac.mapnik.org/wiki/RasterSymbolizer) are exposed in the language. The [BuildingSymbolizer](http://trac.mapnik.org/wiki/BuildingSymbolizer) is also supported in `CartoCSS`. The code stores symbolizer types and properties in a JSON file (in `tree/reference.json`), so new Mapnik features can be quickly implemented here. ## Variables & Expressions _new_ CartoCSS inherits from its basis in [less.js](http://lesscss.org/) some new features in CSS. One can define variables in stylesheets, and use expressions to modify them. @mybackground: #2B4D2D; Map { background-color: @mybackground } #world { polygon-fill: @mybackground + #222; line-color: darken(@mybackground, 10%); } ## Nested Styles _new_ CartoCSS also inherits nesting of rules from less.js. /* Applies to all layers with .land class */ .land { line-color: #ccc; line-width: 0.5; polygon-fill: #eee; /* Applies to #lakes.land */ #lakes { polygon-fill: #000; } } This can be a convenient way to group style changes by zoom level: [zoom > 1] { /* Applies to all layers at zoom > 1 */ polygon-gamma: 0.3; #world { polygon-fill: #323; } #lakes { polygon-fill: #144; } } ## FontSets _new_ By defining multiple fonts in a `text-face-name` definition, you create [FontSets](http://trac.mapnik.org/wiki/FontSet) in `CartoCSS`. These are useful for supporting multiple character sets and fallback fonts for distributed styles.
cartoXML
#world {
  text-name: "[NAME]";
  text-size: 11;
  text-face-name: "Georgia Regular", "Arial Italic";
}
<FontSet name="fontset-0">
  <Font face-name="Georgia Regular"/>
  <Font face-name="Arial Italic"/>
</FontSet>
<Style name="world-text">
  <Rule>
    <TextSymbolizer fontset-name="fontset-0"
      size="11"
      name="[NAME]"/>
  </Rule>
</Style>
## Filters CartoCSS supports a variety of filter styles: Numeric comparisons: ``` #world[population > 100] #world[population < 100] #world[population >= 100] #world[population <= 100] ``` General comparisons: ``` #world[population = 100] #world[population != 100] ``` String comparisons: ``` /* a regular expression over name */ #world[name =~ "A.*"] ``` ## Developers #### Installation If you're using [TileMill](http://mapbox.com/tilemill/), you're already using CartoCSS and don't need to do a thing. If you're a developer-type and want to use the `carto` binary with `node.js` (and you have [npm](http://npmjs.org/) installed), npm install -g carto #### From the binary Install `millstone` to enable support for localizing external resources (URLs and local files) referenced in your mml file. npm install millstone carto map_file.json #### From code Currently CartoCSS is designed to be invoked from [node.js](http://nodejs.org/). The `Renderer` interface is the main API for developers, and it takes an MML file as a string as input. // defined variables: // - input (the name or identifier of the file being parsed) // - data (a string containing the MML or an object of MML) var carto = require('carto'); new carto.Renderer({ filename: input, local_data_dir: path.dirname(input), }).render(data, function(err, output) { if (err) { if (Array.isArray(err)) { err.forEach(function(e) { carto.writeError(e, options); }); } else { throw err; } } else { sys.puts(output); } }); ### Vim To install, download or clone this repository, then add the `vim-carto` directory located at `build/vim-carto` to your `~/.vim` file. ## Credits CartoCSS is based on [less.js](https://github.com/cloudhead/less.js), a CSS compiler written by Alexis Sellier. It depends on: * [underscore.js](https://github.com/documentcloud/underscore/) Only for running tests: * [mocha](https://github.com/visionmedia/mocha) * [sax-js](https://github.com/isaacs/sax-js/) ## Authors * Tom MacWright (tmcw) * Konstantin Käfer (kkaefer) * AJ Ashton (ajashton) * Dane Springmeyer (springmeyer) carto-0.9.5/bin/000077500000000000000000000000001223255147500134135ustar00rootroot00000000000000carto-0.9.5/bin/carto000077500000000000000000000120701223255147500144510ustar00rootroot00000000000000#!/usr/bin/env node var path = require('path'), fs = require('fs'), carto = require('../lib/carto'), url = require('url'), _ = require('underscore'); var existsSync = require('fs').existsSync || require('path').existsSync var optimist = require('optimist') .usage("Usage: $0 ") .options('h', {alias:'help', describe:'Display this help message'}) .options('v', {alias:'version', boolean:true, describe:'Display version information'}) .options('b', {alias:'benchmark', boolean:true, describe:'Outputs total compile time'}) .options('l', {alias:'localize', boolean:true, default:false, describe:'Use millstone to localize resources when loading an MML'}) .options('n', {alias:'nosymlink', boolean:true, describe:'Use absolute paths instead of symlinking files'}) .options('ppi', {describe:'Pixels per inch used to convert m, mm, cm, in, pt, pc to pixels', default:90.714}); var options = optimist.argv; if (options.help) { optimist.showHelp(); process.exit(0); } if (options.version) { console.log("carto " + carto.version.join('.') + " (Carto map stylesheet compiler)"); process.exit(0); } var input = options._[0]; if (input && input[0] != '/') { input = path.join(process.cwd(), input); } if (!input) { console.log("carto: no input files ('carto -h or --help' for help)"); process.exit(1); } if (options.benchmark) { var start = +new Date; } var ext = path.extname(input); if (!ext) { console.log("carto: please pass either a .mml file or .mss file"); process.exit(1); } if (!existsSync(input)) { console.log("carto: file does not exist: '" + input + "'"); process.exit(1); } function compileMML(err, data) { // force drain the millstone download pool now // to ensure we can exit without waiting if (options.localize && millstone.drainPool) { millstone.drainPool(function() {}); } if (err) { console.error(err); process.exit(1); } try { var renderer = new carto.Renderer({ filename: input, benchmark: options.benchmark, ppi: options.ppi }); renderer.render(data, function(err, output) { if (err) { console.error(err); throw err; process.exit(1); } else { if (!options.benchmark) { console.log(output); } else { var duration = (+new Date) - start; console.log('TOTAL: ' + (duration) + 'ms'); } } }); } catch (e) { if (e.stack) { console.error(e.stack); } else { console.error(e); } process.exit(1); } }; function compileMSS(err, data) { if (err) { console.error(err); process.exit(1); } try { var renderer = new carto.Renderer({ filename: path.basename(input), benchmark: options.benchmark, ppi: options.ppi }); renderer.renderMSS(data, function(err, output) { if (err) { console.error(err); throw err; process.exit(1); } else { if (!options.benchmark) { console.log(output); } else { var duration = (+new Date) - start; console.log('TOTAL: ' + (duration) + 'ms'); } } }); } catch (e) { if (e.stack) { console.error(e.stack); } else { console.error(e); } process.exit(1); } }; try { var data = fs.readFileSync(input, 'utf-8'); } catch(err) { console.error("carto: " + err.message.replace(/^[A-Z]+, /, '')); process.exit(1); } if (ext == '.mml') { try { data = JSON.parse(data); } catch(err) { console.error("carto: " + err.message.replace(/^[A-Z]+, /, '')); process.exit(1); } if (options.localize) { var millstone = undefined; try { require.resolve('millstone'); millstone = require('millstone'); } catch (err) { console.error('carto: Millstone not found, required if localizing stylesheet resources. ' + err.message.replace(/^[A-Z]+, /, '')); process.exit(1); } millstone.resolve({ mml: data, base: path.dirname(input), cache: path.join(path.dirname(input), 'cache'), nosymlink: options.nosymlink }, compileMML); } else { data.Stylesheet = data.Stylesheet.map(function(x) { if (typeof x !== 'string') { return { id: x, data: x.data } } return { id: x, data: fs.readFileSync(path.join(path.dirname(input), x), 'utf8') } }); compileMML(null,data); } } else if (ext == '.mss') { compileMSS(null,data); } else { console.log("carto: please pass either a .mml file or .mss file"); } carto-0.9.5/bin/mml2json.js000077500000000000000000000040751223255147500155230ustar00rootroot00000000000000#!/usr/bin/env node var xml2js = require('xml2js'), fs = require('fs'); if (!process.argv[2]) { console.log('Please specify a XML file.'); process.exit(1); } fs.readFile(process.argv[2], 'utf-8', function(err, data) { if (err) throw err; // Replace entities. var entities = {}; var match = data.match(/]|"([^"]|\\")*")+>/g) if (match != null) { match.forEach(function(entity) { var parts = entity.match(/^$/); entities['&' + parts[1] + ';'] = parts[2]; }); } data = data.replace(/&\w+;/g, function(entity) { return entities[entity]; }); function addAttributes(obj) { if (obj['$']) for (var key in obj['$']) obj[key] = obj['$'][key]; delete obj['$']; return obj; } function simplifyExternal(obj) { if (obj.src) return obj.src; else return obj; } var parser = new xml2js.Parser({ explicitRoot: false, explicitArray: false }); parser.addListener('end', function(json) { console.log(JSON.stringify(json, function(key, value) { if (!key) { return addAttributes(value); } else if (key === 'Stylesheet') { if (Array.isArray(value)) return value.map(addAttributes).map(simplifyExternal); else return [ simplifyExternal(addAttributes(value)) ]; } else if (key === 'Layer' || key === 'Stylesheet') { if (Array.isArray(value)) return value.map(addAttributes); else return [ addAttributes(value) ]; } else if (key === 'Datasource') { value = addAttributes(value); value.Parameter.forEach(function(parameter) { value[parameter['$'].name] = parameter['_']; }); delete value.Parameter; return value; } else { return value; } }, 4)); }); parser.parseString(data); }); carto-0.9.5/build/000077500000000000000000000000001223255147500137425ustar00rootroot00000000000000carto-0.9.5/build/carto.tmbundle/000077500000000000000000000000001223255147500166635ustar00rootroot00000000000000carto-0.9.5/build/carto.tmbundle/Commands/000077500000000000000000000000001223255147500204245ustar00rootroot00000000000000carto-0.9.5/build/carto.tmbundle/Commands/preview.tmCommand000066400000000000000000000021261223255147500237470ustar00rootroot00000000000000 beforeRunningCommand nop command #!/usr/bin/env ruby nvmdir = File.expand_path('~/.nvm') localdir = "/usr/local/bin/" if File.directory?nvmdir then cartos = Dir.glob(nvmdir + '/*/bin/mapnik-render.js') carto = cartos.pop() if cartos node = carto.gsub('/bin/mapnik-render.js', '/bin/node') elsif File.exist?localdir + "mapnik-render.js" carto = localdir + "mapnik-render.js" node = localdir + "node" end if carto `#{node} #{carto} #{ENV['TM_FILEPATH']} /tmp/test.png` else puts 'node and mapnik-render.js could not be found' end input none keyEquivalent ^~@p name Preview output showAsHTML scope source.mml uuid 4A0B3C2B-5F11-4D70-AFF4-EC4A4A042D66 carto-0.9.5/build/carto.tmbundle/Syntaxes/000077500000000000000000000000001223255147500205015ustar00rootroot00000000000000carto-0.9.5/build/carto.tmbundle/Syntaxes/carto.tmLanguage000066400000000000000000000271771223255147500236350ustar00rootroot00000000000000 comment Carto fileTypes mss foldingStartMarker /\*\*(?!\*)|\{\s*($|/\*(?!.*?\*/.*\S)) foldingStopMarker (?<!\*)\*\*/|^\s*\} keyEquivalent ^~C name Carto patterns match \b(Map)\b name keyword.control.carto.elements begin " end " name string.quoted.double.carto patterns match \\. name constant.character.escaped.carto begin ' end ' name string.quoted.single.carto patterns match \\. name constant.character.escaped.carto captures 1 name punctuation.definition.entity.carto 2 name entity.other.class.carto match (\.)([a-zA-Z0-9_-]+) name meta.selector.class.carto captures 1 name punctuation.definition.entity.carto 2 name keyword.control.id.carto match (#)([a-zA-Z0-9_-]+) name meta.selector.id.carto captures 1 name punctuation.definition.entity.carto 2 name entity.other.attachment.carto match (::)([a-zA-Z0-9_/-]+)\b name meta.selector.attachment.carto captures 1 name punctuation.definition.entity.carto 10 name string.quoted.attribute-value.carto 11 name punctuation.definition.string.begin.carto 12 name punctuation.definition.string.end.carto 13 name punctuation.definition.string.begin.carto 14 name punctuation.definition.string.end.carto 15 name punctuation.definition.entity.carto 2 name meta.tag.zoomfilter.carto 3 name variable.other.carto 4 name punctuation.definition.string.begin.carto 5 name punctuation.definition.string.end.carto 6 name punctuation.definition.string.begin.carto 7 name punctuation.definition.string.end.carto 8 name punctuation.separator.operator.carto 9 name constant.numeric.carto match (\[)\s*(?:(zoom)|((")(?:[^"\\]|\\.)*(")|(')(?:[^'\\]|\\.)*(')|[a-zA-Z0-9_][a-zA-Z0-9_-]*))\s*(!?=|>=?|<=?)\s*(?:(\d+)|((")(?:[^"\\]|\\.)*(")|(')(?:[^'\\]|\\.)*(')|[a-zA-Z0-9_][a-zA-Z0-9_-]*))\s*(\]) name meta.attribute-selector.carto begin url\( contentName variable.parameter.url end \) name support.function.any-method.builtin.carto match (#)([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b name constant.other.rgb-value.carto begin /\* end \*/ name comment.block.carto match (-|\+)?\s*[0-9]+(\.[0-9]+)? name constant.numeric.carto match (?<=[\d])(px)\b|% name keyword.unit.carto captures 1 name keyword.control.at-rule.import.carto 2 name punctuation.definition.keyword.carto match ^\s*((@)import\b) name meta.at-rule.import.carto captures 1 name support.type.property-name.carto match \b(background-color|background-image|srs|buffer|font-directory|polygon-fill|polygon-gamma|polygon-opacity|polygon-meta-output|polygon-meta-writer|line-color|line-width|line-opacity|line-join|line-cap|line-gamma|line-dasharray|line-meta-output|line-meta-writer|marker-file|marker-opacity|marker-line-color|marker-line-width|marker-line-opacity|marker-placement|marker-type|marker-width|marker-height|marker-fill|marker-allow-overlap|marker-spacing|marker-max-error|marker-transform|marker-meta-output|marker-meta-writer|shield-name|shield-face-name|shield-size|shield-fill|shield-min-distance|shield-halo-fill|shield-halo-radius|shield-spacing|shield-character-spacing|shield-line-spacing|shield-file|shield-width|shield-height|shield-type|shield-text-dx|shield-text-dy|shield-dx|shield-dy|shield-meta-output|shield-meta-writer|line-pattern-file|line-pattern-width|line-pattern-height|line-pattern-type|line-pattern-meta-output|line-pattern-meta-writer|polygon-pattern-file|polygon-pattern-width|polygon-pattern-height|polygon-pattern-type|polygon-pattern-meta-output|polygon-pattern-meta-writer|raster-opacity|raster-comp-op|raster-scaling|point-file|point-width|point-height|point-type|point-allow-overlap|point-placement|point-meta-output|point-meta-writer|text-name|text-face-name|text-size|text-ratio|text-wrap-width|text-spacing|text-character-spacing|text-line-spacing|text-label-position-tolerance|text-max-char-angle-delta|text-fill|text-halo-fill|text-halo-radius|text-dx|text-dy|text-avoid-edges|text-min-distance|text-min-padding|text-allow-overlap|text-placement|text-placement-type|text-placements|text-transform|text-meta-output|text-meta-writer|building-fill|building-fill-opacity|building-height)\s*: match \b(miter|round|bevel|butt|round|square|point|line|arrow|ellipse|png|jpg|svg|normal|grain_merge|grain_merge2|multiply|multiply2|divide|divide2|screen|hard_light|near|bilinear|bilinear8|centroid|interior|point|line|vertex|interior|none|uppercase|lowercase)\b name meta.property-value.carto comment http://www.w3.org/TR/CSS21/syndata.html#value-def-color match \b(aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|grey|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|transparent)\b name constant.color.w3c-standard-color-name.carto match \b(saturate|desaturate|lighten|darken|grayscale)\b name support.function.any-method.builtin.carto match \b(rgb|rgba|hsl|hsla|url)\b name support.function.any-method.builtin.carto captures 1 name support.function.carto match (\.[a-zA-Z0-9_-]+)\s*(;|\() begin // end $\n? name comment.line.double-slash.carto match @[a-zA-Z0-9_-][\w-]* name variable.other.carto match \$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|(?<!\()/=|%=|\+=|\-=|&=|\^=|\/\b name keyword.operator.carto match \{|\} name meta.brace.curly.js match \(|\) name meta.brace.round.js match \[|\] name meta.brace.square.js scopeName source.css.carto uuid 43F4EF91-F880-4CE7-A4C8-02DA726BC5FF carto-0.9.5/build/carto.tmbundle/Syntaxes/mml.tmLanguage000066400000000000000000000170341223255147500233010ustar00rootroot00000000000000 fileTypes mml foldingStartMarker (?x: # turn on extended mode ^ # a line beginning with \s* # some optional space [{\[] # the start of an object or array (?! # but not followed by .* # whatever [}\]] # and the close of an object or array ,? # an optional comma \s* # some optional space $ # at the end of the line ) | # ...or... [{\[] # the start of an object or array \s* # some optional space $ # at the end of the line ) foldingStopMarker (?x: # turn on extended mode ^ # a line beginning with \s* # some optional space [}\]] # and the close of an object or array ) keyEquivalent ^~M name Carto MML patterns include #value repository array begin \[ beginCaptures 0 name punctuation.definition.array.begin.json end \] endCaptures 0 name punctuation.definition.array.end.json name meta.structure.array.json patterns include #value match , name punctuation.separator.array.json match [^\s\]] name invalid.illegal.expected-array-separator.json constant match \b(?:true|false|null)\b name constant.language.json number comment handles integer and decimal numbers match (?x: # turn on extended mode -? # an optional minus (?: 0 # a zero | # ...or... [1-9] # a 1-9 character \d* # followed by zero or more digits ) (?: (?: \. # a period \d+ # followed by one or more digits )? (?: [eE] # an e character [+-]? # followed by an option +/- \d+ # followed by one or more digits )? # make exponent optional )? # make decimal portion optional ) name constant.numeric.json object begin \{ beginCaptures 0 name punctuation.definition.dictionary.begin.json comment a JSON object end \} endCaptures 0 name punctuation.definition.dictionary.end.json name meta.structure.dictionary.json patterns comment the JSON object key include #string begin : beginCaptures 0 name punctuation.separator.dictionary.key-value.json end (,)|(?=\}) endCaptures 1 name punctuation.separator.dictionary.pair.json name meta.structure.dictionary.value.json patterns comment the JSON object value include #value match [^\s,] name invalid.illegal.expected-dictionary-separator.json match [^\s\}] name invalid.illegal.expected-dictionary-separator.json string begin " beginCaptures 0 name punctuation.definition.string.begin.json end " endCaptures 0 name punctuation.definition.string.end.json name string.quoted.double.json patterns match (?x: # turn on extended mode \\ # a literal backslash (?: # ...followed by... ["\\/bfnrt] # one of these characters | # ...or... u # a u [0-9a-fA-F]{4} # and four hex digits ) ) name constant.character.escape.json match \\. name invalid.illegal.unrecognized-string-escape.json value comment the 'value' diagram at http://json.org patterns include #constant include #number include #string include #array include #object scopeName source.mml uuid 74FEE366-FF0A-4AAA-B8C5-1C66CECA7F86 carto-0.9.5/build/carto.tmbundle/info.plist000066400000000000000000000007051223255147500206750ustar00rootroot00000000000000 name Carto ordering 43F4EF91-F880-4CE7-A4C8-02DA726BC5FF 4A0B3C2B-5F11-4D70-AFF4-EC4A4A042D66 uuid 3D813315-4B2E-4537-8E22-BD1A75AB84A9 carto-0.9.5/build/syntaxgenerate000077500000000000000000000030761223255147500167370ustar00rootroot00000000000000#!/usr/bin/env node var path = require('path'), fs = require('fs'), _ = require('underscore')._; var carto = require('../lib/carto'); var color_names = _.keys(carto.tree.Reference.data.colors); var property_names = carto.tree.Reference.selectors; var keyword_names = _.reduce(carto.tree.Reference.data.symbolizers, function(memo, s) { for (var i in s) { if (_.isArray(s[i].type)) { memo = memo.concat(s[i].type); } } return memo; }, []); // TextMate // -------- // Generate TextMate tmLanguage file for use in bundle var tm_tmpl = fs.readFileSync(path.join(__dirname, 'tmlanguage_template.js'), 'utf-8'); fs.writeFile('carto.tmLanguage', _.template(tm_tmpl, { color_names: color_names.filter(function(a) { return a; }).join('|'), keyword_names: keyword_names.filter(function(a) { return a; }).join('|'), property_names: property_names.filter(function(a) { return a; }).join('|') }), function(err) { if (!err) console.log('tmLanguage created'); }); // VIM // --- // Generate carto.syntax var tm_tmpl = fs.readFileSync(path.join(__dirname, 'vimsyntax_template.js'), 'utf-8'); fs.writeFile('vim-carto/syntax/carto.vim', _.template(tm_tmpl, { color_names: color_names.filter(function(a) { return a; }).join('\\|'), keyword_names: keyword_names.filter(function(a) { return a; }).join('\\|'), property_names: property_names.filter(function(a) { return a; }).map(function(a) { return a.replace(/\-/g, '\\-'); }).join('\\|') }), function(err) { if (!err) console.log('carto.vim created'); }); carto-0.9.5/build/tmlanguage_template.js000066400000000000000000000104221223255147500203160ustar00rootroot00000000000000{ scopeName = 'source.css.carto'; comment = 'Carto'; fileTypes = ( 'mss' ); foldingStartMarker = '/\*\*(?!\*)|\{\s*($|/\*(?!.*?\*/.*\S))'; foldingStopMarker = '(?=?|<=?)\s*(?:(\d+)|((")(?:[^"\\]|\\.)*(")|('')(?:[^''\\]|\\.)*('')|[a-zA-Z0-9_][a-zA-Z0-9_-]*))\s*(\])'; captures = { 1 = { name = 'punctuation.definition.entity.carto'; }; 2 = { name = 'meta.tag.zoomfilter.carto'; }; 3 = { name = 'variable.other.carto'; }; 4 = { name = 'punctuation.definition.string.begin.carto'; }; 5 = { name = 'punctuation.definition.string.end.carto'; }; 6 = { name = 'punctuation.definition.string.begin.carto'; }; 7 = { name = 'punctuation.definition.string.end.carto'; }; 8 = { name = 'punctuation.separator.operator.carto'; }; 9 = { name = 'constant.numeric.carto'; }; 10 = { name = 'string.quoted.attribute-value.carto'; }; 11 = { name = 'punctuation.definition.string.begin.carto'; }; 12 = { name = 'punctuation.definition.string.end.carto'; }; 13 = { name = 'punctuation.definition.string.begin.carto'; }; 14 = { name = 'punctuation.definition.string.end.carto'; }; 15 = { name = 'punctuation.definition.entity.carto'; }; }; }, { name = 'support.function.any-method.builtin.carto'; contentName = 'variable.parameter.url'; begin = 'url\('; end = '\)'; }, { name = 'constant.other.rgb-value.carto'; match = '(#)([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b'; }, { name = 'comment.block.carto'; begin = '/\*'; end = '\*/'; }, { name = 'constant.numeric.carto'; match = '(-|\+)?\s*[0-9]+(\.[0-9]+)?'; }, { name = 'keyword.unit.carto'; match = '(?<=[\d])(px)\b|%'; }, { name = 'meta.at-rule.import.carto'; match = '^\s*((@)import\b)'; captures = { 1 = { name = 'keyword.control.at-rule.import.carto'; }; 2 = { name = 'punctuation.definition.keyword.carto'; }; }; }, { match = '\b(<%= property_names %>)\s*:'; captures = { 1 = { name = 'support.type.property-name.carto'; }; }; }, { name = 'meta.property-value.carto'; match = '\b(<%= keyword_names %>)\b'; }, { name = 'constant.color.w3c-standard-color-name.carto'; comment = 'http://www.w3.org/TR/CSS21/syndata.html#value-def-color'; match = '\b(<%= color_names %>)\b'; }, { name = 'support.function.any-method.builtin.carto'; match = '\b(saturate|desaturate|lighten|darken|grayscale)\b'; }, { name = 'support.function.any-method.builtin.carto'; match = '\b(rgb|rgba|hsl|hsla|url)\b'; }, { match = '(\.[a-zA-Z0-9_-]+)\s*(;|\()'; captures = { 1 = { name = 'support.function.carto'; }; }; }, { name = 'comment.line.double-slash.carto'; begin = '//'; end = '$\n?'; }, { name = 'variable.other.carto'; match = '@[a-zA-Z0-9_-][\w-]*'; }, { name = 'keyword.operator.carto'; match = '\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|(? " Original Author: Leaf Corcoran " Modifier: Bryan J Swift " Last Change: 2011 January 27 " Carto by Tom MacWright " LESS by Leaf Corcoran " CSS2 by Nikolai Weibull " Full CSS2, HTML4 support by Yeti " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if !exists("main_syntax") if version < 600 syntax clear elseif exists("b:current_syntax") finish endif let main_syntax = 'carto' endif syn case ignore syn keyword cartoTagName Map syn match cartoSelectorOp "[+>.]" syn match cartoSelectorOp2 "[~|><]\?=" contained syn region cartoAttributeSelector matchgroup=cartoSelectorOp start="\[" end="]" transparent contains=cartoUnicodeEscape,cartoSelectorOp2,cartoStringQ,cartoStringQQ try syn match cartoIdentifier "#[A-Za-zÀ-ÿ_@][A-Za-zÀ-ÿ0-9_@-]*" catch /^.*/ syn match cartoIdentifier "#[A-Za-z_@][A-Za-z0-9_@-]*" endtry syn match cartoValueInteger "[-+]\=\d\+" syn match cartoValueNumber "[-+]\=\d\+\(\.\d*\)\=" syn match cartoValueLength "[-+]\=\d\+\(\.\d*\)\=\(%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\)" syn match cartoFontDescriptor "@font-face\>" nextgroup=cartoFontDescriptorBlock skipwhite skipnl syn region cartoFontDescriptorBlock contained transparent matchgroup=cartoBraces start="{" end="}" contains=cartoComment,cartoError,cartoUnicodeEscape,cartoFontProp,cartoFontAttr,cartoStringQ,cartoStringQQ,cartoFontDescriptorProp,cartoValue.*,cartoFontDescriptorFunction,cartoUnicodeRange,cartoFontDescriptorAttr syn match cartoFontDescriptorProp contained "\<\(unicode-range\|unit-per-em\|panose-1\|cap-height\|x-height\|definition-src\)\>" syn keyword cartoFontDescriptorProp contained src stemv stemh slope ascent descent widths bbox baseline centerline mathline topline syn keyword cartoFontDescriptorAttr contained all syn region cartoFontDescriptorFunction contained matchgroup=cartoFunctionName start="\<\(uri\|url\|local\|format\)\s*(" end=")" contains=cartoStringQ,cartoStringQQ oneline keepend syn match cartoUnicodeRange contained "U+[0-9A-Fa-f?]\+" syn match cartoUnicodeRange contained "U+\x\+-\x\+" syn match cartoKeywordAttr "/\|miter\|round\|bevel\|butt\|round\|square\|point\|line\|arrow\|ellipse\|point\|line\|vertex\|interior\|local\|global\|normal\|grain_merge\|grain_merge2\|multiply\|multiply2\|divide\|divide2\|screen\|hard_light\|near\|bilinear\|bilinear8\|bicubic\|spline16\|gaussian\|lanczos\|centroid\|interior\|top\|middle\|bottom\|point\|line\|vertex\|interior\|dummy\|simple\|none\|uppercase\|lowercase\|capitalize\|/" " syn keyword cartoColor contained {{#colors}}{{.}} {{/colors}} syn match cartoColor "/\|aliceblue\|antiquewhite\|aqua\|aquamarine\|azure\|beige\|bisque\|black\|blanchedalmond\|blue\|blueviolet\|brown\|burlywood\|cadetblue\|chartreuse\|chocolate\|coral\|cornflowerblue\|cornsilk\|crimson\|cyan\|darkblue\|darkcyan\|darkgoldenrod\|darkgray\|darkgreen\|darkgrey\|darkkhaki\|darkmagenta\|darkolivegreen\|darkorange\|darkorchid\|darkred\|darksalmon\|darkseagreen\|darkslateblue\|darkslategrey\|darkturquoise\|darkviolet\|deeppink\|deepskyblue\|dimgray\|dimgrey\|dodgerblue\|firebrick\|floralwhite\|forestgreen\|fuchsia\|gainsboro\|ghostwhite\|gold\|goldenrod\|gray\|grey\|green\|greenyellow\|honeydew\|hotpink\|indianred\|indigo\|ivory\|khaki\|lavender\|lavenderblush\|lawngreen\|lemonchiffon\|lightblue\|lightcoral\|lightcyan\|lightgoldenrodyellow\|lightgray\|lightgreen\|lightgrey\|lightpink\|lightsalmon\|lightseagreen\|lightskyblue\|lightslategray\|lightslategrey\|lightsteelblue\|lightyellow\|lime\|limegreen\|linen\|magenta\|maroon\|mediumaquamarine\|mediumblue\|mediumorchid\|mediumpurple\|mediumseagreen\|mediumslateblue\|mediumspringgreen\|mediumturquoise\|mediumvioletred\|midnightblue\|mintcream\|mistyrose\|moccasin\|navajowhite\|navy\|oldlace\|olive\|olivedrab\|orange\|orangered\|orchid\|palegoldenrod\|palegreen\|paleturquoise\|palevioletred\|papayawhip\|peachpuff\|peru\|pink\|plum\|powderblue\|purple\|red\|rosybrown\|royalblue\|saddlebrown\|salmon\|sandybrown\|seagreen\|seashell\|sienna\|silver\|skyblue\|slateblue\|slategray\|slategrey\|snow\|springgreen\|steelblue\|tan\|teal\|thistle\|tomato\|turquoise\|violet\|wheat\|white\|whitesmoke\|yellow\|yellowgreen\|transparent\|/" " FIXME: These are actually case-insentivie too, but (a) specs recommend using " mixed-case (b) it's hard to highlight the word `Background' correctly in " all situations syn case match syn keyword cartoColor contained ActiveBorder ActiveCaption AppWorkspace ButtonFace ButtonHighlight ButtonShadow ButtonText CaptionText GrayText Highlight HighlightText InactiveBorder InactiveCaption InactiveCaptionText InfoBackground InfoText Menu MenuText Scrollbar ThreeDDarkShadow ThreeDFace ThreeDHighlight ThreeDLightShadow ThreeDShadow Window WindowFrame WindowText Background syn case ignore syn match cartoColor contained "\" syn match cartoColor contained "\" syn match cartoColor contained "#[0-9A-Fa-f]\{3\}\>" syn match cartoColor contained "#[0-9A-Fa-f]\{6\}\>" "syn match cartoColor contained "\" syn region cartoDefinition transparent matchgroup=cartoBraces start='{' end='}' contains=carto.*Attr,cartoProp,cartoComment,cartoValue.*,cartoColor,cartoColor,cartoURL,cartoImportant,cartoStringQ,cartoStringQQ,cartoFunction,cartoUnicodeEscape,cartoDefinition,cartoClassName,cartoTagName,cartoIdentifier,cartoComment,cartoVariable,cartoFunction " syn match cartoBraceError "}" syn match cartoPseudoClass ":\S*" contains=cartoPseudoClassId,cartoUnicodeEscape syn keyword cartoPseudoClassId contained link visited active hover focus before after left right syn match cartoPseudoClassId contained "\" syn region cartoPseudoClassLang matchgroup=cartoPseudoClassId start=":lang(" end=")" oneline syn region cartoComment start="/\*" end="\*/" contains=@Spell syn match cartoUnicodeEscape "\\\x\{1,6}\s\?" syn match cartoSpecialCharQQ +\\"+ contained syn match cartoSpecialCharQ +\\'+ contained syn region cartoStringQQ start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=cartoUnicodeEscape,cartoSpecialCharQQ syn region cartoStringQ start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=cartoUnicodeEscape,cartoSpecialCharQ syn match cartoClassName "\.[A-Za-z][A-Za-z0-9_-]\+" if main_syntax == "carto" syn sync minlines=10 syntax sync match cartoHighlight grouphere cartoDefinition /{/ endif " Define the default highlighting. " For version 5.7 and earlier: only when not done already " For version 5.8 and later: only when an item doesn't have highlighting yet if version >= 508 || !exists("did_carto_syn_inits") if version < 508 let did_carto_syn_inits = 1 command -nargs=+ HiLink hi link else command -nargs=+ HiLink hi def link endif HiLink cartoComment Comment HiLink cartoVariable Identifier HiLink cartoFuncDef Function HiLink cartoComment Comment HiLink cartoTagName Statement HiLink cartoSelectorOp Special HiLink cartoSelectorOp2 Special HiLink cartoAttributeSelector Conditional HiLink cartoProp StorageClass HiLink cartoFontAttr Type HiLink cartoColorAttr Type HiLink cartoKeywordAttr Constant HiLink cartoPseudoClassId PreProc HiLink cartoPseudoClassLang Constant HiLink cartoValueLength Number HiLink cartoValueInteger Number HiLink cartoValueNumber Number HiLink cartoFunction Constant HiLink cartoURL String HiLink cartoFunctionName Function HiLink cartoColor Constant HiLink cartoColor Constant HiLink cartoIdentifier Function HiLink cartoInclude Include HiLink cartoBraces SpecialChar HiLink cartoBraceError Error HiLink cartoError Error HiLink cartoInclude Include HiLink cartoUnicodeEscape Special HiLink cartoStringQQ String HiLink cartoStringQ String HiLink cartoFontDescriptor Special HiLink cartoFontDescriptorFunction Constant HiLink cartoFontDescriptorProp StorageClass HiLink cartoFontDescriptorAttr Type HiLink cartoUnicodeRange Constant HiLink cartoClassName Function delcommand HiLink endif let b:current_syntax = "carto" if main_syntax == 'carto' unlet main_syntax endif " vim: ts=8 carto-0.9.5/build/vimsyntax_template.js000066400000000000000000000166321223255147500202450ustar00rootroot00000000000000" Vim syntax file " Language: Carto " Maintainer: Tom MacWright " Original Author: Leaf Corcoran " Modifier: Bryan J Swift " Last Change: 2011 January 27 " Carto by Tom MacWright " LESS by Leaf Corcoran " CSS2 by Nikolai Weibull " Full CSS2, HTML4 support by Yeti " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if !exists("main_syntax") if version < 600 syntax clear elseif exists("b:current_syntax") finish endif let main_syntax = 'carto' endif syn case ignore syn keyword cartoTagName Map syn match cartoSelectorOp "[+>.]" syn match cartoSelectorOp2 "[~|><]\?=" contained syn region cartoAttributeSelector matchgroup=cartoSelectorOp start="\[" end="]" transparent contains=cartoUnicodeEscape,cartoSelectorOp2,cartoStringQ,cartoStringQQ try syn match cartoIdentifier "#[A-Za-zÀ-ÿ_@][A-Za-zÀ-ÿ0-9_@-]*" catch /^.*/ syn match cartoIdentifier "#[A-Za-z_@][A-Za-z0-9_@-]*" endtry syn match cartoValueInteger "[-+]\=\d\+" syn match cartoValueNumber "[-+]\=\d\+\(\.\d*\)\=" syn match cartoValueLength "[-+]\=\d\+\(\.\d*\)\=\(%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\)" syn match cartoFontDescriptor "@font-face\>" nextgroup=cartoFontDescriptorBlock skipwhite skipnl syn region cartoFontDescriptorBlock contained transparent matchgroup=cartoBraces start="{" end="}" contains=cartoComment,cartoError,cartoUnicodeEscape,cartoFontProp,cartoFontAttr,cartoStringQ,cartoStringQQ,cartoFontDescriptorProp,cartoValue.*,cartoFontDescriptorFunction,cartoUnicodeRange,cartoFontDescriptorAttr syn match cartoFontDescriptorProp contained "\<\(unicode-range\|unit-per-em\|panose-1\|cap-height\|x-height\|definition-src\)\>" syn keyword cartoFontDescriptorProp contained src stemv stemh slope ascent descent widths bbox baseline centerline mathline topline syn keyword cartoFontDescriptorAttr contained all syn region cartoFontDescriptorFunction contained matchgroup=cartoFunctionName start="\<\(uri\|url\|local\|format\)\s*(" end=")" contains=cartoStringQ,cartoStringQQ oneline keepend syn match cartoUnicodeRange contained "U+[0-9A-Fa-f?]\+" syn match cartoUnicodeRange contained "U+\x\+-\x\+" syn match cartoKeywordAttr "/\|<%= keyword_names %>\|/" " syn keyword cartoColor contained {{#colors}}{{.}} {{/colors}} syn match cartoColor "/\|<%= color_names %>\|/" " FIXME: These are actually case-insentivie too, but (a) specs recommend using " mixed-case (b) it's hard to highlight the word `Background' correctly in " all situations syn case match syn keyword cartoColor contained ActiveBorder ActiveCaption AppWorkspace ButtonFace ButtonHighlight ButtonShadow ButtonText CaptionText GrayText Highlight HighlightText InactiveBorder InactiveCaption InactiveCaptionText InfoBackground InfoText Menu MenuText Scrollbar ThreeDDarkShadow ThreeDFace ThreeDHighlight ThreeDLightShadow ThreeDShadow Window WindowFrame WindowText Background syn case ignore syn match cartoColor contained "\" syn match cartoColor contained "\" syn match cartoColor contained "#[0-9A-Fa-f]\{3\}\>" syn match cartoColor contained "#[0-9A-Fa-f]\{6\}\>" "syn match cartoColor contained "\\|/" syn match cartoComment "//.*$" contains=@Spell syn match cartoVariable "@[A-Za-z_-][A-Za-z0-9_-]*" contained syn region cartoVariableDefinition start="^@" end=";" contains=carto.*Attr,carto.*Prop,cartoComment,cartoValue.*,cartoColor,cartoURL,cartoImportant,cartoStringQ,cartoStringQQ,cartoFunction,cartoUnicodeEscape,cartoDefinition,cartoClassName,cartoTagName,cartoIdentifier,cartoComment,cartoVariable,cartoFunction " captures both the definition and the call syn region cartoFunction matchgroup=cartoFuncDef start="@[A-Za-z_-][A-Za-z0-9_-]*(" end=")" contains=carto.*Attr,carto.*Prop,cartoComment,cartoValue.*,cartoColor,cartoURL,cartoImportant,cartoStringQ,cartoStringQQ,cartoFunction,cartoUnicodeEscape,cartoDefinition,cartoClassName,cartoTagName,cartoIdentifier,cartoComment,cartoVariable,cartoFunction syn match cartoBraces contained "[{}]" syn match cartoError contained "{@<>" syn region cartoDefinition transparent matchgroup=cartoBraces start='{' end='}' contains=carto.*Attr,cartoProp,cartoComment,cartoValue.*,cartoColor,cartoColor,cartoURL,cartoImportant,cartoStringQ,cartoStringQQ,cartoFunction,cartoUnicodeEscape,cartoDefinition,cartoClassName,cartoTagName,cartoIdentifier,cartoComment,cartoVariable,cartoFunction " syn match cartoBraceError "}" syn match cartoPseudoClass ":\S*" contains=cartoPseudoClassId,cartoUnicodeEscape syn keyword cartoPseudoClassId contained link visited active hover focus before after left right syn match cartoPseudoClassId contained "\" syn region cartoPseudoClassLang matchgroup=cartoPseudoClassId start=":lang(" end=")" oneline syn region cartoComment start="/\*" end="\*/" contains=@Spell syn match cartoUnicodeEscape "\\\x\{1,6}\s\?" syn match cartoSpecialCharQQ +\\"+ contained syn match cartoSpecialCharQ +\\'+ contained syn region cartoStringQQ start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=cartoUnicodeEscape,cartoSpecialCharQQ syn region cartoStringQ start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=cartoUnicodeEscape,cartoSpecialCharQ syn match cartoClassName "\.[A-Za-z][A-Za-z0-9_-]\+" if main_syntax == "carto" syn sync minlines=10 syntax sync match cartoHighlight grouphere cartoDefinition /{/ endif " Define the default highlighting. " For version 5.7 and earlier: only when not done already " For version 5.8 and later: only when an item doesn't have highlighting yet if version >= 508 || !exists("did_carto_syn_inits") if version < 508 let did_carto_syn_inits = 1 command -nargs=+ HiLink hi link else command -nargs=+ HiLink hi def link endif HiLink cartoComment Comment HiLink cartoVariable Identifier HiLink cartoFuncDef Function HiLink cartoComment Comment HiLink cartoTagName Statement HiLink cartoSelectorOp Special HiLink cartoSelectorOp2 Special HiLink cartoAttributeSelector Conditional HiLink cartoProp StorageClass HiLink cartoFontAttr Type HiLink cartoColorAttr Type HiLink cartoKeywordAttr Constant HiLink cartoPseudoClassId PreProc HiLink cartoPseudoClassLang Constant HiLink cartoValueLength Number HiLink cartoValueInteger Number HiLink cartoValueNumber Number HiLink cartoFunction Constant HiLink cartoURL String HiLink cartoFunctionName Function HiLink cartoColor Constant HiLink cartoColor Constant HiLink cartoIdentifier Function HiLink cartoInclude Include HiLink cartoBraces SpecialChar HiLink cartoBraceError Error HiLink cartoError Error HiLink cartoInclude Include HiLink cartoUnicodeEscape Special HiLink cartoStringQQ String HiLink cartoStringQ String HiLink cartoFontDescriptor Special HiLink cartoFontDescriptorFunction Constant HiLink cartoFontDescriptorProp StorageClass HiLink cartoFontDescriptorAttr Type HiLink cartoUnicodeRange Constant HiLink cartoClassName Function delcommand HiLink endif let b:current_syntax = "carto" if main_syntax == 'carto' unlet main_syntax endif " vim: ts=8 carto-0.9.5/lib/000077500000000000000000000000001223255147500134115ustar00rootroot00000000000000carto-0.9.5/lib/carto/000077500000000000000000000000001223255147500145215ustar00rootroot00000000000000carto-0.9.5/lib/carto/functions.js000066400000000000000000000143551223255147500170770ustar00rootroot00000000000000(function (tree) { tree.functions = { rgb: function (r, g, b) { return this.rgba(r, g, b, 1.0); }, rgba: function (r, g, b, a) { var rgb = [r, g, b].map(function (c) { return number(c); }); a = number(a); if (rgb.some(isNaN) || isNaN(a)) return null; return new tree.Color(rgb, a); }, // Only require val stop: function (val) { var color, mode; if (arguments.length > 1) color = arguments[1]; if (arguments.length > 2) mode = arguments[2]; return { is: 'tag', val: val, color: color, mode: mode, toString: function(env) { return '\n\t'; } }; }, hsl: function (h, s, l) { return this.hsla(h, s, l, 1.0); }, hsla: function (h, s, l, a) { h = (number(h) % 360) / 360; s = number(s); l = number(l); a = number(a); if ([h, s, l, a].some(isNaN)) return null; var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s, m1 = l * 2 - m2; return this.rgba(hue(h + 1/3) * 255, hue(h) * 255, hue(h - 1/3) * 255, a); function hue(h) { h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h); if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; else if (h * 2 < 1) return m2; else if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6; else return m1; } }, hue: function (color) { if (!('toHSL' in color)) return null; return new tree.Dimension(Math.round(color.toHSL().h)); }, saturation: function (color) { if (!('toHSL' in color)) return null; return new tree.Dimension(Math.round(color.toHSL().s * 100), '%'); }, lightness: function (color) { if (!('toHSL' in color)) return null; return new tree.Dimension(Math.round(color.toHSL().l * 100), '%'); }, alpha: function (color) { if (!('toHSL' in color)) return null; return new tree.Dimension(color.toHSL().a); }, saturate: function (color, amount) { if (!('toHSL' in color)) return null; var hsl = color.toHSL(); hsl.s += amount.value / 100; hsl.s = clamp(hsl.s); return hsla(hsl); }, desaturate: function (color, amount) { if (!('toHSL' in color)) return null; var hsl = color.toHSL(); hsl.s -= amount.value / 100; hsl.s = clamp(hsl.s); return hsla(hsl); }, lighten: function (color, amount) { if (!('toHSL' in color)) return null; var hsl = color.toHSL(); hsl.l += amount.value / 100; hsl.l = clamp(hsl.l); return hsla(hsl); }, darken: function (color, amount) { if (!('toHSL' in color)) return null; var hsl = color.toHSL(); hsl.l -= amount.value / 100; hsl.l = clamp(hsl.l); return hsla(hsl); }, fadein: function (color, amount) { if (!('toHSL' in color)) return null; var hsl = color.toHSL(); hsl.a += amount.value / 100; hsl.a = clamp(hsl.a); return hsla(hsl); }, fadeout: function (color, amount) { if (!('toHSL' in color)) return null; var hsl = color.toHSL(); hsl.a -= amount.value / 100; hsl.a = clamp(hsl.a); return hsla(hsl); }, spin: function (color, amount) { if (!('toHSL' in color)) return null; var hsl = color.toHSL(); var hue = (hsl.h + amount.value) % 360; hsl.h = hue < 0 ? 360 + hue : hue; return hsla(hsl); }, replace: function (entity, a, b) { if (entity.is === 'field') { return entity.toString + '.replace(' + a.toString() + ', ' + b.toString() + ')'; } else { return entity.replace(a, b); } }, // // Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein // http://sass-lang.com // mix: function (color1, color2, weight) { var p = weight.value / 100.0; var w = p * 2 - 1; var a = color1.toHSL().a - color2.toHSL().a; var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; var w2 = 1 - w1; var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2, color1.rgb[1] * w1 + color2.rgb[1] * w2, color1.rgb[2] * w1 + color2.rgb[2] * w2]; var alpha = color1.alpha * p + color2.alpha * (1 - p); return new tree.Color(rgb, alpha); }, greyscale: function (color) { return this.desaturate(color, new tree.Dimension(100)); }, '%': function (quoted /* arg, arg, ...*/) { var args = Array.prototype.slice.call(arguments, 1), str = quoted.value; for (var i = 0; i < args.length; i++) { str = str.replace(/%s/, args[i].value) .replace(/%[da]/, args[i].toString()); } str = str.replace(/%%/g, '%'); return new tree.Quoted(str); } }; var image_filter_functors = [ 'emboss', 'blur', 'gray', 'sobel', 'edge-detect', 'x-gradient', 'y-gradient', 'sharpen']; for (var i = 0; i < image_filter_functors.length; i++) { var f = image_filter_functors[i]; tree.functions[f] = (function(f) { return function() { return new tree.ImageFilter(f); }; })(f); } tree.functions['agg-stack-blur'] = function(x, y) { return new tree.ImageFilter('agg-stack-blur', [x, y]); }; tree.functions['scale-hsla'] = function(h0,h1,s0,s1,l0,l1,a0,a1) { return new tree.ImageFilter('scale-hsla', [h0,h1,s0,s1,l0,l1,a0,a1]); }; function hsla(h) { return tree.functions.hsla(h.h, h.s, h.l, h.a); } function number(n) { if (n instanceof tree.Dimension) { return parseFloat(n.unit == '%' ? n.value / 100 : n.value); } else if (typeof(n) === 'number') { return n; } else { return NaN; } } function clamp(val) { return Math.min(1, Math.max(0, val)); } })(require('./tree')); carto-0.9.5/lib/carto/index.js000066400000000000000000000055041223255147500161720ustar00rootroot00000000000000var util = require('util'), fs = require('fs'), path = require('path'); function getVersion() { if (parseInt(process.version.split('.')[1], 10) > 4) { return require('../../package.json').version.split('.'); } else { // older node var package_json = JSON.parse(fs.readFileSync(path.join(__dirname,'../../package.json'))); return package_json.version.split('.'); } } var carto = { version: getVersion(), Parser: require('./parser').Parser, Renderer: require('./renderer').Renderer, tree: require('./tree'), // @TODO writeError: function(ctx, options) { var message = ''; var extract = ctx.extract; var error = []; options = options || {}; if (options.silent) { return; } options.indent = options.indent || ''; if (!('index' in ctx) || !extract) { return util.error(options.indent + (ctx.stack || ctx.message)); } if (typeof(extract[0]) === 'string') { error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey')); } if (extract[1] === '' && typeof extract[2] === 'undefined') { extract[1] = '¶'; } error.push(ctx.line + ' ' + extract[1].slice(0, ctx.column) + stylize(stylize(extract[1][ctx.column], 'bold') + extract[1].slice(ctx.column + 1), 'yellow')); if (typeof(extract[2]) === 'string') { error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey')); } error = options.indent + error.join('\n' + options.indent) + '\033[0m\n'; message = options.indent + message + stylize(ctx.message, 'red'); if (ctx.filename) (message += stylize(' in ', 'red') + ctx.filename); util.error(message, error); if (ctx.callLine) { util.error(stylize('from ', 'red') + (ctx.filename || '')); util.error(stylize(ctx.callLine, 'grey') + ' ' + ctx.callExtract); } if (ctx.stack) { util.error(stylize(ctx.stack, 'red')); } } }; [ 'call', 'color', 'comment', 'definition', 'dimension', 'element', 'expression', 'filterset', 'filter', 'field', 'keyword', 'layer', 'literal', 'operation', 'quoted', 'imagefilter', 'reference', 'rule', 'ruleset', 'selector', 'style', 'url', 'value', 'variable', 'zoom', 'invalid', 'fontset' ].forEach(function(n) { require('./tree/' + n); }); require('./functions'); for (var k in carto) { exports[k] = carto[k]; } // Stylize a string function stylize(str, style) { var styles = { 'bold' : [1, 22], 'inverse' : [7, 27], 'underline' : [4, 24], 'yellow' : [33, 39], 'green' : [32, 39], 'red' : [31, 39], 'grey' : [90, 39] }; return '\033[' + styles[style][0] + 'm' + str + '\033[' + styles[style][1] + 'm'; } carto-0.9.5/lib/carto/parser.js000066400000000000000000000675251223255147500163720ustar00rootroot00000000000000var carto = exports, tree = require('./tree'), _ = require('underscore'); // Token matching is done with the `$` function, which either takes // a terminal string or regexp, or a non-terminal function to call. // It also takes care of moving all the indices forwards. carto.Parser = function Parser(env) { var input, // LeSS input string i, // current index in `input` j, // current chunk temp, // temporarily holds a chunk's state, for backtracking memo, // temporarily holds `i`, when backtracking furthest, // furthest index the parser has gone to chunks, // chunkified input current, // index of current chunk, in `input` parser; var that = this; // This function is called after all files // have been imported through `@import`. var finish = function() {}; function save() { temp = chunks[j]; memo = i; current = i; } function restore() { chunks[j] = temp; i = memo; current = i; } function sync() { if (i > current) { chunks[j] = chunks[j].slice(i - current); current = i; } } // // Parse from a token, regexp or string, and move forward if match // function $(tok) { var match, args, length, c, index, endIndex, k; // Non-terminal if (tok instanceof Function) { return tok.call(parser.parsers); // Terminal // Either match a single character in the input, // or match a regexp in the current chunk (chunk[j]). } else if (typeof(tok) === 'string') { match = input.charAt(i) === tok ? tok : null; length = 1; sync(); } else { sync(); match = tok.exec(chunks[j]); if (match) { length = match[0].length; } else { return null; } } // The match is confirmed, add the match length to `i`, // and consume any extra white-space characters (' ' || '\n') // which come after that. The reason for this is that LeSS's // grammar is mostly white-space insensitive. if (match) { var mem = i += length; endIndex = i + chunks[j].length - length; while (i < endIndex) { c = input.charCodeAt(i); if (! (c === 32 || c === 10 || c === 9)) { break; } i++; } chunks[j] = chunks[j].slice(length + (i - mem)); current = i; if (chunks[j].length === 0 && j < chunks.length - 1) { j++; } if (typeof(match) === 'string') { return match; } else { return match.length === 1 ? match[0] : match; } } } // Same as $(), but don't change the state of the parser, // just return the match. function peek(tok) { if (typeof(tok) === 'string') { return input.charAt(i) === tok; } else { return !!tok.test(chunks[j]); } } // Make an error object from a passed set of properties. // Accepted properties: // - `message`: Text of the error message. // - `filename`: Filename where the error occurred. // - `index`: Char. index where the error occurred. function makeError(err) { var einput; _(err).defaults({ index: furthest, filename: env.filename, message: 'Parse error.', line: 0, column: -1 }); if (err.filename && that.env.inputs && that.env.inputs[err.filename]) { einput = that.env.inputs[err.filename]; } else { einput = input; } err.line = (einput.slice(0, err.index).match(/\n/g) || '').length + 1; for (var n = err.index; n >= 0 && einput.charAt(n) !== '\n'; n--) { err.column++; } return new Error(_('<%=filename%>:<%=line%>:<%=column%> <%=message%>').template(err)); } this.env = env = env || {}; this.env.filename = this.env.filename || null; this.env.inputs = this.env.inputs || {}; // The Parser parser = { // Parse an input string into an abstract syntax tree. // Throws an error on parse errors. parse: function(str) { var root, start, end, zone, line, lines, buff = [], c, error = null; i = j = current = furthest = 0; chunks = []; input = str.replace(/\r\n/g, '\n'); if (env.filename) { that.env.inputs[env.filename] = input; } var early_exit = false; // Split the input into chunks. chunks = (function (chunks) { var j = 0, skip = /(?:@\{[\w-]+\}|[^"'`\{\}\/\(\)\\])+/g, comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g, string = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`]|\\.)*)`/g, level = 0, match, chunk = chunks[0], inParam; for (var i = 0, c, cc; i < input.length;) { skip.lastIndex = i; if (match = skip.exec(input)) { if (match.index === i) { i += match[0].length; chunk.push(match[0]); } } c = input.charAt(i); comment.lastIndex = string.lastIndex = i; if (match = string.exec(input)) { if (match.index === i) { i += match[0].length; chunk.push(match[0]); continue; } } if (!inParam && c === '/') { cc = input.charAt(i + 1); if (cc === '/' || cc === '*') { if (match = comment.exec(input)) { if (match.index === i) { i += match[0].length; chunk.push(match[0]); continue; } } } } switch (c) { case '{': if (! inParam) { level ++; chunk.push(c); break; } case '}': if (! inParam) { level --; chunk.push(c); chunks[++j] = chunk = []; break; } case '(': if (! inParam) { inParam = true; chunk.push(c); break; } case ')': if ( inParam) { inParam = false; chunk.push(c); break; } default: chunk.push(c); } i++; } if (level !== 0) { error = { index: i - 1, type: 'Parse', message: (level > 0) ? "missing closing `}`" : "missing opening `{`" }; } return chunks.map(function (c) { return c.join(''); }); })([[]]); if (error) { throw makeError(error); } // Start with the primary rule. // The whole syntax tree is held under a Ruleset node, // with the `root` property set to true, so no `{}` are // output. The callback is called when the input is parsed. root = new tree.Ruleset([], $(this.parsers.primary)); root.root = true; // Get an array of Ruleset objects, flattened // and sorted according to specificitySort root.toList = (function() { return function(env) { env.error = function(e) { if (!env.errors) env.errors = new Error(''); if (env.errors.message) { env.errors.message += '\n' + makeError(e).message; } else { env.errors.message = makeError(e).message; } }; env.frames = env.frames || []; // call populates Invalid-caused errors var definitions = this.flatten([], [], env); definitions.sort(specificitySort); return definitions; }; })(); // Sort rules by specificity: this function expects selectors to be // split already. // // Written to be used as a .sort(Function); // argument. // // [1, 0, 0, 467] > [0, 0, 1, 520] var specificitySort = function(a, b) { var as = a.specificity; var bs = b.specificity; if (as[0] != bs[0]) return bs[0] - as[0]; if (as[1] != bs[1]) return bs[1] - as[1]; if (as[2] != bs[2]) return bs[2] - as[2]; return bs[3] - as[3]; }; return root; }, // Here in, the parsing rules/functions // // The basic structure of the syntax tree generated is as follows: // // Ruleset -> Rule -> Value -> Expression -> Entity // // In general, most rules will try to parse a token with the `$()` function, and if the return // value is truly, will return a new node, of the relevant type. Sometimes, we need to check // first, before parsing, that's when we use `peek()`. parsers: { // The `primary` rule is the *entry* and *exit* point of the parser. // The rules here can appear at any level of the parse tree. // // The recursive nature of the grammar is an interplay between the `block` // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule, // as represented by this simplified grammar: // // primary → (ruleset | rule)+ // ruleset → selector+ block // block → '{' primary '}' // // Only at one point is the primary rule not called from the // block rule: at the root level. primary: function() { var node, root = []; while ((node = $(this.rule) || $(this.ruleset) || $(this.comment)) || $(/^[\s\n]+/) || (node = $(this.invalid))) { if (node) root.push(node); } return root; }, invalid: function () { var chunk = $(/^[^;\n]*[;\n]/); // To fail gracefully, match everything until a semicolon or linebreak. if (chunk) { return new tree.Invalid(chunk, memo); } }, // We create a Comment node for CSS comments `/* */`, // but keep the LeSS comments `//` silent, by just skipping // over them. comment: function() { var comment; if (input.charAt(i) !== '/') return; if (input.charAt(i + 1) === '/') { return new tree.Comment($(/^\/\/.*/), true); } else if (comment = $(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/)) { return new tree.Comment(comment); } }, // Entities are tokens which can be found inside an Expression entities: { // A string, which supports escaping " and ' "milky way" 'he\'s the one!' quoted: function() { if (input.charAt(i) !== '"' && input.charAt(i) !== "'") return; var str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/); if (str) { return new tree.Quoted(str[1] || str[2]); } }, // A reference to a Mapnik field, like [NAME] // Behind the scenes, this has the same representation, but Carto // needs to be careful to warn when unsupported operations are used. field: function() { if (! $('[')) return; var field_name = $(/(^[^\]]+)/); if (! $(']')) return; if (field_name) return new tree.Field(field_name[1]); }, // This is a comparison operator comparison: function() { var str = $(/^=~|=|!=|<=|>=|<|>/); if (str) { return str; } }, // A catch-all word, such as: hard-light // These can start with either a letter or a dash (-), // and then contain numbers, underscores, and letters. keyword: function() { var k = $(/^[A-Za-z-]+[A-Za-z-0-9_]*/); if (k) { return new tree.Keyword(k); } }, // A function call like rgb(255, 0, 255) // The arguments are parsed with the `entities.arguments` parser. call: function() { var name, args; if (!(name = /^([\w\-]+|%)\(/.exec(chunks[j]))) return; name = name[1]; if (name === 'url') { // url() is handled by the url parser instead return null; } else { i += name.length; } $('('); // Parse the '(' and consume whitespace. args = $(this.entities['arguments']); if (!$(')')) return; if (name) { return new tree.Call(name, args, i); } }, // Arguments are comma-separated expressions 'arguments': function() { var args = [], arg; while (arg = $(this.expression)) { args.push(arg); if (! $(',')) { break; } } return args; }, literal: function() { return $(this.entities.dimension) || $(this.entities.keywordcolor) || $(this.entities.hexcolor) || $(this.entities.quoted); }, // Parse url() tokens // // We use a specific rule for urls, because they don't really behave like // standard function calls. The difference is that the argument doesn't have // to be enclosed within a string, so it can't be parsed as an Expression. url: function() { var value; if (input.charAt(i) !== 'u' || !$(/^url\(/)) return; value = $(this.entities.quoted) || $(this.entities.variable) || $(/^[\-\w%@$\/.&=:;#+?~]+/) || ''; if (! $(')')) { return new tree.Invalid(value, memo, 'Missing closing ) in URL.'); } else { return new tree.URL((typeof value.value !== 'undefined' || value instanceof tree.Variable) ? value : new tree.Quoted(value)); } }, // A Variable entity, such as `@fink`, in // // width: @fink + 2px // // We use a different parser for variable definitions, // see `parsers.variable`. variable: function() { var name, index = i; if (input.charAt(i) === '@' && (name = $(/^@[\w-]+/))) { return new tree.Variable(name, index, env.filename); } }, hexcolor: function() { var rgb; if (input.charAt(i) === '#' && (rgb = $(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/))) { return new tree.Color(rgb[1]); } }, keywordcolor: function() { var rgb = chunks[j].match(/^[a-z]+/); if (rgb && rgb[0] in tree.Reference.data.colors) { return new tree.Color(tree.Reference.data.colors[$(/^[a-z]+/)]); } }, // A Dimension, that is, a number and a unit. The only // unit that has an effect is % dimension: function() { var c = input.charCodeAt(i); if ((c > 57 || c < 45) || c === 47) return; var value = $(/^(-?\d*\.?\d+)(\%|\w+)?/); if (value) { return new tree.Dimension(value[1], value[2], memo); } } }, // The variable part of a variable definition. // Used in the `rule` parser. Like @fink: variable: function() { var name; if (input.charAt(i) === '@' && (name = $(/^(@[\w-]+)\s*:/))) { return name[1]; } }, // Entities are the smallest recognized token, // and can be found inside a rule's value. entity: function() { return $(this.entities.call) || $(this.entities.literal) || $(this.entities.field) || $(this.entities.variable) || $(this.entities.url) || $(this.entities.keyword); }, // A Rule terminator. Note that we use `peek()` to check for '}', // because the `block` rule will be expecting it, but we still need to make sure // it's there, if ';' was ommitted. end: function() { return $(';') || peek('}'); }, // Elements are the building blocks for Selectors. They consist of // an element name, such as a tag a class, or `*`. element: function() { var e = $(/^(?:[.#][\w\-]+|\*|Map)/); if (e) return new tree.Element(e); }, // Attachments allow adding multiple lines, polygons etc. to an // object. There can only be one attachment per selector. attachment: function() { var s = $(/^::([\w\-]+(?:\/[\w\-]+)*)/); if (s) return s[1]; }, // Selectors are made out of one or more Elements, see above. selector: function() { var a, attachment, e, elements = [], f, filters = new tree.Filterset(), z, zooms = [], segments = 0, conditions = 0; while ( (e = $(this.element)) || (z = $(this.zoom)) || (f = $(this.filter)) || (a = $(this.attachment)) ) { segments++; if (e) { elements.push(e); } else if (z) { zooms.push(z); conditions++; } else if (f) { var err = filters.add(f); if (err) { throw makeError({ message: err, index: i - 1 }); } conditions++; } else if (attachment) { throw makeError({ message: 'Encountered second attachment name.', index: i - 1 }); } else { attachment = a; } var c = input.charAt(i); if (c === '{' || c === '}' || c === ';' || c === ',') { break; } } if (segments) { return new tree.Selector(filters, zooms, elements, attachment, conditions, memo); } }, filter: function() { save(); var key, op, val; if (! $('[')) return; if (key = $(/^[a-zA-Z0-9\-_]+/) || $(this.entities.quoted) || $(this.entities.variable) || $(this.entities.keyword) || $(this.entities.field)) { // TODO: remove at 1.0.0 if (key instanceof tree.Quoted) { key = new tree.Field(key.toString()); } if ((op = $(this.entities.comparison)) && (val = $(this.entities.quoted) || $(this.entities.variable) || $(this.entities.dimension) || $(this.entities.keyword) || $(this.entities.field))) { if (! $(']')) { throw makeError({ message: 'Missing closing ] of filter.', index: memo - 1 }); } if (!key.is) key = new tree.Field(key); return new tree.Filter(key, op, val, memo, env.filename); } } }, zoom: function() { save(); var op, val; if ($(/^\[\s*zoom/g) && (op = $(this.entities.comparison)) && (val = $(this.entities.variable) || $(this.entities.dimension)) && $(']')) { return new tree.Zoom(op, val, memo); } else { // backtrack restore(); } }, // The `block` rule is used by `ruleset` // It's a wrapper around the `primary` rule, with added `{}`. block: function() { var content; if ($('{') && (content = $(this.primary)) && $('}')) { return content; } }, // div, .class, body > p {...} ruleset: function() { var selectors = [], s, f, l, rules, filters = []; save(); while (s = $(this.selector)) { selectors.push(s); while ($(this.comment)) {} if (! $(',')) { break; } while ($(this.comment)) {} } if (s) { while ($(this.comment)) {} } if (selectors.length > 0 && (rules = $(this.block))) { if (selectors.length === 1 && selectors[0].elements.length && selectors[0].elements[0].value === 'Map') { var rs = new tree.Ruleset(selectors, rules); rs.isMap = true; return rs; } return new tree.Ruleset(selectors, rules); } else { // Backtrack restore(); } }, rule: function() { var name, value, c = input.charAt(i); save(); if (c === '.' || c === '#') { return; } if (name = $(this.variable) || $(this.property)) { value = $(this.value); if (value && $(this.end)) { return new tree.Rule(name, value, memo, env.filename); } else { furthest = i; restore(); } } }, font: function() { var value = [], expression = [], weight, font, e; while (e = $(this.entity)) { expression.push(e); } value.push(new tree.Expression(expression)); if ($(',')) { while (e = $(this.expression)) { value.push(e); if (! $(',')) { break; } } } return new tree.Value(value); }, // A Value is a comma-delimited list of Expressions // In a Rule, a Value represents everything after the `:`, // and before the `;`. value: function() { var e, expressions = []; while (e = $(this.expression)) { expressions.push(e); if (! $(',')) { break; } } if (expressions.length > 1) { return new tree.Value(expressions.map(function(e) { return e.value[0]; })); } else if (expressions.length === 1) { return new tree.Value(expressions); } }, // A sub-expression, contained by parenthensis sub: function() { var e; if ($('(') && (e = $(this.expression)) && $(')')) { return e; } }, // This is a misnomer because it actually handles multiplication // and division. multiplication: function() { var m, a, op, operation; if (m = $(this.operand)) { while ((op = ($('/') || $('*') || $('%'))) && (a = $(this.operand))) { operation = new tree.Operation(op, [operation || m, a], memo); } return operation || m; } }, addition: function() { var m, a, op, operation; if (m = $(this.multiplication)) { while ((op = $(/^[-+]\s+/) || (input.charAt(i - 1) != ' ' && ($('+') || $('-')))) && (a = $(this.multiplication))) { operation = new tree.Operation(op, [operation || m, a], memo); } return operation || m; } }, // An operand is anything that can be part of an operation, // such as a Color, or a Variable operand: function() { return $(this.sub) || $(this.entity); }, // Expressions either represent mathematical operations, // or white-space delimited Entities. @var * 2 expression: function() { var e, delim, entities = [], d; while (e = $(this.addition) || $(this.entity)) { entities.push(e); } if (entities.length > 0) { return new tree.Expression(entities); } }, property: function() { var name = $(/^(([a-z][-a-z_0-9]*\/)?\*?-?[-a-z_0-9]+)\s*:/); if (name) return name[1]; } } }; return parser; }; carto-0.9.5/lib/carto/renderer.js000066400000000000000000000345631223255147500167000ustar00rootroot00000000000000var _ = require('underscore'); var carto = require('./index'); carto.Renderer = function Renderer(env, options) { this.env = env || {}; this.options = options || {}; this.options.mapnik_version = this.options.mapnik_version || 'latest'; }; // Prepare a MSS document (given as an string) into a // XML Style fragment (mostly useful for debugging) // // - @param {String} str the mss contents as a string. // - @param {Object} env renderer environment options. carto.Renderer.prototype.renderMSS = function render(data, callback) { // effects is a container for side-effects, which currently // are limited to FontSets. var env = _(this.env).defaults({ benchmark: false, validation_data: false, effects: [] }); if (!carto.tree.Reference.setVersion(this.options.mapnik_version)) { return callback(new Error("Could not set mapnik version to " + this.options.mapnik_version), null); } var output = []; var styles = []; if (env.benchmark) console.time('Parsing MSS'); var parser = (carto.Parser(env)).parse(data); if (env.benchmark) console.timeEnd('Parsing MSS'); if (env.benchmark) console.time('Rule generation'); var rule_list = parser.toList(env); if (env.benchmark) console.timeEnd('Rule generation'); if (env.benchmark) console.time('Rule inheritance'); var rules = inheritDefinitions(rule_list, env); if (env.benchmark) console.timeEnd('Rule inheritance'); if (env.benchmark) console.time('Style sort'); var sorted = sortStyles(rules,env); if (env.benchmark) console.timeEnd('Style sort'); if (env.benchmark) console.time('Total Style generation'); for (var k = 0, rule, style_name; k < sorted.length; k++) { rule = sorted[k]; style_name = 'style' + (rule.attachment !== '__default__' ? '-' + rule.attachment : ''); styles.push(style_name); var bench_name = '\tStyle "'+style_name+'" (#'+k+') toXML'; if (env.benchmark) console.time(bench_name); // env.effects can be modified by this call output.push(carto.tree.StyleXML(style_name, rule.attachment, rule, env)); if (env.benchmark) console.timeEnd(bench_name); } if (env.benchmark) console.timeEnd('Total Style generation'); if (env.errors) return callback(env.errors); return callback(null, output.join('\n')); }; // Prepare a MML document (given as an object) into a // fully-localized XML file ready for Mapnik2 consumption // // - @param {String} str the JSON file as a string. // - @param {Object} env renderer environment options. carto.Renderer.prototype.render = function render(m, callback) { // effects is a container for side-effects, which currently // are limited to FontSets. var env = _(this.env).defaults({ benchmark: false, validation_data: false, effects: [], ppi: 90.714 }); if (!carto.tree.Reference.setVersion(this.options.mapnik_version)) { return callback(new Error("Could not set mapnik version to " + this.options.mapnik_version), null); } var output = []; // Transform stylesheets into definitions. var definitions = _(m.Stylesheet).chain() .map(function(s) { if (typeof s == 'string') { callback(new Error("Stylesheet object is expected not a string: '" + s + "'")); } // Passing the environment from stylesheet to stylesheet, // allows frames and effects to be maintained. env = _(env).extend({filename:s.id}); // @TODO try/catch? var time = +new Date(), root = (carto.Parser(env)).parse(s.data); if (env.benchmark) console.warn('Parsing time: ' + (new Date() - time) + 'ms'); return root.toList(env); }) .flatten() .value(); function appliesTo(name, classIndex) { return function(definition) { return definition.appliesTo(l.name, classIndex); }; } // Iterate through layers and create styles custom-built // for each of them, and apply those styles to the layers. var styles, l, classIndex, rules, sorted, matching; for (var i = 0; i < m.Layer.length; i++) { l = m.Layer[i]; styles = []; classIndex = {}; if (env.benchmark) console.warn('processing layer: ' + l.id); // Classes are given as space-separated alphanumeric strings. var classes = (l['class'] || '').split(/\s+/g); for (var j = 0; j < classes.length; j++) { classIndex[classes[j]] = true; } matching = definitions.filter(appliesTo(l.name, classIndex)); rules = inheritDefinitions(matching, env); sorted = sortStyles(rules, env); for (var k = 0, rule, style_name; k < sorted.length; k++) { rule = sorted[k]; style_name = l.name + (rule.attachment !== '__default__' ? '-' + rule.attachment : ''); // env.effects can be modified by this call var styleXML = carto.tree.StyleXML(style_name, rule.attachment, rule, env); if (styleXML) { output.push(styleXML); styles.push(style_name); } } output.push(carto.tree.LayerXML(l, styles)); } output.unshift(env.effects.map(function(e) { return e.toXML(env); }).join('\n')); var map_properties; try { map_properties = getMapProperties(m, definitions, env); } catch (err) { env.error(err); return callback(err); } // Exit on errors. if (env.errors) return callback(env.errors); // Pass TileJSON and other custom parameters through to Mapnik XML. var parameters = _(m).reduce(function(memo, v, k) { if (!v && v !== 0) return memo; switch (k) { // Known skippable properties. case 'srs': case 'Layer': case 'Stylesheet': break; // Non URL-bound TileJSON properties. case 'bounds': case 'center': case 'minzoom': case 'maxzoom': case 'version': memo.push(' ' + v + ''); break; // Properties that require CDATA. case 'name': case 'description': case 'legend': case 'attribution': case 'template': memo.push(' '); break; // Mapnik image format. case 'format': memo.push(' ' + v + ''); break; // Mapnik interactivity settings. case 'interactivity': memo.push(' ' + v.layer + ''); memo.push(' ' + v.fields + ''); break; // Support any additional scalar properties. default: if ('string' === typeof v) { memo.push(' '); } else if ('number' === typeof v) { memo.push(' ' + v + ''); } else if ('boolean' === typeof v) { memo.push(' ' + v + ''); } break; } return memo; }, []); if (parameters.length) output.unshift( '\n' + parameters.join('\n') + '\n\n' ); var properties = _(map_properties).map(function(v) { return ' ' + v; }).join(''); if(!map_properties['maximum-extent']) { properties += ' maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34"'; } output.unshift( '\n' + '\n' + '\n'); output.push(''); return callback(null, output.join('\n')); }; // This function currently modifies 'current' // // @param {Array} the current list of rules // @param {Object} definition a Definition object to add to the rules // @param {Object} byFilter an object/dictionary of existing filters. This is // actually keyed `attachment->filter` // @param {Object} env the current environment function addRules(current, definition, byFilter, env) { var newFilters = definition.filters, newRules = definition.rules, updatedFilters, clone, previous; // The current definition might have been split up into // multiple definitions already. for (var k = 0; k < current.length; k++) { updatedFilters = current[k].filters.cloneWith(newFilters); if (updatedFilters) { previous = byFilter[updatedFilters]; if (previous) { // There's already a definition with those exact // filters. Add the current definitions' rules // and stop processing it as the existing rule // has already gone down the inheritance chain. previous.addRules(newRules); } else { clone = current[k].clone(updatedFilters); // Make sure that we're only maintaining the clone // when we did actually add rules. If not, there's // no need to keep the clone around. if (clone.addRules(newRules)) { // We inserted an element before this one, so we need // to make sure that in the next loop iteration, we're // not performing the same task for this element again, // hence the k++. byFilter[updatedFilters] = clone; current.splice(k, 0, clone); k++; } } } else if (updatedFilters === null) { // if updatedFilters is null, then adding the filters doesn't // invalidate or split the selector, so we addRules to the // combined selector // Filters can be added, but they don't change the // filters. This means we don't have to split the // definition. // // this is cloned here because of shared classes, see // sharedclass.mss current[k] = current[k].clone(); current[k].addRules(newRules); } // if updatedFeatures is false, then the filters split the rule, // so they aren't the same inheritance chain } return current; } // Apply inherited styles from their ancestors to them. // // called either once per render (in the case of mss) or per layer // (for mml) // // @param {Object} definitions: a list of definitions objects that contain .rules // @param {Object} env the environment // // result: an array of arrays is returned, in which each array refers to a // specific attachment function inheritDefinitions(definitions, env) { var inheritTime = +new Date(); // definitions are ordered by specificity, // high (index 0) to low var byAttachment = {}, byFilter = {}; var result = []; var current, previous, attachment; // Evaluate the filters specified by each definition with the given // environment to correctly resolve variable references definitions.forEach(function(d) { d.filters.ev(env); }); for (var i = 0; i < definitions.length; i++) { attachment = definitions[i].attachment; current = [definitions[i]]; if (!byAttachment[attachment]) { byAttachment[attachment] = []; byAttachment[attachment].attachment = attachment; byFilter[attachment] = {}; result.push(byAttachment[attachment]); } // Iterate over all subsequent rules. for (var j = i + 1; j < definitions.length; j++) { if (definitions[j].attachment === attachment) { // Only inherit rules from the same attachment. current = addRules(current, definitions[j], byFilter[attachment], env); } } for (var k = 0; k < current.length; k++) { byFilter[attachment][current[k].filters] = current[k]; byAttachment[attachment].push(current[k]); } } if (env.benchmark) console.warn('Inheritance time: ' + ((new Date() - inheritTime)) + 'ms'); return result; } // Sort styles by the minimum index of their rules. // This sorts a slice of the styles, so it returns a sorted // array but does not change the input. function sortStylesIndex(a, b) { return b.index - a.index; } function sortStyles(styles, env) { for (var i = 0; i < styles.length; i++) { var style = styles[i]; style.index = Infinity; for (var b = 0; b < style.length; b++) { var rules = style[b].rules; for (var r = 0; r < rules.length; r++) { var rule = rules[r]; if (rule.index < style.index) { style.index = rule.index; } } } } var result = styles.slice(); result.sort(sortStylesIndex); return result; } // Find a rule like Map { background-color: #fff; }, // if any, and return a list of properties to be inserted // into the 255 ? 255 : (i < 0 ? 0 : i)).toString(16); return i.length === 1 ? '0' + i : i; }).join(''); } }, // Operations have to be done per-channel, if not, // channels will spill onto each other. Once we have // our result, in the form of an integer triplet, // we create a new Color node to hold the result. operate: function(env, op, other) { var result = []; if (! (other instanceof tree.Color)) { other = other.toColor(); } for (var c = 0; c < 3; c++) { result[c] = tree.operate(op, this.rgb[c], other.rgb[c]); } return new tree.Color(result); }, toHSL: function() { var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha; var max = Math.max(r, g, b), min = Math.min(r, g, b); var h, s, l = (max + min) / 2, d = max - min; if (max === min) { h = s = 0; } else { s = l > 0.5 ? d / (2 - max - min) : d / (max + min); switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h /= 6; } return { h: h * 360, s: s, l: l, a: a }; } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/comment.js000066400000000000000000000004521223255147500174610ustar00rootroot00000000000000(function(tree) { tree.Comment = function Comment(value, silent) { this.value = value; this.silent = !!silent; }; tree.Comment.prototype = { toString: function(env) { return ''; }, 'ev': function() { return this; } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/definition.js000066400000000000000000000165071223255147500201570ustar00rootroot00000000000000(function(tree) { var assert = require('assert'), _ = require('underscore'); // A definition is the combination of a selector and rules, like // #foo { // polygon-opacity:1.0; // } // // The selector can have filters tree.Definition = function Definition(selector, rules) { this.elements = selector.elements; assert.ok(selector.filters instanceof tree.Filterset); this.rules = rules; this.ruleIndex = {}; for (var i = 0; i < this.rules.length; i++) { if ('zoom' in this.rules[i]) this.rules[i] = this.rules[i].clone(); this.rules[i].zoom = selector.zoom; this.ruleIndex[this.rules[i].updateID()] = true; } this.filters = selector.filters; this.zoom = selector.zoom; this.attachment = selector.attachment || '__default__'; this.specificity = selector.specificity(); }; tree.Definition.prototype.toString = function() { var str = this.filters.toString(); for (var i = 0; i < this.rules.length; i++) { str += '\n ' + this.rules[i]; } return str; }; tree.Definition.prototype.clone = function(filters) { if (filters) assert.ok(filters instanceof tree.Filterset); var clone = Object.create(tree.Definition.prototype); clone.rules = this.rules.slice(); clone.ruleIndex = _.clone(this.ruleIndex); clone.filters = filters ? filters : this.filters.clone(); clone.attachment = this.attachment; return clone; }; tree.Definition.prototype.addRules = function(rules) { var added = 0; // Add only unique rules. for (var i = 0; i < rules.length; i++) { if (!this.ruleIndex[rules[i].id]) { this.rules.push(rules[i]); this.ruleIndex[rules[i].id] = true; added++; } } return added; }; // Determine whether this selector matches a given id // and array of classes, by determining whether // all elements it contains match. tree.Definition.prototype.appliesTo = function(id, classes) { for (var i = 0, l = this.elements.length; i < l; i++) { var elem = this.elements[i]; if (!(elem.wildcard || (elem.type === 'class' && classes[elem.clean]) || (elem.type === 'id' && id === elem.clean))) return false; } return true; }; function symbolizerName(symbolizer) { function capitalize(str) { return str[1].toUpperCase(); } return symbolizer.charAt(0).toUpperCase() + symbolizer.slice(1).replace(/\-./, capitalize) + 'Symbolizer'; } // Get a simple list of the symbolizers, in order function symbolizerList(sym_order) { return sym_order.sort(function(a, b) { return a[1] - b[1]; }) .map(function(v) { return v[0]; }); } tree.Definition.prototype.symbolizersToXML = function(env, symbolizers, zoom) { var xml = zoom.toXML(env).join('') + this.filters.toXML(env); // Sort symbolizers by the index of their first property definition var sym_order = [], indexes = []; for (var key in symbolizers) { indexes = []; for (var prop in symbolizers[key]) { indexes.push(symbolizers[key][prop].index); } var min_idx = Math.min.apply(Math, indexes); sym_order.push([key, min_idx]); } sym_order = symbolizerList(sym_order); for (var i = 0; i < sym_order.length; i++) { var attributes = symbolizers[sym_order[i]]; var symbolizer = sym_order[i].split('/').pop(); // Skip the magical * symbolizer which is used for universal properties // which are bubbled up to Style elements intead of Symbolizer elements. if (symbolizer === '*') continue; var fail = tree.Reference.requiredProperties(symbolizer, attributes); if (fail) { var rule = attributes[Object.keys(attributes).shift()]; env.error({ message: fail, index: rule.index, filename: rule.filename }); } var name = symbolizerName(symbolizer); var selfclosing = true, tagcontent; xml += ' <' + name + ' '; for (var j in attributes) { if (symbolizer === 'map') env.error({ message: 'Map properties are not permitted in other rules', index: attributes[j].index, filename: attributes[j].filename }); var x = tree.Reference.selector(attributes[j].name); if (x && x.serialization && x.serialization === 'content') { selfclosing = false; tagcontent = attributes[j].ev(env).toXML(env, true); } else if (x && x.serialization && x.serialization === 'tag') { selfclosing = false; tagcontent = attributes[j].ev(env).toXML(env, true); } else { xml += attributes[j].ev(env).toXML(env) + ' '; } } if (selfclosing) { xml += '/>\n'; } else if (typeof tagcontent !== "undefined") { if (tagcontent.indexOf('<') != -1) { xml += '>' + tagcontent + '\n'; } else { xml += '>\n'; } } } if (!xml) return ''; return ' \n' + xml + ' \n'; }; // Take a zoom range of zooms and 'i', the index of a rule in this.rules, // and finds all applicable symbolizers tree.Definition.prototype.collectSymbolizers = function(zooms, i) { var symbolizers = {}, child; for (var j = i; j < this.rules.length; j++) { child = this.rules[j]; var key = child.instance + '/' + child.symbolizer; if (zooms.current & child.zoom && (!(key in symbolizers) || (!(child.name in symbolizers[key])))) { zooms.current &= child.zoom; if (!(key in symbolizers)) { symbolizers[key] = {}; } symbolizers[key][child.name] = child; } } if (Object.keys(symbolizers).length) { zooms.rule &= (zooms.available &= ~zooms.current); return symbolizers; } }; // The tree.Zoom.toString function ignores the holes in zoom ranges and outputs // scaledenominators that cover the whole range from the first to last bit set. // This algorithm can produces zoom ranges that may have holes. However, // when using the filter-mode="first", more specific zoom filters will always // end up before broader ranges. The filter-mode will pick those first before // resorting to the zoom range with the hole and stop processing further rules. tree.Definition.prototype.toXML = function(env, existing) { var filter = this.filters.toString(); if (!(filter in existing)) existing[filter] = tree.Zoom.all; var available = tree.Zoom.all, xml = '', zoom, symbolizers, zooms = { available: tree.Zoom.all }; for (var i = 0; i < this.rules.length && available; i++) { zooms.rule = this.rules[i].zoom; if (!(existing[filter] & zooms.rule)) continue; while (zooms.current = zooms.rule & available) { if (symbolizers = this.collectSymbolizers(zooms, i)) { if (!(existing[filter] & zooms.current)) continue; xml += this.symbolizersToXML(env, symbolizers, (new tree.Zoom()).setZoom(existing[filter] & zooms.current)); existing[filter] &= ~zooms.current; } } } return xml; }; })(require('../tree')); carto-0.9.5/lib/carto/tree/dimension.js000066400000000000000000000055741223255147500200160ustar00rootroot00000000000000(function(tree) { var _ = require('underscore'); // // A number with a unit // tree.Dimension = function Dimension(value, unit, index) { this.value = parseFloat(value); this.unit = unit || null; this.index = index; }; tree.Dimension.prototype = { is: 'float', physical_units: ['m', 'cm', 'in', 'mm', 'pt', 'pc'], screen_units: ['px', '%'], all_units: ['m', 'cm', 'in', 'mm', 'pt', 'pc', 'px', '%'], densities: { m: 0.0254, mm: 25.4, cm: 2.54, pt: 72, pc: 6 }, ev: function (env) { if (this.unit && !_.contains(this.all_units, this.unit)) { env.error({ message: "Invalid unit: '" + this.unit + "'", index: this.index }); return { is: 'undefined', value: 'undefined' }; } // normalize units which are not px or % if (this.unit && _.contains(this.physical_units, this.unit)) { if (!env.ppi) { env.error({ message: "ppi is not set, so metric units can't be used", index: this.index }); return { is: 'undefined', value: 'undefined' }; } // convert all units to inch // convert inch to px using ppi this.value = (this.value / this.densities[this.unit]) * env.ppi; this.unit = 'px'; } return this; }, 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(); }, operate: function(env, op, other) { if (this.unit === '%' && other.unit !== '%') { env.error({ message: 'If two operands differ, the first must not be %', index: this.index }); return { is: 'undefined', value: 'undefined' }; } if (this.unit !== '%' && other.unit === '%') { if (op === '*' || op === '/' || op === '%') { env.error({ message: 'Percent values can only be added or subtracted from other values', index: this.index }); return { is: 'undefined', value: 'undefined' }; } return new tree.Dimension(tree.operate(op, this.value, this.value * other.value * 0.01), this.unit); } //here the operands are either the same (% or undefined or px), or one is undefined and the other is px return new tree.Dimension(tree.operate(op, this.value, other.value), this.unit || other.unit); } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/element.js000066400000000000000000000014101223255147500174430ustar00rootroot00000000000000(function(tree) { // An element is an id or class selector tree.Element = function Element(value) { this.value = value.trim(); if (this.value[0] === '#') { this.type = 'id'; this.clean = this.value.replace(/^#/, ''); } if (this.value[0] === '.') { this.type = 'class'; this.clean = this.value.replace(/^\./, ''); } if (this.value.indexOf('*') !== -1) { this.type = 'wildcard'; } }; // Determine the 'specificity matrix' of this // specific selector tree.Element.prototype.specificity = function() { return [ (this.type === 'id') ? 1 : 0, // a (this.type === 'class') ? 1 : 0 // b ]; }; tree.Element.prototype.toString = function() { return this.value; }; })(require('../tree')); carto-0.9.5/lib/carto/tree/expression.js000066400000000000000000000010711223255147500202140ustar00rootroot00000000000000(function(tree) { tree.Expression = function Expression(value) { this.value = value; }; tree.Expression.prototype = { is: 'expression', ev: function(env) { if (this.value.length > 1) { return new tree.Expression(this.value.map(function(e) { return e.ev(env); })); } else { return this.value[0].ev(env); } }, toString: function(env) { return this.value.map(function(e) { return e.toString(env); }).join(' '); } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/field.js000066400000000000000000000004371223255147500171050ustar00rootroot00000000000000(function(tree) { tree.Field = function Field(content) { this.value = content || ''; }; tree.Field.prototype = { is: 'field', toString: function() { return '[' + this.value + ']'; }, 'ev': function() { return this; } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/filter.js000066400000000000000000000037501223255147500173100ustar00rootroot00000000000000(function(tree) { tree.Filter = function Filter(key, op, val, index, filename) { this.key = key; this.op = op; this.val = val; this.index = index; this.filename = filename; this.id = this.key + this.op + this.val; }; // xmlsafe, numeric, suffix var ops = { '<': [' < ', 'numeric'], '>': [' > ', 'numeric'], '=': [' = ', 'both'], '!=': [' != ', 'both'], '<=': [' <= ', 'numeric'], '>=': [' >= ', 'numeric'], '=~': ['.match(', 'string', ')'] }; tree.Filter.prototype.ev = function(env) { this.key = this.key.ev(env); this.val = this.val.ev(env); return this; }; tree.Filter.prototype.toXML = function(env) { if (tree.Reference.data.filter) { if (this.key.is === 'keyword' && -1 === tree.Reference.data.filter.value.indexOf(this.key.toString())) { env.error({ message: this.key.toString() + ' is not a valid keyword in a filter expression', index: this.index, filename: this.filename }); } if (this.val.is === 'keyword' && -1 === tree.Reference.data.filter.value.indexOf(this.val.toString())) { env.error({ message: this.val.toString() + ' is not a valid keyword in a filter expression', index: this.index, filename: this.filename }); } } var key = this.key.toString(false); var val = this.val.toString(this.val.is == 'string'); if ( (ops[this.op][1] == 'numeric' && isNaN(val) && this.val.is !== 'field') || (ops[this.op][1] == 'string' && (val)[0] != "'") ) { env.error({ message: 'Cannot use operator "' + this.op + '" with value ' + this.val, index: this.index, filename: this.filename }); } return key + ops[this.op][0] + val + (ops[this.op][2] || ''); }; tree.Filter.prototype.toString = function() { return '[' + this.id + ']'; }; })(require('../tree')); carto-0.9.5/lib/carto/tree/filterset.js000066400000000000000000000233361223255147500200260ustar00rootroot00000000000000var tree = require('../tree'); tree.Filterset = function Filterset() { this.filters = {}; }; tree.Filterset.prototype.toXML = function(env) { var filters = []; for (var id in this.filters) { filters.push('(' + this.filters[id].toXML(env).trim() + ')'); } if (filters.length) { return ' ' + filters.join(' and ') + '\n'; } else { return ''; } }; tree.Filterset.prototype.toString = function() { var arr = []; for (var id in this.filters) arr.push(this.filters[id].id); return arr.sort().join('\t'); }; tree.Filterset.prototype.ev = function(env) { for (var i in this.filters) { this.filters[i].ev(env); } return this; }; tree.Filterset.prototype.clone = function() { var clone = new tree.Filterset(); for (var id in this.filters) { clone.filters[id] = this.filters[id]; } return clone; }; // Note: other has to be a tree.Filterset. tree.Filterset.prototype.cloneWith = function(other) { var additions = []; for (var id in other.filters) { var status = this.addable(other.filters[id]); // status is true, false or null. if it's null we don't fail this // clone nor do we add the filter. if (status === false) { return false; } if (status === true) { // Adding the filter will override another value. additions.push(other.filters[id]); } } // Adding the other filters doesn't make this filterset invalid, but it // doesn't add anything to it either. if (!additions.length) { return null; } // We can successfully add all filters. Now clone the filterset and add the // new rules. var clone = new tree.Filterset(); // We can add the rules that are already present without going through the // add function as a Filterset is always in it's simplest canonical form. for (id in this.filters) { clone.filters[id] = this.filters[id]; } // Only add new filters that actually change the filter. while (id = additions.shift()) { clone.add(id); } return clone; }; // Returns true when the new filter can be added, false otherwise. // It can also return null, and on the other side we test for === true or // false tree.Filterset.prototype.addable = function(filter) { var key = filter.key.toString(), value = filter.val.toString(); if (value.match(/^[0-9]+(\.[0-9]*)?$/)) value = parseFloat(value); switch (filter.op) { case '=': // if there is already foo= and we're adding foo= if (this.filters[key + '='] !== undefined) { if (this.filters[key + '='].val.toString() != value) { return false; } else { return null; } } if (this.filters[key + '!=' + value] !== undefined) return false; if (this.filters[key + '>'] !== undefined && this.filters[key + '>'].val >= value) return false; if (this.filters[key + '<'] !== undefined && this.filters[key + '<'].val <= value) return false; if (this.filters[key + '>='] !== undefined && this.filters[key + '>='].val > value) return false; if (this.filters[key + '<='] !== undefined && this.filters[key + '<='].val < value) return false; return true; case '=~': return true; case '!=': if (this.filters[key + '='] !== undefined) return (this.filters[key + '='].val == value) ? false : null; if (this.filters[key + '!=' + value] !== undefined) return null; if (this.filters[key + '>'] !== undefined && this.filters[key + '>'].val >= value) return null; if (this.filters[key + '<'] !== undefined && this.filters[key + '<'].val <= value) return null; if (this.filters[key + '>='] !== undefined && this.filters[key + '>='].val > value) return null; if (this.filters[key + '<='] !== undefined && this.filters[key + '<='].val < value) return null; return true; case '>': if (key + '=' in this.filters) { if (this.filters[key + '='].val <= value) { return false; } else { return null; } } if (this.filters[key + '<'] !== undefined && this.filters[key + '<'].val <= value) return false; if (this.filters[key + '<='] !== undefined && this.filters[key + '<='].val <= value) return false; if (this.filters[key + '>'] !== undefined && this.filters[key + '>'].val >= value) return null; if (this.filters[key + '>='] !== undefined && this.filters[key + '>='].val > value) return null; return true; case '>=': if (this.filters[key + '=' ] !== undefined) return (this.filters[key + '='].val < value) ? false : null; if (this.filters[key + '<' ] !== undefined && this.filters[key + '<'].val <= value) return false; if (this.filters[key + '<='] !== undefined && this.filters[key + '<='].val < value) return false; if (this.filters[key + '>' ] !== undefined && this.filters[key + '>'].val >= value) return null; if (this.filters[key + '>='] !== undefined && this.filters[key + '>='].val >= value) return null; return true; case '<': if (this.filters[key + '=' ] !== undefined) return (this.filters[key + '='].val >= value) ? false : null; if (this.filters[key + '>' ] !== undefined && this.filters[key + '>'].val >= value) return false; if (this.filters[key + '>='] !== undefined && this.filters[key + '>='].val >= value) return false; if (this.filters[key + '<' ] !== undefined && this.filters[key + '<'].val <= value) return null; if (this.filters[key + '<='] !== undefined && this.filters[key + '<='].val < value) return null; return true; case '<=': if (this.filters[key + '=' ] !== undefined) return (this.filters[key + '='].val > value) ? false : null; if (this.filters[key + '>' ] !== undefined && this.filters[key + '>'].val >= value) return false; if (this.filters[key + '>='] !== undefined && this.filters[key + '>='].val > value) return false; if (this.filters[key + '<' ] !== undefined && this.filters[key + '<'].val <= value) return null; if (this.filters[key + '<='] !== undefined && this.filters[key + '<='].val <= value) return null; return true; } }; // Does the new filter constitute a conflict? tree.Filterset.prototype.conflict = function(filter) { var key = filter.key.toString(), value = filter.val.toString(); if (!isNaN(parseFloat(value))) value = parseFloat(value); // if (a=b) && (a=c) // if (a=b) && (a!=b) // or (a!=b) && (a=b) if ((filter.op === '=' && this.filters[key + '='] !== undefined && value != this.filters[key + '='].val.toString()) || (filter.op === '!=' && this.filters[key + '='] !== undefined && value == this.filters[key + '='].val.toString()) || (filter.op === '=' && this.filters[key + '!='] !== undefined && value == this.filters[key + '!='].val.toString())) { return filter.toString() + ' added to ' + this.toString() + ' produces an invalid filter'; } return false; }; // Only call this function for filters that have been cleared by .addable(). tree.Filterset.prototype.add = function(filter, env) { var key = filter.key.toString(), id, op = filter.op, conflict = this.conflict(filter), numval; if (conflict) return conflict; if (op === '=') { for (var i in this.filters) { if (this.filters[i].key == key) delete this.filters[i]; } this.filters[key + '='] = filter; } else if (op === '!=') { this.filters[key + '!=' + filter.val] = filter; } else if (op === '=~') { this.filters[key + '=~' + filter.val] = filter; } else if (op === '>') { // If there are other filters that are also > // but are less than this one, they don't matter, so // remove them. for (var j in this.filters) { if (this.filters[j].key == key && this.filters[j].val <= filter.val) { delete this.filters[j]; } } this.filters[key + '>'] = filter; } else if (op === '>=') { for (var k in this.filters) { numval = (+this.filters[k].val.toString()); if (this.filters[k].key == key && numval < filter.val) { delete this.filters[k]; } } if (this.filters[key + '!=' + filter.val] !== undefined) { delete this.filters[key + '!=' + filter.val]; filter.op = '>'; this.filters[key + '>'] = filter; } else { this.filters[key + '>='] = filter; } } else if (op === '<') { for (var l in this.filters) { numval = (+this.filters[l].val.toString()); if (this.filters[l].key == key && numval >= filter.val) { delete this.filters[l]; } } this.filters[key + '<'] = filter; } else if (op === '<=') { for (var m in this.filters) { numval = (+this.filters[m].val.toString()); if (this.filters[m].key == key && numval > filter.val) { delete this.filters[m]; } } if (this.filters[key + '!=' + filter.val] !== undefined) { delete this.filters[key + '!=' + filter.val]; filter.op = '<'; this.filters[key + '<'] = filter; } else { this.filters[key + '<='] = filter; } } }; carto-0.9.5/lib/carto/tree/fontset.js000066400000000000000000000014271223255147500175040ustar00rootroot00000000000000(function(tree) { tree._getFontSet = function(env, fonts) { var fontKey = fonts.join(''); if (env._fontMap && env._fontMap[fontKey]) { return env._fontMap[fontKey]; } var new_fontset = new tree.FontSet(env, fonts); env.effects.push(new_fontset); if (!env._fontMap) env._fontMap = {}; env._fontMap[fontKey] = new_fontset; return new_fontset; }; tree.FontSet = function FontSet(env, fonts) { this.fonts = fonts; this.name = 'fontset-' + env.effects.length; }; tree.FontSet.prototype.toXML = function(env) { return '\n' + this.fonts.map(function(f) { return ' '; }).join('\n') + '\n'; }; })(require('../tree')); carto-0.9.5/lib/carto/tree/imagefilter.js000066400000000000000000000006671223255147500203170ustar00rootroot00000000000000(function(tree) { tree.ImageFilter = function ImageFilter(filter, args) { this.filter = filter; this.args = args || null; }; tree.ImageFilter.prototype = { is: 'imagefilter', ev: function() { return this; }, toString: function() { if (this.args) { return this.filter + '(' + this.args.join(',') + ')'; } else { return this.filter; } } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/invalid.js000066400000000000000000000010271223255147500174440ustar00rootroot00000000000000(function (tree) { tree.Invalid = function Invalid(chunk, index, message) { this.chunk = chunk; this.index = index; this.type = 'syntax'; this.message = message || "Invalid code: " + this.chunk; }; tree.Invalid.prototype.is = 'invalid'; tree.Invalid.prototype.ev = function(env) { env.error({ chunk: this.chunk, index: this.index, type: 'syntax', message: this.message || "Invalid code: " + this.chunk }); return { is: 'undefined' }; }; })(require('../tree')); carto-0.9.5/lib/carto/tree/keyword.js000066400000000000000000000006171223255147500175060ustar00rootroot00000000000000(function(tree) { tree.Keyword = function Keyword(value) { this.value = value; var special = { 'transparent': 'color', 'true': 'boolean', 'false': 'boolean' }; this.is = special[value] ? special[value] : 'keyword'; }; tree.Keyword.prototype = { ev: function() { return this; }, toString: function() { return this.value; } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/layer.js000066400000000000000000000023711223255147500171350ustar00rootroot00000000000000(function(tree) { tree.LayerXML = function(obj, styles) { var dsoptions = []; for (var i in obj.Datasource) { dsoptions.push(''); } var prop_string = ''; for (var prop in obj.properties) { if (prop === 'minzoom') { prop_string += ' maxzoom="' + tree.Zoom.ranges[obj.properties[prop]] + '"\n'; } else if (prop === 'maxzoom') { prop_string += ' minzoom="' + tree.Zoom.ranges[obj.properties[prop]+1] + '"\n'; } else { prop_string += ' ' + prop + '="' + obj.properties[prop] + '"\n'; } } return '\n ' + styles.reverse().map(function(s) { return '' + s + ''; }).join('\n ') + (dsoptions.length ? '\n \n ' + dsoptions.join('\n ') + '\n \n' : '') + ' \n'; }; })(require('../tree')); carto-0.9.5/lib/carto/tree/literal.js000066400000000000000000000006261223255147500174560ustar00rootroot00000000000000// A literal is a literal string for Mapnik - the // result of the combination of a `tree.Field` with any // other type. (function(tree) { tree.Literal = function Field(content) { this.value = content || ''; this.is = 'field'; }; tree.Literal.prototype = { toString: function() { return this.value; }, 'ev': function() { return this; } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/operation.js000066400000000000000000000052641223255147500200250ustar00rootroot00000000000000// An operation is an expression with an op in between two operands, // like 2 + 1. (function(tree) { tree.Operation = function Operation(op, operands, index) { this.op = op.trim(); this.operands = operands; this.index = index; }; tree.Operation.prototype.is = 'operation'; tree.Operation.prototype.ev = function(env) { var a = this.operands[0].ev(env), b = this.operands[1].ev(env), temp; if (a.is === 'undefined' || b.is === 'undefined') { return { is: 'undefined', value: 'undefined' }; } if (a instanceof tree.Dimension && b instanceof tree.Color) { if (this.op === '*' || this.op === '+') { temp = b, b = a, a = temp; } else { env.error({ name: "OperationError", message: "Can't substract or divide a color from a number", index: this.index }); } } // Only concatenate plain strings, because this is easily // pre-processed if (a instanceof tree.Quoted && b instanceof tree.Quoted && this.op !== '+') { env.error({ message: "Can't subtract, divide, or multiply strings.", index: this.index, type: 'runtime', filename: this.filename }); return { is: 'undefined', value: 'undefined' }; } // Fields, literals, dimensions, and quoted strings can be combined. if (a instanceof tree.Field || b instanceof tree.Field || a instanceof tree.Literal || b instanceof tree.Literal) { if (a.is === 'color' || b.is === 'color') { env.error({ message: "Can't subtract, divide, or multiply colors in expressions.", index: this.index, type: 'runtime', filename: this.filename }); return { is: 'undefined', value: 'undefined' }; } else { return new tree.Literal(a.ev(env).toString(true) + this.op + b.ev(env).toString(true)); } } if (a.operate === undefined) { env.error({ message: 'Cannot do math with type ' + a.is + '.', index: this.index, type: 'runtime', filename: this.filename }); return { is: 'undefined', value: 'undefined' }; } return a.operate(env, this.op, b); }; tree.operate = function(op, a, b) { switch (op) { case '+': return a + b; case '-': return a - b; case '*': return a * b; case '%': return a % b; case '/': return a / b; } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/quoted.js000066400000000000000000000012741223255147500173230ustar00rootroot00000000000000(function(tree) { tree.Quoted = function Quoted(content) { this.value = content || ''; }; tree.Quoted.prototype = { is: 'string', toString: function(quotes) { var xmlvalue = this.value .replace(/&/g, '&') .replace(/\'/g, ''') .replace(/\"/g, '"') .replace(//g, '>'); return (quotes === true) ? "'" + xmlvalue + "'" : this.value; }, 'ev': function() { return this; }, operate: function(env, op, other) { return new tree.Quoted(tree.operate(op, this.toString(), other.toString(this.contains_field))); } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/reference.js000066400000000000000000000157451223255147500177700ustar00rootroot00000000000000// Carto pulls in a reference from the `mapnik-reference` // module. This file builds indexes from that file for its various // options, and provides validation methods for property: value // combinations. (function(tree) { var _ = require('underscore'), mapnik_reference = require('mapnik-reference'), ref = {}; ref.setData = function(data) { ref.data = data; ref.selector_cache = generateSelectorCache(data); ref.mapnikFunctions = generateMapnikFunctions(data); ref.required_cache = generateRequiredProperties(data); }; ref.setVersion = function(version) { if (mapnik_reference.version.hasOwnProperty(version)) { ref.setData(mapnik_reference.version[version]); return true; } else { return false; } }; ref.selectorData = function(selector, i) { if (ref.selector_cache[selector]) return ref.selector_cache[selector][i]; }; ref.validSelector = function(selector) { return !!ref.selector_cache[selector]; }; ref.selectorName = function(selector) { return ref.selectorData(selector, 2); }; ref.selector = function(selector) { return ref.selectorData(selector, 0); }; ref.symbolizer = function(selector) { return ref.selectorData(selector, 1); }; function generateSelectorCache(data) { var index = {}; for (var i in data.symbolizers) { for (var j in data.symbolizers[i]) { if (data.symbolizers[i][j].hasOwnProperty('css')) { index[data.symbolizers[i][j].css] = [data.symbolizers[i][j], i, j]; } } } return index; } function generateMapnikFunctions(data) { var functions = {}; for (var i in data.symbolizers) { for (var j in data.symbolizers[i]) { if (data.symbolizers[i][j].type === 'functions') { for (var k = 0; k < data.symbolizers[i][j].functions.length; k++) { var fn = data.symbolizers[i][j].functions[k]; functions[fn[0]] = fn[1]; } } } } return functions; } function generateRequiredProperties(data) { var cache = {}; for (var symbolizer_name in data.symbolizers) { cache[symbolizer_name] = []; for (var j in data.symbolizers[symbolizer_name]) { if (data.symbolizers[symbolizer_name][j].required) { cache[symbolizer_name].push(data.symbolizers[symbolizer_name][j].css); } } } return cache; } ref.requiredProperties = function(symbolizer_name, rules) { var req = ref.required_cache[symbolizer_name]; for (var i in req) { if (!(req[i] in rules)) { return 'Property ' + req[i] + ' required for defining ' + symbolizer_name + ' styles.'; } } }; // TODO: finish implementation - this is dead code ref._validateValue = { 'font': function(env, value) { if (env.validation_data && env.validation_data.fonts) { return env.validation_data.fonts.indexOf(value) != -1; } else { return true; } } }; ref.isFont = function(selector) { return ref.selector(selector).validate == 'font'; }; // https://gist.github.com/982927 ref.editDistance = function(a, b){ if (a.length === 0) return b.length; if (b.length === 0) return a.length; var matrix = []; for (var i = 0; i <= b.length; i++) { matrix[i] = [i]; } for (var j = 0; j <= a.length; j++) { matrix[0][j] = j; } for (i = 1; i <= b.length; i++) { for (j = 1; j <= a.length; j++) { if (b.charAt(i-1) == a.charAt(j-1)) { matrix[i][j] = matrix[i-1][j-1]; } else { matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution Math.min(matrix[i][j-1] + 1, // insertion matrix[i-1][j] + 1)); // deletion } } } return matrix[b.length][a.length]; }; function validateFunctions(value, selector) { if (value.value[0].is === 'string') return true; for (var i in value.value) { for (var j in value.value[i].value) { if (value.value[i].value[j].is !== 'call') return false; var f = _.find(ref .selector(selector).functions, function(x) { return x[0] == value.value[i].value[j].name; }); if (!(f && f[1] == -1)) { // This filter is unknown or given an incorrect number of arguments if (!f || f[1] !== value.value[i].value[j].args.length) return false; } } } return true; } function validateKeyword(value, selector) { if (typeof ref.selector(selector).type === 'object') { return ref.selector(selector).type .indexOf(value.value[0].value) !== -1; } else { // allow unquoted keywords as strings return ref.selector(selector).type === 'string'; } } ref.validValue = function(env, selector, value) { var i, j; // TODO: handle in reusable way if (!ref.selector(selector)) { return false; } else if (value.value[0].is == 'keyword') { return validateKeyword(value, selector); } else if (value.value[0].is == 'undefined') { // caught earlier in the chain - ignore here so that // error is not overridden return true; } else if (ref.selector(selector).type == 'numbers') { for (i in value.value) { if (value.value[i].is !== 'float') { return false; } } return true; } else if (ref.selector(selector).type == 'tags') { if (!value.value) return false; if (!value.value[0].value) { return value.value[0].is === 'tag'; } for (i = 0; i < value.value[0].value.length; i++) { if (value.value[0].value[i].is !== 'tag') return false; } return true; } else if (ref.selector(selector).type == 'functions') { // For backwards compatibility, you can specify a string for `functions`-compatible // values, though they will not be validated. return validateFunctions(value, selector); } else if (ref.selector(selector).type === 'expression') { return true; } else if (ref.selector(selector).type === 'unsigned') { if (value.value[0].is === 'float') { value.value[0].round(); return true; } else { return false; } } else { if (ref.selector(selector).validate) { var valid = false; for (i = 0; i < value.value.length; i++) { if (ref.selector(selector).type == value.value[i].is && ref ._validateValue [ref.selector(selector).validate] (env, value.value[i].value)) { return true; } } return valid; } else { return ref.selector(selector).type == value.value[0].is; } } }; ref.setVersion('latest'); tree.Reference = ref; })(require('../tree')); carto-0.9.5/lib/carto/tree/rule.js000066400000000000000000000102351223255147500167660ustar00rootroot00000000000000(function(tree) { // a rule is a single property and value combination, or variable // name and value combination, like // polygon-opacity: 1.0; or @opacity: 1.0; tree.Rule = function Rule(name, value, index, filename) { var parts = name.split('/'); this.name = parts.pop(); this.instance = parts.length ? parts[0] : '__default__'; this.value = (value instanceof tree.Value) ? value : new tree.Value([value]); this.index = index; this.symbolizer = tree.Reference.symbolizer(this.name); this.filename = filename; this.variable = (name.charAt(0) === '@'); }; tree.Rule.prototype.is = 'rule'; tree.Rule.prototype.clone = function() { var clone = Object.create(tree.Rule.prototype); clone.name = this.name; clone.value = this.value; clone.index = this.index; clone.instance = this.instance; clone.symbolizer = this.symbolizer; clone.filename = this.filename; clone.variable = this.variable; return clone; }; tree.Rule.prototype.updateID = function() { return this.id = this.zoom + '#' + this.instance + '#' + this.name; }; tree.Rule.prototype.toString = function() { return '[' + tree.Zoom.toString(this.zoom) + '] ' + this.name + ': ' + this.value; }; function getMean(name) { return Object.keys(tree.Reference.selector_cache).map(function(f) { return [f, tree.Reference.editDistance(name, f)]; }).sort(function(a, b) { return a[1] - b[1]; }); } // second argument, if true, outputs the value of this // rule without the usual attribute="content" wrapping. Right // now this is just for the TextSymbolizer, but applies to other // properties in reference.json which specify serialization=content tree.Rule.prototype.toXML = function(env, content, sep, format) { if (!tree.Reference.validSelector(this.name)) { var mean = getMean(this.name); var mean_message = ''; if (mean[0][1] < 3) { mean_message = '. Did you mean ' + mean[0][0] + '?'; } return env.error({ message: "Unrecognized rule: " + this.name + mean_message, index: this.index, type: 'syntax', filename: this.filename }); } if ((this.value instanceof tree.Value) && !tree.Reference.validValue(env, this.name, this.value)) { if (!tree.Reference.selector(this.name)) { return env.error({ message: 'Unrecognized property: ' + this.name, index: this.index, type: 'syntax', filename: this.filename }); } else { var typename; if (tree.Reference.selector(this.name).validate) { typename = tree.Reference.selector(this.name).validate; } else if (typeof tree.Reference.selector(this.name).type === 'object') { typename = 'keyword (options: ' + tree.Reference.selector(this.name).type.join(', ') + ')'; } else { typename = tree.Reference.selector(this.name).type; } return env.error({ message: 'Invalid value for ' + this.name + ', the type ' + typename + ' is expected. ' + this.value + ' (of type ' + this.value.value[0].is + ') ' + ' was given.', index: this.index, type: 'syntax', filename: this.filename }); } } if (this.variable) { return ''; } else if (tree.Reference.isFont(this.name) && this.value.value.length > 1) { var f = tree._getFontSet(env, this.value.value); return 'fontset-name="' + f.name + '"'; } else if (content) { return this.value.toString(env, this.name, sep); } else { return tree.Reference.selectorName(this.name) + '="' + this.value.toString(env, this.name) + '"'; } }; // TODO: Rule ev chain should add fontsets to env.frames tree.Rule.prototype.ev = function(context) { return new tree.Rule(this.name, this.value.ev(context), this.index, this.filename); }; })(require('../tree')); carto-0.9.5/lib/carto/tree/ruleset.js000066400000000000000000000144651223255147500175130ustar00rootroot00000000000000(function(tree) { tree.Ruleset = function Ruleset(selectors, rules) { this.selectors = selectors; this.rules = rules; // static cache of find() function this._lookups = {}; }; tree.Ruleset.prototype = { is: 'ruleset', 'ev': function(env) { var i, ruleset = new tree.Ruleset(this.selectors, this.rules.slice(0)); ruleset.root = this.root; // push the current ruleset to the frames stack env.frames.unshift(ruleset); // Evaluate everything else for (i = 0, rule; i < ruleset.rules.length; i++) { rule = ruleset.rules[i]; ruleset.rules[i] = rule.ev ? rule.ev(env) : rule; } // Pop the stack env.frames.shift(); return ruleset; }, match: function(args) { return !args || args.length === 0; }, variables: function() { if (this._variables) { return this._variables; } else { return this._variables = this.rules.reduce(function(hash, r) { if (r instanceof tree.Rule && r.variable === true) { hash[r.name] = r; } return hash; }, {}); } }, variable: function(name) { return this.variables()[name]; }, rulesets: function() { if (this._rulesets) { return this._rulesets; } else { return this._rulesets = this.rules.filter(function(r) { return (r instanceof tree.Ruleset); }); } }, find: function(selector, self) { self = self || this; var rules = [], rule, match, key = selector.toString(); if (key in this._lookups) { return this._lookups[key]; } this.rulesets().forEach(function(rule) { if (rule !== self) { for (var j = 0; j < rule.selectors.length; j++) { match = selector.match(rule.selectors[j]); if (match) { if (selector.elements.length > 1) { Array.prototype.push.apply(rules, rule.find( new tree.Selector(null, null, selector.elements.slice(1)), self)); } else { rules.push(rule); } break; } } } }); return this._lookups[key] = rules; }, // Zooms can use variables. This replaces tree.Zoom objects on selectors // with simple bit-arrays that we can compare easily. evZooms: function(env) { for (var i = 0; i < this.selectors.length; i++) { var zval = tree.Zoom.all; for (var z = 0; z < this.selectors[i].zoom.length; z++) { zval = zval & this.selectors[i].zoom[z].ev(env).zoom; } this.selectors[i].zoom = zval; } }, flatten: function(result, parents, env) { var selectors = [], i, j; if (this.selectors.length === 0) { env.frames = env.frames.concat(this.rules); } // evaluate zoom variables on this object. this.evZooms(env); for (i = 0; i < this.selectors.length; i++) { var child = this.selectors[i]; if (!child.filters) { // TODO: is this internal inconsistency? // This is an invalid filterset. continue; } if (parents.length) { for (j = 0; j < parents.length; j++) { var parent = parents[j]; var mergedFilters = parent.filters.cloneWith(child.filters); if (mergedFilters === null) { // Filters could be added, but they didn't change the // filters. This means that we only have to clone when // the zoom levels or the attachment is different too. if (parent.zoom === (parent.zoom & child.zoom) && parent.attachment === child.attachment && parent.elements.join() === child.elements.join()) { selectors.push(parent); continue; } else { mergedFilters = parent.filters; } } else if (!mergedFilters) { // The merged filters are invalid, that means we don't // have to clone. continue; } var clone = Object.create(tree.Selector.prototype); clone.filters = mergedFilters; clone.zoom = parent.zoom & child.zoom; clone.elements = parent.elements.concat(child.elements); if (parent.attachment && child.attachment) { clone.attachment = parent.attachment + '/' + child.attachment; } else clone.attachment = child.attachment || parent.attachment; clone.conditions = parent.conditions + child.conditions; clone.index = child.index; selectors.push(clone); } } else { selectors.push(child); } } var rules = []; for (i = 0; i < this.rules.length; i++) { var rule = this.rules[i]; // Recursively flatten any nested rulesets if (rule instanceof tree.Ruleset) { rule.flatten(result, selectors, env); } else if (rule instanceof tree.Rule) { rules.push(rule); } else if (rule instanceof tree.Invalid) { env.error(rule); } } var index = rules.length ? rules[0].index : false; for (i = 0; i < selectors.length; i++) { // For specificity sort, use the position of the first rule to allow // defining attachments that are under current element as a descendant // selector. if (index !== false) { selectors[i].index = index; } result.push(new tree.Definition(selectors[i], rules.slice())); } return result; } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/selector.js000066400000000000000000000014721223255147500176420ustar00rootroot00000000000000(function(tree) { tree.Selector = function Selector(filters, zoom, elements, attachment, conditions, index) { this.elements = elements || []; this.attachment = attachment; this.filters = filters || {}; this.zoom = typeof zoom !== 'undefined' ? zoom : tree.Zoom.all; this.conditions = conditions; this.index = index; }; // Determine the specificity of this selector // based on the specificity of its elements - calling // Element.specificity() in order to do so // // [ID, Class, Filters, Position in document] tree.Selector.prototype.specificity = function() { return this.elements.reduce(function(memo, e) { var spec = e.specificity(); memo[0] += spec[0]; memo[1] += spec[1]; return memo; }, [0, 0, this.conditions, this.index]); }; })(require('../tree')); carto-0.9.5/lib/carto/tree/style.js000066400000000000000000000044451223255147500171650ustar00rootroot00000000000000(function(tree) { var _ = require('underscore'); // Given a style's name, attachment, definitions, and an environment object, // return a stringified style for Mapnik tree.StyleXML = function(name, attachment, definitions, env) { var existing = {}; var image_filters = [], direct_image_filters = [], comp_op = [], opacity = []; for (var i = 0; i < definitions.length; i++) { for (var j = 0; j < definitions[i].rules.length; j++) { if (definitions[i].rules[j].name === 'image-filters') { image_filters.push(definitions[i].rules[j]); } if (definitions[i].rules[j].name === 'direct-image-filters') { direct_image_filters.push(definitions[i].rules[j]); } if (definitions[i].rules[j].name === 'comp-op') { comp_op.push(definitions[i].rules[j]); } if (definitions[i].rules[j].name === 'opacity') { opacity.push(definitions[i].rules[j]); } } } var rules = definitions.map(function(definition) { return definition.toXML(env, existing); }); var attrs_xml = ''; if (image_filters.length) { attrs_xml += ' image-filters="' + _.chain(image_filters) // prevent identical filters from being duplicated in the style .uniq(function(i) { return i.id; }).map(function(f) { return f.ev(env).toXML(env, true, ',', 'image-filter'); }).value().join(',') + '"'; } if (direct_image_filters.length) { attrs_xml += ' direct-image-filters="' + _.chain(direct_image_filters) // prevent identical filters from being duplicated in the style .uniq(function(i) { return i.id; }).map(function(f) { return f.ev(env).toXML(env, true, ',', 'direct-image-filter'); }).value().join(',') + '"'; } if (comp_op.length) { attrs_xml += ' comp-op="' + comp_op[0].value.ev(env).toString() + '"'; } if (opacity.length) { attrs_xml += ' opacity="' + opacity[0].value.ev(env).toString() + '"'; } var rule_string = rules.join(''); if (!attrs_xml && !rule_string) return ''; return ''; }; })(require('../tree')); carto-0.9.5/lib/carto/tree/url.js000066400000000000000000000005201223255147500166150ustar00rootroot00000000000000(function(tree) { tree.URL = function URL(val, paths) { this.value = val; this.paths = paths; }; tree.URL.prototype = { is: 'uri', toString: function() { return this.value.toString(); }, ev: function(ctx) { return new tree.URL(this.value.ev(ctx), this.paths); } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/value.js000066400000000000000000000014611223255147500171340ustar00rootroot00000000000000(function(tree) { tree.Value = function Value(value) { this.value = value; }; tree.Value.prototype = { is: 'value', ev: function(env) { if (this.value.length === 1) { return this.value[0].ev(env); } else { return new tree.Value(this.value.map(function(v) { return v.ev(env); })); } }, toString: function(env, selector, sep, format) { return this.value.map(function(e) { return e.toString(env, format); }).join(sep || ', '); }, clone: function() { var obj = Object.create(tree.Value.prototype); if (Array.isArray(obj)) obj.value = this.value.slice(); else obj.value = this.value; obj.is = this.is; return obj; } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/variable.js000066400000000000000000000017231223255147500176060ustar00rootroot00000000000000(function(tree) { tree.Variable = function Variable(name, index, filename) { this.name = name; this.index = index; this.filename = filename; }; tree.Variable.prototype = { is: 'variable', toString: function() { return this.name; }, ev: function(env) { var variable, v, name = this.name; if (this._css) return this._css; var thisframe = env.frames.filter(function(f) { return f.name == this.name; }.bind(this)); if (thisframe.length) { return thisframe[0].value.ev(env); } else { env.error({ message: 'variable ' + this.name + ' is undefined', index: this.index, type: 'runtime', filename: this.filename }); return { is: 'undefined', value: 'undefined' }; } } }; })(require('../tree')); carto-0.9.5/lib/carto/tree/zoom.js000066400000000000000000000053671223255147500170150ustar00rootroot00000000000000var tree = require('../tree'); // Storage for zoom ranges. Only supports continuous ranges, // and stores them as bit-sequences so that they can be combined, // inverted, and compared quickly. tree.Zoom = function(op, value, index) { this.op = op; this.value = value; this.index = index; }; tree.Zoom.prototype.setZoom = function(zoom) { this.zoom = zoom; return this; }; tree.Zoom.prototype.ev = function(env) { var start = 0, end = Infinity, value = parseInt(this.value.ev(env).toString(), 10), zoom = 0; if (value > tree.Zoom.maxZoom || value < 0) { env.error({ message: 'Only zoom levels between 0 and ' + tree.Zoom.maxZoom + ' supported.', index: this.index }); } switch (this.op) { case '=': this.zoom = 1 << value; return this; case '>': start = value + 1; break; case '>=': start = value; break; case '<': end = value - 1; break; case '<=': end = value; break; } for (var i = 0; i <= tree.Zoom.maxZoom; i++) { if (i >= start && i <= end) { zoom |= (1 << i); } } this.zoom = zoom; return this; }; tree.Zoom.prototype.toString = function() { return this.zoom; }; // Covers all zoomlevels from 0 to 22 tree.Zoom.all = 0x7FFFFF; tree.Zoom.maxZoom = 22; tree.Zoom.ranges = { 0: 1000000000, 1: 500000000, 2: 200000000, 3: 100000000, 4: 50000000, 5: 25000000, 6: 12500000, 7: 6500000, 8: 3000000, 9: 1500000, 10: 750000, 11: 400000, 12: 200000, 13: 100000, 14: 50000, 15: 25000, 16: 12500, 17: 5000, 18: 2500, 19: 1500, 20: 750, 21: 500, 22: 250, 23: 100 }; // Only works for single range zooms. `[XXX....XXXXX.........]` is invalid. tree.Zoom.prototype.toXML = function() { var conditions = []; if (this.zoom != tree.Zoom.all) { var start = null, end = null; for (var i = 0; i <= tree.Zoom.maxZoom; i++) { if (this.zoom & (1 << i)) { if (start === null) start = i; end = i; } } if (start > 0) conditions.push(' ' + tree.Zoom.ranges[start] + '\n'); if (end < 22) conditions.push(' ' + tree.Zoom.ranges[end + 1] + '\n'); } return conditions; }; tree.Zoom.prototype.toString = function() { var str = ''; for (var i = 0; i <= tree.Zoom.maxZoom; i++) { str += (this.zoom & (1 << i)) ? 'X' : '.'; } return str; }; carto-0.9.5/man/000077500000000000000000000000001223255147500134165ustar00rootroot00000000000000carto-0.9.5/man/carto.1000066400000000000000000000013131223255147500146060ustar00rootroot00000000000000.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.12. .TH CARTO "1" "March 2013" "carto 0.9.4" "User Commands" .SH NAME carto \- Carto map stylesheet compiler .SH SYNOPSIS .B carto [OPTION] \fI\fR .SH DESCRIPTION Carto is a stylesheet renderer for Mapnik. It's an evolution of the Cascadenik idea and language, with an emphasis on speed and flexibility. .SH OPTIONS .TP \fB\-v\fR \fB\-\-version\fR Parse JSON map manifest .TP \fB\-b\fR \fB\-\-benchmark\fR Outputs total compile time .TP \fB\-n\fR \fB\-\-nosymlink\fR Use absolute paths instead of symlinking files .SH REPORTING BUGS Please report bugs on the GitHub issue tracker: <\fBhttps://github.com/mapbox/carto/issues\fR> carto-0.9.5/package.json000066400000000000000000000020701223255147500151300ustar00rootroot00000000000000{ "name": "carto", "version": "0.9.5", "description": "Mapnik Stylesheet Compiler", "url": "https://github.com/mapbox/carto", "repository": { "type": "git", "url": "http://github.com/mapbox/carto.git" }, "author": { "name": "MapBox", "url": "http://mapbox.com/", "email": "info@mapbox.com" }, "keywords": [ "mapnik", "maps", "css", "stylesheets" ], "contributors": [ "Tom MacWright ", "Konstantin Käfer", "Alexis Sellier " ], "licenses": [{ "type": "Apache" }], "bin": { "carto": "./bin/carto", "mml2json.js": "./bin/mml2json.js" }, "man": "./man/carto.1", "main": "./lib/carto/index", "engines": { "node": ">=0.4.x" }, "dependencies": { "underscore": "~1.4.3", "mapnik-reference": "~5.0.7", "xml2js": "~0.2.4", "optimist": "~0.6.0" }, "devDependencies": { "mocha": "1.12.x", "jshint": "0.2.x", "sax": "0.1.x" }, "scripts": { "pretest": "npm install", "test": "mocha -R spec" } } carto-0.9.5/test/000077500000000000000000000000001223255147500136225ustar00rootroot00000000000000carto-0.9.5/test/benchmark/000077500000000000000000000000001223255147500155545ustar00rootroot00000000000000carto-0.9.5/test/benchmark/opened.mml000066400000000000000000000010741223255147500175370ustar00rootroot00000000000000{ "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": [ "opened.mss" ], "Layer": [{ "id": "data", "name": "data", "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://client-data.s3.amazonaws.com/ndi-afghanistan/district_boundaries.zip", "type": "shape" } }] } carto-0.9.5/test/benchmark/opened.mss000066400000000000000000000761131223255147500175620ustar00rootroot00000000000000#data[Dist_ID = 1001] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1002] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1003] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1004] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1005] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1006] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1007] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 101] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 102] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 103] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 104] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 105] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 106] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 107] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 108] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 109] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 110] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1101] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1102] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1103] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 1104] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 1105] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 1106] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1107] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 1108] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 1109] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 111] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1110] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 1111] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 1112] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1113] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1114] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1115] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 1116] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 1117] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1118] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 1119] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 112] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 113] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 114] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 115] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1201] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1202] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1203] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1204] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 1205] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 1206] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 1207] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 1208] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1209] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 1210] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1211] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1301] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1302] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1303] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1304] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1305] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1306] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1307] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1308] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1309] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1310] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1311] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1312] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 1313] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 1314] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1315] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1401] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 1402] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 1403] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 1404] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1405] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1406] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1407] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 1408] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1501] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1502] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1503] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1504] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1505] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1506] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1507] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1508] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1509] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1510] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1511] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1512] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1513] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1514] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1515] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1516] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1517] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1518] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1519] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1520] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1521] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1522] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1523] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1524] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1525] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1526] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1527] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1528] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1601] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1602] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1603] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1604] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1605] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1606] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1607] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1608] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1609] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1610] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1611] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1612] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1613] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1614] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1615] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1616] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1617] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 1701] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1702] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1703] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1704] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1705] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1706] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1707] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 1801] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1802] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1803] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1804] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1805] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1806] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1807] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1808] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1809] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1810] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1811] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 1812] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1813] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 1814] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1815] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1816] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 1901] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1902] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1903] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 1904] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1905] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1906] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 1907] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2001] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2002] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2003] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2004] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2005] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2006] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2007] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 201] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 202] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 203] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 204] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 205] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 206] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 207] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2101] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2102] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2103] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2104] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2105] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2106] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2107] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 2108] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2109] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2110] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2201] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2202] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2203] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2204] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2205] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2206] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2207] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2208] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2209] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2301] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2302] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2303] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2304] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2305] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2401] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2402] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2403] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2404] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2405] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2406] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2407] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 2408] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2409] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2410] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2411] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2501] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2502] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2503] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2504] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2505] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 2506] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2507] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 2508] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2509] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2510] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2511] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 2512] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2513] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 2514] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2515] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2516] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2517] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2518] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2519] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2601] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2602] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2603] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2604] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2605] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2606] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2607] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2608] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2609] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2610] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2611] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 2612] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2613] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2701] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2702] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2703] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2704] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 2705] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 2706] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2707] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2708] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2709] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2710] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2711] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 2801] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2802] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2803] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2804] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2805] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2806] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2807] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2808] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2809] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 2810] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2811] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2812] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2813] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2814] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2901] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 2902] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 2903] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 2904] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2905] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 2906] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 2907] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 3001] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 3002] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 3003] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3004] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 3005] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3006] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3007] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3008] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3009] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 301] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 3010] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3011] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3012] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 3013] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3014] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3015] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3016] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 302] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 303] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 304] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 305] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 306] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 307] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 308] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 309] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 310] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3101] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3102] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 3103] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3104] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 3105] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3106] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 3107] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 3108] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 3109] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 3110] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 3111] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 3201] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3202] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3203] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 3204] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3205] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3206] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3207] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3208] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 3209] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3210] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 3211] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 3212] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 3213] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 3301] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3302] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3303] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 3304] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 3305] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 3306] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 3307] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 3308] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3309] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 3310] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 3311] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3312] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 3313] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 3314] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 3315] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 3316] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 3401] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 3402] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 3403] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3404] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 3405] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 401] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 402] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 403] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 404] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 405] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 406] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 407] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 408] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 409] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 501] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 502] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 503] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 504] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 505] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 506] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 507] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 601] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 602] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 603] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 604] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 605] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 606] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 607] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 608] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 609] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 610] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 611] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 612] { polygon-fill: #F73; polygon-opacity: 0.6; } #data[Dist_ID = 613] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 614] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 615] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 616] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 617] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 618] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 619] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 620] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 621] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 622] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 701] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 702] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 703] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 704] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 705] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 801] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 802] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 803] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 804] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 805] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 806] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 807] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 901] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 902] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 903] { polygon-fill: #666; polygon-opacity: 0.6; } #data[Dist_ID = 904] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 905] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 906] { polygon-fill: #E30; polygon-opacity: 0.6; } #data[Dist_ID = 907] { polygon-fill: #FFF; polygon-opacity: 0.6; } #data[Dist_ID = 908] { polygon-fill: #FDC; polygon-opacity: 0.6; } #data[Dist_ID = 909] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 910] { polygon-fill: #F96; polygon-opacity: 0.6; } #data[Dist_ID = 911] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 912] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 913] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 914] { polygon-fill: #FBA; polygon-opacity: 0.6; } #data[Dist_ID = 915] { polygon-fill: #FBA; polygon-opacity: 0.6; } carto-0.9.5/test/benchmark/opened.result000066400000000000000000001415311223255147500202730ustar00rootroot00000000000000 data-polygon [absolute path] shape carto-0.9.5/test/errorhandling.test.js000066400000000000000000000076241223255147500200050ustar00rootroot00000000000000var path = require('path'), assert = require('assert'), fs = require('fs'); var carto = require('../lib/carto'); var tree = require('../lib/carto/tree'); var helper = require('./support/helper'); describe('Error handling mml+mss', function() { helper.files('errorhandling', 'mml', function(file) { var basename = path.basename(file); it('should handle errors in ' + basename, function(done) { var completed = false; var renderResult; var mml = helper.mml(file); try { new carto.Renderer({ paths: [ path.dirname(file) ], data_dir: path.join(__dirname, '../data'), local_data_dir: path.join(__dirname, 'rendering'), filename: file }).render(mml, function (err) { if (!err) { throw new Error("*** invalid error handling test found: " + basename + ": all error handling tests should throw!"); } var result = helper.resultFile(file); var output = err.message; // @TODO for some reason, fs.readFile includes an additional \n // at the end of read files. Determine why. fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); done(); }); }); } catch(err) { if (err.message.indexOf('***') > -1) throw err; var result = helper.resultFile(file); var output = err.message; // @TODO for some reason, fs.readFile includes an additional \n // at the end of read files. Determine why. fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); done(); }); } }); }); }); describe('Error handling mss', function() { helper.files('errorhandling', 'mss', function(file) { var basename = path.basename(file); if (basename == 'multi_stylesheets_a.mss') { return; } it('should handle errors in ' + basename, function(done) { var completed = false; var renderResult; var mss = helper.mss(file); try { new carto.Renderer({ paths: [ path.dirname(file) ], data_dir: path.join(__dirname, '../data'), local_data_dir: path.join(__dirname, 'rendering'), // note: we use the basename here so that the expected error result // will match if the style was loaded from mml filename: basename }).renderMSS(mss, function (err) { if (!err) { throw new Error("*** invalid error handling test found: " + basename + ": all error handling tests should throw!"); } var result = helper.resultFile(file); var output = err.message; // @TODO for some reason, fs.readFile includes an additional \n // at the end of read files. Determine why. fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); done(); }); }); } catch(err) { if (err.message.indexOf('***') > -1) throw err; var result = helper.resultFile(file); var output = err.message; // @TODO for some reason, fs.readFile includes an additional \n // at the end of read files. Determine why. fs.readFile(helper.resultFile(file), 'utf8', function(err, data) { if (!err) assert.deepEqual(output, data.substr(0, data.length - 1)); done(); }); } }); }); }); carto-0.9.5/test/errorhandling/000077500000000000000000000000001223255147500164605ustar00rootroot00000000000000carto-0.9.5/test/errorhandling/color_functions.mml000066400000000000000000000010721223255147500223750ustar00rootroot00000000000000{ "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": [ "color_functions.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.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" } }] } carto-0.9.5/test/errorhandling/color_functions.mss000066400000000000000000000000711223255147500224100ustar00rootroot00000000000000@foo: 'bar'; #world { polygon-fill: hsl(1, @foo, 3); } carto-0.9.5/test/errorhandling/color_functions.result000066400000000000000000000000741223255147500231270ustar00rootroot00000000000000color_functions.mss:3:31 incorrect arguments given to hsl() carto-0.9.5/test/errorhandling/contradiction.mml000066400000000000000000000010721223255147500220270ustar00rootroot00000000000000{ "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": [ "contradiction.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/district.geojson", "type": "ogr", "layer": "OGRGeoJSON" } }] } carto-0.9.5/test/errorhandling/contradiction.mss000066400000000000000000000001021223255147500220350ustar00rootroot00000000000000#world[FeatureCla!=""][FeatureCla=""] { polygon-fill: #fff; } carto-0.9.5/test/errorhandling/contradiction.result000066400000000000000000000001321223255147500225540ustar00rootroot00000000000000contradiction.mss:1:37 [[FeatureCla]=] added to [FeatureCla]!= produces an invalid filter carto-0.9.5/test/errorhandling/contradiction_2.mss000066400000000000000000000001021223255147500222560ustar00rootroot00000000000000#world[FeatureCla=""][FeatureCla!=""] { polygon-fill: #fff; } carto-0.9.5/test/errorhandling/contradiction_2.result000066400000000000000000000001341223255147500227770ustar00rootroot00000000000000contradiction_2.mss:1:37 [[FeatureCla]!=] added to [FeatureCla]= produces an invalid filter carto-0.9.5/test/errorhandling/function_args.mml000066400000000000000000000010701223255147500220260ustar00rootroot00000000000000{ "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": [ "function_args.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.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" } }] } carto-0.9.5/test/errorhandling/function_args.mss000066400000000000000000000001251223255147500220430ustar00rootroot00000000000000#world { point-transform: scale(2, 2); image-filters: agg-stack-blu(2, 1); } carto-0.9.5/test/errorhandling/function_args.result000066400000000000000000000001301223255147500225530ustar00rootroot00000000000000function_args.mss:3:38 unknown function agg-stack-blu(), did you mean agg-stack-blur(2) carto-0.9.5/test/errorhandling/invalid_color_in_fn.mss000066400000000000000000000000571223255147500232030ustar00rootroot00000000000000#world { polygon-fill: spin(#f00f00f, 10); } carto-0.9.5/test/errorhandling/invalid_color_in_fn.result000066400000000000000000000001011223255147500237050ustar00rootroot00000000000000invalid_color_in_fn.mss:2:34 incorrect arguments given to spin() carto-0.9.5/test/errorhandling/invalid_property.mml000066400000000000000000000010731223255147500225620ustar00rootroot00000000000000{ "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": [ "invalid_property.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.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" } }] } carto-0.9.5/test/errorhandling/invalid_property.mss000066400000000000000000000001001223255147500225650ustar00rootroot00000000000000#world[zoom=5] { polygon-fill: #f00; polygonopacity: 0.5; } carto-0.9.5/test/errorhandling/invalid_property.result000066400000000000000000000001321223255147500233060ustar00rootroot00000000000000invalid_property.mss:3:2 Unrecognized rule: polygonopacity. Did you mean polygon-opacity? carto-0.9.5/test/errorhandling/invalid_value.mml000066400000000000000000000010701223255147500220070ustar00rootroot00000000000000{ "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": [ "invalid_value.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.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" } }] } carto-0.9.5/test/errorhandling/invalid_value.mss000066400000000000000000000001271223255147500220260ustar00rootroot00000000000000#world[zoom=5] { text-face-name: 2; line-rasterizer: 'full'; text-name: 'foo'; } carto-0.9.5/test/errorhandling/invalid_value.result000066400000000000000000000004001223255147500225340ustar00rootroot00000000000000invalid_value.mss:2:2 Invalid value for text-face-name, the type font is expected. 2 (of type float) was given. invalid_value.mss:3:2 Invalid value for line-rasterizer, the type keyword (options: full, fast) is expected. full (of type string) was given. carto-0.9.5/test/errorhandling/issue119.mml000066400000000000000000000010401223255147500205450ustar00rootroot00000000000000{ "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": [ "issue119.mss" ], "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.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" } }] } carto-0.9.5/test/errorhandling/issue119.mss000066400000000000000000000000501223255147500205620ustar00rootroot00000000000000#countries { background-color:#f00; } carto-0.9.5/test/errorhandling/issue123.mml000066400000000000000000000010401223255147500205400ustar00rootroot00000000000000{ "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": [ "issue123.mss" ], "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.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" } }] } carto-0.9.5/test/errorhandling/issue123.mss000066400000000000000000000002011223255147500205530ustar00rootroot00000000000000#countries { ::outline { line-color: darken(#85c5d3); line-width: 2; line-join: round; } polygon-fill: #fff; } carto-0.9.5/test/errorhandling/issue123.result000066400000000000000000000001121223255147500212700ustar00rootroot00000000000000issue123.mss:3:31 incorrect number of arguments for darken(). 2 expected. carto-0.9.5/test/errorhandling/issue124.mml000066400000000000000000000010401223255147500205410ustar00rootroot00000000000000{ "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": [ "issue124.mss" ], "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.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" } }] } carto-0.9.5/test/errorhandling/issue124.mss000066400000000000000000000001231223255147500205570ustar00rootroot00000000000000#countries { [NAME = 14]{ polygon-pattern-file: url(stripe8.png; } } carto-0.9.5/test/errorhandling/issue297.mml000066400000000000000000000001411223255147500205550ustar00rootroot00000000000000{ "Stylesheet": [ "issue297.mss" ], "Layer": [{ "name": "t" }] } carto-0.9.5/test/errorhandling/issue297.mss000066400000000000000000000000721223255147500205750ustar00rootroot00000000000000#t { text-name: invalid; text-face-name: "Dejagnu"; } carto-0.9.5/test/errorhandling/issue297.result000066400000000000000000000001651223255147500213140ustar00rootroot00000000000000issue297.mss:2:2 Invalid value for text-name, the type expression is expected. invalid (of type keyword) was given. carto-0.9.5/test/errorhandling/issue_204_a.mss000066400000000000000000000000461223255147500212210ustar00rootroot00000000000000#countries { polygon-fill: green; }}carto-0.9.5/test/errorhandling/issue_204_b.mss000066400000000000000000000000471223255147500212230ustar00rootroot00000000000000#countries { polygon-fill: green; }} carto-0.9.5/test/errorhandling/issue_204_c.mss000066400000000000000000000000471223255147500212240ustar00rootroot00000000000000#countries { polygon-fill: green; }} carto-0.9.5/test/errorhandling/issue_218.mss000066400000000000000000000000671223255147500207310ustar00rootroot00000000000000#country-label { [one = 2] marker-width:1; } } carto-0.9.5/test/errorhandling/mapnik_keyword.mml000066400000000000000000000010421223255147500222070ustar00rootroot00000000000000{ "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": [ "mapnik_keyword.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" } }] } carto-0.9.5/test/errorhandling/mapnik_keyword.mss000066400000000000000000000000501223255147500222220ustar00rootroot00000000000000#world[[FOO]=nul] { line-width:2; } carto-0.9.5/test/errorhandling/mapnik_keyword.result000066400000000000000000000001111223255147500227340ustar00rootroot00000000000000mapnik_keyword.mss:1:6 nul is not a valid keyword in a filter expression carto-0.9.5/test/errorhandling/missing_close.mml000066400000000000000000000010411223255147500220210ustar00rootroot00000000000000{ "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": [ "missing_close.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" } }] } carto-0.9.5/test/errorhandling/missing_close.mss000066400000000000000000000000611223255147500220370ustar00rootroot00000000000000#world[natural="water" { polygon-fill: blue; } carto-0.9.5/test/errorhandling/missing_close.result000066400000000000000000000000631223255147500225550ustar00rootroot00000000000000missing_close.mss:1:5 Missing closing ] of filter. carto-0.9.5/test/errorhandling/multi_stylesheets.mml000066400000000000000000000011411223255147500227520ustar00rootroot00000000000000{ "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": [ "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.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" } }] } carto-0.9.5/test/errorhandling/multi_stylesheets_a.mss000066400000000000000000000001321223255147500232660ustar00rootroot00000000000000#world { polygon-opacity: 0.5; line-width:4; line-color:#fff; line-opacity:0.3; } carto-0.9.5/test/errorhandling/multi_stylesheets_b.mss000066400000000000000000000000421223255147500232670ustar00rootroot00000000000000#world { polygonopacity: 0.5; } carto-0.9.5/test/errorhandling/nopound.mml000066400000000000000000000010621223255147500206500ustar00rootroot00000000000000{ "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": [ "nopound.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.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" } }] } carto-0.9.5/test/errorhandling/nopound.mss000066400000000000000000000001641223255147500206670ustar00rootroot00000000000000world { ::outline { line-color: #85c5d3; line-width: 2; line-join: round; } polygon-fill: #fff; } carto-0.9.5/test/errorhandling/notenoughargs.mml000066400000000000000000000010701223255147500220500ustar00rootroot00000000000000{ "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": [ "notenoughargs.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.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" } }] } carto-0.9.5/test/errorhandling/notenoughargs.mss000066400000000000000000000001751223255147500220720ustar00rootroot00000000000000#world { ::outline { line-color: darken(#85c5d3); line-width: 2; line-join: round; } polygon-fill: #fff; } carto-0.9.5/test/errorhandling/undefined_variable.mml000066400000000000000000000010751223255147500230000ustar00rootroot00000000000000{ "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": [ "undefined_variable.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.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" } }] } carto-0.9.5/test/errorhandling/undefined_variable.mss000066400000000000000000000001671223255147500230160ustar00rootroot00000000000000#world[zoom=5] { polygon-fill: @something; line-color: @something + #111; marker-fill: darken(@something, 10); } carto-0.9.5/test/errorhandling/undefined_variable.result000066400000000000000000000002671223255147500235330ustar00rootroot00000000000000undefined_variable.mss:2:16 variable @something is undefined undefined_variable.mss:3:14 variable @something is undefined undefined_variable.mss:4:22 variable @something is undefined carto-0.9.5/test/errorhandling/zoom_as_var.mml000066400000000000000000000010661223255147500215110ustar00rootroot00000000000000{ "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": [ "zoom_as_var.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.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" } }] } carto-0.9.5/test/errorhandling/zoom_as_var.mss000066400000000000000000000000621223255147500215210ustar00rootroot00000000000000#world[zoom=5] { polygon-opacity: zoom / 0.5; } carto-0.9.5/test/errorhandling/zoom_as_var.result000066400000000000000000000000661223255147500222410ustar00rootroot00000000000000zoom_as_var.mss:2:2 Cannot do math with type keyword. carto-0.9.5/test/errorhandling/zoommax.mml000066400000000000000000000010621223255147500206600ustar00rootroot00000000000000{ "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": [ "zoommax.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.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" } }] } carto-0.9.5/test/errorhandling/zoommax.mss000066400000000000000000000000541223255147500206750ustar00rootroot00000000000000#world[zoom > 40] { polygon-fill: #fff; } carto-0.9.5/test/errorhandling/zoommax.result000066400000000000000000000000751223255147500214140ustar00rootroot00000000000000zoommax.mss:1:6 Only zoom levels between 0 and 22 supported. carto-0.9.5/test/field.test.js000066400000000000000000000010701223255147500162170ustar00rootroot00000000000000var assert = require('assert'); var tree = require('../lib/carto/tree.js'); require('../lib/carto/tree/field'); describe('Field', function() { describe('basic functionality', function() { it('should be constructed', function() { var f = new tree.Field("foo"); assert.ok(f); assert.equal(f.is, 'field'); }); it('should produce xml-friendly output', function() { var f = new tree.Field("bar"); assert.ok(f); assert.equal(f.toString(), "[bar]"); }); }); }); carto-0.9.5/test/filter.test.js000066400000000000000000000015351223255147500164270ustar00rootroot00000000000000var assert = require('assert'); var tree = require('../lib/carto/tree.js'); require('../lib/carto/tree/field'); require('../lib/carto/tree/dimension'); require('../lib/carto/tree/filter'); describe('Field', function() { describe('basic functionality', function() { it('should be constructed', function() { var f = new tree.Filter(new tree.Field('foo'), '=', new tree.Dimension(1)); assert.ok(f); }); it('can be evaluated', function() { var f = new tree.Filter(new tree.Field('foo'), '=', new tree.Dimension(1)); f.ev({}); assert.ok(f); }); it('yields xml', function() { var f = new tree.Filter(new tree.Field('foo'), '=', new tree.Dimension(1)); f.ev({}); assert.equal(f.toXML({}), '[foo] = 1'); }); }); }); carto-0.9.5/test/filterset.test.js000066400000000000000000000440611223255147500171440ustar00rootroot00000000000000var assert = require('assert'); var tree = require('../lib/carto/tree.js'); require('../lib/carto/tree/filterset'); describe('Filtersets', function() { describe('basic functionality', function() { it('should be constructed', function() { var f = new tree.Filterset(); assert.ok(f); assert.ok(f.filters); }); it('yields xml', function() { var f = new tree.Filterset(); assert.equal(f.toXML({}), ''); }); it('yields a clone', function() { var f = new tree.Filterset(); assert.ok(f.clone() instanceof tree.Filterset); }); }); describe('should add filters correctly', function() { it('adding to empty set', function() { var f = new tree.Filterset(); assert.ok(true === f.addable({ key: 'TOTAL', op: '=', val: '11' }), '=11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '90' }), '!=90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>', val: 9 }), '>9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>=', val: 9 }), '>=9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<', val: 90 }), '<90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<=', val: 90 }), '<=90'); }); it('adding to set with one and same key', function() { var f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '=', val: '11' }); assert.ok(null === f.addable({ key: 'TOTAL', op: '=', val: '11' }), '=11 =11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '90' }), '=11 !=90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>', val: '9' }), '=11 >9'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>=', val: '9' }), '=11 >=9'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<', val: '90' }), '=11 <90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<=', val: '90' }), '=11 <=90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '90' }), '=11 =90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '!=', val: '11' }), '=11 !=11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>', val: 90 }), '=11 >90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>=', val: 90 }), '=11 >=90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<', val: 9 }), '=11 <9'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<=', val: 9 }), '=11 <=9'); }); it('adding to set with one and same key and !=', function() { var f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '11' }), '!=11 =11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '11' }), '!=11 !=11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '9' }), '!=11 !=9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '90' }), '!=11 !=90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>', val: 9 }), '!=11 >9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>=', val: 9 }), '!=11 >=9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>', val: 90 }), '!=11 >90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>=', val: 90 }), '!=11 >=90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<', val: 9 }), '!=11 <9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<=', val: 9 }), '!=11 <=9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<', val: 90 }), '!=11 <90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<=', val: 90 }), '!=11 <=90'); }); it('adding to set with one and same key and >', function() { var f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '>', val: 11 }); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '11' }), '>11 =11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '11' }), '>11 !=11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>', val: 11 }), '>11 >11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>=', val: 11 }), '>11 >=11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<', val: 11 }), '>11 <11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<=', val: 11 }), '>11 <=11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '=', val: '90' }), '>11 =90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '90' }), '>11 !=90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>', val: 90 }), '>11 >90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>=', val: 90 }), '>11 >=90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<', val: 90 }), '>11 <90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<=', val: 90 }), '>11 <=90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '9' }), '>11 =9'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '9' }), '>11 !=9'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>', val: 9 }), '>11 >9'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>=', val: 9 }), '>11 >=9'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<', val: 9 }), '>11 <9'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<=', val: 9 }), '>11 <=9'); }); it('adding to set with one and same key and >=', function() { var f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '>=', val: 11 }); assert.ok(true === f.addable({ key: 'TOTAL', op: '=', val: '11' }), '>=11 =11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '11' }), '>=11 !=11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>', val: 11 }), '>=11 >11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>=', val: 11 }), '>=11 >=11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<', val: 11 }), '>=11 <11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<=', val: 11 }), '>=11 <=11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '=', val: '90' }), '>=11 =90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '90' }), '>=11 !=90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>', val: 90 }), '>=11 >90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>=', val: 90 }), '>=11 >=90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<', val: 90 }), '>=11 <90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<=', val: 90 }), '>=11 <=90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '9' }), '>=11 =9'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '9' }), '>=11 !=9'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>', val: 9 }), '>=11 >9'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>=', val: 9 }), '>=11 >=9'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<', val: 9 }), '>=11 <9'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<=', val: 9 }), '>=11 <=9'); }); it('adding to set with one and same key and <', function() { var f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '<', val: 11 }); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '11' }), '<11 =11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '11' }), '<11 !=11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>', val: 11 }), '<11 >11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>=', val: 11 }), '<11 >=11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<', val: 11 }), '<11 <11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<=', val: 11 }), '<11 <=11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '90' }), '<11 =90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '90' }), '<11 !=90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>', val: 90 }), '<11 >90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>=', val: 90 }), '<11 >=90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<', val: 90 }), '<11 <90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<=', val: 90 }), '<11 <=90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '=', val: '9' }), '<11 =9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '9' }), '<11 !=9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>', val: 9 }), '<11 >9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>=', val: 9 }), '<11 >=9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<', val: 9 }), '<11 <9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<=', val: 9 }), '<11 <=9'); }); it('adding to set with one and same key and <=', function() { var f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '<=', val: 11 }); assert.ok(true === f.addable({ key: 'TOTAL', op: '=', val: '11' }), '<=11 =11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '11' }), '<=11 !=11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>', val: 11 }), '<=11 >11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>=', val: 11 }), '<=11 >=11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<', val: 11 }), '<=11 <11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<=', val: 11 }), '<=11 <=11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '90' }), '<=11 =90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '90' }), '<=11 !=90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>', val: 90 }), '<=11 >90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>=', val: 90 }), '<=11 >=90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<', val: 90 }), '<=11 <90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<=', val: 90 }), '<=11 <=90'); assert.ok(true === f.addable({ key: 'TOTAL', op: '=', val: '9' }), '<=11 =9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '9' }), '<=11 !=9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>', val: 9 }), '<=11 >9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>=', val: 9 }), '<=11 >=9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<', val: 9 }), '<=11 <9'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<=', val: 9 }), '<=11 <=9'); }); it('adding to filterset with three filters', function() { var f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '<=', val: 11 }); f.add({ key: 'TOTAL', op: '>', val: 9 }); f.add({ key: 'TOTAL', op: '!=', val: '10' }); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '10' }), '<=11 >9 !=10 =10'); assert.ok(true === f.addable({ key: 'TOTAL', op: '=', val: '10.5' }), '<=11 >9 !=10 =10.5'); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '9' }), '<=11 >9 !=10 =9'); assert.ok(false === f.addable({ key: 'TOTAL', op: '=', val: '8' }), '<=11 >9 !=10 =8'); assert.ok(true === f.addable({ key: 'TOTAL', op: '=', val: '11' }), '<=11 >9 !=10 =11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '10' }), '<=11 >9 !=10 !=10'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '10.5' }), '<=11 >9 !=10 !=10.5'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '9' }), '<=11 >9 !=10 !=9'); assert.ok(null === f.addable({ key: 'TOTAL', op: '!=', val: '8' }), '<=11 >9 !=10 !=8'); assert.ok(true === f.addable({ key: 'TOTAL', op: '!=', val: '11' }), '<=11 >9 !=10 !=11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>', val: 11 }), '<=11 >9 !=10 >11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '>=', val: 11 }), '<=11 >9 !=10 >=11'); assert.ok(true === f.addable({ key: 'TOTAL', op: '<', val: 11 }), '<=11 >9 !=10 <11'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<=', val: 11 }), '<=11 >9 !=10 <=11'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>', val: 90 }), '<=11 >9 !=10 >90'); assert.ok(false === f.addable({ key: 'TOTAL', op: '>=', val: 90 }), '<=11 >9 !=10 >=90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<', val: 90 }), '<=11 >9 !=10 <90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '<=', val: 90 }), '<=11 >9 !=10 <=90'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>', val: 9 }), '<=11 >9 !=10 >9'); assert.ok(null === f.addable({ key: 'TOTAL', op: '>=', val: 9 }), '<=11 >9 !=10 >=9'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<', val: 9 }), '<=11 >9 !=10 <9'); assert.ok(false === f.addable({ key: 'TOTAL', op: '<=', val: 9 }), '<=11 >9 !=10 <=9'); }); }); it('should add filtersets', function() { var f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '=', val: '11' }); assert.deepEqual(f.filters, { 'TOTAL=': { key: 'TOTAL', op: '=', val: '11' }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '4' }); assert.deepEqual(f.filters, { 'TOTAL!=4': { key: 'TOTAL', op: '!=', val: '4' }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '>', val: '4' }); assert.deepEqual(f.filters, { 'TOTAL>': { key: 'TOTAL', op: '>', val: '4' }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '>=', val: '4' }); assert.deepEqual(f.filters, { 'TOTAL>=': { key: 'TOTAL', op: '>=', val: '4' }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '<', val: '4' }); assert.deepEqual(f.filters, { 'TOTAL<': { key: 'TOTAL', op: '<', val: '4' }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '<=', val: '4' }); assert.deepEqual(f.filters, { 'TOTAL<=': { key: 'TOTAL', op: '<=', val: '4' }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '!=', val: '9' }); assert.deepEqual(f.filters, { 'TOTAL!=9': { key: 'TOTAL', op: '!=', val: '9' }, 'TOTAL!=11': { key: 'TOTAL', op: '!=', val: '11' }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '>', val: 9 }); assert.deepEqual(f.filters, { 'TOTAL>': { key: 'TOTAL', op: '>', val: 9 }, 'TOTAL!=11': { key: 'TOTAL', op: '!=', val: '11' }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '>', val: 11 }); assert.deepEqual(f.filters, { 'TOTAL>': { key: 'TOTAL', op: '>', val: 11 }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '>', val: 90 }); assert.deepEqual(f.filters, { 'TOTAL>': { key: 'TOTAL', op: '>', val: 90 }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '>=', val: 9 }); assert.deepEqual(f.filters, { 'TOTAL>=': { key: 'TOTAL', op: '>=', val: 9 }, 'TOTAL!=11': { key: 'TOTAL', op: '!=', val: '11' }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '>=', val: 11 }); assert.deepEqual(f.filters, { 'TOTAL>': { key: 'TOTAL', op: '>', val: 11 }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '>=', val: 90 }); assert.deepEqual(f.filters, { 'TOTAL>=': { key: 'TOTAL', op: '>=', val: 90 }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '<', val: 9 }); assert.deepEqual(f.filters, { 'TOTAL<': { key: 'TOTAL', op: '<', val: 9 }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '<', val: 11 }); assert.deepEqual(f.filters, { 'TOTAL<': { key: 'TOTAL', op: '<', val: 11 }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '<', val: 90 }); assert.deepEqual(f.filters, { 'TOTAL<': { key: 'TOTAL', op: '<', val: 90 }, 'TOTAL!=11': { key: 'TOTAL', op: '!=', val: '11' }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '<=', val: 9 }); assert.deepEqual(f.filters, { 'TOTAL<=': { key: 'TOTAL', op: '<=', val: 9 }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '<=', val: 11 }); assert.deepEqual(f.filters, { 'TOTAL<': { key: 'TOTAL', op: '<', val: 11 }}); f = new tree.Filterset(); f.add({ key: 'TOTAL', op: '!=', val: '11' }); f.add({ key: 'TOTAL', op: '<=', val: 90 }); assert.deepEqual(f.filters, { 'TOTAL<=': { key: 'TOTAL', op: '<=', val: 90 }, 'TOTAL!=11': { key: 'TOTAL', op: '!=', val: '11' }}); }); }); carto-0.9.5/test/operation.test.js000066400000000000000000000034311223255147500171370ustar00rootroot00000000000000var assert = require('assert'); var tree = require('../lib/carto/tree.js'); require('../lib/carto/tree/operation'); require('../lib/carto/tree/dimension'); require('../lib/carto/tree/color'); require('../lib/carto/tree/field'); require('../lib/carto/tree/literal'); require('../lib/carto/tree/quoted'); describe('Operation', function() { it('should work with percent', function() { var env = { ppi:72, error:function(err) { console.log(err.message); } }; var o = new tree.Operation("+", [ new tree.Dimension(2), new tree.Dimension(10, "%") ]); assert.equal(o.ev(env).value, 2.2); }); it('should work with units', function() { var env = { ppi:72, error:function(err) { console.log(err.message); } }; var o = new tree.Operation("+", [ new tree.Dimension(2.54, 'cm'), new tree.Dimension(0.0254, 'm') ]); assert.equal(o.ev(env).value, 144); var o = new tree.Operation("+", [ new tree.Dimension(25.4, 'mm'), new tree.Dimension(72, 'pt') ]); assert.equal(o.ev(env).value, 144); var o = new tree.Operation("+", [ new tree.Dimension(72, 'pt'), new tree.Dimension(6, 'pc') ]); assert.equal(o.ev(env).value, 144); }); it('should work with different ppi', function() { var env = { ppi:300, error:function(err) { console.log(err.message); } }; var o = new tree.Operation("+", [ new tree.Dimension(2.54, 'cm'), new tree.Dimension(0.0254, 'm') ]); assert.equal(o.ev(env).value, 600); var o = new tree.Operation("+", [ new tree.Dimension(25.4, 'mm'), new tree.Dimension(72, 'pt') ]); assert.equal(o.ev(env).value, 600); var o = new tree.Operation("+", [ new tree.Dimension(72, 'pt'), new tree.Dimension(6, 'pc') ]); assert.equal(o.ev(env).value, 600); }); }); carto-0.9.5/test/quoted.test.js000066400000000000000000000015461223255147500164450ustar00rootroot00000000000000var assert = require('assert'); var tree = require('../lib/carto/tree.js'); require('../lib/carto/tree/quoted'); describe('Quoted', function() { describe('basic functionality', function() { it('should be constructed', function() { var f = new tree.Quoted("Tom's & \"\""); assert.ok(f); assert.equal(f.is, 'string'); }); it('should produce normal output', function() { var f = new tree.Quoted("Tom's & \"\""); assert.ok(f); assert.equal(f.toString(), "Tom's & \"\""); }); it('should produce xml-friendly output', function() { var f = new tree.Quoted("Tom's & \"\""); assert.ok(f); assert.equal(f.toString(true), "'Tom's & "<quoted>"'"); }); }); }); carto-0.9.5/test/rendering-mss.test.js000066400000000000000000000026751223255147500177250ustar00rootroot00000000000000var path = require('path'), assert = require('assert'), fs = require('fs'); var existsSync = require('fs').existsSync || require('path').existsSync; var carto = require('../lib/carto'); var tree = require('../lib/carto/tree'); var helper = require('./support/helper'); describe('Rendering mss', function() { helper.files('rendering-mss', 'mss', function(file) { it('should render mss ' + path.basename(file) + ' correctly', function(done) { var completed = false; var renderResult; var mss = helper.mss(file); new carto.Renderer({ paths: [ path.dirname(file) ], data_dir: path.join(__dirname, '../data'), local_data_dir: path.join(__dirname, 'rendering'), filename: file }).renderMSS(mss, function (err, output) { if (err) { if (Array.isArray(err)){ err.forEach(carto.writeError); done(); } else { throw err; done(); } } else { var expected = file.replace(path.extname(file),'')+'.xml'; if (!existsSync(expected)) { fs.writeFileSync(expected,output); } var expected_data = fs.readFileSync(expected).toString(); assert.equal(output,expected_data); done(); } }); }); }); }); carto-0.9.5/test/rendering-mss/000077500000000000000000000000001223255147500163775ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/basic_attachment_internal.mss000066400000000000000000000002261223255147500243100ustar00rootroot00000000000000#layer { // default attachement comes before line-color: chartreuse; line-width: 10; ::inline { line-color: lime; line-width: 5; } }carto-0.9.5/test/rendering-mss/basic_attachment_internal.xml000066400000000000000000000004031223255147500243030ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/basic_attachment_internal_before.mss000066400000000000000000000002271223255147500256330ustar00rootroot00000000000000#layer { ::outline { line-color: aliceblue; line-width: 5; } // default attachement comes after line-color: orchid; line-width: 10; }carto-0.9.5/test/rendering-mss/basic_attachment_internal_before.xml000066400000000000000000000004041223255147500256260ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/basic_attachment_internal_before_and_after.mss000066400000000000000000000002541223255147500276360ustar00rootroot00000000000000#layer { ::outline { line-color: salmon; line-width: 10; } line-color: coral; line-width: 5; ::inline { line-color: moccasin; line-width: 1; } }carto-0.9.5/test/rendering-mss/basic_attachment_internal_before_and_after.xml000066400000000000000000000006111223255147500276310ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/basic_attachment_internal_double.mss000066400000000000000000000002131223255147500256360ustar00rootroot00000000000000#layer { ::outline { line-color: whitesmoke; line-width: 10; } ::inline { line-color: mintcream; line-width: 5; } }carto-0.9.5/test/rendering-mss/basic_attachment_internal_double.xml000066400000000000000000000004141223255147500256370ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/basic_attachment_internal_with_label.mss000066400000000000000000000003261223255147500265030ustar00rootroot00000000000000#places { marker-width: 10; marker-allow-overlap: true; marker-fill: peru; ::label { text-face-name: "DejaVu Sans Book"; text-name: "'1'"; text-fill: tomato; text-allow-overlap: true; } } carto-0.9.5/test/rendering-mss/basic_attachment_internal_with_label.xml000066400000000000000000000005171223255147500265030ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/basic_attachment_separate.mss000066400000000000000000000002241223255147500242760ustar00rootroot00000000000000#layer { // default attachement comes before line-color: chartreuse; line-width: 10; } #layer::inline { line-color: lime; line-width: 5; }carto-0.9.5/test/rendering-mss/basic_attachment_separate.xml000066400000000000000000000004031223255147500242730ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/basic_attachment_separate_before.mss000066400000000000000000000002241223255147500256200ustar00rootroot00000000000000#layer::outline { line-color: aliceblue; line-width: 10; } #layer { // default attachment comes after line-color: orchid; line-width: 5; }carto-0.9.5/test/rendering-mss/basic_attachment_separate_before.xml000066400000000000000000000004041223255147500256160ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/basic_attachment_separate_before_and_after.mss000066400000000000000000000002501223255147500276220ustar00rootroot00000000000000#layer::outline { line-color: salmon; line-width: 10; } #layer { line-color: coral; line-width: 5; } #layer::inline { line-color: moccasin; line-width: 1; }carto-0.9.5/test/rendering-mss/basic_attachment_separate_before_and_after.xml000066400000000000000000000006111223255147500276210ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/basic_attachment_separate_double.mss000066400000000000000000000001741223255147500256340ustar00rootroot00000000000000#layer::outline { line-color: whitesmoke; line-width: 10; } #layer::inline { line-color: mintcream; line-width: 5; }carto-0.9.5/test/rendering-mss/basic_attachment_separate_double.xml000066400000000000000000000004131223255147500256260ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/basic_attachment_separate_with_label.mss000066400000000000000000000003171223255147500264730ustar00rootroot00000000000000#layer { marker-width: 10; marker-allow-overlap: true; marker-fill: peru; } #layer::label { text-face-name: "DejaVu Sans Book"; text-name: "'1'"; text-fill: tomato; text-allow-overlap: true; } carto-0.9.5/test/rendering-mss/basic_attachment_separate_with_label.xml000066400000000000000000000005171223255147500264730ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/empty_name.mss000066400000000000000000000001661223255147500212640ustar00rootroot00000000000000#poi-point { text-name: ""; text-face-name: "DejaVu Sans Book"; text-size: 10; text-fill: chocolate; }carto-0.9.5/test/rendering-mss/empty_name.xml000066400000000000000000000002551223255147500212610ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/image-filters.mss000066400000000000000000000001031223255147500216450ustar00rootroot00000000000000#layer { image-filters:invert(); direct-image-filters:invert(); }carto-0.9.5/test/rendering-mss/image-filters.xml000066400000000000000000000001461223255147500216520ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/issue_197.mss000066400000000000000000000001331223255147500206500ustar00rootroot00000000000000@foo: 6; @a: 8; #bar[zoom > @foo] { marker-width: 1; } #a[zoom = @a] { marker-width: 1; } carto-0.9.5/test/rendering-mss/issue_197.xml000066400000000000000000000005041223255147500206500ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/issue_247_1.mss000066400000000000000000000002751223255147500210730ustar00rootroot00000000000000#countries { ::outline { line-color: #85c5d3; line-width: 4; line-join: round; //[ne_10m_adm = 'AAA'] { } } ::inline { line-color: black; line-width: 1; } }carto-0.9.5/test/rendering-mss/issue_247_1.xml000066400000000000000000000004431223255147500210660ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/issue_247_2.mss000066400000000000000000000002731223255147500210720ustar00rootroot00000000000000#countries { ::outline { line-color: #85c5d3; line-width: 4; line-join: round; [ne_10m_adm = 'AAA'] { } } ::inline { line-color: black; line-width: 1; } }carto-0.9.5/test/rendering-mss/issue_247_2.xml000066400000000000000000000006631223255147500210730ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/issue_284.mss000066400000000000000000000003261223255147500206510ustar00rootroot00000000000000#roads_high::outline { [type='primary'] { line-color: red; } [foo='bar'] { line-width: 10; } } #roads_high { [type='primary'] { line-color: red; } [foo='bar'] { line-width: 10; } } carto-0.9.5/test/rendering-mss/issue_284.xml000066400000000000000000000014151223255147500206470ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/issue_284_b.mss000066400000000000000000000003431223255147500211510ustar00rootroot00000000000000#roads_high::inline { [type='primary'] { line-color: darkred; } [foo='bar'] { line-width: 11; } } #roads_high::outline { [type='primary'] { line-color: red; } [foo='bar'] { line-width: 10; } } carto-0.9.5/test/rendering-mss/issue_284_b.xml000066400000000000000000000014241223255147500211500ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/issue_284_c.mss000066400000000000000000000003221223255147500211470ustar00rootroot00000000000000#roads_high { [type='primary'] { line-color: darkred; } [foo='bar'] { line-width: 11; } } #roads_high { [type='primary'] { line-color: red; } [foo='bar'] { line-width: 10; } } carto-0.9.5/test/rendering-mss/issue_284_c.xml000066400000000000000000000006021223255147500211460ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/quoted_attr.mss000066400000000000000000000001261223255147500214550ustar00rootroot00000000000000#layer[power = 'generator']['generator:source' = 'wind']::power { marker-width:0; }carto-0.9.5/test/rendering-mss/quoted_attr.xml000066400000000000000000000002751223255147500214600ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/scale-hsla-filter.mss000066400000000000000000000002221223255147500224160ustar00rootroot00000000000000#layer { polygon-fill:red; image-filters:scale-hsla(.5,.5,.5,.5,.5,.5,.5,.5); direct-image-filters:scale-hsla(.5,.5,.5,.5,.5,.5,.5,.5); }carto-0.9.5/test/rendering-mss/scale-hsla-filter.xml000066400000000000000000000003541223255147500224220ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/should-discard-empty-style-and-attach.mss000066400000000000000000000000341223255147500263210ustar00rootroot00000000000000#landcover { ::foo { } }carto-0.9.5/test/rendering-mss/should-discard-empty-style-and-attach.xml000066400000000000000000000000011223255147500263110ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/should-discard-empty-style.mss000066400000000000000000000000161223255147500243170ustar00rootroot00000000000000#landcover { }carto-0.9.5/test/rendering-mss/should-discard-empty-style.xml000066400000000000000000000000001223255147500243060ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/should-discard-empty-style2.mss000066400000000000000000000001421223255147500244010ustar00rootroot00000000000000#landcover { ::a { //polygon-fill: #aacbaf; } ::b { // marker-width:4; } }carto-0.9.5/test/rendering-mss/should-discard-empty-style2.xml000066400000000000000000000000021223255147500243720ustar00rootroot00000000000000 carto-0.9.5/test/rendering-mss/style-level-prop-only.mss000066400000000000000000000000341223255147500233220ustar00rootroot00000000000000#landcover { opacity:.5; }carto-0.9.5/test/rendering-mss/style-level-prop-only.xml000066400000000000000000000000771223255147500233270ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/style-level-prop-only2.mss000066400000000000000000000000441223255147500234050ustar00rootroot00000000000000#landcover { comp-op:color-burn; }carto-0.9.5/test/rendering-mss/style-level-prop-only2.xml000066400000000000000000000001061223255147500234020ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/style-level-prop-only3.mss000066400000000000000000000000501223255147500234030ustar00rootroot00000000000000#landcover { image-filters:invert(); }carto-0.9.5/test/rendering-mss/style-level-prop-only3.xml000066400000000000000000000001101223255147500233760ustar00rootroot00000000000000carto-0.9.5/test/rendering-mss/zoom-like-field-name.mss000066400000000000000000000000521223255147500230250ustar00rootroot00000000000000#world[zoomy > 2] { polygon-fill:#f00; }carto-0.9.5/test/rendering-mss/zoom_space.mss000066400000000000000000000000531223255147500212600ustar00rootroot00000000000000#world[ zoom > 2] { polygon-fill:#f00; } carto-0.9.5/test/rendering-mss/zoom_space.xml000066400000000000000000000002461223255147500212620ustar00rootroot00000000000000carto-0.9.5/test/rendering.test.js000066400000000000000000000056421223255147500171220ustar00rootroot00000000000000var path = require('path'), assert = require('assert'), fs = require('fs'); var carto = require('../lib/carto'); var tree = require('../lib/carto/tree'); var helper = require('./support/helper'); describe('Rendering', function() { helper.files('rendering', 'mml', function(file) { it('should render ' + path.basename(file) + ' correctly', function(done) { var completed = false; var renderResult; var mml = helper.mml(file); new carto.Renderer({ paths: [ path.dirname(file) ], data_dir: path.join(__dirname, '../data'), local_data_dir: path.join(__dirname, 'rendering'), filename: file }).render(mml, function (err, output) { if (err) { if (Array.isArray(err)){ err.forEach(carto.writeError); } else { throw err; } } else { var result = helper.resultFile(file); renderResult = output; helper.compareToXMLFile(result, output, function(err,expected_json,actual_json) { completed = true; var actual = file.replace(path.extname(file),'') + '-actual.json'; var expected = file.replace(path.extname(file),'') + '-expected.json'; if (err) { // disabled since it can break on large diffs /* console.warn( helper.stylize("Failure", 'red') + ': ' + helper.stylize(file, 'underline') + ' differs from expected result.'); helper.showDifferences(err); throw ''; */ fs.writeFileSync(actual,JSON.stringify(actual_json,null,4)); fs.writeFileSync(expected,JSON.stringify(expected_json,null,4)); throw new Error('failed: xml ' + result + ' in json form does not match expected result:\n' + actual + ' (actual)\n' + expected + ' (expected)'); } else { // cleanup any actual renders that no longer fail try { fs.unlinkSync(actual); fs.unlinkSync(expected); } catch (err) {} } done(); }, [ helper.removeAbsoluteImages, helper.removeAbsoluteDatasources ]); } }); // beforeExit(function() { // if (!completed && renderResult) { // console.warn(helper.stylize('renderer produced:', 'bold')); // console.warn(renderResult); // } // assert.ok(completed, 'Rendering finished.'); // }); }); }); }); carto-0.9.5/test/rendering/000077500000000000000000000000001223255147500155775ustar00rootroot00000000000000carto-0.9.5/test/rendering/afghanistan_votes.mml000066400000000000000000000010751223255147500220140ustar00rootroot00000000000000{ "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": [ "afghanistan_votes.mss" ], "Layer": [{ "name": "data", "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/district.geojson", "type": "ogr", "layer": "OGRGeoJSON" } }] } carto-0.9.5/test/rendering/afghanistan_votes.mss000066400000000000000000000036011223255147500220260ustar00rootroot00000000000000#data[_votes_total_null = 0][votes_total >= 3][votes_total <= 34730.2] { marker-allow-overlap: true; marker-width: 2; marker-height: 2; marker-fill: #222; marker-opacity: 0.8; marker-line-width: 0; marker-line-color: #222; marker-line-opacity: 0.8; marker-type: ellipse; } #data[_votes_total_null = 0][votes_total >= 34730.2][votes_total <= 69457.4] { marker-allow-overlap: true; marker-width: 5; marker-height: 5; marker-fill: #222; marker-opacity: .8; marker-line-width: 0; marker-line-color: #222; marker-line-opacity: .8; marker-type: ellipse; } #data[_votes_total_null = 0][votes_total >= 69457.4][votes_total <= 104184.59999999999] { marker-allow-overlap: true; marker-width: 8; marker-height: 8; marker-fill: #222; marker-opacity: .8; marker-line-width: 0; marker-line-color: #222; marker-line-opacity: .8; marker-type: ellipse; } #data[_votes_total_null = 0][votes_total >= 104184.59999999999][votes_total <= 138911.8] { marker-allow-overlap: true; marker-width: 11; marker-height: 11; marker-fill: #222; marker-opacity: .8; marker-line-width: 0; marker-line-color: #222; marker-line-opacity: .8; marker-type: ellipse; } #data[_votes_total_null = 0][votes_total >= 138911.8][votes_total <= 173639] { marker-allow-overlap: true; marker-width: 14; marker-height: 14; marker-fill: #222; marker-opacity: .8; marker-line-width: 0; marker-line-color: #222; marker-line-opacity: .8; marker-type: ellipse; } #data[_votes_total_null = 0][votes_total >= 173639][votes_total <= 208366.2] { marker-allow-overlap: true; marker-width: 17; marker-height: 17; marker-fill: #222; marker-opacity: .8; marker-line-width: 0; marker-line-color: #222; marker-line-opacity: .8; marker-type: ellipse; } carto-0.9.5/test/rendering/afghanistan_votes.result000066400000000000000000000051001223255147500225360ustar00rootroot00000000000000 data carto-0.9.5/test/rendering/background_attributes.mml000066400000000000000000000003421223255147500226720ustar00rootroot00000000000000{ "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": [ "background_attributes.mss" ], "Layer": [] } carto-0.9.5/test/rendering/background_attributes.mss000066400000000000000000000000441223255147500227060ustar00rootroot00000000000000Map { background-color: #fff; } carto-0.9.5/test/rendering/background_attributes.result000066400000000000000000000004561223255147500234310ustar00rootroot00000000000000 carto-0.9.5/test/rendering/buffersize.mml000066400000000000000000000010361223255147500204520ustar00rootroot00000000000000{ "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": [ "buffersize.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" } }] } carto-0.9.5/test/rendering/buffersize.mss000066400000000000000000000002061223255147500204650ustar00rootroot00000000000000Map { buffer-size: 256; } #world { text-name: "[NAME]"; text-size: 11; text-face-name: "Georgia Regular", "Arial Italic"; } carto-0.9.5/test/rendering/buffersize.result000066400000000000000000000016441223255147500212100ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/building_height.mml000066400000000000000000000010431223255147500214310ustar00rootroot00000000000000{ "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": [ "building_height.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" } }] } carto-0.9.5/test/rendering/building_height.mss000066400000000000000000000001261223255147500214470ustar00rootroot00000000000000@n: 4; #world { building-height: 2 * 3 * [HEIGHT] + 2 + [NOTHEIGHT] + (@n * 2); } carto-0.9.5/test/rendering/building_height.result000066400000000000000000000014061223255147500221650ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/color_variable.mml000066400000000000000000000010421223255147500212660ustar00rootroot00000000000000{ "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": [ "color_variable.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" } }] } carto-0.9.5/test/rendering/color_variable.mss000066400000000000000000000001031223255147500213000ustar00rootroot00000000000000#world { polygon-fill: green; line-color: hsl(30, 40%, 90%); } carto-0.9.5/test/rendering/color_variable.result000066400000000000000000000014311223255147500220210ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/combined_class.mml000066400000000000000000000017061223255147500212570ustar00rootroot00000000000000{ "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": [ "combined_class.mss" ], "Layer": [ { "name": "just_land", "class": "land", "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" } }, { "name": "lakes", "id": "lakes", "class": "land", "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" } } ] } carto-0.9.5/test/rendering/combined_class.mss000066400000000000000000000003011223255147500212620ustar00rootroot00000000000000/* Applies to all layers with .land class */ .land { line-color: #ccc; line-width: 0.5; polygon-fill: #eee; } .land#lakes { line-color: #ccc; line-width: 0.5; polygon-fill: #000; } carto-0.9.5/test/rendering/combined_class.result000066400000000000000000000025211223255147500220040ustar00rootroot00000000000000 just_land lakes carto-0.9.5/test/rendering/complex_cascades.mml000066400000000000000000000016151223255147500216060ustar00rootroot00000000000000{ "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": [ "complex_cascades.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" } }] } carto-0.9.5/test/rendering/complex_cascades.mss000066400000000000000000000007331223255147500216230ustar00rootroot00000000000000#world { polygon-fill: #FFF; line-color:#F00; line-width: 0.5; } #world[NAME='United States'] { polygon-fill:#CCC; [zoom > 6] { polygon-fill:#DDD; } [zoom > 7] { polygon-fill:#999; } [zoom > 5] { polygon-fill:#666; } } #world[NAME='Canada'], #countries { polygon-fill: #eee; line-color: #ccc; line-width: 1; .new { polygon-fill: #CCC; } .new[zoom > 5] { line-width:0.5; [NAME='United States'] { polygon-fill:#AFC; } } } carto-0.9.5/test/rendering/complex_cascades.result000066400000000000000000000051151223255147500223360ustar00rootroot00000000000000 world countries carto-0.9.5/test/rendering/complexfontset.mml000066400000000000000000000016131223255147500213610ustar00rootroot00000000000000{ "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": [ "complexfontset.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" } }] } carto-0.9.5/test/rendering/complexfontset.mss000066400000000000000000000003251223255147500213750ustar00rootroot00000000000000#world { text-name: "[NAME]"; text-size: 11; text-face-name: "Georgia Regular", "Arial Italic"; } #countries { text-name: "[NAME]"; text-size: 11; text-face-name: "Georgia Regular", "Arial Italic"; } carto-0.9.5/test/rendering/complexfontset.result000066400000000000000000000026261223255147500221170ustar00rootroot00000000000000 world countries carto-0.9.5/test/rendering/cross_stylesheet_variable.mml000066400000000000000000000011321223255147500235520ustar00rootroot00000000000000{ "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": [ "cross_stylesheet_variable_a.mss", "cross_stylesheet_variable_b.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" } }] } carto-0.9.5/test/rendering/cross_stylesheet_variable.result000066400000000000000000000013341223255147500243070ustar00rootroot00000000000000 world [absolute path] shape carto-0.9.5/test/rendering/cross_stylesheet_variable_a.mss000066400000000000000000000000121223255147500240630ustar00rootroot00000000000000@b: #f00; carto-0.9.5/test/rendering/cross_stylesheet_variable_b.mss000066400000000000000000000000371223255147500240730ustar00rootroot00000000000000#world { polygon-fill: @b; } carto-0.9.5/test/rendering/data_only.mml000066400000000000000000000010001223255147500202470ustar00rootroot00000000000000{ "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": [], "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" } }] } carto-0.9.5/test/rendering/data_only.result000066400000000000000000000011401223255147500210050ustar00rootroot00000000000000 carto-0.9.5/test/rendering/empty_style.mml000066400000000000000000000010371223255147500206650ustar00rootroot00000000000000{ "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": [ "empty_style.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" } }] } carto-0.9.5/test/rendering/empty_style.mss000066400000000000000000000001441223255147500207000ustar00rootroot00000000000000#world { ::outline { line-color: #000000; } ::fill { line-color: #ffffff; } } carto-0.9.5/test/rendering/empty_style.result000066400000000000000000000016261223255147500214220ustar00rootroot00000000000000 world-outline world-fill carto-0.9.5/test/rendering/empty_url.mml000066400000000000000000000010351223255147500203250ustar00rootroot00000000000000{ "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": [ "empty_url.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" } }] } carto-0.9.5/test/rendering/empty_url.mss000066400000000000000000000000441223255147500203410ustar00rootroot00000000000000#world { marker-file:url(""); } carto-0.9.5/test/rendering/empty_url.result000066400000000000000000000013511223255147500210570ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/external_image.mml000066400000000000000000000010421223255147500212670ustar00rootroot00000000000000{ "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": [ "external_image.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" } }] } carto-0.9.5/test/rendering/external_image.mss000066400000000000000000000001251223255147500213050ustar00rootroot00000000000000#world { polygon-pattern-file: url('http://a.tile.openstreetmap.org/0/0/0.png'); } carto-0.9.5/test/rendering/external_image.result000066400000000000000000000013531223255147500220250ustar00rootroot00000000000000 world [absolute path] shape carto-0.9.5/test/rendering/fadeout.mml000066400000000000000000000010331223255147500177320ustar00rootroot00000000000000{ "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": [ "fadeout.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" } }] } carto-0.9.5/test/rendering/fadeout.mss000066400000000000000000000000601223255147500177460ustar00rootroot00000000000000#world { marker-fill: fadeout(#000, 50%); } carto-0.9.5/test/rendering/fadeout.result000066400000000000000000000013721223255147500204710ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/field.mml000066400000000000000000000010311223255147500173640ustar00rootroot00000000000000{ "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": [ "field.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" } }] } carto-0.9.5/test/rendering/field.mss000066400000000000000000000001751223255147500174110ustar00rootroot00000000000000#world { text-name: "hello " + [NAME] + " hello"; text-size: 11; text-face-name: "Georgia Regular", "Arial Italic"; } carto-0.9.5/test/rendering/field.result000066400000000000000000000016431223255147500201260ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/field_advanced.mml000066400000000000000000000010421223255147500212130ustar00rootroot00000000000000{ "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": [ "field_advanced.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" } }] } carto-0.9.5/test/rendering/field_advanced.mss000066400000000000000000000002011223255147500212240ustar00rootroot00000000000000#world { text-name: "hello " + [NAME] + " hello" + 2; text-size: 11; text-face-name: "Georgia Regular", "Arial Italic"; } carto-0.9.5/test/rendering/field_advanced.result000066400000000000000000000016451223255147500217550ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/filter_comparing_fields.mml000066400000000000000000000011051223255147500231550ustar00rootroot00000000000000{ "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": [ "filter_comparing_fields.mss" ], "Layer": [{ "name": "world", "class": "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" } }] } carto-0.9.5/test/rendering/filter_comparing_fields.mss000066400000000000000000000005241223255147500231760ustar00rootroot00000000000000#world[[FOO] = [BAR]] { polygon-fill: #FFF; line-color:#F00; line-width: 0.5; } #world[[BAR] = [HI]] { polygon-fill: #FFF; line-color:#F00; line-width: 0.5; } #world[[BAR] = [HI]] { polygon-fill: #FFF; line-color:#F00; line-width: 5; } #world[[BAR] > [HI]] { polygon-fill: #FFF; line-color:#F00; line-width: 5; } carto-0.9.5/test/rendering/filter_comparing_fields.result000066400000000000000000000022051223255147500237100ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/filterquote.mml000066400000000000000000000010401223255147500206440ustar00rootroot00000000000000{ "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": [ "filterquote.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" } }] } carto-0.9.5/test/rendering/filterquote.mss000066400000000000000000000000621223255147500206640ustar00rootroot00000000000000#world[name2=" Sa'ad"] { polygon-fill:#fff; } carto-0.9.5/test/rendering/filterquote.result000066400000000000000000000014371223255147500214070ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/filters.mml000066400000000000000000000010331223255147500177530ustar00rootroot00000000000000{ "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": [ "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" } }] } carto-0.9.5/test/rendering/filters.mss000066400000000000000000000001321223255147500177670ustar00rootroot00000000000000#world[[POP2005] > 100.1] { polygon-fill: #FFF; line-color:#F00; line-width: 0.5; } carto-0.9.5/test/rendering/filters.result000066400000000000000000000015301223255147500205060ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/filtervariable.mml000066400000000000000000000010431223255147500212770ustar00rootroot00000000000000{ "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": [ "filtervariable.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" } }] } carto-0.9.5/test/rendering/filtervariable.mss000066400000000000000000000002001223255147500213060ustar00rootroot00000000000000@us: 'US'; @thing: [COUNTRY]; #world[COUNTRY=@us] { polygon-fill: #000; } #world[@thing != 'US'] { polygon-fill: #f00; } carto-0.9.5/test/rendering/filtervariable.result000066400000000000000000000016041223255147500220330ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/fontset-duplication.mml000066400000000000000000000017541223255147500223100ustar00rootroot00000000000000{ "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":[ "fontset-duplication.mss" ], "Layer":[ { "id":"city", "name":"city", "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", "class":"", "Datasource":{ "file":"http://tilemill-data.s3.amazonaws.com/natural-earth-10m-1.3.0/populated_places_simple.zip", "type":"shape" }, "geometry":"point" }, { "id":"country-label", "name":"country-label", "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", "class":"", "Datasource":{ "file":"http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip", "type":"shape" }, "geometry":"point" } ] } carto-0.9.5/test/rendering/fontset-duplication.mss000066400000000000000000000077171223255147500223320ustar00rootroot00000000000000/* Font sets */ @gothic_book: "Franklin Gothic FS Book","DejaVu Sans Book"; @gothic_med: "Franklin Gothic FS Medium","DejaVu Sans Book"; /* ---- COUNTRIES ---- */ #country-label[zoom>1][zoom<10]{ text-face-name: @gothic_book; text-fill:rgba(0,0,0,0.5); text-size:9; text-transform:uppercase; text-halo-fill:rgba(255,255,255,0.5); text-halo-radius:1; text-character-spacing:1; text-line-spacing:1; text-wrap-width:20; text-name:"''"; [zoom=3] { text-size:9; } [zoom=4] { text-size:11; } [zoom=5] { text-size:12; text-character-spacing:1; text-line-spacing:1; } [zoom=6] { text-size:14; text-character-spacing:2; text-line-spacing:2; } [zoom>6][zoom<10] { text-size:16; text-character-spacing:2; text-line-spacing:4; } [zoom>=2][Z_ABBREV = 2], [zoom>=3][Z_ABBREV = 3], [zoom>=4][Z_ABBREV = 4], [zoom>=5][Z_ABBREV = 5], [zoom>=6][Z_ABBREV = 6] { text-name: "[ABBREV]"; } [zoom>=2][Z_NAME = 2], [zoom>=3][Z_NAME = 3], [zoom>=4][Z_NAME = 4], [zoom>=5][Z_NAME = 5], [zoom>=6][Z_NAME = 6] { text-name: "[NAME]"; } [zoom>=2][Z_ADMIN = 2], [zoom>=3][Z_ADMIN = 3], [zoom>=4][Z_ADMIN = 4], [zoom>=5][Z_ADMIN = 5], [zoom>=6][Z_ADMIN = 6] { text-name: "[ADMIN]"; } } /* ---- CITIES ---- */ #city { [SCALERANK<3][zoom>=4], [SCALERANK=3][zoom>=5], [SCALERANK=4][zoom>=5], [SCALERANK=5][zoom>=6], [SCALERANK=6][zoom>=6], [SCALERANK=7][zoom>=7], [SCALERANK=8][zoom>=7], [SCALERANK=9][zoom>=8], [SCALERANK=10][zoom>=8] { text-name: "[NAMEASCII]"; text-face-name: @gothic_med; text-size: 10; text-fill: rgba(0,0,0,0.6); text-halo-radius: 1; text-halo-fill: rgba(255,255,255,0.4); } [zoom=4] { [SCALERANK<3] { text-size: 12; } } [zoom=5] { [SCALERANK<3] { text-size: 13; } [SCALERANK=3] { text-size: 12; } [SCALERANK=4] { text-size: 11; } } [zoom=6] { [SCALERANK<3] { text-size: 14; } [SCALERANK=3] { text-size: 13; } [SCALERANK=4] { text-size: 12; } [SCALERANK=5] { text-size: 11; } } [zoom=7] { [SCALERANK<3] { text-size: 15; } [SCALERANK=3] { text-size: 14; } [SCALERANK=4] { text-size: 13; } [SCALERANK=5] { text-size: 12; } [SCALERANK=6] { text-size: 11; } [SCALERANK=7] { text-size: 11; } } [zoom=8] { [SCALERANK<3] { text-size: 15; } [SCALERANK=3] { text-size: 15; } [SCALERANK=4] { text-size: 14; } [SCALERANK=5] { text-size: 14; } [SCALERANK=6] { text-size: 13; } [SCALERANK=7] { text-size: 13; } [SCALERANK=8] { text-size: 12; } [SCALERANK=9] { text-size: 11; } } [zoom=9] { [SCALERANK<3] { text-size: 16; } [SCALERANK=3] { text-size: 16; } [SCALERANK=4] { text-size: 15; } [SCALERANK=5] { text-size: 15; } [SCALERANK=6] { text-size: 14; } [SCALERANK=7] { text-size: 14; } [SCALERANK=8] { text-size: 13; } [SCALERANK=9] { text-size: 13; } [SCALERANK=10] { text-size: 12; } } [zoom=10] { [SCALERANK<3] { text-size: 16; text-character-spacing:2; } [SCALERANK=3] { text-size: 16; text-character-spacing:2; } [SCALERANK=4] { text-size: 15; text-character-spacing:1; } [SCALERANK=5] { text-size: 15; text-character-spacing:1; } [SCALERANK=6] { text-size: 15; text-character-spacing:1; } [SCALERANK=7] { text-size: 14; } [SCALERANK=8] { text-size: 14; } [SCALERANK=9] { text-size: 13; } [SCALERANK=10] { text-size: 13; } } [zoom>10] { [SCALERANK<3] { text-size: 16; text-character-spacing:3; } [SCALERANK=3] { text-size: 16; text-character-spacing:3; } [SCALERANK=4] { text-size: 16; text-character-spacing:3; } [SCALERANK=5] { text-size: 15; text-character-spacing:2; } [SCALERANK=6] { text-size: 15; text-character-spacing:2; } [SCALERANK=7] { text-size: 15; text-character-spacing:2; } [SCALERANK=8] { text-size: 14; text-character-spacing:1; } [SCALERANK=9] { text-size: 14; text-character-spacing:1; } [SCALERANK=10] { text-size: 14; text-character-spacing:1; } } } carto-0.9.5/test/rendering/fontset-duplication.result000066400000000000000000013310261223255147500230400ustar00rootroot00000000000000 city country-label carto-0.9.5/test/rendering/gray_function.mml000066400000000000000000000010411223255147500211510ustar00rootroot00000000000000{ "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": [ "gray_function.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" } }] } carto-0.9.5/test/rendering/gray_function.mss000066400000000000000000000000421223255147500211660ustar00rootroot00000000000000#world { polygon-fill:gray; } carto-0.9.5/test/rendering/gray_function.result000066400000000000000000000013601223255147500217060ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/highzooms.mml000066400000000000000000000010351223255147500203140ustar00rootroot00000000000000{ "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": [ "highzooms.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" } }] } carto-0.9.5/test/rendering/highzooms.mss000066400000000000000000000004131223255147500203300ustar00rootroot00000000000000#world { polygon-fill: #000; [zoom=22] { polygon-fill: #f00000; } [zoom=21] { polygon-fill: #0f0000; } [zoom=20] { polygon-fill: #00f000; } [zoom=19] { polygon-fill: #000f00; } [zoom=18] { polygon-fill: #0000f0; } [zoom=17] { polygon-fill: #00000f; } } carto-0.9.5/test/rendering/highzooms.result000066400000000000000000000033111223255147500210440ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/identity.mml000066400000000000000000000010341223255147500201350ustar00rootroot00000000000000{ "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": [ "identity.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" } }] } carto-0.9.5/test/rendering/identity.mss000066400000000000000000000001151223255147500201510ustar00rootroot00000000000000#world[foo='bar'] { #world[foo='bar'] { marker-width: 5; } } carto-0.9.5/test/rendering/identity.result000066400000000000000000000014171223255147500206730ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/image_filters.mml000066400000000000000000000010411223255147500211140ustar00rootroot00000000000000{ "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": [ "image_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" } }] } carto-0.9.5/test/rendering/image_filters.mss000066400000000000000000000002541223255147500211360ustar00rootroot00000000000000#world { polygon-fill: #FFF; line-color:#F00; line-width: 0.5; image-filters: blur(), sharpen(), agg-stack-blur(2, 2); comp-op: src-in; line-dasharray: 2, 3; } carto-0.9.5/test/rendering/image_filters.result000066400000000000000000000016041223255147500216520ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/imagefilter-duplication.mml000066400000000000000000000010541223255147500231070ustar00rootroot00000000000000{ "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": [ "imagefilter-duplication.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" } }] } carto-0.9.5/test/rendering/imagefilter-duplication.mss000066400000000000000000000001621223255147500231230ustar00rootroot00000000000000#world { image-filters:agg-stack-blur(3,3); [zoom=2] { line-width: 3; } [zoom=3] { line-width: 5; } } carto-0.9.5/test/rendering/imagefilter-duplication.result000066400000000000000000000020601223255147500236360ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/instance_names.mml000066400000000000000000000010421223255147500212720ustar00rootroot00000000000000{ "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": [ "instance_names.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" } }] } carto-0.9.5/test/rendering/instance_names.mss000066400000000000000000000004151223255147500213120ustar00rootroot00000000000000#world[zoom >= 13] { center/line-width: 1; center/line-color: black; } #world[zoom >= 14] { center/line-width: 5; center/line-color: blue; } #world[highway='primary'][zoom >= 14] { dash/line-color: red; dash/line-width: 15; dash/line-dasharray: 5,15; } carto-0.9.5/test/rendering/instance_names.result000066400000000000000000000027211223255147500220300ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/issue294.mml000066400000000000000000000005551223255147500177020ustar00rootroot00000000000000{ "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": [], "Layer": [{ "name": "world", "Datasource": { "file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip", "type": "shape" } }] } carto-0.9.5/test/rendering/issue294.result000066400000000000000000000007351223255147500204330ustar00rootroot00000000000000 carto-0.9.5/test/rendering/issue32.mml000066400000000000000000000010631223255147500176030ustar00rootroot00000000000000{ "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": [ "issue32a.mss", "issue32.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" } }] } carto-0.9.5/test/rendering/issue32.mss000066400000000000000000000000461223255147500176200ustar00rootroot00000000000000Map { background-color: #aaaaff; } carto-0.9.5/test/rendering/issue32.result000066400000000000000000000017121223255147500203350ustar00rootroot00000000000000 world-outline world carto-0.9.5/test/rendering/issue32a.mss000066400000000000000000000001731223255147500177620ustar00rootroot00000000000000#world { ::outline { line-color: #000000; line-width: 8.0; } line-color: #ffffff; line-width: 6.0; } carto-0.9.5/test/rendering/issue60.mml000066400000000000000000000010331223255147500176010ustar00rootroot00000000000000{ "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": [ "issue60.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" } }] } carto-0.9.5/test/rendering/issue60.mss000066400000000000000000000003011223255147500176130ustar00rootroot00000000000000#world { [NET_INFLOW > -30000] { polygon-fill: #f00; } [NET_INFLOW > -10000] { polygon-fill: #0f0; } } #world [OBJECTID=12] { polygon-pattern-file:url(../resources/textures/stripe.png); } carto-0.9.5/test/rendering/issue60.result000066400000000000000000000025711223255147500203420ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/issue_100_filters.mml000066400000000000000000000010451223255147500215460ustar00rootroot00000000000000{ "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" } }] } carto-0.9.5/test/rendering/issue_100_filters.mss000066400000000000000000000006131223255147500215630ustar00rootroot00000000000000#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; } carto-0.9.5/test/rendering/issue_100_filters.result000066400000000000000000000053161223255147500223040ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/issue_239.mml000066400000000000000000000016051223255147500200350ustar00rootroot00000000000000{ "bounds": [ -180, -85.05112877980659, 180, 85.05112877980659 ], "center": [ 0, 0, 2 ], "format": "png", "interactivity": false, "minzoom": 0, "maxzoom": 22, "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_239_a.mss", "issue_239_b.mss" ], "Layer": [ { "id": "countries", "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", "geometry": "polygon", "Datasource": { "file": "http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.4.0/cultural/10m-admin-0-countries.zip", "type": "shape" } } ], "scale": 1, "metatile": 2, "name": "", "description": "" }carto-0.9.5/test/rendering/issue_239.result000066400000000000000000000025071223255147500205700ustar00rootroot00000000000000 -180,-85.05112877980659,180,85.05112877980659 0,0,2 png 0 22 1 2 countries-fill countries-outline [absolute path] carto-0.9.5/test/rendering/issue_239_a.mss000066400000000000000000000002221223255147500203440ustar00rootroot00000000000000// Only the coastlines should be visible, // not land boundaries. #countries::outline { line-color: #024; line-width: 2; line-join: round; }carto-0.9.5/test/rendering/issue_239_b.mss000066400000000000000000000001661223255147500203540ustar00rootroot00000000000000// This attachment should cover most of the outlines #countries::fill { polygon-fill: #ace; polygon-gamma: 0.3; } carto-0.9.5/test/rendering/layer_nodatasource.mml000066400000000000000000000006211223255147500221700ustar00rootroot00000000000000{ "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": [ "layer_nodatasource.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" }] } carto-0.9.5/test/rendering/layer_nodatasource.mss000066400000000000000000000001031223255147500222000ustar00rootroot00000000000000#world { polygon-fill: green; line-color: hsl(30, 40%, 90%); } carto-0.9.5/test/rendering/layer_nodatasource.result000066400000000000000000000011641223255147500227240ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/layer_properties.mml000066400000000000000000000011541223255147500216770ustar00rootroot00000000000000{ "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": [ "layer_properties.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", "properties": { "cache-features": "true" }, "Datasource": { "file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip", "type": "shape" } }] } carto-0.9.5/test/rendering/layer_properties.mss000066400000000000000000000001031223255147500217050ustar00rootroot00000000000000#world { polygon-fill: green; line-color: hsl(30, 40%, 90%); } carto-0.9.5/test/rendering/layer_properties.result000066400000000000000000000014621223255147500224320ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/mapnik_keyword.mml000066400000000000000000000010421223255147500213260ustar00rootroot00000000000000{ "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": [ "mapnik_keyword.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" } }] } carto-0.9.5/test/rendering/mapnik_keyword.mss000066400000000000000000000000511223255147500213420ustar00rootroot00000000000000#world[[FOO]=null] { line-width:2; } carto-0.9.5/test/rendering/mapnik_keyword.result000066400000000000000000000014231223255147500220620ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/modulus.mml000066400000000000000000000010331223255147500177730ustar00rootroot00000000000000{ "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" } }] } carto-0.9.5/test/rendering/modulus.mss000066400000000000000000000001551223255147500200140ustar00rootroot00000000000000#world { text-name: "hello "; text-size: 11 % 2; text-face-name: "Georgia Regular", "Arial Italic"; } carto-0.9.5/test/rendering/modulus.result000066400000000000000000000016201223255147500205260ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/multiple_symbolizers.mml000066400000000000000000000010501223255147500225770ustar00rootroot00000000000000{ "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": [ "multiple_symbolizers.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" } }] } carto-0.9.5/test/rendering/multiple_symbolizers.mss000066400000000000000000000001321223255147500226140ustar00rootroot00000000000000#world { polygon-fill: #fff; line-width: 2; alternate/line-color: #f00; } carto-0.9.5/test/rendering/multiple_symbolizers.result000066400000000000000000000014521223255147500233360ustar00rootroot00000000000000 world [absolute path] shape carto-0.9.5/test/rendering/nesting_class.mml000066400000000000000000000016771223255147500211550ustar00rootroot00000000000000{ "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": [ "nesting_class.mss" ], "Layer": [ { "name": "foo", "class": "land", "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" } }, { "name": "lakes", "id": "lakes", "class": "land", "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" } } ] } carto-0.9.5/test/rendering/nesting_class.mss000066400000000000000000000002721223255147500211600ustar00rootroot00000000000000/* Applies to all layers with .land class */ .land { line-color: #ccc; line-width: 0.5; polygon-fill: #eee; /* Applies to #lakes.land */ #lakes { polygon-fill: #000; } } carto-0.9.5/test/rendering/nesting_class.result000066400000000000000000000024771223255147500217050ustar00rootroot00000000000000 foo lakes carto-0.9.5/test/rendering/nominzoom.mml000066400000000000000000000010351223255147500203320ustar00rootroot00000000000000{ "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": [ "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.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" } }] } carto-0.9.5/test/rendering/nominzoom.mss000066400000000000000000000000531223255147500203460ustar00rootroot00000000000000#world[zoom < 5] { polygon-fill: #000; } carto-0.9.5/test/rendering/nominzoom.result000066400000000000000000000014501223255147500210640ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/noquote_font.mml000066400000000000000000000010401223255147500210210ustar00rootroot00000000000000{ "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": [ "noquote_font.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" } }] } carto-0.9.5/test/rendering/noquote_font.mss000066400000000000000000000001001223255147500210320ustar00rootroot00000000000000#world { text-name: 'foo'; text-face-name: Helvetica; } carto-0.9.5/test/rendering/noquote_font.result000066400000000000000000000014231223255147500215570ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/parameters.mml000066400000000000000000000013601223255147500204510ustar00rootroot00000000000000{ "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", "bounds": [-180,-85,180,85], "center": [-78,40,8], "name": "Parameters", "description": "Mapnik parameter test.", "legend": "

This is HTML.

", "attribution": "OpenStreetMap", "template": "{{NAME}}", "minzoom": 0, "maxzoom": 12, "version": "1.0.0", "format": "png", "interactivity": { "layer": "world", "fields": ["NAME"] }, "customString": "Hello world", "customNumber": 5, "customBoolean": true, "customOmitted": { "foo": "bar" }, "Stylesheet": [], "Layer": [] } carto-0.9.5/test/rendering/parameters.result000066400000000000000000000024011223255147500211770ustar00rootroot00000000000000 -180,-85,180,85 -78,40,8 This is HTML.

]]>
OpenStreetMap]]> {{NAME}}]]> 0 12 1.0.0 png world NAME 5 true
carto-0.9.5/test/rendering/partial_overrides.mml000066400000000000000000000011421223255147500220220ustar00rootroot00000000000000{ "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": [ "partial_overrides.mss" ], "Layer": [{ "name": "world", "class": "m_0 m_1 m_2 m_3 m_4 m_5 m_6 m_7 m_8 m_9", "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" } }] } carto-0.9.5/test/rendering/partial_overrides.mss000066400000000000000000000007711223255147500220460ustar00rootroot00000000000000#world.m_0 { line-width: 3; } #world.m_1[zoom > 2] { line-opacity: .2; } #world.m_2[zoom > 8] { line-opacity: .4; } #world.m_3[NAME!="Canada"] { line-width: 5; } #world.m_4[NAME="United States"] { line-color: #f00; } #world.m_6[NAME!="Canada"][zoom > 5] { line-opacity: .7; } #world.m_7[NAME!="Canada"][POP > 100000000] { line-width:20; } #world.m_8[NAME="United States"][zoom > 8] { line-opacity: .5; } #world.m_9[NAME="United States"][zoom > 8][zoom < 4] { line-opacity: .5; } carto-0.9.5/test/rendering/partial_overrides.result000066400000000000000000000102471223255147500225610ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/raster-mesh-size.mml000066400000000000000000000010741223255147500215120ustar00rootroot00000000000000{ "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": [ "raster-mesh-size.mss" ], "Layer": [{ "name": "data", "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/nasa_raster/lasvegas_tm5_12jan09_crop_geo_merc.tif", "type": "gdal" } }] } carto-0.9.5/test/rendering/raster-mesh-size.mss000066400000000000000000000000721223255147500215240ustar00rootroot00000000000000#data { raster-opacity: 1; raster-mesh-size: 1; } carto-0.9.5/test/rendering/raster-mesh-size.result000066400000000000000000000013431223255147500222420ustar00rootroot00000000000000 data [absolute path] gdal carto-0.9.5/test/rendering/raster.mml000066400000000000000000000010621223255147500176050ustar00rootroot00000000000000{ "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": [ "raster.mss" ], "Layer": [{ "name": "data", "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/nasa_raster/lasvegas_tm5_12jan09_crop_geo_merc.tif", "type": "gdal" } }] } carto-0.9.5/test/rendering/raster.mss000066400000000000000000000001011223255147500176130ustar00rootroot00000000000000#data { raster-opacity: 1; raster-comp-op: hard-light; } carto-0.9.5/test/rendering/raster.result000066400000000000000000000013521223255147500203400ustar00rootroot00000000000000 data [absolute path] gdal carto-0.9.5/test/rendering/raster_colorizer.mml000066400000000000000000000010441223255147500216750ustar00rootroot00000000000000{ "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": [ "raster_colorizer.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" } }] } carto-0.9.5/test/rendering/raster_colorizer.mss000066400000000000000000000004221223255147500217110ustar00rootroot00000000000000#world { raster-opacity:1; raster-scaling:bilinear; raster-colorizer-default-mode: linear; raster-colorizer-default-color: transparent; raster-colorizer-stops: stop(0,#000) stop(1000, #00f) stop(2000, #0ff) stop(3000, #ff0) stop(4000, #f00); } carto-0.9.5/test/rendering/raster_colorizer.result000066400000000000000000000020131223255147500224230ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/raster_colorizer_comma.mml000066400000000000000000000010521223255147500230500ustar00rootroot00000000000000{ "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": [ "raster_colorizer_comma.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" } }] } carto-0.9.5/test/rendering/raster_colorizer_comma.mss000066400000000000000000000002131223255147500230630ustar00rootroot00000000000000#world { raster-colorizer-stops: stop(0,#000) stop(1000, #00f) stop(2000, #0ff) stop(3000, #ff0) stop(4000, #f00); } carto-0.9.5/test/rendering/raster_colorizer_comma.result000066400000000000000000000016651223255147500236130ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/raster_colorizer_onestop.mml000066400000000000000000000010541223255147500234450ustar00rootroot00000000000000{ "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": [ "raster_colorizer_onestop.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" } }] } carto-0.9.5/test/rendering/raster_colorizer_onestop.mss000066400000000000000000000002721223255147500234630ustar00rootroot00000000000000#world { raster-opacity:1; raster-scaling:bilinear; raster-colorizer-default-mode: linear; raster-colorizer-default-color: transparent; raster-colorizer-stops: stop(0,#000); } carto-0.9.5/test/rendering/raster_colorizer_onestop.result000066400000000000000000000015531223255147500242020ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/rastercolorizer.mml000066400000000000000000000010421223255147500215340ustar00rootroot00000000000000{ "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": [ "rastercolorizer.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" } }] }carto-0.9.5/test/rendering/rastercolorizer.mss000066400000000000000000000003531223255147500215550ustar00rootroot00000000000000#world { raster-opacity:0; raster-colorizer-default-mode:discrete; raster-colorizer-default-color:#f00; raster-colorizer-epsilon:0.05; raster-colorizer-stops: stop(5, #f00) stop(10, #f40, linear) stop(10, #f80); }carto-0.9.5/test/rendering/rastercolorizer.result000066400000000000000000000016571223255147500223010ustar00rootroot00000000000000 world [absolute path] carto-0.9.5/test/rendering/regex.mml000066400000000000000000000010311223255147500174130ustar00rootroot00000000000000{ "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": [ "regex.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" } }] } carto-0.9.5/test/rendering/regex.mss000066400000000000000000000001241223255147500174320ustar00rootroot00000000000000#world[ISO =~ "U*"] { polygon-fill: #FFF; line-color:#F00; line-width: 0.5; } carto-0.9.5/test/rendering/regex.result000066400000000000000000000015231223255147500201520ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/regex_nest.mml000066400000000000000000000010401223255147500204440ustar00rootroot00000000000000{ "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": [ "regex_nest.mss" ], "Layer": [{ "name": "railway", "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" } }] } carto-0.9.5/test/rendering/regex_nest.mss000066400000000000000000000001511223255147500204630ustar00rootroot00000000000000#railway[foo='bar'] { [name =~ "East.*"] { line-color: green; line-width: 4; } } carto-0.9.5/test/rendering/regex_nest.result000066400000000000000000000015101223255147500211770ustar00rootroot00000000000000 railway carto-0.9.5/test/rendering/selector_comment.mml000066400000000000000000000015611223255147500216530ustar00rootroot00000000000000{ "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": [ "selector_comment.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" } }, { "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" } }] } carto-0.9.5/test/rendering/selector_comment.mss000066400000000000000000000000721223255147500216640ustar00rootroot00000000000000#world, // bar // blah #countries { marker-width:4; } carto-0.9.5/test/rendering/selector_comment.result000066400000000000000000000023171223255147500224040ustar00rootroot00000000000000 world countries carto-0.9.5/test/rendering/sharedclass.mml000066400000000000000000000017111223255147500206020ustar00rootroot00000000000000{ "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": [ "sharedclass.mss" ], "Layer": [ { "id": "ab", "name": "ab", "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", "geometry": "polygon", "Datasource": { "file": "http://tilemill-data.s3.amazonaws.com/world_borders_merc.zip", "type": "shape" }, "class": "a b" }, { "Datasource": { "file": "http://tilemill-data.s3.amazonaws.com/world_borders_merc.zip", "type": "shape" }, "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", "id": "bc", "name": "bc", "class": "b c", "geometry": "polygon" } ] } carto-0.9.5/test/rendering/sharedclass.mss000066400000000000000000000001261223255147500206160ustar00rootroot00000000000000.a { polygon-fill: #f00; } .b { line-color: #0f0; } .c { marker-fill: #00f; } carto-0.9.5/test/rendering/sharedclass.result000066400000000000000000000024161223255147500213360ustar00rootroot00000000000000 ab bc carto-0.9.5/test/rendering/simplefontset.mml000066400000000000000000000010421223255147500211770ustar00rootroot00000000000000{ "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": [ "simplefontset.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" } }] } carto-0.9.5/test/rendering/simplefontset.mss000066400000000000000000000001501223255147500212130ustar00rootroot00000000000000#world { text-name: "[NAME]"; text-size: 11; text-face-name: "Georgia Regular", "Arial Italic"; } carto-0.9.5/test/rendering/simplefontset.result000066400000000000000000000015621223255147500217370ustar00rootroot00000000000000 world [absolute path] shape carto-0.9.5/test/rendering/simplevariabletest.mml000066400000000000000000000010471223255147500222070ustar00rootroot00000000000000{ "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": [ "simplevariabletest.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" } }] } carto-0.9.5/test/rendering/simplevariabletest.mss000066400000000000000000000001061223255147500222170ustar00rootroot00000000000000@worldbackground: #fff; #world { polygon-fill: @worldbackground; } carto-0.9.5/test/rendering/simplevariabletest.result000066400000000000000000000013341223255147500227370ustar00rootroot00000000000000 world [absolute path] shape carto-0.9.5/test/rendering/style_level_opacity.mml000066400000000000000000000010471223255147500223670ustar00rootroot00000000000000{ "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": [ "style_level_opacity.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" } }] } carto-0.9.5/test/rendering/style_level_opacity.mss000066400000000000000000000001671223255147500224060ustar00rootroot00000000000000#world { opacity:0.2; text-name: "[NAME]"; text-size: 11; text-face-name: "Georgia Regular", "Arial Italic"; } carto-0.9.5/test/rendering/style_level_opacity.result000066400000000000000000000016401223255147500231170ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/support4504.mml000066400000000000000000000010731223255147500203400ustar00rootroot00000000000000{ "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": [ "support4504.mss" ], "Layer": [{ "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" } }] } carto-0.9.5/test/rendering/support4504.mss000066400000000000000000000001761223255147500203600ustar00rootroot00000000000000@z13: 19; @num_pixels: 50; @z13area: @z13 * @z13 * @num_pixels; #countries[way_area > @z13area] { polygon-opacity:0.2; } carto-0.9.5/test/rendering/support4504.result000066400000000000000000000014551223255147500210750ustar00rootroot00000000000000 countries carto-0.9.5/test/rendering/symbolizer_order.mml000066400000000000000000000010441223255147500216770ustar00rootroot00000000000000{ "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": [ "symbolizer_order.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" } }] } carto-0.9.5/test/rendering/symbolizer_order.mss000066400000000000000000000000721223255147500217140ustar00rootroot00000000000000#world { polygon-fill: #fff; line-width: 2; } carto-0.9.5/test/rendering/symbolizer_order.result000066400000000000000000000014031223255147500224270ustar00rootroot00000000000000 world [absolute path] shape carto-0.9.5/test/rendering/text_property_overrides.mml000066400000000000000000000011471223255147500233230ustar00rootroot00000000000000{ "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": [ "text_property_overrides.mss" ], "Layer": [{ "name": "world", "class": "m_0 m_1 m_2 m_3 m_4 m_5 m_6 m_7 m_8 m_9", "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" } }] } carto-0.9.5/test/rendering/text_property_overrides.mss000066400000000000000000000003251223255147500233350ustar00rootroot00000000000000#world[zoom>3] { text-name:"[COUNTRY]"; text-face-name:"DejaVu Sans Book"; text-fill:#000; text-size:9; } #world[zoom=5] { text-size:10; } #world[zoom=6] { text-size:11; } #world[zoom=7] { text-size:12; } carto-0.9.5/test/rendering/text_property_overrides.result000066400000000000000000000030121223255147500240450ustar00rootroot00000000000000 world [absolute path] shape carto-0.9.5/test/rendering/transforms.mml000066400000000000000000000010361223255147500205040ustar00rootroot00000000000000{ "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": [ "transforms.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" } }] } carto-0.9.5/test/rendering/transforms.mss000066400000000000000000000001451223255147500205210ustar00rootroot00000000000000@trans: 2; #world { point-file: url(foo.png); point-transform: translate( @trans * 2, @trans); } carto-0.9.5/test/rendering/transforms.result000066400000000000000000000014211223255147500212330ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/transforms_backwards.mml000066400000000000000000000010501223255147500225210ustar00rootroot00000000000000{ "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": [ "transforms_backwards.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" } }] } carto-0.9.5/test/rendering/transforms_backwards.mss000066400000000000000000000001321223255147500225360ustar00rootroot00000000000000#world { point-file: url(foo.png); point-transform: "translate(2, 2), scale(2, 2)"; } carto-0.9.5/test/rendering/transforms_backwards.result000066400000000000000000000014371223255147500232630ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/transforms_field.mml000066400000000000000000000010441223255147500216460ustar00rootroot00000000000000{ "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": [ "transforms_field.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" } }] } carto-0.9.5/test/rendering/transforms_field.mss000066400000000000000000000001571223255147500216670ustar00rootroot00000000000000#world { point-file:url(foo.png); point-transform: scale(2 * 5 * [POP2005], [POP2005]), rotate(10,1,-1); } carto-0.9.5/test/rendering/transforms_field.result000066400000000000000000000014611223255147500224020ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/transforms_single.mml000066400000000000000000000010451223255147500220450ustar00rootroot00000000000000{ "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": [ "transforms_single.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" } }] } carto-0.9.5/test/rendering/transforms_single.mss000066400000000000000000000000531223255147500220600ustar00rootroot00000000000000#world { point-transform: scale(2, 2); } carto-0.9.5/test/rendering/transforms_single.result000066400000000000000000000013651223255147500226030ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/units.mml000066400000000000000000000010311223255147500174430ustar00rootroot00000000000000{ "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": [ "units.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" } }] } carto-0.9.5/test/rendering/units.mss000066400000000000000000000001521223255147500174630ustar00rootroot00000000000000#world { line-width: 2mm; marker-width: 2pc; marker-height: 5pt; building-height: 10cm; } carto-0.9.5/test/rendering/units.result000066400000000000000000000015721223255147500202060ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/unsigned.mml000066400000000000000000000010341223255147500201200ustar00rootroot00000000000000{ "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" } }] } carto-0.9.5/test/rendering/unsigned.mss000066400000000000000000000002201223255147500201310ustar00rootroot00000000000000#world { text-size:10.5; text-ratio:2.1; text-wrap-width:5; text-spacing:12.1; text-name:[FOO]; text-face-name:'Foo'; } carto-0.9.5/test/rendering/unsigned.result000066400000000000000000000015061223255147500206550ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/var_concat.mml000066400000000000000000000010361223255147500204250ustar00rootroot00000000000000{ "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": [ "var_concat.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" } }] } carto-0.9.5/test/rendering/var_concat.mss000066400000000000000000000001301223255147500204340ustar00rootroot00000000000000@var: 'foo'; #world { text-face-name: 'Helvetica'; text-name: @var + ' bar'; } carto-0.9.5/test/rendering/var_concat.result000066400000000000000000000014271223255147500211620ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/weird_comments.mml000066400000000000000000000010411223255147500213210ustar00rootroot00000000000000{ "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": [ "weird_comments.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" } }] }carto-0.9.5/test/rendering/weird_comments.mss000066400000000000000000000004171223255147500213440ustar00rootroot00000000000000#world { polygon-fill: #A22; } /* comment */ /* #world { line-opacity:0.5; } #world { line-width:10; } #world { line-color:#0ff; } */ /* *//* { *//* *//* *//* */#world { polygon-fill:#A33; }/* } */ /* { *//* [ ] *//* *//* { } *//* #world { polygon-fill:#a00; } */carto-0.9.5/test/rendering/weird_comments.result000066400000000000000000000012641223255147500220610ustar00rootroot00000000000000 world [absolute path] shape carto-0.9.5/test/rendering/weird_comments_2.mml000066400000000000000000000010441223255147500215450ustar00rootroot00000000000000{ "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": [ "weird_comments_2.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" } }] } carto-0.9.5/test/rendering/weird_comments_2.mss000066400000000000000000000001741223255147500215650ustar00rootroot00000000000000#world { [ne_10m_adm = 'GBR'], /* United Kingdom */ [ne_10m_adm = 'FRA'] /* France */ { polygon-fill: #fff; } } carto-0.9.5/test/rendering/weird_comments_2.result000066400000000000000000000016041223255147500223000ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/weird_simple_comments.mml000066400000000000000000000010511223255147500226730ustar00rootroot00000000000000{ "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": [ "weird_simple_comments.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" } }] } carto-0.9.5/test/rendering/weird_simple_comments.mss000066400000000000000000000005621223255147500227160ustar00rootroot00000000000000#world { one/marker-file: url(http://upload.wikimedia.org/wikipedia/commons/7/72/Cup_of_coffee.svg); two/marker-file: url('http://upload.wikimedia.org/wikipedia/commons/7/72/Cup_of_coffee.svg'); three/marker-file: url(http://upload.wikimedia.org/wikipedia/en/c/ce/SVG-logo.svg); four/marker-file: url("http://a.tiles.mapbox.com/v3/marker/pin-m-fast-food+AA0000.png"); } carto-0.9.5/test/rendering/weird_simple_comments.result000066400000000000000000000016131223255147500234300ustar00rootroot00000000000000 world carto-0.9.5/test/rendering/zoomlevels.mml000066400000000000000000000015601223255147500205070ustar00rootroot00000000000000{ "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": [ "zoomlevels.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" } }, { "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" } }] } carto-0.9.5/test/rendering/zoomlevels.mss000066400000000000000000000010111223255147500205130ustar00rootroot00000000000000#world[zoom=9] { polygon-fill: #000; [zoom > 9] { polygon-fill: #FFF; } } #world[zoom<4] { polygon-fill: #FF0; } #countries { [zoom=1] { line-width:2; } [zoom=2] { line-width:1.5; } [zoom=3], [zoom=4] { line-width:1.25; } [zoom=5] { line-width:1; } [zoom=6] { line-width:0.9; } [zoom=7] { line-width:0.8; } [zoom=8] { line-width:0.7; } [zoom=9] { line-width:.6; } [zoom=10] { line-width:.5; } [zoom=11] { line-width:.4; } [zoom=12] { line-width:.3; } [zoom>12] { line-width:.25; } }carto-0.9.5/test/rendering/zoomlevels.result000066400000000000000000000070141223255147500212400ustar00rootroot00000000000000 world countries carto-0.9.5/test/rendering/zoomselector.mml000066400000000000000000000011141223255147500210300ustar00rootroot00000000000000{ "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": [ "zoomselector.mss" ], "Layer": [{ "name": "world", "id": "world", "class": "", "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" } }] } carto-0.9.5/test/rendering/zoomselector.mss000066400000000000000000000002501223255147500210450ustar00rootroot00000000000000#world { [zoom=9] { marker-height: 4; } [zoom>6][zoom<10] { marker-height: 3; } [zoom>3][zoom<7] { marker-height: 2; } [zoom<4] { marker-height: 1; } } carto-0.9.5/test/rendering/zoomselector.result000066400000000000000000000021671223255147500215720ustar00rootroot00000000000000 world carto-0.9.5/test/specificity.test.js000066400000000000000000000040261223255147500174530ustar00rootroot00000000000000var path = require('path'), assert = require('assert'), fs = require('fs'); var carto = require('../lib/carto'); var tree = require('../lib/carto').tree; var helper = require('./support/helper'); function cleanupItem(key, value) { if (key === 'rules') return; else if (key === 'ruleIndex') return; else if (key === 'elements') return value.map(function(item) { return item.value; }); else if (key === 'filters') { var arr = []; for (var id in value.filters) arr.push(id + value.filters[id].val); if (arr.length) return arr; } else if (key === 'attachment' && value === '__default__') return; else if (key === 'zoom') { if (value != tree.Zoom.all) return (new tree.Zoom()).setZoom(value).toString(); } else return value; } describe('Specificity', function() { helper.files('specificity', 'mss', function(file) { it('should handle spec correctly in ' + file, function(done) { helper.file(file, function(content) { var tree = (new carto.Parser({ paths: [ path.dirname(file) ], filename: file })).parse(content); var mss = tree.toList({}); mss = helper.makePlain(mss, cleanupItem); var json = JSON.parse(fs.readFileSync(helper.resultFile(file))); var actual = file.replace(path.extname(file),'') + '-actual.json'; var expected = file.replace(path.extname(file),'') + '-expected.json'; try { assert.deepEqual(mss, json); // cleanup any actual renders that no longer fail try { fs.unlinkSync(actual); fs.unlinkSync(expected); } catch (err) {} } catch (err) { fs.writeFileSync(actual,JSON.stringify(mss,null,4)); fs.writeFileSync(expected,JSON.stringify(json,null,4)); throw new Error('failed: ' + actual + ' not equal to expected: ' + expected); } done(); }); }); }); }); carto-0.9.5/test/specificity/000077500000000000000000000000001223255147500161355ustar00rootroot00000000000000carto-0.9.5/test/specificity/classes.mss000066400000000000000000000001211223255147500203100ustar00rootroot00000000000000.baz .bar {} .foo {} .bar {} .foo .bar .baz {} .baz {} .baz .foo {} .foo .baz {} carto-0.9.5/test/specificity/classes.result000066400000000000000000000006201223255147500210300ustar00rootroot00000000000000[ {"elements":[".foo",".bar",".baz"],"specificity":[0,3,0,29]}, {"elements":[".foo",".baz"],"specificity":[0,2,0,68]}, {"elements":[".baz",".foo"],"specificity":[0,2,0,55]}, {"elements":[".baz",".bar"],"specificity":[0,2,0,0]}, {"elements":[".baz"],"specificity":[0,1,0,47]}, {"elements":[".bar"],"specificity":[0,1,0,21]}, {"elements":[".foo"],"specificity":[0,1,0,13]} ]carto-0.9.5/test/specificity/demo.mss000066400000000000000000000004271223255147500176100ustar00rootroot00000000000000#world { polygon-fill:#CCC; } #world[NAME='United States'] { polygon-fill:#F00; [BLUE='red'] { } } #countries .countries .two { polygon-fill:#0FF; } #countries, #world { polygon-fill:#F0F; polygon-opacity: 0.5; } #countries, #countries.foo.bar.baz {} carto-0.9.5/test/specificity/demo.result000066400000000000000000000011041223255147500203150ustar00rootroot00000000000000[ {"elements":["#countries",".foo",".bar",".baz"],"specificity":[1,3,0,241]}, {"elements":["#countries",".countries",".two"],"specificity":[1,2,0,149]}, {"elements":["#world"],"filters":["[NAME]=United States","[BLUE]=red"],"specificity":[1,0,2,90]}, {"elements":["#world"],"filters":["[NAME]=United States"],"specificity":[1,0,1,66]}, {"elements":["#countries"],"specificity":[1,0,0,241]}, {"elements":["#countries"],"specificity":[1,0,0,194]}, {"elements":["#world"],"specificity":[1,0,0,194]}, {"elements":["#world"],"specificity":[1,0,0,11]} ] carto-0.9.5/test/specificity/filters_and_ids.mss000066400000000000000000000002371223255147500220140ustar00rootroot00000000000000#world [NAME='Canada'] {} #world [NAME='United States'] { [zoom > 5] {} } #world #countries [NAME='United States'] {} [NAME='United States'] {} [zoom > 5] {}carto-0.9.5/test/specificity/filters_and_ids.result000066400000000000000000000010571223255147500225310ustar00rootroot00000000000000[ {"elements":["#world","#countries"],"filters":["[NAME]=United States"],"specificity":[2,0,1,94]}, {"elements":["#world"],"filters":["[NAME]=United States"],"zoom":"......XXXXXXXXXXXXXXXXX","specificity":[1,0,2,60]}, {"elements":["#world"],"filters":["[NAME]=United States"],"specificity":[1,0,1,33]}, {"elements":["#world"],"filters":["[NAME]=Canada"],"specificity":[1,0,1,7]}, {"elements":[],"zoom":"......XXXXXXXXXXXXXXXXX","specificity":[0,0,1,146]}, {"elements":[],"filters":["[NAME]=United States"],"specificity":[0,0,1,120]} ] carto-0.9.5/test/specificity/issue60.mml000066400000000000000000000010331223255147500201370ustar00rootroot00000000000000{ "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": [ "issue60.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" } }] } carto-0.9.5/test/specificity/issue60.mss000066400000000000000000000003011223255147500201510ustar00rootroot00000000000000#world { [NET_INFLOW > -30000] { polygon-fill: #f00; } [NET_INFLOW > -10000] { polygon-fill: #0f0; } } #world [OBJECTID=12] { polygon-pattern-file:url(../resources/textures/stripe.png); } carto-0.9.5/test/specificity/issue60.result000066400000000000000000000004731223255147500206770ustar00rootroot00000000000000[ {"elements":["#world"],"filters":["[OBJECTID]=12"],"specificity":[1,0,1,131]}, {"elements":["#world"],"filters":["[NET_INFLOW]>-10000"],"specificity":[1,0,1,83]}, {"elements":["#world"],"filters":["[NET_INFLOW]>-30000"],"specificity":[1,0,1,35]}, {"elements":["#world"],"specificity":[1,0,0,0]} ] carto-0.9.5/test/support/000077500000000000000000000000001223255147500153365ustar00rootroot00000000000000carto-0.9.5/test/support/diff.js000066400000000000000000000220041223255147500166020ustar00rootroot00000000000000/** * Fragment used to represent a string fragment in the diff. */ var Fragment = function (string) { this.content = string; this.equiv = false; }; /** * Wrap in given tag or return the clean value. */ Fragment.prototype.toString = function (tag) { if (this.equiv || !tag) { return this.content; } else { return '<' + tag + '>' + this.content + ''; } }; var moveToEnd = function (a, i, k) { if (!a.equiv && (!k[i-1] || k[i-1].equiv)) { // Find next item equiv item. for (var j = i+1; k[j] && !k[j].equiv; j++); if (k[j] && k[j].content === a.content) { k[i] = k[j]; k[j] = a; } } }; var aggregate = function (a, i, k) { if (!a.equiv && k[i+1] && !k[i+1].equiv) { k[i+1].content = a.content + k[i+1].content; delete k[i]; } }; var join = function (what, t) { return what.map(function (a) { if (a) return a.toString(t); }).join(''); }; var clone = function(source) { if (typeof source === 'object' && source !== null) { var target = Array.isArray(source) ? [] : {}; for (var key in source) target[key] = clone(source[key]); return target; } return source; }; var WordDiff = { nonWord: /(&.+?;|[\u0000-\u0040\u005B-\u0060\u007B-\u00A9\u00AB-\u00B4\u00B6-\u00B9\u00BB-\u00BF\u00D7\u00F7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u036F\u0375\u037E\u0384\u0385\u0387\u03F6\u0482-\u0489\u055A-\u055F\u0589\u058A\u0591-\u05C7\u05F3\u05F4\u0600-\u0603\u0606-\u061B\u061E\u061F\u064B-\u065E\u0660-\u066D\u0670\u06D4\u06D6-\u06E4\u06EA-\u06ED\u06F0-\u06F9\u06FD\u06FE\u0700-\u070D\u070F\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07F6-\u07F9\u0901-\u0903\u093C\u093E-\u094D\u0951-\u0954\u09E2\u0962-\u0970\u06E7-\u06E9\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E3\u09E6-\u09EF\u09F2-\u09FA\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AF1\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B66-\u0B70\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BFA\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C78-\u0C7F\u0C82\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D75\u0D79\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2-\u0DF4\u0E31\u0E34-\u0E3A\u0E3F\u0E47-\u0E5B\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0ED0-\u0ED9\u0F01-\u0F3F\u0F71-\u0F87\u0F90-\u0F97\u0F99-\u0FBC\u0FBE-\u0FCC\u0FCE-\u0FD4\u102B-\u103E\u1040-\u104F\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u1099\u109E\u109F\u10FB\u135F-\u137C\u1390-\u1399\u166D\u166E\u1680\u169B\u169C\u16EB-\u16F0\u1712-\u1714\u1732-\u1736\u1752\u1753\u1772\u1773\u17B4-\u17D6\u17D8-\u17DB\u17DD\u17E0-\u17E9\u17F0-\u17F9\u1800-\u180E\u1810-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1940\u1944-\u194F\u19B0-\u19C0\u19C8\u19C9\u19D0-\u19D9\u19DE-\u19FF\u1A17-\u1A1B\u1A1E\u1A1F\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B7C\u1B80-\u1B82\u1BA1-\u1BAA\u1BB0-\u1BB9\u1C24-\u1C37\u1C3B-\u1C49\u1C50-\u1C59\u1C7E\u1C7F\u1DC0-\u1DE6\u1DFE\u1DFF\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2000-\u2064\u206A-\u2070\u2074-\u207E\u2080-\u208E\u20A0-\u20B5\u20D0-\u20F0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u2153-\u2182\u2185-\u2188\u2190-\u23E7\u2400-\u2426\u2440-\u244A\u2460-\u269D\u26A0-\u26BC\u26C0-\u26C3\u2701-\u2704\u2706-\u2709\u270C-\u2727\u2729-\u274B\u274D\u274F-\u2752\u2756\u2758-\u275E\u2761-\u2794\u2798-\u27AF\u27B1-\u27BE\u27C0-\u27CA\u27CC\u27D0-\u2B4C\u2B50-\u2B54\u2CE5-\u2CEA\u2CF9-\u2CFF\u2DE0-\u2E2E\u2E30\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u3004\u3007-\u3030\u3036-\u303A\u303D-\u303F\u3099-\u309C\u30A0\u30FB\u3190-\u319F\u31C0-\u31E3\u3200-\u321E\u3220-\u3243\u3250-\u32FE\u3300-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA60D-\uA60F\uA620-\uA629\uA66F-\uA673\uA67C-\uA67E\uA700-\uA716\uA720\uA721\uA789\uA78A\uA802\uA806\uA80B\uA823-\uA82B\uA874-\uA877\uA880\uA881\uA8B4-\uA8C4\uA8CE-\uA8D9\uA900-\uA909\uA926-\uA92F\uA947-\uA953\uA95F\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA5C-\uAA5F\uD800\uDB7F\uDB80\uDBFF\uDC00\uDFFF\uE000\uF8FF\uFB1E\uFB29\uFD3E\uFD3F\uFDFC\uFDFD\uFE00-\uFE19\uFE20-\uFE26\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFEFF\uFF01-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFF9-\uFFFD])/, tokenize: function (args) { // Split on non-word characters. for (var type in args) { args[type] = args[type].split(WordDiff.nonWord).filter(function (s) { return s.length; }); } // Calculate the indexes and offsets for common suffixes and prefixes. var i = -1, j = args.del.length, k = args.ins.length; while (args.del[++i] === args.ins[i] && i <= j); while (j >= i && k >= i && args.del[--j] === args.ins[--k]); args.prefix = args.del.slice(0, i).join(''); args.suffix = args.del.slice(j + 1).join(''); args.del = args.del.slice(i, ++j); args.ins = args.ins.slice(i, ++k); }, lcs: function (args) { var matrix = []; for (var i = 0; i < args.del.length; i++) { matrix[i] = []; for (var j = 0; j < args.ins.length; j++) { if (args.del[i] === args.ins[j]) { matrix[i][j] = (matrix[i - 1] && matrix[i - 1][j - 1] || 0) + args.del[i].length; } else { matrix[i][j] = Math.max(matrix[i][j - 1] || 0, matrix[i - 1] && matrix[i - 1][j] || 0); } } } return matrix; }, changeset: function (args, matrix) { var result = {}; ['del', 'ins'].forEach(function (type) { result[type] = args[type].map(function (a) { return new Fragment(a); }); }); // Backtrack through the matrix. for (var i = result.del.length - 1, j = result.ins.length - 1; i >= 0; i--, j--) { if (j < 0 || result.del[i].content !== result.ins[j].content) { if (j < 0 || (j > 0 && matrix[i - 1] && (matrix[i][j - 1] < matrix[i - 1][j]))) { j++; } else { i++; } } else { result.del[i] = result.ins[j]; result.del[i].equiv = true; } } // Fill up gaps. for (var i = 0; i < result.del.length; i++) { if (result.del[i].equiv && result.del[i].content.length < 3) { var j = result.ins.indexOf(result.del[i]); if (result.del[i-1] && result.del[i+1] && result.ins[j-1] && result.ins[j+1] && !result.del[i-1].equiv && !result.del[i+1].equiv && !result.ins[j-1].equiv && !result.ins[j+1].equiv){ result.del[i].equiv = false; result.ins[j] = clone(result.del[i]); } } } ['del', 'ins'].forEach(function (type) { // Try to move changes to the end. for (var i = 0; i < result[type].length; i++) moveToEnd(result[type][i], i, result[type]); // Aggregate subsequent changes to minimize ins/del tags. for (var i = 0; i < result[type].length; i++) aggregate(result[type][i], i, result[type]); }); return result; }, htmlRender: function (args, result) { var diff = { del: args.prefix + join(result.del, 'del') + args.suffix, ins: args.prefix + join(result.ins, 'ins') + args.suffix }; return diff; }, htmlDiff: function (del, ins) { var args = { 'del': del, 'ins': ins }; WordDiff.tokenize(args); var matrix = WordDiff.lcs(args); var result = WordDiff.changeset(args, matrix); return WordDiff.htmlRender(args, result); }, render: function (args, result) { var join = function (what, type) { return what.map(function (a) { if (!a) return; if (a.equiv) return a.content; if (type == 'del') return '\033[31;4m' + a.content + '\033[0m'; if (type == 'ins') return '\033[32;4m' + a.content + '\033[0m'; }).join(''); }; return { del: args.prefix + join(result.del, 'del') + args.suffix, ins: args.prefix + join(result.ins, 'ins') + args.suffix }; }, diff: function(del, ins) { var args = { 'del': del, 'ins': ins }; WordDiff.tokenize(args); var matrix = WordDiff.lcs(args); var result = WordDiff.changeset(args, matrix); return WordDiff.render(args, result); } }; module.exports = WordDiff; carto-0.9.5/test/support/helper.js000066400000000000000000000133161223255147500171570ustar00rootroot00000000000000var path = require('path'), _ = require('underscore'), fs = require('fs'), assert = require('assert'), crypto = require('crypto'), sax = require('sax'), diff = require('./diff').diff, constants = ((!process.ENOENT) >= 1) ? require('constants') : { ENOENT: process.ENOENT }; var helper = exports; exports.files = function(dir, extension, callback) { var dir = path.join(__dirname, '..', dir); extension = new RegExp('\\.' + extension + '$'); fs.readdirSync(dir).forEach(function(filename) { if (extension.test(filename)) { callback(path.join(dir, filename)); } }); }; exports.file = function(file, callback) { fs.readFile(file, 'utf-8', function(err, content) { if (err) throw err; callback(content); }); }; exports.json = function(file, callback) { fs.readFile(file, 'utf-8', function(err, content) { if (err) throw err; callback(JSON.parse(content)); }); }; exports.mml = function(file) { var mml = JSON.parse(fs.readFileSync(file, 'utf-8')); mml.Stylesheet = _(mml.Stylesheet).map(function(s) { return { id: s, data: fs.readFileSync(path.join(path.dirname(file), s), 'utf-8') }; }); return mml; }; exports.mss = function(file) { return fs.readFileSync(file, 'utf-8'); }; exports.showDifferences = function(e, format) { var changes = diff( (format || JSON.stringify)(e.actual), (format || JSON.stringify)(e.expected) ); console.warn(helper.stylize('actual:', 'bold') + '\n' + changes.del); console.warn(helper.stylize('expected:', 'bold') + '\n' + changes.ins); }; exports.formatJSON = function(arr) { return '[\n ' + arr.map(function(t) { return JSON.stringify(t); }).join(',\n ') + '\n]'; }; exports.makePlain = function(obj, fn) { return JSON.parse(JSON.stringify(obj, fn)); }; exports.parseXML = function(xml, callback) { var parser = sax.parser(true); var i = 0; var tree = [ {} ]; parser.onopentag = function(node) { if (!(node.name in tree[0])) tree[0][node.name] = []; node.attributes.__order__ = i++; tree[0][node.name].push(node.attributes); tree.unshift(node.attributes); }; parser.onclosetag = function() { tree.shift(); if (tree.length === 1) callback(tree[0]); }; parser.ontext = parser.oncdata = function(text) { if (text.trim()) tree[0].text = (tree[0].text || '') + text; }; parser.write(xml.toString()); }; exports.compareToXMLFile = function(filename, second, callback, processors) { helper.file(filename, function(first) { helper.parseXML(first, function(firstXML) { helper.parseXML(second, function(secondXML) { processors.forEach(function(processor) { processor(secondXML); }); try { assert.deepEqual(secondXML, firstXML); callback(null); } catch (err) { callback(err,secondXML, firstXML); } }); }); }); }; exports.resultFile = function(file) { return path.join(path.dirname(file), path.basename(file).replace(/\.\w+$/, '.result')); }; // Stylize a string exports.stylize = function(str, style) { var styles = { 'bold' : [1, 22], 'inverse' : [7, 27], 'underline' : [4, 24], 'yellow' : [33, 39], 'green' : [32, 39], 'red' : [31, 39] }; return '\033[' + styles[style][0] + 'm' + str + '\033[' + styles[style][1] + 'm'; }; exports.isDirectory = function(dir, context) { fs.stat(dir, function(err, stats) { if (err) throw err; assert.ok(stats.isDirectory()); context.tests++; }); }; exports.isFile = function(file, context) { fs.stat(file, function(err, stats) { if (err) throw err; assert.ok(stats.isFile()); context.tests++; }); }; exports.rmrf = function rmrf(p) { try { if (fs.statSync(p).isDirectory()) { fs.readdirSync(p).forEach(function(file) { rmrf(path.join(p, file)); }); fs.rmdirSync(p); } else fs.unlinkSync(p); } catch (err) { if (err.errno !== constants.ENOENT) throw err; } }; exports.md5File = function(file, md5, context) { fs.readFile(file, 'binary', function(err, data) { var hash = crypto.createHash('md5').update(data).digest('hex'); assert.equal(hash, md5); context.tests++; }); }; helper.removeErrorFilename = function(error) { error.forEach(function(e) { e.filename = '[absolute path]'; }); return error; }; helper.removeAbsoluteImages = function(xml) { xml.Map.forEach(function(map) { if (map.Style) map.Style.forEach(function(style) { style.Rule.forEach(function(rule) { for (var symbolizer in rule) { for (var i = 0; i < rule[symbolizer].length; i++) { if (rule[symbolizer][i].file) { rule[symbolizer][i].file = '[absolute path]'; } } } }); }); }); }; helper.removeAbsoluteDatasources = function(xml) { xml.Map.forEach(function(map) { if (map.Layer) map.Layer.forEach(function(layer) { if (!layer.Datasource) return; layer.Datasource.forEach(function(datasource) { datasource.Parameter.forEach(function(param) { if (param.name === 'file') { param.text = '[absolute path]'; } }); }); }); }); }; carto-0.9.5/test/version.test.js000066400000000000000000000011711223255147500166230ustar00rootroot00000000000000var carto = require('../lib/carto'); var fs = require('fs'); var path = require('path'); var assert = require('assert'); describe('Version check', function() { it('test version matches package.json version and changelog', function() { if (parseInt(process.version.split('.')[1]) > 4) { var info = require('../package.json'); assert.deepEqual(info.version.split('.'), carto.version); } else { var info = JSON.parse(require('fs').readFileSync(path.join(__dirname,'../package.json'))); assert.deepEqual(info.version.split('.'), carto.version); } }); });