Compare commits

...

458 Commits

Author SHA1 Message Date
Daniel García Aubert
85881d99dd Release 0.15.1-cdb5 2018-11-20 17:47:20 +01:00
Daniel G. Aubert
d3a5c97143
Merge pull request #50 from CartoDB/nodejs-10
Drop support for oldest Node.js versions and support latest LTS releases
2018-11-20 17:45:16 +01:00
Daniel García Aubert
8ed3ad15c1 Add CHANGELOG.carto.md 2018-11-20 17:36:46 +01:00
Daniel García Aubert
72f79efbdd Prepare next release version 2018-11-20 17:36:30 +01:00
Daniel García Aubert
161516b721 Support package-lock.json 2018-10-29 12:47:17 +01:00
Daniel García Aubert
e48d5ff993 Drop support for oldest Node.js versions and support latest LTS releases 2018-10-29 12:37:47 +01:00
IagoLast
31abb8bee0 0.15.1 2018-05-10 16:07:00 +02:00
IagoLast
e2177cf443 Add release scripts 2018-05-10 16:06:56 +02:00
Carlos Matallín
664b45cdde
Merge pull request #47 from CartoDB/shield_placement_type
adds shield-placement-type to torque-reference
2018-02-23 11:05:33 +01:00
Alegoiko
368dad0d11 adds shield-placement-type to torque-reference 2018-02-20 12:01:45 +01:00
David M
4dfe5361b3 Merge pull request #45 from CartoDB/ampersand-fix
Fix for ampersand on values (JS only)
2017-10-20 15:08:27 +02:00
David Manzanares
3596991362 Fix for ampersand on values (JS only) 2017-10-20 12:45:03 +02:00
David M
bf4c67034a Merge pull request #44 from CartoDB/js-ampersand-fix
Fix ampersand escaping on JS values
2017-10-10 18:20:57 +02:00
David Manzanares
ad5d919139 Use regular expression to replace all occurrences 2017-10-10 18:12:01 +02:00
David Manzanares
9fb894181d Fix replacement 2017-10-10 18:10:40 +02:00
David Manzanares
ffdf2d3c9b Fix ampersand escaping on JS values 2017-10-10 18:00:47 +02:00
David M
cbe66020f9 Merge pull request #42 from CartoDB/dasharrayJSsupport
Cover 'numbers' type, like in line-dasharray
2017-09-01 17:33:15 +02:00
David Manzanares
056081ace6 Cover 'numbers' type, like in line-dasharray 2017-09-01 13:30:19 +02:00
Pablo Alonso
a48ba58cae Merge pull request #41 from CartoDB/carto-40
Ignore zoom for the filtered field when the value is the default one.
2017-08-23 13:26:00 +02:00
Pablo Alonso Garcia
9f67f1bdde Dist files 2017-08-23 13:25:35 +02:00
IagoLast
55c0786130 Use tree.Zoom.all instead custom constant 2017-08-21 17:40:04 +02:00
Pablo Alonso Garcia
fef8cb369f Minor copy changes 2017-08-21 17:35:08 +02:00
IagoLast
d35e54859a Ignore zoom for the filtered field when the value is the default one. 2017-08-21 16:33:05 +02:00
IagoLast
daafa9fbf2 Merge pull request #39 from CartoDB/expose-filtered-field
Expose filtered field
2017-08-18 16:46:13 +02:00
IagoLast
34799db0cc Boy scout rule 2017-08-18 15:59:04 +02:00
IagoLast
41133a65ad Make test compatible with an old node version 2017-08-18 13:21:22 +02:00
IagoLast
1016f6870c Refactor filtered field code 2017-08-18 13:10:15 +02:00
IagoLast
72f93abf16 Expose filtered field 2017-08-18 12:58:01 +02:00
IagoLast
a3538d9007 Add filtered field tests 2017-08-18 12:57:45 +02:00
IagoLast
66cc146a02 Merge pull request #38 from CartoDB/use-hexa-instead-octal
Use hexadecimal values instead octal
2017-08-01 11:04:01 +02:00
IagoLast
aab27e6be8 Use hexadecimal values instead octal
Strict mode in ECMAScript 5 forbids octal syntax. This octal literals
are breaking the webpack compilation in upper packages like tangram-cartocss.

Mapbox have already [fixed this](https://github.com/mapbox/carto/blob/master/lib/carto/index.js#L104)

This PR changes the octal literals and uses hexadecimal ones.
2017-07-31 18:02:13 +02:00
IagoLast
cea1e7c620 Merge pull request #37 from CartoDB/36-remove-console-log
Remove console.log from tests
2017-07-31 17:58:14 +02:00
IagoLast
f8a9995050 Add a tdd option into the package.json scripts
This option includes a env variable to control the verbosity of the test logs.
2017-07-28 12:01:37 +02:00
IagoLast
0de8b82ff9 Remove console.log from tests 2017-07-26 13:08:05 +02:00
Francisco López
7d00bfdf23 Merge pull request #35 from CartoDB/v-release
Bump version
2017-06-15 15:30:33 +02:00
Francisco López
3db2fa322b Bump version 2017-06-15 14:54:29 +02:00
Francisco López
f4a2605a23 Release dist files 2017-05-19 13:57:16 +02:00
Francisco López
d95967247d Merge branch 'master' of github.com:CartoDB/carto 2017-05-19 13:56:36 +02:00
Francisco López
da8707a17f Release changes! 2017-05-19 13:56:26 +02:00
Francisco López
3f9f6ef40d Merge pull request #27 from CartoDB/reference-errors
[WIP] Reference errors (attempt 2)
2017-05-19 13:55:39 +02:00
Francisco López
b051ae284e Remove throw check 2017-05-19 13:51:27 +02:00
Francisco López
ea880ccf7b Check throw 2017-05-19 12:24:50 +02:00
Francisco López
ab412165b2 Set correct indentation 2017-05-19 12:21:00 +02:00
Francisco López
7974fb0a05 Remove editor.test.js 2017-05-19 12:20:22 +02:00
Francisco López
59c0208caa Fix tests.
Now we don't run the parser so there is no errors, we can't look for errors.
2017-04-17 16:00:07 +02:00
Francisco López
9b5fb6a408 Make the error flag more strict 2017-04-17 15:48:55 +02:00
Daniel García Aubert
945f5efb74 Release 0.15.1-cdb3 2017-03-07 11:10:29 +01:00
Daniel
decdcc5d46 Merge pull request #30 from CartoDB/support-multiple-values
Support multiple values/operands
2017-03-07 11:03:23 +01:00
Daniel García Aubert
34bd0a045d Merge branch 'master' into support-multiple-values 2017-03-07 10:46:59 +01:00
Daniel
ed819c3b51 Merge pull request #29 from CartoDB/24-reference-error
Support `=~` operator
2017-03-07 10:43:04 +01:00
Daniel García Aubert
a42afef5a8 Add assertions 2017-03-06 19:20:01 +01:00
Daniel García Aubert
410ecfd3c7 Use constructor for test validation 2017-03-06 12:04:29 +01:00
Daniel García Aubert
8c75b4b0c6 Remove spaces 2017-03-06 11:59:41 +01:00
Daniel García Aubert
fd94fbd2e6 Support numbers for '=~' operator 2017-03-06 11:57:07 +01:00
Daniel García Aubert
5c4bed9593 Keep spaces 2017-03-06 11:38:59 +01:00
Raul Ochoa
2c092f6b39 Support multiple values/operands 2017-03-05 23:31:32 +01:00
Daniel García Aubert
cc2104eb49 Fix typo 2017-03-03 15:35:57 +01:00
Daniel García Aubert
c780998dc8 Prevent TypeError when parsing '=~' operator 2017-03-03 15:27:42 +01:00
Daniel García Aubert
0063ddba7f Support '=~' operator 2017-03-03 14:36:14 +01:00
Francisco López
510847a3b2 Make the validation in the correct place 2017-02-03 16:49:30 +01:00
Raul Ochoa
0c1990f655 Merge branch 'master' into reference-errors 2017-02-01 12:25:57 +01:00
Raul Ochoa
7315428079 Adds test to validate supported features are validated and work 2017-02-01 12:15:46 +01:00
Raul Ochoa
515fbd0991 Only set previous reference if it existed 2017-02-01 11:23:39 +01:00
Raul Ochoa
975abe9b5c Set tree data just before render happens 2017-02-01 11:16:03 +01:00
Raul Ochoa
b6186d884c Merge pull request #26 from CartoDB/revert-21-reference-errors
Revert "Throw an error when not valid ccss"
2017-02-01 11:12:22 +01:00
Raul Ochoa
e6ba32bc07 Revert "Throw an error when not valid ccss" 2017-02-01 10:44:42 +01:00
Raul Ochoa
fd4caf7595 Merge pull request #21 from CartoDB/reference-errors
Throw an error when not valid ccss
2017-01-31 15:36:38 +01:00
Raul Ochoa
45e59f6a5b Revert changes not needed for PR 2017-01-31 15:23:18 +01:00
Raul Ochoa
dfecbbb976 Revert changes in rendering_js test 2017-01-31 15:22:13 +01:00
Raul Ochoa
50fa97564e Strict parser mode.
When options.strict is set to true, it throws parse errors associated to invalid rules,
or in general rules not compliant with the given reference.
2017-01-31 15:19:47 +01:00
Raul Ochoa
8f9982c313 Fix reference to make test pass due to valid error message 2017-01-31 14:50:56 +01:00
Raul Ochoa
01c6f0c6e5 Validate the expected error message, make test to fail 2017-01-31 14:50:09 +01:00
Raul Ochoa
7e02aac641 Reference options from a valid object 2017-01-31 11:31:11 +01:00
María Checa
4f792fbead Merge pull request #25 from CartoDB/allow_expression_in_polygon_pattern_file
Added expression property to `polygon-pattern-file` and `line-pattern-file`
2017-01-19 18:18:05 +01:00
María Checa
9e12a3b0d8 Added expression property to line-pattern-file 2017-01-19 16:44:49 +01:00
María Checa
09d6384b1f Added expression property to polygon-pattern-file 2017-01-19 16:39:10 +01:00
Raul Ochoa
11ffba0a8e Isolate reference as options test 2017-01-17 17:34:28 +01:00
Francisco López
199d41f20d Throw an error when not valid ccss 2017-01-11 11:39:33 +01:00
Raul Ochoa
e931f91475 Merge pull request #20 from CartoDB/more-expressions
More expressions
2017-01-04 17:32:21 +01:00
Raul Ochoa
11d597e733 Accept expressions in marker file 2017-01-03 19:03:39 +01:00
Raul Ochoa
1960aca276 Accept expresions in polygon fill 2017-01-03 19:03:10 +01:00
Raul Ochoa
f17aea8657 Merge pull request #18 from CartoDB/turbo-carto-fn-support
Adds support for other turbo-carto functions
2016-07-20 14:32:34 +02:00
Raul Ochoa
dfaed546e0 Remove only from test 2016-07-20 13:19:00 +02:00
Raul Ochoa
803f0c0a49 Adds support for other turbo-carto functions 2016-07-20 13:17:10 +02:00
Raul Ochoa
0d6f9d4634 Ignore idea based configurations 2016-07-20 13:08:41 +02:00
javi santana
c042733845 Merge pull request #17 from CartoDB/update_reference
adds expression: true for attributes supported by turbo
2016-06-01 14:37:37 +02:00
javi
1fc486b1b9 adds expression: true for attributes supported by turbo 2016-06-01 14:31:14 +02:00
Buti
b50ee48386 Merge pull request #16 from CartoDB/turbo
adds parser support for arrays and also updates reference to add "ram…
2016-05-31 15:12:06 +02:00
javi
cf5886579f adds parser support for arrays and also updates reference to add "ramp" function 2016-05-31 12:40:31 +02:00
Buti
72d005a082 Merge pull request #15 from CartoDB/fix-parser-underscore-template
Fix parser's use of underscore's template
2016-05-30 16:45:18 +02:00
nobuti
9e8c90b6f9 Bumped version of underscore.
Updated some method calls.
Dist generation files.
2016-05-30 16:06:04 +02:00
nobuti
d3e23dcb5d Fix parser's use of underscore's template method to work with modern use of it. 2016-05-30 14:05:42 +02:00
Raul Ochoa
176886f1ad Use build status from cartodb repo 2016-04-27 15:37:35 +02:00
Raul Ochoa
673cf38121 Add test for non-dot notation filters 2016-04-27 15:23:01 +02:00
Raul Ochoa
860bc0adeb Merge pull request #14 from CartoDB/filter-avoid-dot-notation
Avoid using dot notation to allow complex keys
2016-04-27 15:12:51 +02:00
Raul Ochoa
be56e24d9a Avoid using dot notation to allow complex keys, e.g., mapnik::geometry_type 2016-04-26 18:19:53 +02:00
javi santana
27850ed122 Merge pull request #12 from CartoDB/fixed_strings_with_quote
fixed cartocss with single quoted strings
2016-02-24 12:28:45 +01:00
javi
0d2dddf978 fixed cartocss with single quoted strings 2016-02-24 12:16:29 +01:00
Raul Ochoa
fba91a0633 Merge pull request #11 from CartoDB/missed_small_changes
Missed changes
2015-12-14 17:44:59 +01:00
Young Hahn
1612b5a8b7 Drop xml2js and thus mml2json.
(cherry picked from commit bde0d0e2ab)
2015-11-30 16:14:53 -08:00
Paul Norman
4f13aabb6c Update less link
Update Less page link to match the current layout
(cherry picked from commit 73e6726e089ff47fae5115183aa3776918946ab7)
2015-11-30 13:56:53 -08:00
Raul Ochoa
8050ec843f Release 0.15.1-cdb1 2015-02-20 19:48:15 +01:00
Francisco Dans
885849fe82 Merge pull request #9 from CartoDB/image-filters-fixes
Image filters fixes
2015-01-21 14:41:51 +01:00
Francisco Dans
14c0d3f550 adds color sequence test 2015-01-21 14:38:43 +01:00
Francisco Dans
0f46b57020 returns correct object for color list 2015-01-21 12:54:04 +01:00
Francisco Dans
152954ee70 adds additional filters to ref 2015-01-21 12:53:13 +01:00
Francisco Dans
2631c928b7 adds Makefile to produce uncompressed and minified dists 2015-01-19 14:29:11 +01:00
Francisco Dans
9e3ae6e6fd adds uncompressed version of carto 2015-01-12 18:39:49 +01:00
Francisco Dans
eae8886b95 new dist 2015-01-12 18:35:15 +01:00
Francisco Dans
00c7a631b1 Merge pull request #8 from CartoDB/icon-list
Adding method to extract all "marker-file" properties
2015-01-08 17:35:53 +01:00
Francisco Dans
bd03e0c454 adds basic test for marker-files 2015-01-08 17:30:49 +01:00
Francisco Dans
981e117731 uses proper equality checks 2015-01-08 17:10:43 +01:00
Francisco Dans
d2a557acd9 removes old reference, renames method 2015-01-08 16:40:02 +01:00
Francisco Dans
f91ac22bfc adds method to gather image asset file names 2015-01-08 16:21:24 +01:00
javi
db1cf0a8aa missing torque prop 2014-12-18 11:02:20 +01:00
javi
46b3f4857f version bump 2014-12-18 09:04:03 +01:00
javi
b5b03cc8d7 expose the default reference used 2014-12-18 09:02:13 +01:00
javi
8f86216fe0 updates the reference to work with the new parser
see db3c03bd1a
2014-12-18 09:01:59 +01:00
Raul Ochoa
bbfe3b3084 Merge pull request #6 from CartoDB/browserify_fixes
browserify fixes
2014-12-17 14:47:42 +01:00
javi
56d69ab68a browserify fixes 2014-12-17 14:35:42 +01:00
javi
e491c64ceb improved package.json 2014-12-16 18:39:18 +01:00
Raul Ochoa
26c30d2fb5 Remove doc block for non-existent param 2014-12-09 12:52:42 +01:00
Raul Ochoa
6ae21b3ee0 Merge pull request #4 from CartoDB/remove-run-coverage-on-travis
Remove coverage run from travis configuration as it is failing
2014-12-05 17:36:42 +01:00
Raul Ochoa
12d1b1a4fe Merge pull request #3 from CartoDB/console-output-on-debug-only
Only use console output if debug option is present
2014-12-05 17:36:24 +01:00
Raul Ochoa
8a5f75546f Remove coverage run from travis configuration as it is failing 2014-12-05 13:06:53 +01:00
Raul Ochoa
74d807a3ae Only use console output if debug option is present 2014-12-05 13:01:15 +01:00
Raul Ochoa
bf6537071a Check for style property 2014-12-04 19:09:43 +01:00
Raul Ochoa
1cb891ef92 Return style function from shader 2014-12-04 18:58:37 +01:00
javi
79a770f0af removed unnused files 2014-12-04 18:43:13 +01:00
javi
44610ab1c4 using torque reference 2014-12-04 18:42:30 +01:00
javi
7c35dda115 Merge remote-tracking branch 'origin/browserify' into update_to_master
Conflicts:
	.gitignore
	.travis.yml
	CHANGELOG.md
	Makefile
	README.md
	bin/mml2json.js
	lib/carto/index.js
	lib/carto/parser.js
	lib/carto/tree/call.js
	lib/carto/tree/filterset.js
	lib/carto/tree/reference.js
	lib/carto/tree/ruleset.js
	package.json
	test/errorhandling.test.js
	test/errorhandling/invalid_value.mss
	test/errorhandling/invalid_value.result
	test/errorhandling/issue297.mss
	test/errorhandling/issue297.result
	test/rendering-mss.test.js
	test/rendering/transforms.mss
	test/rendering/transforms.result
	test/specificity/demo.result
	test/specificity/filters_and_ids.result
	test/specificity/issue60.result
	test/version.test.js
2014-12-04 18:35:24 +01:00
javi
146976c8a3 using process.browser instead of type window 2014-12-04 17:29:15 +01:00
javi
ae111041dd making explicit imports 2014-12-04 17:28:54 +01:00
javi
2e00705b64 adds support for browserify
this pr also changes some code to make compatible with the browser. It exposes the global variable "carto"
One of the problems is mapnik reference, the module is not read to work with browserify since it loads modules dynamically. It does not make sense to make it compatible since mapnik-reference is not going to be used so people must to set the reference needed before parse/render:

carto.tree.Reference.setData(reference)
2014-12-04 16:29:20 +01:00
Dane Springmeyer
b19ade3850 use latest mapnik-reference@6.0.2 2014-09-26 13:10:51 -07:00
Dane Springmeyer
fe770630bb Add test for proposed syntax for passing variable to mapnik (just as string) - refs #269 2014-09-25 18:57:48 -07:00
Dane Springmeyer
8df31b4fe6 Merge pull request #373 from mapbox/expressions
Al(most) all symbolizer properties as expressions
2014-09-25 18:56:53 -07:00
Dane Springmeyer
e29b900342 call this branch v0.14.0 2014-09-25 18:17:48 -07:00
Dane Springmeyer
150e7166f6 mapnik ref: default to Mapnik 3.0.0 2014-09-25 18:13:35 -07:00
Dane Springmeyer
1d6e4a6f5d drop node v0.8.x testing on travis 2014-09-25 15:12:54 -07:00
Dane Springmeyer
52343ff833 text-name is an expression so flat string is okay - tweak issue297 to actually be invalid since text-face-name is not currently an expression 2014-09-25 15:06:56 -07:00
Dane Springmeyer
544491b91d quoting of enumerations is okay, so let this be okay to carto tests 2014-09-25 14:58:58 -07:00
Dane Springmeyer
7d3ba895f5 trim rendering results to avoid comparing ending newlines 2014-09-25 14:56:29 -07:00
Dane Springmeyer
d5bf19a64f remove back compat shim now that new mapnik-ref@6.0.0 is tagged 2014-09-25 12:37:52 -07:00
Dane Springmeyer
5890802d6d use new mapnik-reference@6.0.0 2014-09-25 12:33:06 -07:00
Saman Bemel-Benrud
26a918d2e6 Merge pull request #372 from mapbox/fix-formatting
Fix formatting
2014-09-25 12:33:48 -04:00
samanpwbb
1ba5e0035e Re-generate 2014-09-25 12:24:01 -04:00
samanpwbb
1e0657ee1e bump / add newline 2014-09-23 18:58:14 -04:00
samanpwbb
2a5c85a9d5 smaller headings 2014-09-23 18:54:19 -04:00
samanpwbb
cbd4c0250d better rules 2014-09-23 18:52:24 -04:00
samanpwbb
08ca40d3f7 try linebreaks 2014-09-23 18:51:11 -04:00
samanpwbb
9386a56464 whitespace adjustments 2014-09-23 18:47:10 -04:00
samanpwbb
d24998705d adjust docs formatting 2014-09-23 18:45:55 -04:00
Dane Springmeyer
4de08ce68d new mapnik-reference that declares all expressions for mapnik 3.x 2014-09-23 15:31:58 -07:00
samanpwbb
9f65589279 formatting fixes 2014-09-23 18:19:02 -04:00
Saman Bemel-Benrud
6f2ec7b335 Merge pull request #371 from mapbox/no-site
add minimal markdown docs
2014-09-23 18:10:13 -04:00
samanpwbb
89a282be82 add minimal markdown docs 2014-09-23 17:52:36 -04:00
Dane Springmeyer
51baca34ae if test does not error (as expected) then assert false instead of hanging 2014-09-23 14:22:59 -07:00
Young Hahn
481a0fc406 0.13.0 2014-09-04 17:22:19 -04:00
Young Hahn
60e33e609b Merge pull request #366 from mapbox/newref
Use newer mapnik ref
2014-09-04 17:17:10 -04:00
Young Hahn
339d781ca6 Use newer mapnik ref. 2014-09-04 16:34:48 -04:00
Tom MacWright
b7819be42d Merge pull request #365 from mapbox/variable-transforms-test-coverage
Add support for variable transforms - refs #163, and improve test covera...
2014-09-03 15:21:16 -04:00
Tom MacWright
c570c2cd0e Add support for variable transforms - refs #163, and improve test coverage 2014-09-03 15:12:31 -04:00
javi santana
30b4fe1fc6 Merge pull request #2 from CartoDB/update_to_master_fix
env parameter added to several function calls
2014-08-29 10:52:11 +02:00
Young Hahn
57ddf46813 0.12.1 2014-08-02 21:47:27 -04:00
Young Hahn
ba720bcb84 Update changelog 2014-08-02 21:42:03 -04:00
Young Hahn
d608fa93b8 0.12.0 2014-08-02 21:41:17 -04:00
Young Hahn
bb81e5c785 Merge pull request #364 from mapbox/no-xml2js
Drop xml2js and thus mml2json
2014-08-02 18:40:27 -07:00
Young Hahn
bde0d0e2ab Drop xml2js and thus mml2json. 2014-08-02 17:40:54 -04:00
Tom MacWright
145f1cc0b1 test color fns 2014-07-03 12:00:40 -04:00
Tom MacWright
2273e0174f Test colors and comments 2014-07-03 11:53:12 -04:00
Tom MacWright
b9a00ed68b Use coveralls and add coverage 2014-07-03 11:44:35 -04:00
Young Hahn
b675a648c0 0.11.0 2014-05-20 17:15:09 -04:00
Young Hahn
e0fe7bce17 Merge pull request #346 from mapbox/sync
Sync
2014-05-20 17:12:17 -04:00
Young Hahn
eb2623d677 Add tests that run the carto binary. 2014-05-20 17:00:37 -04:00
Young Hahn
302d409fab Update error handling tests. 2014-05-20 16:10:31 -04:00
Young Hahn
c5d8f4510e Switch carto to be synchronous. 2014-05-20 16:01:43 -04:00
Young Hahn
cd18bea7ba 0.10.0 2014-05-15 00:25:17 -04:00
Young Hahn
55b70b86c8 Merge pull request #342 from mapbox/no-max-extent
Nuke forced maximum-extent
2014-05-14 19:52:17 -04:00
Young Hahn
d9f97d3202 Nuke forced maximum-extent property to enable buffered geometries beyond visual extent. 2014-05-08 16:37:12 -04:00
Dane Springmeyer
a52412c41e Merge pull request #340 from scw/patch-1
minor typos.
2014-04-28 18:16:09 -07:00
Shaun Walbridge
be4e687aa3 minor typos. 2014-04-28 21:02:08 -04:00
Dane Springmeyer
4b386326c7 don't output style if opacity and comp-op are defaults - refs #219 and #339 2014-04-28 16:05:59 -07:00
Dane Springmeyer
4f771ed2a5 fix #339 2014-04-28 15:57:51 -07:00
Dane Springmeyer
580e946cc0 add currently failing testcase for #339 2014-04-28 15:56:52 -07:00
Dane Springmeyer
5dc4610785 use latest mapnik-reference 2014-04-25 16:11:28 -07:00
Dane Springmeyer
9d44691111 fix #313 2014-04-17 10:38:32 -07:00
Dane Springmeyer
bb2c045325 add testcase for #315 if I'm understanding right should produce no output 2014-04-10 22:20:33 -04:00
Dane Springmeyer
9f18e9cc2c bump to v0.9.6 in package.json 2014-04-10 22:10:23 -04:00
Dane Springmeyer
c6f787f761 add v0.9.6 to changelog 2014-04-10 22:06:27 -04:00
Dane Springmeyer
cfab4f6369 fix #303 2014-04-10 22:03:09 -04:00
Dane Springmeyer
fb06bb4bb1 fix #319 2014-04-10 21:51:19 -04:00
Dane Springmeyer
87f57bdb38 Merge pull request #319 from mojodna/text-face-name-escaping
[bug] text-face-names containing &s aren't escaped properly
2014-04-10 21:50:25 -04:00
Dane Springmeyer
b9309a7f80 Merge pull request #308 from strk/aposquote
Fix escaping of single quote.
2014-04-10 21:22:50 -04:00
Dane Springmeyer
96886c73c6 use mapnik-reference@5.0.8 2014-04-10 21:07:47 -04:00
Dane Springmeyer
443b81012e upgrade underscore and xml2js 2014-04-10 21:02:00 -04:00
Dane Springmeyer
f691a47306 more readme modernization tweaks 2014-04-07 16:56:25 -04:00
Dane Springmeyer
02a657f373 modernize readme and move cascadenik mentions to https://github.com/mapbox/carto/wiki/Differences-With-Cascadenik 2014-04-07 16:49:27 -04:00
Dane Springmeyer
a5e5c045c9 add support for image-filters-inflate - refs mapnik/mapnik#2165 2014-02-27 10:41:43 -08:00
Dane Springmeyer
12a3d6cad2 start using mapnik-reference master 2014-02-19 11:57:58 -08:00
Tom MacWright
bbdb6e5988 Merge pull request #325 from iwillig/iwillig/fix-jsdocs
IW: Fix docs strings
2014-02-07 08:04:55 -05:00
Ivan Willig
f6a76ec666 IW: Fix docs strings 2014-02-07 07:41:03 -05:00
Dane Springmeyer
84618be5df travis: stop testing on node v0.6.x as per isaacs/npm#4379 2014-01-07 16:04:10 -08:00
samanpwbb
f333705cc2 revert rename 2013-12-09 20:39:54 -05:00
Seth Fitzsimmons
0b584a84e7 Failing test for text-face-names containing &s 2013-11-22 16:36:57 -08:00
Tom MacWright
65a7d6589e Merge pull request #314 from strk/exponent-in-filter
Support exponential notation in filter values
2013-11-07 07:09:11 -08:00
Sandro Santilli
ce4c61cc7f Support exponential notation in filter values
Closes #311
Includes testcase
2013-11-07 12:48:19 +01:00
Dane Springmeyer
5a7429d30d Bump to v0.9.5 with many fixes and optimizations 2013-10-25 13:23:25 -07:00
Tom MacWright
cb177b7a24 Throw a more descriptive error for invalid colors in ops. Fixes #309 2013-10-23 19:45:19 -04:00
Dane Springmeyer
15140e49ee travis: add more node versions 2013-10-18 18:07:25 -04:00
Dane Springmeyer
c4f02e4681 update developing doc 2013-10-05 16:06:14 -07:00
Sandro Santilli
60030b1e69 Fix escaping of single quote. Closes #307, updates tests. 2013-10-03 13:40:50 +02:00
Dane Springmeyer
21f03b3f9e track latest mapnik-reference 2013-09-26 16:20:26 -07:00
Dane Springmeyer
922740da5a fix direct-image-filters output and add test for image-filters 2013-09-25 17:21:27 -07:00
Dane Springmeyer
c1d750a246 Merge pull request #306 from dboze/fix-drainpool
check for millstone.drainpool only if -l flag is passed
2013-09-24 13:34:39 -07:00
Daniel Bozeman
72a79ab073 checks for millstone.drainpool only if -l flag is passed 2013-09-24 15:16:17 -05:00
Dane Springmeyer
f6dea7fcb3 drain millstone pool forcefully so we can exit quickly - refs #301 and mapbox/millstone#110 2013-09-23 18:55:38 -07:00
Tom MacWright
4b5e217107 Merge pull request #305 from yohanboniface/empty_name_invalid_xml
Fix empty name value resulting in non closed tag
2013-09-21 08:12:24 -07:00
Yohan Boniface
6b51cd370b Fix empty name value resulting in non closed tag 2013-09-21 17:05:10 +02:00
Dane Springmeyer
1c5c84587e bump mapnik-reference version and prep changelog for v0.9.5 release 2013-09-19 10:57:57 -07:00
Tom MacWright
2c9692b029 Merge pull request #294 from kapouer/patch-1
layer srs is inherited from map srs
2013-09-17 07:26:08 -07:00
Tom MacWright
3a6cae7836 Merge pull request #300 from strk/master-invalid-non-selfclosing-mml
Integrate mml parsing test for issue #297
2013-09-17 07:25:40 -07:00
Sandro Santilli
ba51c74771 Integrate mml parsing test for issue #297 2013-09-12 10:40:35 +02:00
Jérémy Lal
bd454b4b6b Add test for #294 2013-09-12 10:23:46 +02:00
Jérémy Lal
b63fe0a9af layer srs is inherited from map srs
Do not output srs attribute when srs is undefined,
since layer srs is inherited from map srs, it is optional.
2013-09-12 09:56:45 +02:00
Tom MacWright
525bdc5bef Add test for #197. Fixes #197 2013-09-11 11:26:28 -04:00
Tom MacWright
5938ebb609 Correctly deal with invalid content in non-selfclosing tags. Fixes #297 2013-09-11 11:18:40 -04:00
Tom MacWright
2ead8dafa2 Backtrack on invalid zoom. Fixes #290 2013-08-09 19:58:52 -04:00
Tom MacWright
b18f162d87 Merge pull request #293 from yohanboniface/attachment-tests
More attachment tests (cf #245)
2013-08-09 14:53:18 -07:00
Yohan Boniface
8497bd36f7 More attachment tests (cf #245) 2013-08-09 22:03:55 +02:00
Dane Springmeyer
2729aefd6e Merge pull request #292 from yohanboniface/attachment-tests
Attachment tests (cf #245)
2013-08-09 09:40:49 -07:00
Yohan Boniface
7a3b659d4e More tests for attachement (cf #245) 2013-08-09 15:39:12 +02:00
Yohan Boniface
50a27c213c Add test/rendering-mss/npm-debug.log to .gitignore 2013-08-09 15:37:06 +02:00
Dane Springmeyer
d1af35763a add currently failing test for #290 2013-08-07 20:46:32 -04:00
Tom MacWright
92b67a0a73 Test for #288 to keep it closed, space before zoom bug 2013-08-06 11:45:02 -04:00
Tom MacWright
d170825685 Merge pull request #289 from javisantana/master
fixes mapbox/carto#288
2013-08-06 08:42:38 -07:00
javi
d788fb8f07 fixes mapbox/carto#288 2013-08-05 18:12:42 +02:00
Dane Springmeyer
60396cbeef add support for direct-image-filters 2013-07-24 22:03:13 -04:00
Dane Springmeyer
f88711db72 add scale-hsla function to work with latest mapnik-reference: 66502bfde0 2013-07-24 21:59:05 -04:00
Tom MacWright
4f0e998dab Merge branch 'master' of github.com:mapbox/carto 2013-07-16 14:09:09 -04:00
Tom MacWright
fd3338ccb5 Add developing docs 2013-07-16 14:08:54 -04:00
Dane Springmeyer
1d637717d5 fix typo - refs #245 2013-07-09 15:41:00 -04:00
Dane Springmeyer
45fae55ac0 add more variations (currently passing) on the issue #284 test 2013-07-09 15:33:42 -04:00
Tom MacWright
bbeff81a16 Fix byFilter regression 2013-07-09 15:00:13 -04:00
Tom MacWright
afac483b35 More comments
:
2013-07-09 14:38:27 -04:00
Tom MacWright
66b0c1ff7a Update mocha and optimist dependencies 2013-07-09 14:03:59 -04:00
Dane Springmeyer
93264c6e41 add test for #284 - passes as 6eda91a and fails in master 2013-07-02 19:00:33 -04:00
Young Hahn
45b5c107af Merge pull request #279 from mapbox/dataonly
Allow Layer-only rendering without corresponding styles
2013-06-24 08:58:48 -07:00
Tom MacWright
84e0628a8e Merge pull request #280 from mapbox/custom-params
Allow custom map parameters
2013-06-17 06:16:50 -07:00
Young Hahn
15ab78a3a8 Allow custom map parameters. 2013-06-14 18:25:55 -04:00
Young Hahn
bb153521e2 Allow Layer-only rendering without corresponding styles. 2013-06-14 12:21:13 -04:00
Young Hahn
ff0fc2b1c8 Revert "Dimensions." Refs #258.
This reverts commit 0f65b869fd.
2013-06-14 10:47:43 -04:00
Tom MacWright
4cc262b563 Merge pull request #277 from mapbox/fix-attachment-order-breakage
fix #247
2013-06-01 09:13:50 -07:00
Dane Springmeyer
4203578093 fix #247 2013-05-31 17:17:36 -07:00
Dane Springmeyer
cfc90da91e Add regression test for issue #247 - broken in master at 4d4abb2, works in 6eda91a 2013-05-31 17:15:45 -07:00
Dane Springmeyer
8786bf51c7 bin/carto: be careful not to resolve inline stylesheet data 2013-05-29 15:52:59 -07:00
Dane Springmeyer
ae95aa7575 fix repository in package.json 2013-05-22 19:16:35 -07:00
Tom MacWright
b113bfea99 Prevent image filter duplication. Fixes #270 2013-04-16 10:24:48 -04:00
Tom MacWright
0f65b869fd Dimensions. 2013-04-15 16:10:00 -04:00
Tom MacWright
c21a763dc7 Refactor physical unit support 2013-04-15 15:59:17 -04:00
Tom MacWright
207b120dee Fix dimension.js code style 2013-04-15 15:49:39 -04:00
Tom MacWright
49b2324ea1 Handle errant zoom-as-field better. Fixes #269. 2013-04-15 15:45:53 -04:00
Dane Springmeyer
314cef0c75 Merge pull request #271 from mapbox/colorize-alpha
Support variable-length arguments in functions with -1
2013-04-08 13:08:55 -07:00
Tom MacWright
04b1602310 Support variable-length arguments in functions with -1 2013-04-05 16:10:27 -04:00
Tom MacWright
2f76fec686 Do not unnecessarily escape < and chain replacements 2013-03-29 11:47:04 -04:00
Tom MacWright
435452ba50 Merge pull request #265 from strk/master-quote-amp
Quote ampersend chars in XML text. Closes #263.
2013-03-29 08:44:59 -07:00
Tom MacWright
5d626d3c10 Do not output references to empty styles. Fixes #244 2013-03-27 11:59:09 -04:00
Tom MacWright
49c81edd3a Tolerate single-stop colorizers. Fixes #251 2013-03-27 11:48:47 -04:00
Tom MacWright
05797dd711 Tolerate commas in values. Fixes #266 2013-03-27 11:30:51 -04:00
Tom MacWright
86abdcd700 Fix #262,
when selectors are exactly the same, still push them into the list.
2013-03-27 10:44:12 -04:00
Sandro Santilli
d6585d3691 Quote all needed XML chars. See #263.
Includes testcase.
2013-03-27 12:36:25 +01:00
Sandro Santilli
acf94e5fab Quote ampersend chars in XML text. Closes #263.
Includes testcase.
2013-03-22 11:11:16 +01:00
Tom MacWright
60661b68c3 Add failing identity nesting case, refs #262 2013-03-17 19:31:22 -04:00
Tom MacWright
5e2ea67df9 Fix repeated comments in selectors. Fixes #260 2013-03-13 11:27:00 -04:00
Tom MacWright
26dbcf3ca3 Fix test for missing brackets 2013-03-11 16:34:43 -04:00
Tom MacWright
3382bfa29f Merge branch 'missing-bracket' 2013-03-11 16:32:48 -04:00
Tom MacWright
7ac2d81062 Merge pull request #257 from tomhughes/master
Add a man page for carto
2013-03-03 11:30:48 -08:00
Tom Hughes
caa639beb8 Add a man page for carto 2013-03-03 19:05:47 +00:00
Dane Springmeyer
039031b68d fix failing tests in master 2013-03-01 15:22:22 -05:00
Dane Springmeyer
19bf87cf3a fix expected result so test passes because it appears #239 is not actually a regression 2013-03-01 15:14:23 -05:00
Dane Springmeyer
8efc1c5d5e output both path to json mismatches to make debugging test failures easier 2013-03-01 15:08:29 -05:00
Dane Springmeyer
e8566e817e point to master mapnik-reference 2013-03-01 15:08:05 -05:00
root
7deb1b86e0 Merge branch 'layerzoom' 2013-02-26 11:40:58 -05:00
Tom MacWright
c5a67fa938 Missing bracket. Refs #254 2013-02-25 09:17:56 -05:00
Young Hahn
be78202e0b Allow layers to be rendered without datasources. 2013-02-21 15:29:33 -05:00
Tom MacWright
0e0bac0e5c Fix fadeout 2013-02-18 17:34:49 -05:00
Dane Springmeyer
6ca0c705c8 add raster colorizer (https://github.com/mapnik/mapnik/wiki/RasterColorizer) support to master - closes #5 - refs mapbox/tilemill#761 - depends on 41772edbd7 2013-02-12 11:17:56 -08:00
Tom MacWright
4c044f93fe Merge pull request #250 from tomhughes/master
Update xml2js dependency
2013-02-10 12:49:43 -08:00
Tom Hughes
48d89889fe Update to use v0.2.x of xml2js 2013-02-10 20:46:12 +00:00
root
47464fc18d Convert minzoom/maxzoom parameters on Layer properties. 2013-02-04 16:42:57 -05:00
Dane Springmeyer
74fa914c8c updated raster colorizer support 2013-02-01 15:57:29 -05:00
Tom MacWright
55fbafe0d0 Merge branch 'master' of github.com:mapbox/carto 2013-01-31 08:54:41 -05:00
Tom MacWright
5fa4478d40 Fix rgba handling, fixes #246 2013-01-31 08:54:27 -05:00
Dane Springmeyer
633754306e add testcase for issue #239 2013-01-23 16:59:22 -08:00
Dane Springmeyer
3f70b8a36c avoid unneeded whitespace in style XML output 2013-01-23 16:57:27 -08:00
Tom MacWright
16f60edc50 Merge pull request #243 from mapbox/localize-on-demand
Localize on demand
2013-01-23 16:16:39 -08:00
Dane Springmeyer
76b271ebc5 change carto command line to only try to localize mml docs if explicitly requested 2013-01-23 13:01:55 -08:00
Tom MacWright
3fd91ccb6b Predo changelog 2013-01-23 16:01:31 -05:00
Tom MacWright
e2764d12f1 Add rendering tests for units 2013-01-23 16:01:03 -05:00
Dane Springmeyer
8c51c59fe9 Merge pull request #240 from stefanklug/units
Add unit support to css
2013-01-23 12:47:30 -08:00
Stefan Klug
cf8c11f038 replace dpi by ppi 2013-01-23 10:20:04 +01:00
Tom MacWright
31504baabe Merge pull request #241 from stefanklug/extent
don't overwrite maximum-extent when specified in mml
2013-01-21 09:50:41 -08:00
Stefan Klug
8f8c1ad39b remove debug output 2013-01-21 18:43:49 +01:00
Stefan Klug
494c07d383 don't overwrite maximum-extent when specified in mml 2013-01-21 18:28:10 +01:00
Stefan Klug
de40fd4e42 added dpi parameter to carto bin
use optimist to parse command line arguments
2013-01-21 16:40:16 +01:00
Stefan Klug
6a5309e22e fixed regression introduced in last commit 2013-01-21 16:40:16 +01:00
Stefan Klug
56ac678c0a add support for the units m, mm, cm, pt, pc
these are converted to pixels depending on env.dpi (defaulting to 90.714)

adding and subtracting percentages works also
2013-01-21 16:40:15 +01:00
Tom MacWright
1769cb4a59 Merge branch 'master' of github.com:mapbox/carto 2013-01-16 17:42:31 -05:00
AJ Ashton
9deb60cd08 Fix numeric check regex 2013-01-16 17:15:28 -05:00
Tom MacWright
a687bec9b6 Merge pull request #236 from stefanklug/fix-global-install
fix carto to work as global node module
2013-01-11 05:41:46 -08:00
Stefan Klug
c9d88add12 fix carto to work as global node module 2013-01-11 13:17:58 +01:00
Tom MacWright
6ce476d2a2 parseFloat sucks 2013-01-08 16:42:50 -05:00
Dane Springmeyer
0d686bb8d8 fixup code comments - amends 87d4f9627b 2013-01-06 11:58:14 -08:00
Tom MacWright
f3bde1fde3 No more in operator, checking for undefined is much much faster 2013-01-04 18:45:19 -05:00
Dane Springmeyer
bfc9d40f43 fix testcase issue # 214 -> 204 - previously incorrectly referenced 214 - refs #214 and #204 2013-01-03 18:47:10 -08:00
Tom MacWright
f0e245183a Fix hang around massive stylesheets, fixes mapbox-base 2013-01-03 18:43:12 -05:00
Tom MacWright
4d4abb27b5 clean up renderer, possibly fix issue with attachments, work on function names 2013-01-03 18:32:04 -05:00
Tom MacWright
6eda91a541 Fixing basic jshint issues 2013-01-03 16:29:22 -05:00
Tom MacWright
87d4f9627b Rename eval to ev to fix many jshint problems and future safari problems 2013-01-03 16:19:25 -05:00
Tom MacWright
29b641c72d Detect and report basic self-conflicting filters.
This does not yet report anything for more complex cases. We were also testing for
tolerance of self-conflicting filters, which this breaks, in
partial_overrides. This patch may want to wait for warning reporting
since it may break stylesheets in the wild.
2013-01-03 15:06:07 -05:00
Tom MacWright
6f687ff9e3 Remove throws in function evaluation and handle color function arguments
correctly.
2013-01-03 13:47:51 -05:00
Tom MacWright
ece3eb3b0e Remove throw in zoom evaluation 2013-01-03 13:20:49 -05:00
Tom MacWright
d97286de57 Merge branch 'master' of github.com:mapbox/carto 2013-01-03 10:12:02 -05:00
Tom MacWright
c1e8c3b8f3 Support mapnik keywords in filters and error on bare keywords. Fixes 2013-01-03 10:11:30 -05:00
Dane Springmeyer
3cefa968a0 remove Mapnik2 name in readme for more explicit version string 2013-01-02 10:50:40 -08:00
Tom MacWright
b7773c6452 Tolerate everything but ] in field names. Fixes #230 2013-01-02 11:31:17 -05:00
Tom MacWright
9ed9c2b028 Merge pull request #231 from mapbox/condense
Condense
2013-01-02 08:25:44 -08:00
Tom MacWright
fc500db69b Pay attention to types in filterset, fixes #229. 2013-01-02 11:22:25 -05:00
Tom MacWright
0233c523ea Be backwards compatible for now. 2012-12-29 12:40:31 -05:00
Tom MacWright
4b8256e0f8 Fixing new parser reference to makeError. Fixes #228 2012-12-27 18:19:12 -05:00
Tom MacWright
551571fc17 Refactor 2012-12-27 18:11:48 -05:00
Tom MacWright
43073fa1e8 Further performance tuning, about a 10% improvement on
openstreetmap-carto
2012-12-26 22:23:04 -05:00
Tom MacWright
baab7dd0ec Simplify and unify parser code style 2012-12-26 18:32:47 -05:00
Tom MacWright
f87e8adc95 Unswap specificity tests: ordering is now same as master 2012-12-26 18:24:17 -05:00
Tom MacWright
3f31bcbe5f Fix absolute paths in other symbolizer types 2012-12-26 18:19:39 -05:00
Tom MacWright
9f00195100 Use for in rather than object create 2012-12-26 18:12:01 -05:00
Tom MacWright
6fed91d728 Update chunker, fixes #184. 2012-12-26 17:48:01 -05:00
Tom MacWright
a8133e0d77 Bump mocha version to current 2012-12-26 17:40:33 -05:00
Dane Springmeyer
06b147323f add currently failing test for handling of quoted attributes with : 2012-12-21 18:57:56 -08:00
Dane Springmeyer
47882ccb00 Add another empty rendering test 2012-12-21 18:37:39 -08:00
Dane Springmeyer
73e5178f1f re-enable the standalone-mss rendering tests and fix them by avoiding empty styles and empty rules - closes #219 2012-12-21 18:34:30 -08:00
Dane Springmeyer
8846bfbbcd use console.time for mss benchmarking 2012-12-21 17:49:53 -08:00
Dane Springmeyer
16db1c5b03 fix MSS standalone renderer, fixing failing error handling tests after f6c07afee6 2012-12-21 17:36:18 -08:00
Dane Springmeyer
800122e1af error handling tests should rethrow if the test itself does not throw at all 2012-12-21 17:35:48 -08:00
Dane Springmeyer
3ac86f5fd3 use tree off carto object for consistency 2012-12-21 16:39:29 -08:00
Dane Springmeyer
bd17eed9f5 fix race condition in specificity tests and change expected result so all specificity tests now pass 2012-12-21 16:29:59 -08:00
Dane Springmeyer
c707188ed5 serialize json representation rather than mapnik xml for easier comparision 2012-12-21 16:12:02 -08:00
Dane Springmeyer
539d293388 fix failing zoomselector test by adjusting expected test output as it appears we were testing a bug 2012-12-21 16:11:35 -08:00
Dane Springmeyer
12cd05764b Revert "partially fix regex nest test"
This reverts commit 92d239b7f8.
2012-12-21 15:39:18 -08:00
Dane Springmeyer
92d239b7f8 partially fix regex nest test 2012-12-21 15:32:59 -08:00
Dane Springmeyer
a7c1e0bc49 Merge branch 'condense' of github.com:mapbox/carto into condense 2012-12-21 15:22:25 -08:00
Dane Springmeyer
a55b4ca0e9 disable mss tests for now since they are intentionally failing - lets focus on unintential failures 2012-12-21 15:22:14 -08:00
Tom MacWright
958b61c343 Fix specificity tests 2012-12-21 18:17:59 -05:00
Dane Springmeyer
0a9cb6afe7 Merge branch 'condense' of github.com:mapbox/carto into condense 2012-12-21 15:16:26 -08:00
Tom MacWright
67b66b5568 Fix zoom interpretation in helper 2012-12-21 18:15:31 -05:00
Dane Springmeyer
9967393820 cleanup old failures that now pass 2012-12-21 15:14:36 -08:00
Tom MacWright
75f55f8d04 Update specificity test helper 2012-12-21 18:13:36 -05:00
Dane Springmeyer
2aba917e3d merge master into condense to bring in further race condition fixes in errorhandling tests 2012-12-21 15:13:22 -08:00
Dane Springmeyer
f2a6922586 fix race condition in renderer test and write failures instead of diffing since this can crash on large diffs like the fontset dupe test 2012-12-21 15:05:17 -08:00
Tom MacWright
f6c07afee6 Refine heap performance. Switch back to underscore since lodash does npm
all wrong.
2012-12-21 16:53:38 -05:00
Tom MacWright
22f5d0cc45 Support : in column names 2012-12-20 17:49:11 -05:00
Tom MacWright
f4722f516e Fix tiny, critical bug 2012-12-20 17:42:41 -05:00
Tom MacWright
607c4dba5a Be a little safer with naming 2012-12-20 17:35:03 -05:00
Tom MacWright
b3b7fec337 Compare filters numerically if possible 2012-12-20 15:45:43 -05:00
Tom MacWright
5145655c46 Remove oneline tests for now, update external image 2012-12-20 15:37:12 -05:00
Tom MacWright
a106e2768f Revert "Update chunker to less.js's version. Fixes #184"
This reverts commit 78b3a5a5d4.
2012-12-20 14:36:04 -05:00
Tom MacWright
04cf9013a8 Rewrite zoom filters as objects, support variables in zoom definitions. 2012-12-20 12:37:38 -05:00
Tom MacWright
3c4baaf8cb Update filtervariable test 2012-12-20 11:13:18 -05:00
Tom MacWright
667fd483cc Merge pull request #220 from mapbox/mss-renderer
Mss renderer
2012-12-19 16:35:02 -08:00
Tom MacWright
f693f062ec Allow for filters which compare fields. 2012-12-19 18:59:16 -05:00
Tom MacWright
89f8edbddc Optimize fontset detection 2012-12-19 18:43:05 -05:00
Tom MacWright
73f544333a Remove straggling import stuff 2012-12-19 18:24:35 -05:00
Tom MacWright
d4fe84a7cf Simplify, use lodash where possible 2012-12-19 17:43:35 -05:00
Tom MacWright
84a34be10a Add filter test 2012-12-19 17:37:17 -05:00
Tom MacWright
180cd0cc6e Add field test 2012-12-19 17:34:34 -05:00
Tom MacWright
78ea179c46 Add filterset.eval, support variable filter combinations. 2012-12-19 17:29:53 -05:00
Tom MacWright
9eee907467 Simplify filter system, support numeric variables in filters 2012-12-19 17:01:35 -05:00
Tom MacWright
8603799fa7 Add oneline test 2012-12-19 14:19:13 -05:00
Tom MacWright
78b3a5a5d4 Update chunker to less.js's version. Fixes #184 2012-12-19 14:18:35 -05:00
Tom MacWright
71547d059f Merge and fix renderer optimization' 2012-12-19 12:53:09 -05:00
Tom MacWright
0ebfa5f258 Revert renderer optim 2012-12-19 12:46:06 -05:00
Tom MacWright
4ef52a82af Profile and optimize reference lookups 2012-12-19 12:37:48 -05:00
Tom MacWright
ec0699dd45 Cleanup 2012-12-19 11:53:10 -05:00
Dane Springmeyer
e7ba697fc4 Deeper benchmark output 2012-12-18 19:49:38 -08:00
Dane Springmeyer
0d294c1075 add standalone mss rendering tests for desired empty style dropping behavior - refs #219 2012-12-18 18:25:13 -08:00
Dane Springmeyer
23d11fedc6 skip mss that is valid 2012-12-18 16:40:11 -08:00
Dane Springmeyer
e3e2b42277 do not overwrite filename for mss 2012-12-18 16:25:00 -08:00
Dane Springmeyer
675158cba9 call path.basename on mss filename input 2012-12-18 16:24:14 -08:00
Dane Springmeyer
1e6ede278f add to ignores 2012-12-18 16:14:35 -08:00
Dane Springmeyer
75875e2781 add tests for #214 - test 'a' currently fails for me 2012-12-18 16:12:47 -08:00
Dane Springmeyer
cd948535a5 add test for #218 2012-12-18 16:09:31 -08:00
Dane Springmeyer
33d325b0fc return errors if any have occurred - refs #128 2012-12-18 16:07:50 -08:00
Dane Springmeyer
4825f9aee8 only call done when the test is actually finished, whether error or not - refs #210 2012-12-18 16:02:44 -08:00
Dane Springmeyer
7d7cc2653c add tests specifically of error handling of parsing standalone mss files 2012-12-18 15:51:39 -08:00
Dane Springmeyer
0c04ad07b6 move the mss standalone renderer into core to make it easier to maintain - and add more fine grained benchmark output 2012-12-18 15:44:39 -08:00
Tom MacWright
1c569ce39d Simplify style.js 2012-12-18 17:41:08 -05:00
Tom MacWright
f41312597c Move .is to prototype, start testing quoteds 2012-12-18 17:16:40 -05:00
Tom MacWright
4181df378f Rewrite filterset in more vanilla-javascript style, add more tests 2012-12-18 16:50:53 -05:00
Tom MacWright
13bc8c3488 Start on a condense branch. This is related to #20
See https://gist.github.com/4329932 for more detail.
2012-12-18 13:27:04 -05:00
Tom MacWright
4c7af7f492 Merge pull request #217 from mapbox/stderr
Use stderr for error messages, use console instead of util
2012-12-18 08:57:23 -08:00
Tom MacWright
19ac7b2fb0 Use stderr for error messages, use console instead of util 2012-12-15 19:24:44 -05:00
Tom MacWright
217498a207 Push to 0.9.4 with regex nesting fix 2012-12-06 12:50:04 -05:00
Tom MacWright
25a2940ebc Fix regex nesting inheritance 2012-12-06 12:48:09 -05:00
Tom MacWright
2fcbdaacfd Stricter equality for empty string arguments to functions, and tests. 2012-11-29 15:17:06 -05:00
Dane Springmeyer
8ef4efbe39 fix handling of no errors from error handling tests - closes #210 2012-11-29 11:36:39 -08:00
Dane Springmeyer
a21a195f1b log layer id when benchmarking 2012-10-24 16:19:48 -07:00
Dane Springmeyer
dc798c0e07 Merge branch 'master' of github.com:mapbox/carto 2012-10-24 13:06:02 -07:00
Dane Springmeyer
410f47b5ce report correct, current carto version via package.json - closes #205 2012-10-24 13:04:25 -07:00
Tom MacWright
1eaf7e4fbf Remove & from old-style less combinators in the parser 2012-10-21 21:08:11 -04:00
Tom MacWright
e1a484018f Merge pull request #200 from mapbox/mss-out
add mss support to carto command line program
2012-10-21 15:04:18 -07:00
Tom MacWright
8fc2c06b45 Evaluate calls before keywords. Fixes #203 2012-10-21 17:57:45 -04:00
Tom MacWright
5cbe78457c Merge pull request #201 from mapbox/nested-classes
Fix nested class behavior.
2012-10-15 19:21:12 -07:00
Dane Springmeyer
840e16a3f2 improve carto command line to be able to handle just converting mss chunks - mostly for easy testing 2012-10-15 13:14:47 -07:00
Tom MacWright
f9fcffeeba Fix nested class behavior. This changes the output of complex_cascades
and changes current behavior, but to the best of my sleep-deprived
cognition I think we were testing for incorrect behavior.
2012-10-15 10:16:27 -07:00
Tom MacWright
5978135bb6 Finalize renaming 2012-10-09 21:44:59 -04:00
Tom MacWright
dde52e43aa Note gravitystorm 2012-10-09 21:43:44 -04:00
Tom MacWright
1efa60757b Update readme 2012-10-09 21:42:40 -04:00
Tom MacWright
13448ee297 Bump package 2012-10-09 21:35:24 -04:00
Tom MacWright
cce8440755 Push changelog 2012-10-09 21:35:04 -04:00
Tom MacWright
00e797dc2d Did you mean for properties, with proper levenstein distance for
better matching. Fixes #199
2012-10-09 21:30:42 -04:00
Tom MacWright
e7658c618e Much better error reporting, did you mean 2012-10-09 09:09:17 -04:00
Tom MacWright
45657268f9 More verbose and informative error messages, especially when dealing
with keyword values. Fixes #109
2012-10-08 18:39:09 -04:00
Tom MacWright
1d9b5d93ca Permit keywords as strings. Fixes #193 2012-10-08 18:28:27 -04:00
Tom MacWright
4b7fc5fb57 Fix concatenation of strings with variables and other strings 2012-10-08 18:12:54 -04:00
Tom MacWright
67f007064a Report unclosed strings as well. Fixes #188" 2012-10-08 18:03:18 -04:00
Dane Springmeyer
896b247fe9 avoid wrapping in CDATA if special inline 'Format' is used - closes #196 2012-10-05 17:03:13 -07:00
Tom MacWright
3d216f6295 Test for #192 to keep it closed 2012-09-29 16:54:10 -04:00
Tom MacWright
afdac4b94f Merge pull request #192 from gravitystorm/patch-2
Include the instance name in the rule id (fixes #177)
2012-09-29 13:53:31 -07:00
Tom MacWright
e055301fa8 Merge pull request #191 from gravitystorm/patch-1
Remove legacy comment
2012-09-29 13:51:49 -07:00
Andy Allan
25343589ab Include the instance name in the rule id
This fixes #177. The addRules method of definition.js checks rule inheritance using the id of the rule, and only adds rules from ancestors if the id is different. However, without this patch, foo/line-color and bar/line-color have the same id and therefore aren't recognised as applying to different instances.
2012-09-28 16:37:00 +02:00
Andy Allan
0560ae9f86 Remove legacy comment
Remove the comment for the extend method, which was removed back in 7c81eb353d
2012-09-28 16:27:23 +02:00
Tom MacWright
4a9b5b5939 Remove directives. Fixes #157 2012-09-21 15:12:39 -04:00
Tom MacWright
101026fe3c Fix parsing of selectors with comments between elements.
This brings over cloudhead/less.js@3331637913 and fixes #179
2012-09-21 14:52:47 -04:00
Tom MacWright
912988e174 Fix parsing of whitespace in calls.
This brings over cloudmade/less.js@333d1def4 to permit whitespace in
front of arguments of function calls, and tweaks the related test to
make sure it stays that way. This fixes #154
2012-09-21 14:27:19 -04:00
Tom MacWright
033a5cd5a5 Add missing MML file for transforms test 2012-09-21 14:20:21 -04:00
Dane Springmeyer
6a794cd610 add raster-mesh-size test and bump to 0.9.2 2012-09-06 22:33:27 -07:00
Dane Springmeyer
63152ef4e3 fix tests 2012-09-06 22:31:31 -07:00
Dane Springmeyer
31ea5ff6c6 use mapnik-reference tag 2012-09-06 22:23:51 -07:00
Tom MacWright
03867bf61b Point to numbertypes branch of mapnik-reference 2012-09-04 12:58:32 -04:00
Tom MacWright
829fe84baf Add unsigned support and test code 2012-09-04 12:57:25 -04:00
Dane Springmeyer
f4132221d6 use latest mapnik-reference 2012-08-30 17:16:38 -07:00
Dane Springmeyer
5e5de824de bump to 0.9.1 2012-08-15 15:04:49 -07:00
Tom MacWright
02b8cae3c7 Remove anonymous type. Fixes #148 2012-08-15 17:27:22 -04:00
Tom MacWright
0a10327fb1 Update mocha version and use spec reporter 2012-08-15 17:20:43 -04:00
Tom MacWright
bd3073bbed Remove variable is for the time being 2012-08-15 17:12:37 -04:00
Tom MacWright
73a7c6b87a Merge pull request #173 from mapbox/fix-mapnik-functions
Fix mapnik functions
2012-08-15 14:09:02 -07:00
Dane Springmeyer
788aa03e80 use latest mapnik-reference 2012-08-14 13:49:20 -07:00
Dane Springmeyer
874f51870a adapt to Mapnik 2.1 syntax for new features that are settling out - specifically now using commas to separate chained transforms or image-filters and using () in agg-stack-blur image filter - refs #171 and #140 2012-08-14 13:26:33 -07:00
Tom MacWright
26e690dc0d Make more types identify themselves with is, don't tolerate
incorrectly-cased functions.
2012-08-13 17:37:51 -04:00
Tom MacWright
5b024a1465 Fix code style. 2012-08-13 11:15:45 -04:00
Tom MacWright
0c4de0dc38 Merge pull request #170 from strk/throw_on_unsupported_mapnik_version
Error out on unsupported mapnik version
2012-08-13 08:14:31 -07:00
Sandro Santilli
0377e809ea Have setVersion return a bool, rather than throwing an exception 2012-08-13 10:44:59 +02:00
Sandro Santilli
b24288b7ef Have render() catch Reference errors by invoking the user callback 2012-08-10 19:33:14 +02:00
Sandro Santilli
42e9c476f5 Throw an exception when an unsupported mapnik version is requested 2012-08-08 09:31:13 +02:00
Tom MacWright
dd8169ea84 Rename sys to util to fix last commit 2012-08-07 11:32:07 -04:00
Dane Springmeyer
6d8c963af2 remove unused sys require 2012-08-02 14:48:04 -07:00
Dane Springmeyer
53e7ece4cc finish update to use mapnik-reference 0.4.0 2012-08-01 18:16:48 -07:00
Dane Springmeyer
3710517fdc bump to 0.9.0 with breaking rename changes in experimental features via mapnik-reference 2012-08-01 17:55:56 -07:00
67 changed files with 19776 additions and 6222 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
/node_modules
*.swp
.DS_Store
test/rendering/layers/
test/rendering/cache/
test/rendering-mss/npm-debug.log
.idea/

View File

@ -1,6 +1,9 @@
language: node_js
node_js:
- "0.11"
- "0.10"
- "0.8"
- '6'
- '8'
- '10'
script:
- npm test

9
CHANGELOG.carto.md Normal file
View File

@ -0,0 +1,9 @@
## CARTO's Changelog
## 0.15.1-cdb5
2018-11-20
* Support Node.js 6, 8 and, 10
* Drop support for Node.js 0.10 and 0.11
* Add package-lock.json
* Add CHANGELOG.carto.md

View File

@ -1,7 +1,18 @@
## Changelog
## 0.11.1-dev-browser
* added rectangle option for marker-type
## 0.14.0
* Support for Mapnik 3.x
* Bump `mapnik-reference` dependency to ~6.0.1.
## 0.13.0
* Allows optional args in transforms.
* Bump `mapnik-reference` dependency to 5.1.x.
## 0.12.0
* Drop mml2json and xml2js dependency.
## 0.11.0

View File

@ -3,12 +3,15 @@
#
expresso = ./node_modules/.bin/mocha
docco = ./node_modules/.bin/docco
uglify = ./node_modules/.bin/uglify
UGLIFYJS=./node_modules/.bin/uglifyjs
BROWSERIFY = ./node_modules/.bin/browserify
JS_CLIENT_FILES=browser/*.js lib/carto/parser.js lib/carto/tree.js lib/carto/tree/*.js lib/carto/functions.js lib/carto/renderer_js.js
dist/carto.js: dist/carto.uncompressed.js $(shell $(BROWSERIFY) --list lib/carto/index.js)
$(UGLIFYJS) dist/carto.uncompressed.js > $@
dist/carto.uncompressed.js: dist $(shell $(BROWSERIFY) --list lib/carto/index.js)
$(BROWSERIFY) lib/carto/index.js --exclude node_modules/underscore/underscore.js --standalone carto > $@
all: dist
lint:
./node_modules/.bin/jshint lib/carto/*.js lib/carto/tree/*.js
@ -23,13 +26,10 @@ endif
check: test
doc:
$(docco) lib/carto/*.js lib/carto/tree/*.js
dist:
mkdir -p dist
dist/carto.js: $(JS_CLIENT_FILES)
cat $(JS_CLIENT_FILES) > dist/carto.js
dist: dist/carto.js
.PHONY: test

View File

@ -1,6 +1,6 @@
# CartoCSS
[![Build Status](https://secure.travis-ci.org/mapbox/carto.png)](http://travis-ci.org/mapbox/carto)
[![Build Status](https://travis-ci.org/CartoDB/carto.png?branch=master)](https://travis-ci.org/CartoDB/carto)
Is as stylesheet renderer for javascript, It's an evolution of the Mapnik renderer from Mapbox.
Please, see original [Mapbox repo](http://github.com/mapbox/carto) for more information and credits

View File

@ -1,69 +0,0 @@
#!/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(/<!ENTITY([^>]|"([^"]|\\")*")+>/g)
if (match != null) {
match.forEach(function(entity) {
var parts = entity.match(/^<!ENTITY\s+(\w+)\s+"(.+)">$/);
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);
});

View File

@ -1,13 +0,0 @@
var assert = {
ok: function(value, message) {
message = message || '';
if(!value) throw new Error("assertion failed", message);
}
};
if (navigator.userAgent.indexOf('MSIE 8.0') !== -1 || navigator.userAgent.indexOf('MSIE 7.0') !== -1) {
Object.defineProperty = function(o, p, fn) { o[p] = fn.value; };
}

View File

@ -1,4 +0,0 @@
var carto_initialize = function(carto, uri, callback) {
callback();
};

View File

@ -1,23 +0,0 @@
//
// Stub out `require` in the browser
//
window.carto = window.carto || {};
window.carto.underscore = window._;
function require(arg) {
var mod = window.carto[arg];
if(!mod) {
mod = window.carto[arg.split('/')[1]];
}
if(!mod) {
mod = window.carto[arg]
}
if(!mod) {
mod = window[arg.split('/')[1]];
}
// try global scope
if(!mod) {
mod = window[arg]
}
return mod;
}

5255
dist/carto.js vendored

File diff suppressed because one or more lines are too long

7375
dist/carto.uncompressed.js vendored Normal file

File diff suppressed because it is too large Load Diff

15
docs-generator/README.md Normal file
View File

@ -0,0 +1,15 @@
# Generating CartoCSS docs
From the `docs-generator/` directory:
```
$ npm install
```
Then:
```
$ node generate.js
```
Will save docs to `docs/`.

View File

@ -0,0 +1,23 @@
var fs = require('fs'),
path = require('path'),
refs = require('mapnik-reference'),
_ = require('underscore');
function tmpl(x) {
return _.template(fs.readFileSync(path.join(__dirname, x), 'utf-8'));
}
var index = tmpl('index._');
var table = tmpl('symbolizers._');
var versions = Object.keys(refs.version);
for (var v in refs.version) {
var ref = refs.version[v];
fs.writeFileSync(path.join(__dirname, '../docs/' + v + '.md'), index({
symbolizers: ref.symbolizers,
table: table,
version: v,
versions: versions,
_: _
}));
}

144
docs-generator/index._ Normal file
View File

@ -0,0 +1,144 @@
# Carto documentation
The following is a list of properties provided in CartoCSS that you can apply to map elements.
<%= table({symbolizers:symbolizers}) %>
### Values
Below is a list of values and an explanation of any expression that can be applied to properties in CartCSS.
### Color
CartoCSS accepts a variety of syntaxes for colors - HTML-style hex values, rgb, rgba, hsl, and hsla. It also supports the predefined HTML colors names, like `yellow` and `blue`.
``` css
#line {
line-color: #ff0;
line-color: #ffff00;
line-color: rgb(255, 255, 0);
line-color: rgba(255, 255, 0, 1);
line-color: hsl(100, 50%, 50%);
line-color: hsla(100, 50%, 50%, 1);
line-color: yellow;
}
```
Especially of note is the support for hsl, which can be [easier to reason about than rgb()](http://mothereffinghsl.com/). Carto also includes several color operation functions [borrowed from less](http://lesscss.org/functions/#color-operations):
``` css
// lighten and darken colors
lighten(#ace, 10%);
darken(#ace, 10%);
// saturate and desaturate
saturate(#550000, 10%);
desaturate(#00ff00, 10%);
// increase or decrease the opacity of a color
fadein(#fafafa, 10%);
fadeout(#fefefe, 14%);
// spin rotates a color around the color wheel by degrees
spin(#ff00ff, 10);
// mix generates a color in between two other colors.
mix(#fff, #000, 50%);
```
These functions all take arguments which can be color variables, literal colors, or the results of other functions operating on colors.
### Float
Float is a fancy way of saying 'number'. In CartoCSS, you specify _just a number_ - unlike CSS, there are no units, but everything is specified in pixels.
``` css
#line {
line-width: 2;
}
```
It's also possible to do simple math with number values:
``` css
#line {
line-width: 4 / 2; // division
line-width: 4 + 2; // addition
line-width: 4 - 2; // subtraction
line-width: 4 * 2; // multiplication
line-width: 4 % 2; // modulus
}
```
### URI
URI is a fancy way of saying URL. When an argument is a URI, you use the same kind of `url('place.png')` notation that you would with HTML. Quotes around the URL aren't required, but are highly recommended. URIs can be paths to places on your computer, or on the internet.
```css
#markers {
marker-file: url('marker.png');
}
```
### String
A string is basically just text. In the case of CartoCSS, you're going to put it in quotes. Strings can be anything, though pay attention to the cases of `text-name` and `shield-name` - they actually will refer to features, which you refer to by putting them in brackets, as seen in the example below.
```css
#labels {
text-name: "[MY_FIELD]";
}
```
### Boolean
Boolean means yes or no, so it accepts the values `true` or `false`.
```css
#markers {
marker-allow-overlap:true;
}
```
### Expressions
Expressions are statements that can include fields, numbers, and other types in a really flexible way. You have run into expressions before, in the realm of 'fields', where you'd specify `"[FIELD]"`, but expressions allow you to drop the quotes and also do quick addition, division, multiplication, and concatenation from within Carto syntax.
```css
#buildings {
building-height: [HEIGHT_FIELD] * 10;
}
```
### Numbers
Numbers are comma-separated lists of one or more number in a specific order. They're used in line dash arrays, in which the numbers specify intervals of line, break, and line again.
```css
#disputedboundary {
line-dasharray: 1, 4, 2;
}
```
### Percentages
In Carto, the percentage symbol, `%` universally means `value/100`. It's meant to be used with ratio-related properties, like opacity rules.
_You should not use percentages as widths, heights, or other properties - unlike CSS, percentages are not relative to cascaded classes or page size, they're, as stated, simply the value divided by one hundred._
```css
#world {
// this syntax
polygon-opacity: 50%;
// is equivalent to
polygon-opacity: 0.5;
}
```
### Functions
Functions are comma-separated lists of one or more functions. For instance, transforms use the `functions` type to allow for transforms within Carto, which are optionally chainable.
```css
#point {
point-transform: scale(2, 2);
}
```

View File

@ -0,0 +1,20 @@
{
"name": "carto-site",
"private": true,
"version": "0.0.0",
"description": "Mapnik Stylesheet Compiler",
"url": "https://github.com/mapbox/carto",
"repositories": [{
"type": "git",
"url": "http://github.com/mapbox/carto.git"
}],
"author": {
"name": "MapBox",
"url": "http://mapbox.com/",
"email": "info@mapbox.com"
},
"dependencies": {
"mapnik-reference": "5.0.x",
"underscore": "~1.3.3"
}
}

View File

@ -0,0 +1,13 @@
<% _(symbolizers).each(function(symbolizer, name) { %>
<% if (name == '*') { %>## All elements<% } else { %>## <%= name %><% } %>
<% _(symbolizer).chain().filter(function(p) { return p.css; }).each(function(p) { %>
##### <%= p.css.replace(/\s/g, '') %> <% if (_.isArray(p.type)) { %>`keyword`<% } else { %>`<%= p.type %>`<% } %>
<% if (_.isArray(p.type)) { %><% _(p.type).each(function(type) { %>`<%= type %>`<% }); %><% } %>
<% if (typeof p['default-value'] !== '') { %>Default Value: <%= p['default-value'] %><% } %>
<% if (p['default-meaning']) { %>_(<%- p['default-meaning'] %>)_<% } %>
<% if (typeof p['range'] !== 'undefined') { %>Range: <%= '' + p['range'] %><% } %>
<% if (p.doc) { %><%- p.doc%><% } %>
* * *
<% }); %>
<% }); %>

1159
docs/2.0.0.md Normal file

File diff suppressed because it is too large Load Diff

1159
docs/2.0.1.md Normal file

File diff suppressed because it is too large Load Diff

1159
docs/2.0.2.md Normal file

File diff suppressed because it is too large Load Diff

1486
docs/2.1.0.md Normal file

File diff suppressed because it is too large Load Diff

1495
docs/2.1.1.md Normal file

File diff suppressed because it is too large Load Diff

1687
docs/latest.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,18 @@
var util = require('util');
[ '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', 'frame_offset'
].forEach(function(n) {
require('./tree/' + n);
});
var util = require('util'),
fs = require('fs'),
path = require('path');
function getVersion() {
return '0.0.1-browser';
if (process.browser) {
return require('../../package.json').version.split('.');
} else 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 = {
@ -20,6 +21,7 @@ var carto = {
Renderer: require('./renderer').Renderer,
tree: require('./tree'),
RendererJS: require('./renderer_js'),
default_reference: require('./torque-reference'),
// @TODO
writeError: function(ctx, options) {
@ -51,7 +53,7 @@ var carto = {
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';
error = options.indent + error.join('\n' + options.indent) + '\x1B[0m\n';
message = options.indent + message + stylize(ctx.message, 'red');
if (ctx.filename) (message += stylize(' in ', 'red') + ctx.filename);
@ -66,7 +68,34 @@ var carto = {
}
};
require('./tree/call');
require('./tree/color');
require('./tree/comment');
require('./tree/definition');
require('./tree/dimension');
require('./tree/element');
require('./tree/expression');
require('./tree/filterset');
require('./tree/filter');
require('./tree/field');
require('./tree/keyword');
require('./tree/layer');
require('./tree/literal');
require('./tree/operation');
require('./tree/quoted');
require('./tree/imagefilter');
require('./tree/reference');
require('./tree/rule');
require('./tree/ruleset');
require('./tree/selector');
require('./tree/style');
require('./tree/url');
require('./tree/value');
require('./tree/variable');
require('./tree/zoom');
require('./tree/invalid');
require('./tree/fontset');
require('./tree/frame_offset');
require('./functions');
for (var k in carto) { exports[k] = carto[k]; }
@ -82,6 +111,6 @@ function stylize(str, style) {
'red' : [31, 39],
'grey' : [90, 39]
};
return '\033[' + styles[style][0] + 'm' + str +
'\033[' + styles[style][1] + 'm';
return '\x1B[' + styles[style][0] + 'm' + str +
'\x1B[' + styles[style][1] + 'm';
}

View File

@ -1,42 +1,7 @@
var carto = exports,
tree = require('./tree'),
_ = global._ || require('underscore');
if (typeof(exports) !== 'undefined') {
carto = exports;
tree = require('./tree');
_ = require('underscore');
} else {
if (typeof(window.carto) === 'undefined') { window.carto = {}; }
carto = window.carto;
tree = window.carto.tree = {};
_ = window._;
}
// carto.js - parser
//
// A relatively straight-forward predictive parser.
// There is no tokenization/lexing stage, the input is parsed
// in one sweep.
//
// To make the parser fast enough to run in the browser, several
// optimization had to be made:
//
// - Matching and slicing on a huge input is often cause of slowdowns.
// The solution is to chunkify the input into smaller strings.
// The chunks are stored in the `chunks` var,
// `j` holds the current chunk index, and `current` holds
// the index of the current chunk in relation to `input`.
// This gives us an almost 4x speed-up.
//
// - In many cases, we don't need to match individual tokens;
// for example, if a value doesn't hold any variables, operations
// or dynamic references, the parser can effectively 'skip' it,
// treating it as a literal.
// An example would be '1px solid #000' - which evaluates to itself,
// we don't need to know what the individual components are.
// The drawback, of course is that you don't get the benefits of
// syntax-checking on the CSS. This gives us a 50% speed-up in the parser,
// and a smaller speed-up in the code-gen.
//
//
// 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.
@ -149,8 +114,9 @@ carto.Parser = function Parser(env) {
// - `index`: Char. index where the error occurred.
function makeError(err) {
var einput;
var errorTemplate;
_(err).defaults({
_.defaults(err, {
index: furthest,
filename: env.filename,
message: 'Parse error.',
@ -168,8 +134,8 @@ carto.Parser = function Parser(env) {
for (var n = err.index; n >= 0 && einput.charAt(n) !== '\n'; n--) {
err.column++;
}
return new Error(_('<%=filename%>:<%=line%>:<%=column%> <%=message%>').template(err));
errorTemplate = _.template('<%=filename%>:<%=line%>:<%=column%> <%=message%>');
return new Error(errorTemplate(err));
}
this.env = env = env || {};
@ -511,6 +477,7 @@ carto.Parser = function Parser(env) {
return new tree.Dimension(value[1], value[2], memo);
}
}
},
// The variable part of a variable definition.
@ -759,10 +726,22 @@ carto.Parser = function Parser(env) {
},
// A sub-expression, contained by parenthensis
sub: function() {
var e;
var e, expressions = [];
if ($('(') && (e = $(this.expression)) && $(')')) {
return e;
if ($('(')) {
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);
}
},
// This is a misnomer because it actually handles multiplication

View File

@ -1,10 +1,10 @@
var _ = require('underscore');
var _ = global._ || 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';
this.options.mapnik_version = this.options.mapnik_version || '3.0.0';
};
/**
@ -16,7 +16,7 @@ carto.Renderer = function Renderer(env, options) {
carto.Renderer.prototype.renderMSS = function render(data) {
// effects is a container for side-effects, which currently
// are limited to FontSets.
var env = _(this.env).defaults({
var env = _.defaults(this.env, {
benchmark: false,
validation_data: false,
effects: []
@ -70,7 +70,7 @@ carto.Renderer.prototype.renderMSS = function render(data) {
carto.Renderer.prototype.render = function render(m) {
// effects is a container for side-effects, which currently
// are limited to FontSets.
var env = _(this.env).defaults({
var env = _.defaults(this.env, {
benchmark: false,
validation_data: false,
effects: [],
@ -84,14 +84,14 @@ carto.Renderer.prototype.render = function render(m) {
var output = [];
// Transform stylesheets into definitions.
var definitions = _(m.Stylesheet).chain()
var definitions = _.chain(m.Stylesheet)
.map(function(s) {
if (typeof s == 'string') {
throw 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});
env = _.extend(env, {filename:s.id});
var time = +new Date(),
root = (carto.Parser(env)).parse(s.data);
@ -152,7 +152,7 @@ carto.Renderer.prototype.render = function render(m) {
if (env.errors) throw env.errors;
// Pass TileJSON and other custom parameters through to Mapnik XML.
var parameters = _(m).reduce(function(memo, v, k) {
var parameters = _.reduce(m, function(memo, v, k) {
if (!v && v !== 0) return memo;
switch (k) {
@ -205,7 +205,7 @@ carto.Renderer.prototype.render = function render(m) {
'\n</Parameters>\n'
);
var properties = _(map_properties).map(function(v) { return ' ' + v; }).join('');
var properties = _.map(map_properties, function(v) { return ' ' + v; }).join('');
output.unshift(
'<?xml version="1.0" ' +

View File

@ -1,10 +1,11 @@
(function(carto) {
var tree = require('./tree');
var _ = require('underscore');
var _ = global._ || require('underscore');
function CartoCSS(style, options) {
this.options = options || {};
this.imageURLs = [];
if(style) {
this.setStyle(style);
}
@ -37,12 +38,11 @@ CartoCSS.Layer.prototype = {
eval: function(prop) {
var p = this.shader[prop];
if (!p) return;
return p({}, { zoom: 0, 'frame-offset': 0 });
if (!p || !p.style) return;
return p.style({}, { zoom: 0, 'frame-offset': 0 });
},
/*
* `target`: style, 'svg', 'canvas-2d'...
* `props`: feature properties
* `context`: rendering properties, i.e zoom
*/
@ -57,7 +57,7 @@ CartoCSS.Layer.prototype = {
},
/**
* return the symbolizers that need to be rendered with
* return the symbolizers that need to be rendered with
* this style. The order is the rendering order.
* @returns a list with 3 possible values 'line', 'marker', 'polygon'
*/
@ -99,7 +99,7 @@ CartoCSS.Layer.prototype = {
//
// given a geoemtry type returns the transformed one acording the CartoCSS
// For points there are two kind of types: point and sprite, the first one
// For points there are two kind of types: point and sprite, the first one
// is a circle, second one is an image sprite
//
// the other geometry types are the same than geojson (polygon, linestring...)
@ -165,6 +165,9 @@ CartoCSS.prototype = {
}
}
},
getImageURLs: function(){
return this.imageURLs;
},
parse: function(cartocss) {
var parse_env = {
@ -199,10 +202,19 @@ CartoCSS.prototype = {
var layer = layers[key] = (layers[key] || {
symbolizers: []
});
for(var u = 0; u<def.rules.length; u++){
var rule = def.rules[u];
if(rule.name === "marker-file" || rule.name === "point-file"){
var value = rule.value.value[0].value[0].value.value;
this.imageURLs.push(value);
}
}
layer.frames = [];
layer.zoom = tree.Zoom.all;
var props = def.toJS(parse_env);
console.log("props", props);
if (this.options.debug) console.log("props", props);
for(var v in props) {
var lyr = layer[v] = layer[v] || {
constant: false,
@ -217,15 +229,25 @@ CartoCSS.prototype = {
// serach the max index to know rendering order
lyr.index = _.max(props[v].map(function(a) { return a.index; }).concat(lyr.index));
lyr.constant = !_.any(props[v].map(function(a) { return !a.constant; }));
// True when the property is filtered.
lyr.filtered = props[v][0].filtered;
}
}
var ordered_layers = [];
console.log(layers);
if (this.options.debug) console.log(layers);
var done = {};
for(var i = 0; i < defs.length; ++i) {
var def = defs[i];
if (this.options.strict) {
def.toXML(parse_env, {});
if (parse_env.errors.message) {
throw new Error(parse_env.errors.message);
}
}
var k = defKey(def);
var layer = layers[k];
if(!done[k]) {
@ -262,11 +284,13 @@ CartoCSS.prototype = {
carto.RendererJS = function (options) {
this.options = options || {};
this.options.mapnik_version = this.options.mapnik_version || 'latest';
this.reference = this.options.reference || require('./torque-reference').version.latest;
this.options.strict = this.options.hasOwnProperty('strict') ? this.options.strict : false;
};
// Prepare a javascript object which contains the layers
carto.RendererJS.prototype.render = function render(cartocss, callback) {
tree.Reference.setVersion(this.options.mapnik_version);
tree.Reference.setData(this.reference);
return new CartoCSS(cartocss, this.options);
}

View File

@ -1,5 +1,3 @@
window.carto = window.carto || {};
var _mapnik_reference_latest = {
"version": "2.1.1",
"style": {
@ -27,7 +25,10 @@ var _mapnik_reference_latest = {
["x-gradient", 0],
["y-gradient", 0],
["invert", 0],
["sharpen", 0]
["sharpen", 0],
["colorize-alpha", -1],
["color-to-alpha", 1],
["scale-hsla", 8]
],
"doc": "A list of image filters."
},
@ -162,7 +163,20 @@ var _mapnik_reference_latest = {
["x-gradient", 0],
["y-gradient", 0],
["invert", 0],
["sharpen", 0]
["sharpen", 0],
["colorize-alpha", -1],
["color-to-alpha", 1],
["scale-hsla", 8],
["buckets", -1],
["category", -1],
["equal", -1],
["headtails", -1],
["jenks", -1],
["quantiles", -1],
["cartocolor", -1],
["colorbrewer", -1],
["range", -1],
["ramp", -1]
],
"doc": "A list of image filters."
},
@ -289,14 +303,16 @@ var _mapnik_reference_latest = {
"type": "color",
"default-value": "rgba(128,128,128,1)",
"default-meaning": "gray and fully opaque (alpha = 1), same as rgb(128,128,128)",
"doc": "Fill color to assign to a polygon"
"doc": "Fill color to assign to a polygon",
"expression": true
},
"fill-opacity": {
"css": "polygon-opacity",
"type": "float",
"doc": "The opacity of the polygon",
"default-value": 1,
"default-meaning": "opaque"
"default-meaning": "opaque",
"expression": true
},
"gamma": {
"css": "polygon-gamma",
@ -397,13 +413,15 @@ var _mapnik_reference_latest = {
"default-value": "rgba(0,0,0,1)",
"type": "color",
"default-meaning": "black and fully opaque (alpha = 1), same as rgb(0,0,0)",
"doc": "The color of a drawn line"
"doc": "The color of a drawn line",
"expression": true
},
"stroke-width": {
"css": "line-width",
"default-value": 1,
"type": "float",
"doc": "The width of a line in pixels"
"doc": "The width of a line in pixels",
"expression": true
},
"stroke-opacity": {
"css": "line-opacity",
@ -568,7 +586,8 @@ var _mapnik_reference_latest = {
"doc": "An SVG file that this marker shows at each placement. If no file is given, the marker will show an ellipse.",
"default-value": "",
"default-meaning": "An ellipse or circle, if width equals height",
"type": "uri"
"type": "uri",
"expression": true
},
"opacity": {
"css": "marker-opacity",
@ -638,19 +657,22 @@ var _mapnik_reference_latest = {
"css": "marker-width",
"default-value": 10,
"doc": "The width of the marker, if using one of the default types.",
"type": "expression"
"type": "float",
"expression": true
},
"height": {
"css": "marker-height",
"default-value": 10,
"doc": "The height of the marker, if using one of the default types.",
"type": "expression"
"type": "float",
"expression": true
},
"fill": {
"css": "marker-fill",
"default-value": "blue",
"doc": "The color of the area of the marker.",
"type": "color"
"type": "color",
"expression": true
},
"allow-overlap": {
"css": "marker-allow-overlap",
@ -768,7 +790,8 @@ var _mapnik_reference_latest = {
"shield": {
"name": {
"css": "shield-name",
"type": "expression",
"type": "string",
"expression": true,
"serialization": "content",
"doc": "Value to use for a shield\"s text label. Data columns are specified using brackets like [column_name]"
},
@ -815,6 +838,18 @@ var _mapnik_reference_latest = {
"default-value": "point",
"doc": "How this shield should be placed. Point placement attempts to place it on top of points, line places along lines multiple times per feature, vertex places on the vertexes of polygons, and interior attempts to place inside of polygons."
},
"placement-type": {
"css": "shield-placement-type",
"doc": "Re-position and/or re-size shield to avoid overlaps. \"simple\" for basic algorithm (using shield-placements string,) \"dummy\" to turn this feature off.",
"type": [
"dummy",
"simple",
"list"
],
"expression":true,
"default-meaning": "Alternative placements will not be enabled.",
"default-value": "dummy"
},
"avoid-edges": {
"css": "shield-avoid-edges",
"doc": "Tell positioning algorithm to avoid labeling near intersection edges.",
@ -1024,7 +1059,8 @@ var _mapnik_reference_latest = {
"type": "uri",
"default-value": "none",
"required": true,
"doc": "An image file to be repeated and warped along a line"
"doc": "An image file to be repeated and warped along a line",
"expression": true
},
"clip": {
"css": "line-pattern-clip",
@ -1104,7 +1140,8 @@ var _mapnik_reference_latest = {
"type": "uri",
"default-value": "none",
"required": true,
"doc": "Image to use as a repeated pattern fill within a polygon"
"doc": "Image to use as a repeated pattern fill within a polygon",
"expression": true
},
"alignment": {
"css": "polygon-pattern-alignment",
@ -1390,7 +1427,8 @@ var _mapnik_reference_latest = {
"text": {
"name": {
"css": "text-name",
"type": "expression",
"type": "string",
"expression": true,
"required": true,
"default-value": "",
"serialization": "content",
@ -1545,7 +1583,8 @@ var _mapnik_reference_latest = {
},
"orientation": {
"css": "text-orientation",
"type": "expression",
"type": "float",
"expression": true,
"doc": "Rotate the text."
},
"placement": {
@ -1673,11 +1712,19 @@ var _mapnik_reference_latest = {
"height": {
"css": "building-height",
"doc": "The height of the building in pixels.",
"type": "expression",
"type": "float",
"expression": true,
"default-value": "0"
}
},
"torque": {
"-torque-clear-color": {
"css": "-torque-clear-color",
"type": "color",
"default-value": "rgba(255, 255, 255, 0)",
"default-meaning": "full clear",
"doc": "color used to clear canvas on each frame"
},
"-torque-frame-count": {
"css": "-torque-frame-count",
"default-value": "128",
@ -1887,9 +1934,9 @@ var _mapnik_reference_latest = {
}
}
window.carto['mapnik-reference'] = {
module.exports = {
version: {
latest: _mapnik_reference_latest,
'2.1.1': _mapnik_reference_latest
}
}
};

View File

@ -1,5 +1,5 @@
(function(tree) {
var _ = require('underscore');
var _ = global._ || require('underscore');
tree.Call = function Call(name, args, index) {
this.name = name;
this.args = args;
@ -78,6 +78,7 @@ tree.Call.prototype = {
};
}
if (fn !== args.length &&
!(Array.isArray(fn) && _.include(fn, args.length)) &&
// support variable-arg functions like `colorize-alpha`
fn !== -1) {
env.error({

View File

@ -1,6 +1,6 @@
(function(tree) {
var assert = require('assert'),
_ = require('underscore');
_ = global._ || require('underscore');
// A definition is the combination of a selector and rules, like
// #foo {
@ -210,48 +210,37 @@ tree.Definition.prototype.toXML = function(env, existing) {
tree.Definition.prototype.toJS = function(env) {
var shaderAttrs = {};
// merge conditions from filters with zoom condition of the
// definition
var zoom = "(" + this.zoom + " & (1 << ctx.zoom))";
var frame_offset = this.frame_offset;
var _if = this.filters.toJS(env);
var filters = [zoom];
if(_if) filters.push(_if);
if(frame_offset) filters.push('ctx["frame-offset"] === ' + frame_offset);
_if = filters.join(" && ");
_.each(this.rules, function(rule) {
if(rule instanceof tree.Rule) {
shaderAttrs[rule.name] = shaderAttrs[rule.name] || [];
var zoomFilter = "(" + this.zoom + " & (1 << ctx.zoom))";
var filters = [zoomFilter];
var originalFilters = this.filters.toJS(env);
// Ignore default zoom for filtering (https://github.com/CartoDB/carto/issues/40)
var zoomFiltered = this.zoom !== tree.Zoom.all;
if (originalFilters) {
filters.push(originalFilters);
}
var r = {
index: rule.index,
symbolizer: rule.symbolizer
};
if (frame_offset) {
filters.push('ctx["frame-offset"] === ' + frame_offset);
}
if (_if) {
r.js = "if(" + _if + "){" + rule.value.toJS(env) + "}"
} else {
r.js = rule.value.toJS(env);
}
_.each(this.rules, function (rule) {
var exportedRule = {};
r.constant = rule.value.ev(env).is !== 'field';
r.filtered = !!_if;
shaderAttrs[rule.name].push(r);
} else {
throw new Error("Ruleset not supported");
//if (rule instanceof tree.Ruleset) {
//var sh = rule.toJS(env);
//for(var v in sh) {
//shaderAttrs[v] = shaderAttrs[v] || [];
//for(var attr in sh[v]) {
//shaderAttrs[v].push(sh[v][attr]);
//}
//}
//}
if (!rule instanceof tree.Rule) {
throw new Error("Ruleset not supported");
}
exportedRule.index = rule.index;
exportedRule.symbolizer = rule.symbolizer;
exportedRule.js = "if(" + filters.join(" && ") + "){" + rule.value.toJS(env) + "}";
exportedRule.constant = rule.value.ev(env).is !== 'field';
exportedRule.filtered = zoomFiltered || (originalFilters !== '');
shaderAttrs[rule.name] = shaderAttrs[rule.name] || [];
shaderAttrs[rule.name].push(exportedRule);
});
return shaderAttrs;
};

View File

@ -1,5 +1,5 @@
(function(tree) {
var _ = require('underscore');
var _ = global._ || require('underscore');
//
// A number with a unit
//

View File

@ -1,4 +1,5 @@
var tree = require('../tree');
var _ = global._ || require('underscore');
tree.Filterset = function Filterset() {
this.filters = {};
@ -91,7 +92,10 @@ tree.Filterset.prototype.toJS = function(env) {
val = filter._val.toString(true);
}
var attrs = "data";
return attrs + "." + filter.key.value + " " + op + " " + (val.is === 'string' ? "'"+ val +"'" : val);
if (op === '=~') {
return "(" + attrs + "['" + filter.key.value + "'] + '').match(" + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'").replace(/&amp;/g, '&') + "'" : val) + ")";
}
return attrs + "['" + filter.key.value + "'] " + op + " " + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'").replace(/&amp;/g, '&') + "'" : val);
}).join(' && ');
};

View File

@ -4,46 +4,34 @@
// combinations.
(function(tree) {
var _ = require('underscore'),
reference = require('mapnik-reference'),
var _ = global._ || require('underscore'),
ref = {};
tree.Reference = {
data: reference.version.latest
};
tree.Reference.set = function(ref, version) {
reference = ref;
tree.Reference.setVersion(version || 'latest');
};
ref.setData = function(data) {
ref.data = data;
ref.selector_cache = generateSelectorCache(data);
ref.mapnikFunctions = generateMapnikFunctions(data);
ref.mapnikFunctions.matrix = [6];
ref.mapnikFunctions.translate = [1, 2];
ref.mapnikFunctions.scale = [1, 2];
ref.mapnikFunctions.rotate = [1, 3];
ref.mapnikFunctions.skewX = [1];
ref.mapnikFunctions.skewY = [1];
ref.required_cache = generateRequiredProperties(data);
};
ref.setVersion = function(version) {
if (reference.version.hasOwnProperty(version)) {
ref.setData(reference.version[version]);
var mapnik_reference = require('mapnik-reference');
if (mapnik_reference.version.hasOwnProperty(version)) {
ref.setData(mapnik_reference.version[version]);
return true;
} else {
return false;
}
};
tree.Reference.selectors = tree.Reference.selectors || (function() {
var list = [];
for (var i in tree.Reference.data.symbolizers) {
for (var j in tree.Reference.data.symbolizers[i]) {
if (tree.Reference.data.symbolizers[i][j].hasOwnProperty('css')) {
list.push(tree.Reference.data.symbolizers[i][j].css);
}
}
}
});
ref.selectorData = function(selector, i) {
if (ref.selector_cache[selector]) return ref.selector_cache[selector][i];
};
@ -198,8 +186,6 @@ ref.validValue = function(env, selector, value) {
// 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();
@ -207,15 +193,8 @@ ref.validValue = function(env, selector, value) {
} else {
return false;
}
} else if (tree.Reference.selector(selector).type == 'expression') {
} else if ((ref.selector(selector).expression)) {
return true;
} else if (tree.Reference.selector(selector).type === 'unsigned') {
if (value.value[0].is === 'float') {
value.value[0].round();
return true;
} else {
return false;
}
} else {
if (ref.selector(selector).validate) {
var valid = false;
@ -235,8 +214,6 @@ ref.validValue = function(env, selector, value) {
}
};
ref.setVersion('latest');
tree.Reference = ref;
})(require('../tree'));

View File

@ -1,5 +1,5 @@
(function(tree) {
var _ = require('underscore');
var _ = global._ || require('underscore');
// Given a style's name, attachment, definitions, and an environment object,
// return a stringified style for Mapnik

View File

@ -33,10 +33,23 @@ tree.Value.prototype = {
var val = this.ev(env);
var v = val.toString();
if(val.is === "color" || val.is === 'uri' || val.is === 'string' || val.is === 'keyword') {
v = "'" + v + "'";
v = "'" + v.replace(/&amp;/g, '&') + "'";
} else if (Array.isArray(this.value) && this.value.length > 1) {
// This covers something like `line-dasharray: 5, 10;`
// where the return _value has more than one element.
// Without this the generated code will look like:
// _value = 5, 10; which will ignore the 10.
v = '[' + this.value.join(',') + ']';
} else if (val.is === 'field') {
// replace [variable] by ctx['variable']
v = v.replace(/\[(.*)\]/g, "data['$1']");
v = v.replace(/\[([^\]]*)\]/g, function(matched) {
return matched.replace(/\[(.*)\]/g, "data['$1']");
});
}else if (val.is === 'call') {
v = JSON.stringify({
name: val.name,
args: val.args
})
}
return "_value = " + v + ";";
}

View File

@ -1,35 +0,0 @@
#
# Run all tests
#
expresso = ./node_modules/.bin/mocha
docco = ./node_modules/.bin/docco
uglify = ./node_modules/.bin/uglify
JS_CLIENT_FILES=browser/*.js lib/carto/parser.js lib/carto/tree.js lib/carto/tree/*.js lib/carto/functions.js lib/carto/renderer_js.js
all: dist
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
doc:
$(docco) lib/carto/*.js lib/carto/tree/*.js
dist/carto.js: $(JS_CLIENT_FILES)
cat $(JS_CLIENT_FILES) > dist/carto.js
dist: dist/carto.js
.PHONY: test

2110
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,17 @@
{
"name": "carto",
"version": "0.11.0",
"description": "Mapnik Stylesheet Compiler",
"url": "https://github.com/mapbox/carto",
"version": "0.15.1-cdb5",
"description": "CartoCSS Stylesheet Compiler",
"url": "https://github.com/cartodb/carto",
"repository": {
"type": "git",
"url": "http://github.com/mapbox/carto.git"
"type": "git",
"url": "http://github.com/cartodb/carto.git"
},
"author": {
"name": "Mapbox",
"url": "http://mapbox.com/",
"email": "info@mapbox.com"
"name": "CartoDB",
"url": "http://cartodb.com/"
},
"keywords": [
"mapnik",
"maps",
"css",
"stylesheets"
@ -21,14 +19,17 @@
"contributors": [
"Tom MacWright <macwright@gmail.com>",
"Konstantin Käfer",
"Alexis Sellier <self@cloudhead.net>"
"Alexis Sellier <self@cloudhead.net>",
"Raul Ochoa <rochoa@cartodb.com>",
"Javi Santana <jsantana@cartodb.com>"
],
"licenses": [{
"licenses": [
{
"type": "Apache"
}],
}
],
"bin": {
"carto": "./bin/carto",
"mml2json.js": "./bin/mml2json.js"
"carto": "./bin/carto"
},
"man": "./man/carto.1",
"main": "./lib/carto/index",
@ -36,19 +37,27 @@
"node": ">=0.4.x"
},
"dependencies": {
"underscore": "~1.6.0",
"mapnik-reference": "5.0.9",
"xml2js": "~0.4.2",
"underscore": "1.8.3",
"mapnik-reference": "~6.0.2",
"optimist": "~0.6.0"
},
"devDependencies": {
"mocha": "1.12.x",
"jshint": "0.2.x",
"docco": "0.3.x",
"sax": "0.1.x"
"sax": "0.1.x",
"istanbul": "~0.2.14",
"coveralls": "~2.10.1",
"browserify": "~7.0.0",
"uglify-js": "1.3.3"
},
"scripts": {
"pretest": "npm install",
"test": "mocha -R spec"
"test": "mocha -R spec",
"tdd": "env HIDE_LOGS=true mocha -w -R spec",
"coverage": "istanbul cover ./node_modules/.bin/_mocha && coveralls < ./coverage/lcov.info",
"bump": "npm version patch",
"bump:major": "npm version major",
"bump:minor": "npm version minor",
"postversion": "git push origin master --follow-tags"
}
}

25
test/color.test.js Normal file
View File

@ -0,0 +1,25 @@
var assert = require('assert');
var tree = require('../lib/carto/tree.js');
require('../lib/carto/functions');
require('../lib/carto/tree/color');
require('../lib/carto/tree/dimension');
describe('Color', function() {
describe('basic functionality', function() {
it('should be constructed', function() {
var f = new tree.Color([0, 0, 0], 1);
assert.deepEqual(f.toHSL(), {"h":0,"s":0,"l":0,"a":1});
assert.ok(f);
});
});
describe('functions', function() {
it('should be constructed', function() {
assert.deepEqual(tree.functions.rgb(0, 0, 0), new tree.Color([0, 0, 0], 1));
assert.deepEqual(tree.functions.hue(new tree.Color([0, 0, 0], 1)), new tree.Dimension(0));
assert.deepEqual(tree.functions.saturation(new tree.Color([0, 0, 0], 1)), new tree.Dimension(0, '%'));
assert.deepEqual(tree.functions.lightness(new tree.Color([0, 0, 0], 1)), new tree.Dimension(0, '%'));
assert.deepEqual(tree.functions.alpha(new tree.Color([0, 0, 0], 1)), new tree.Dimension(1));
assert.deepEqual(tree.functions.greyscale(new tree.Color([0, 0, 0], 1)), new tree.Color([0, 0, 0], 1));
});
});
});

14
test/comment.test.js Normal file
View File

@ -0,0 +1,14 @@
var assert = require('assert');
var tree = require('../lib/carto/tree.js');
require('../lib/carto/tree/comment');
describe('Comment', function() {
describe('basic functionality', function() {
it('should be constructed', function() {
var f = new tree.Comment('hello world');
assert.deepEqual(f.toString(), '<!--hello world-->');
assert.deepEqual(f.ev(), f);
assert.ok(f);
});
});
});

View File

@ -20,6 +20,9 @@ helper.files('errorhandling', 'mml', function(file) {
local_data_dir: path.join(__dirname, 'rendering'),
filename: file
}).render(mml);
// should not get here
assert.ok(false);
done();
} catch(err) {
if (err.message.indexOf('***') > -1) throw err;
var result = helper.resultFile(file);
@ -54,6 +57,9 @@ helper.files('errorhandling', 'mss', function(file) {
// will match if the style was loaded from mml
filename: basename
}).renderMSS(mss);
// should not get here
assert.ok(false);
done();
} catch(err) {
if (err.message.indexOf('***') > -1) throw err;
var result = helper.resultFile(file);

View File

@ -0,0 +1,15 @@
{
"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": [
"bad_op.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"
}
}]
}

View File

@ -0,0 +1,3 @@
#world {
line-width: 20% + 2px;
}

View File

@ -0,0 +1 @@
bad_op.mss:2:4 If two operands differ, the first must not be %

View File

@ -0,0 +1,15 @@
{
"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": [
"bad_op_2.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"
}
}]
}

View File

@ -0,0 +1,3 @@
#world {
line-width: 20px * 2%;
}

View File

@ -0,0 +1 @@
bad_op_2.mss:2:4 Percent values can only be added or subtracted from other values

View File

@ -1,5 +1,4 @@
#world[zoom=5] {
text-face-name: 2;
line-rasterizer: 'full';
text-name: 'foo';
}

View File

@ -1,2 +1 @@
invalid_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.
invalid_value.mss:2:2 Invalid value for text-face-name, the type font is expected. 2 (of type float) was given.

View File

@ -0,0 +1,15 @@
{
"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": [
"invaliddimension.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"
}
}]
}

View File

@ -0,0 +1,3 @@
#world {
line-width: 10wifflewaffles;
}

View File

@ -0,0 +1 @@
invaliddimension.mss:2:4 Invalid unit: 'wifflewaffles'

View File

@ -1,4 +1,4 @@
#t {
text-name: invalid;
text-face-name: "Dejagnu";
text-name: valid;
text-face-name: 2;
}

View File

@ -1 +1 @@
issue297.mss:2:2 Invalid value for text-name, the type expression is expected. invalid (of type keyword) was given.
issue297.mss:3:2 Invalid value for text-face-name, the type font is expected. 2 (of type float) was given.

102
test/filtered.test.js Normal file
View File

@ -0,0 +1,102 @@
/**
* Test the filtered field.
*
* When compiled, a rule provides metainformation fields like index, constant...etc
* one of this fields is the "filtered field".
*
* This field gives information about whether a property is filtered or not.
*
* A property is filtered if it was activated inside a filter. In the following cartocss
* code marker-color.filtered will be true because it's inside a population filter.
*
* #layer {
* maker-width: 20;
* [population > 100] {
* marker-color: red; // this property is filtered
* }
* }
*
* "zoom" is a special case, and it only should be considered when its value is not the default.
*/
var assert = require('assert');
var Carto = require('../lib/carto/index.js');
var renderer = new Carto.RendererJS({ strict: true });
describe('property.filtered', function () {
it('should be false when the property is not filtered', function () {
var style = [
'#layer {',
' marker-fill: red;',
'}'
].join('\n');
var layers = renderer.render(style).layers[0].shader;
assert(!layers['marker-fill'].filtered);
});
it('should be true when the property is filtered', function () {
var style = [
'#layer {',
' [foo > 30] {',
' marker-fill: red;',
' }',
'}'
].join('\n');
var layers = renderer.render(style).layers[0].shader;
assert(layers['marker-fill'].filtered);
});
it('should be true when the property is filtered at first level', function () {
var style = [
'#layer [foo > 30] {',
' marker-fill: red;',
'}`'
].join('\n');
var layers = renderer.render(style).layers[0].shader;
assert(layers['marker-fill'].filtered);
});
it('should be false when the property is not filterd but there is another filtered properties', function () {
var style = [
'#layer {',
' marker-fill: red;',
' [bar < 200]{',
' marker-allow-overlap: false;',
' }',
'}`'
].join('\n');
var layers = renderer.render(style).layers[0].shader;
assert(!layers['marker-fill'].filtered);
assert(layers['marker-allow-overlap'].filtered);
});
it('should be true when the property is filtered and have a default value', function () {
var style = [
'#layer {',
' marker-fill: red;',
' [bar < 200]{',
' marker-fill: blue;',
' }',
'}`'
].join('\n');
var layers = renderer.render(style).layers[0].shader;
assert(layers['marker-fill'].filtered);
});
it('should be true when filtering by zoom', function () {
var style = [
'#layer {',
' [zoom < 5]{',
' marker-fill: blue;',
' }',
'}`'
].join('\n');
var layers = renderer.render(style).layers[0].shader;
assert(layers['marker-fill'].filtered);
});
});

View File

@ -54,7 +54,8 @@ var _mapnik_reference_latest = {
["x-gradient", 0],
["y-gradient", 0],
["invert", 0],
["sharpen", 0]
["sharpen", 0],
["ramp", 0]
],
"doc": "A list of image filters."
},

View File

@ -34,7 +34,7 @@ helper.files('rendering-mss', 'mss', function(file) {
fs.writeFileSync(expected,output);
}
var expected_data = fs.readFileSync(expected).toString();
assert.equal(output,expected_data);
assert.equal(output.trim(),expected_data.trim());
});
});
});

View File

@ -0,0 +1,3 @@
#layer {
line-width:"@zoom";
}

View File

@ -0,0 +1,5 @@
<Style name="style" filter-mode="first">
<Rule>
<LineSymbolizer stroke-width="@zoom" />
</Rule>
</Style>

View File

@ -0,0 +1,5 @@
#world {
line-rasterizer: 'fast';
// carto should collapse to one
line-rasterizer: fast;
}

View File

@ -0,0 +1,5 @@
<Style name="style" filter-mode="first">
<Rule>
<LineSymbolizer rasterizer="fast" />
</Rule>
</Style>

View File

@ -2,4 +2,6 @@
#world {
point-file: url(foo.png);
point-transform: translate( @trans * 2, @trans);
marker-width: 2;
marker-transform: scale(2);
}

View File

@ -3,9 +3,10 @@
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
<Style name="world" filter-mode="first" >
<Style name="world" filter-mode="first">
<Rule>
<PointSymbolizer file="[absolute path]" transform="translate(4,2)" />
<MarkersSymbolizer width="2" transform="scale(2)" />
</Rule>
</Style>
<Layer name="world"

View File

@ -0,0 +1,148 @@
var assert = require('assert');
var carto = require('../lib/carto');
var tree = require('../lib/carto/tree');
describe('RendererJS Strict Mode', function() {
var style = [
'#world {',
'polygon-fill: red;',
'line-width: 2;',
'line-color: #f00;',
'[frame-offset = 1] {',
'line-width: 3;',
'}',
'[frame-offset = 2] {',
'line-width: 3;',
'}',
'}',
'',
'#worls[frame-offset = 10] {',
'line-width: 4;',
'}'
].join('\n');
var reference = {
version: '1.0.0',
style: {},
layer: {},
colors: {},
filter: {},
symbolizers: {
line: {
"stroke": {
"css": "line-color",
"default-value": "rgba(0,0,0,1)",
"type": "color",
"default-meaning": "black and fully opaque (alpha = 1), same as rgb(0,0,0)",
"doc": "The color of a drawn line"
},
"stroke-width": {
"css": "line-width",
"default-value": 1,
"type": "float",
"doc": "The width of a line in pixels"
},
"stroke-opacity": {
"css": "line-opacity",
"default-value": 1,
"type": "float",
"default-meaning": "opaque",
"doc": "The opacity of a line"
},
"stroke-linejoin": {
"css": "line-join",
"default-value": "miter",
"type": [
"miter",
"miter-revert",
"round",
"bevel"
],
"expression": true,
"doc": "The behavior of lines when joining.",
"default-meaning": "The line joins will be rendered using a miter look."
},
"stroke-linecap": {
"css": "line-cap",
"default-value": "butt",
"type": [
"butt",
"round",
"square"
],
"expression": true,
"doc": "The display of line endings.",
"default-meaning": "The line endings will be rendered using a butt look."
},
"comp-op": {
"css": "line-comp-op",
"default-value": "overlay",
"default-meaning": "Add the current symbolizer on top of other symbolizer.",
"doc": "Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.",
"type": [
"multiply",
"add",
"overlay"
],
"expression": true
},
"stroke-dasharray": {
"css": "line-dasharray",
"type": "numbers",
"expression": true,
"doc": "A pair of length values [a,b], where (a) is the dash length and (b) is the gap length respectively. More than two values are supported for more complex patterns.",
"default-value": "none",
"default-meaning": "The line will be drawn without dashes."
}
}
}
};
var expectedErrorMessageRegex = /Unrecognized rule: polygon-fill/;
before(function() {
this.referenceData = tree.Reference.data;
});
after(function() {
if (this.referenceData) {
tree.Reference.setData(this.referenceData);
}
});
it('should fail if a feature is not supported and strict is turned on', function () {
assert.throws(
function () {
var RendererJS = new carto.RendererJS({reference: reference, mapnik_version: '1.0.0', strict: true });
var shader = RendererJS.render(style);
},
expectedErrorMessageRegex
);
});
function rendererStrictModeOffTest(RendererJS) {
return function () {
var shader = RendererJS.render(style);
assert.ok(shader.layers);
assert.equal(shader.layers.length, 2);
};
}
it('should pass if a feature is not supported but strict mode is not specified', rendererStrictModeOffTest(
new carto.RendererJS({reference: reference, mapnik_version: '1.0.0' })
));
it('should pass if a feature is not supported but strict is turned off', function () {
new carto.RendererJS({reference: reference, mapnik_version: '1.0.0', strict: false })
});
it('should pass if a feature is supported and strict is turned on', function () {
var RendererJS = new carto.RendererJS({reference: reference, mapnik_version: '1.0.0', strict: true });
var cartocss = '#layer { line-width: 10 }';
var shader = RendererJS.render(cartocss);
assert.ok(shader);
});
});

View File

@ -1,27 +1,27 @@
var SHOW_LOGS = (process.env.HIDE_LOGS !== 'true');
var assert = require('assert');
var carto = require('../lib/carto');
describe('RenderingJS', function() {
var shader;
var style = [
'#world {',
'line-width: 2;',
'line-color: #f00;',
'[frame-offset = 1] {',
'line-width: 3;',
'}',
'[frame-offset = 2] {',
'line-width: 3;',
'}',
'}',
'',
'#worls[frame-offset = 10] {',
'line-width: 4;',
'#world {',
'line-width: 2;',
'line-color: #f00;',
'[frame-offset = 1] {',
'line-width: 3;',
'}',
'[frame-offset = 2] {',
'line-width: 3;',
'}',
'}',
'',
'#worls[frame-offset = 10] {',
'line-width: 4;',
'}'
].join('\n');
beforeEach(function() {
shader = (new carto.RendererJS({ debug: true })).render(style);
shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
});
it ("shold render layers", function() {
@ -45,7 +45,7 @@ describe('RenderingJS', function() {
it ("shold render variables", function() {
var style = '#test { marker-width: [testing]; }';
shader = (new carto.RendererJS({ debug: true })).render(style);
shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
var layer = shader.getLayers()[0];
var props = layer.getStyle({testing: 2}, { 'zoom': 0, 'frame-offset': 10 });
assert( props['marker-width'] === 2);
@ -53,7 +53,7 @@ describe('RenderingJS', function() {
it ("should allow filter based rendering", function() {
var style = '#test { marker-width: 10; [zoom = 1] { marker-width: 1; } }';
shader = (new carto.RendererJS({ debug: true })).render(style);
shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
var layer = shader.getLayers()[0];
var props = layer.getStyle({}, { 'zoom': 0, 'frame-offset': 10 });
assert( props['marker-width'] === 10);
@ -63,8 +63,8 @@ describe('RenderingJS', function() {
it ("symbolizers should be in rendering order", function() {
var style = '#test { polygon-fill: red; line-color: red; }';
style += '#test2 { line-color: red;polygon-fill: red; line-witdh: 10; }';
var shader = (new carto.RendererJS({ debug: true })).render(style);
style += '#test2 { line-color: red;polygon-fill: red; line-width: 10; }';
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
var layer0 = shader.getLayers()[0];
assert(layer0.getSymbolizers()[0] === 'polygon');
assert(layer0.getSymbolizers()[1] === 'line');
@ -74,22 +74,166 @@ describe('RenderingJS', function() {
assert(layer0.getSymbolizers()[1] === 'line');
});
it ("colorize should return a list of colours in same order", function() {
var style = '#test { image-filters: colorize-alpha(blue, cyan, green, yellow, orange, red); }';
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
var layer0 = shader.getLayers()[0];
var st = layer0.getStyle({ value: 1 }, {"frame-offset": 0, "zoom": 3});
var expectedColours = [[0, 0, 255], [0, 255, 255], [0, 128, 0], [255, 255, 0], [255, 165, 0], [255, 0, 0]];
for (var i = 0; i < st["image-filters"].args; i++){
assert (st["image-filters"].args[i].rgb === expectedColours[i]);
}
});
it ("should return list of marker-files", function(){
var css = [
'Map {',
'-torque-time-attribute: "date";',
'-torque-aggregation-function: "count(cartodb_id)";',
'-torque-frame-count: 760;',
'-torque-animation-duration: 15;',
'-torque-resolution: 2',
'}',
'#layer {',
' marker-width: 3;',
' marker-fill-opacity: 0.8;',
' marker-fill: #FEE391; ',
' marker-file: url(http://localhost:8081/gal.svg); ',
' comp-op: "lighten";',
' [value > 2] { marker-file: url(http://upload.wikimedia.org/wikipedia/commons/4/43/Flag_of_the_Galactic_Empire.svg); }',
' [value > 3] { marker-file: url(http://upload.wikimedia.org/wikipedia/commons/c/c9/Flag_of_Syldavia.svg); }',
' [frame-offset = 1] { marker-width: 10; marker-fill-opacity: 0.05;}',
' [frame-offset = 2] { marker-width: 15; marker-fill-opacity: 0.02;}',
'}'
].join('\n');
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(css);
var markerURLs = shader.getImageURLs();
var against = ["http://localhost:8081/gal.svg", "http://upload.wikimedia.org/wikipedia/commons/4/43/Flag_of_the_Galactic_Empire.svg", "http://upload.wikimedia.org/wikipedia/commons/c/c9/Flag_of_Syldavia.svg"];
for(var i = 0; i<against.length; i++){
assert(against[i] == markerURLs[i])
}
})
it ("should return variable for styles that change", function() {
var style = '#test { marker-width: [prop]; }';
var shader = (new carto.RendererJS({ debug: true })).render(style);
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
var layer0 = shader.getLayers()[0];
assert(layer0.isVariable());
style = '#test { marker-width: 1; }';
shader = (new carto.RendererJS({ debug: true })).render(style);
shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
layer0 = shader.getLayers()[0];
assert(!layer0.isVariable());
style = '#test { marker-width: [prop]; marker-fill: red; }';
shader = (new carto.RendererJS({ debug: true })).render(style);
shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
layer0 = shader.getLayers()[0];
assert(layer0.isVariable());
});
it("should parse styles with string", function() {
var style = '#test { [column = "test\'ing"] { marker-width: 10; } }';
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
var layer = shader.getLayers()[0];
var props = layer.getStyle({column: 'test\'ing'}, { 'zoom': 0, 'frame-offset': 10 });
assert(props['marker-width'] === 10);
});
it("should parse styles with filters not supported by dot notation", function() {
var style = '#test["mapnik::geometry_type"=1] { marker-width: 10; }';
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(style);
var layer = shader.getLayers()[0];
var props = layer.getStyle({"mapnik::geometry_type": 1}, { 'zoom': 0 });
assert.equal(props['marker-width'], 10);
var emptyFilterProps = layer.getStyle({"mapnik::geometry_type": 2}, { 'zoom': 0 });
assert.equal(emptyFilterProps['marker-width'], null);
});
it ("should parse turbocarto", function(){
var css = [
'#layer {',
' marker-width: ramp([cartodb_id], (#fff, #bbb), jenks);',
'}'
].join('\n');
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(css);
var layer = shader.getLayers()[0];
var st = layer.shader['marker-width'].style({}, {zoom: 1})
assert.equal(st.name, "ramp")
assert.equal(st.args.length, 3);
assert.equal(st.args[1].value[0].rgb[0], 255);
assert.equal(st.args[1].value[0].rgb[1], 255);
assert.equal(st.args[1].value[0].rgb[2], 255);
assert.equal(st.args[2].value, 'jenks');
})
it("should parse turbocarto with inner functions", function(){
var css = [
'#layer {',
' marker-width: ramp([cartodb_id], cartocolor(Bold), category(10));',
'}'
].join('\n');
var shader = (new carto.RendererJS({ debug: SHOW_LOGS })).render(css);
var layer = shader.getLayers()[0];
var st = layer.shader['marker-width'].style({}, {zoom: 1});
assert.equal(st.name, "ramp");
assert.equal(st.args.length, 3);
assert.equal(st.args[1].name, 'cartocolor');
assert.equal(st.args[1].args[0].value, 'Bold');
assert.equal(st.args[2].name, 'category');
assert.equal(st.args[2].args[0].value, 10);
});
it("should work with multiple operands", function(){
var css = [
'#layer {',
' marker-width: [value] * [value] * 0.5;',
'}'
].join('\n');
var shader = (new carto.RendererJS({ debug: false })).render(css);
var layer = shader.getLayers()[0];
var width = layer.shader['marker-width'].style({value: 4}, {zoom: 1});
assert.equal(width, 8);
});
it("should work with numbers", function(){
var css = [
'#layer {',
' line-dasharray: 5, 10;',
'}'
].join('\n');
var shader = (new carto.RendererJS({ debug: false })).render(css);
var layer = shader.getLayers()[0];
var dasharray = layer.shader['line-dasharray'].style({value: 4}, {zoom: 1});
assert.deepEqual(dasharray, [5, 10]);
});
it("should not throw `ReferenceError` with `=~` operator", function(){
var css = [
'#layer[name=~".*wadus*"] {',
' marker-width: 14;',
'}'
].join('\n');
assert.doesNotThrow(function () {
var shader = (new carto.RendererJS({})).render(css);
var layer = shader.getLayers()[0];
var value = layer.shader['marker-width'].style({ name: 'wadus' }, { zoom: 1 });
assert.equal(value, 14);
}, ReferenceError);
});
it("`=~` operator should support numbers", function(){
var css = [
'#layer[value=~"^10"] {',
' marker-width: 14;',
'}'
].join('\n');
assert.doesNotThrow(function () {
var shader = (new carto.RendererJS({})).render(css);
var layer = shader.getLayers()[0];
var value = layer.shader['marker-width'].style({ value: 10 }, { zoom: 1 });
assert.equal(value, 14);
}, Error);
});
});

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@ var assert = require('assert');
describe('Version check', function() {
xit('test version matches package.json version and changelog', 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);