Compare commits

...

598 Commits

Author SHA1 Message Date
Raul Ochoa
9c9609eb2b Release 3.4.0 2017-04-03 16:21:29 +02:00
Raul Ochoa
418d3c074f Merge pull request #657 from CartoDB/upgrade-camshaft
Upgrade camshaft to 0.51.0
2017-04-03 16:15:48 +02:00
Raul Ochoa
6bbda3d41e Upgrade camshaft to 0.51.0 2017-04-03 15:53:39 +02:00
Raul Ochoa
25669bb3f2 Stubs next version 2017-04-03 13:07:53 +02:00
Raul Ochoa
508d495a23 Release 3.3.0 2017-04-03 13:07:05 +02:00
Raul Ochoa
06427dc009 Bump version and add news 2017-04-03 13:06:37 +02:00
Raul Ochoa
c325df1414 Merge pull request #655 from CartoDB/static-maps-layers-filter
Static maps layers filter
2017-04-03 12:07:38 +02:00
Raul Ochoa
07447160e3 Merge pull request #654 from CartoDB/non-conditional-profiler
Remove all conditional branches to call req.profiler
2017-04-03 11:58:38 +02:00
Raul Ochoa
ededc73fd7 Throw on invalid params argument 2017-03-31 18:39:29 +02:00
Raul Ochoa
cad02bfad7 Remove all conditional branches to call req.profiler
req.profiler is created in a middleware for all requests.
2017-03-30 20:31:53 +02:00
Raul Ochoa
94299f0452 Configure extra allowed params per endpoint via middleware
Instead of making all params available in all endpoints, we control
what endpoints allow what extra params.

Dataviews endpoints should be migrated to this.
2017-03-30 20:12:55 +02:00
Raul Ochoa
ae5d82c41d Add test to go red 2017-03-30 20:12:20 +02:00
Raul Ochoa
6468822295 Remove layer param before creating a better solution 2017-03-30 20:08:45 +02:00
Raul Ochoa
777ae31426 Merge branch 'master' into static-maps-layers-filter 2017-03-30 19:33:59 +02:00
Raul Ochoa
1ca56fb81c Update news 2017-03-30 17:52:25 +02:00
Raul Ochoa
5d74e1eafe Stubs next version 2017-03-30 14:33:41 +02:00
Raul Ochoa
f3fdd7ff25 Release 3.2.0 2017-03-30 14:32:48 +02:00
Raul Ochoa
fbbe69dac0 Merge pull request #652 from CartoDB/upgrade-windshaft
Update windshaft to 3.1.0
2017-03-30 14:32:21 +02:00
Raul Ochoa
ac54179f14 Update windshaft to 3.1.0 2017-03-30 14:12:31 +02:00
Raul Ochoa
50d296e46c Merge pull request #650 from CartoDB/upgrade-grainstore-1.6.2
Upgrade dependencies: grainstore@1.6.2
2017-03-29 16:16:50 +02:00
Raul Ochoa
616ba6500c Merge pull request #649 from CartoDB/gc
Active GC interval
2017-03-29 16:11:48 +02:00
Daniel García Aubert
d9968f2c91 Upgrade dependencies: grainstore@1.6.2 2017-03-29 16:02:37 +02:00
Raul Ochoa
8ca9c5bcf7 Active GC interval
Interval timer is configurable, disabling by using <=0 value.
2017-03-29 15:56:30 +02:00
csobier
a7b0618f91 Merge pull request #643 from CartoDB/docs-fix-broken-hyperlinks
fixed docs example links, Andy changed his user name so links broke. …
2017-03-24 09:44:50 -04:00
csobier
e9896e34e1 found and fixed a typo 2017-03-24 09:33:15 -04:00
csobier
28bd03765a fixed docs example links, Andy changed his user name so links broke. I fixed. 2017-03-24 09:04:31 -04:00
Daniel García Aubert
24a86ae8df Stubs next version 2017-03-23 11:04:12 +01:00
Daniel García Aubert
f5c349e105 Release 3.1.1 2017-03-23 11:02:04 +01:00
Raul Ochoa
e8d2e28dba Merge pull request #642 from CartoDB/resources-urls-crc-hash
Use crc32 instead of md5 for computing subdomain candidate
2017-03-23 01:21:50 +01:00
Raul Ochoa
e0c2423ace Remove unused import 2017-03-23 01:14:56 +01:00
Raul Ochoa
5e429ba71f Use crc32 instead of md5 for computing subdomain candidate 2017-03-23 01:03:45 +01:00
Daniel García Aubert
64dfdba94d Release 3.1.0 2017-03-22 19:20:24 +01:00
Daniel
3866413504 Merge pull request #641 from CartoDB/resource-urls
Generate URLs for resources based on CDN + template rules
2017-03-22 19:15:08 +01:00
Raul Ochoa
2da834784f Generate URLs for resources based on CDN + template rules 2017-03-22 18:58:37 +01:00
Daniel García Aubert
d6181da32b Stubs next version 2017-03-22 13:53:48 +01:00
Daniel García Aubert
8287b94a25 Release 3.0.2 2017-03-22 13:20:59 +01:00
Daniel García Aubert
bc633301fe Update HOWTO_RELEASE 2017-03-22 13:11:12 +01:00
Daniel García Aubert
ed94fb4a66 Define yarn version of clients that must be used 2017-03-22 13:10:06 +01:00
Daniel García Aubert
fc27086052 Remove script to generate shrinkwrap 2017-03-22 13:08:12 +01:00
Daniel García Aubert
de1d1961e3 Upgrade yarn.lock depdendencies: depth > 1 2017-03-22 12:55:22 +01:00
Daniel García Aubert
a90a9383b4 Stubs next version 2017-03-21 19:45:25 +01:00
Daniel García Aubert
fd244287d5 Release 3.0.1 2017-03-21 19:43:46 +01:00
Daniel
fafe9e7e8a Merge pull request #640 from CartoDB/upgrade-windshaft-3.0.1
Bump windshaft version to 3.0.1
2017-03-21 19:35:54 +01:00
Daniel García Aubert
db37513206 Bump windshaft version to 3.0.1 2017-03-21 19:15:41 +01:00
Daniel García Aubert
c023088a3f Stubs next version 2017-03-21 15:44:33 +01:00
Daniel García Aubert
59f6217c4f Release 3.0.0 2017-03-21 15:34:47 +01:00
Daniel
0e43fbbb34 Merge pull request #635 from CartoDB/node-v6
Support Node v6 LTS and upgrade to Mapnik v3.x
2017-03-21 15:30:59 +01:00
Daniel García Aubert
1720f22247 Improve doc: 'yarn install' command is deprecated, use 'yarn' instead 2017-03-21 14:58:09 +01:00
Daniel García Aubert
3f791d25b5 Add a note about moving from npm to yarn 2017-03-17 17:58:33 +01:00
Daniel García Aubert
acd3047500 Update NEWS 2017-03-17 17:49:19 +01:00
Daniel García Aubert
7b3a4aa2a8 Update README.md 2017-03-17 17:41:20 +01:00
Daniel García Aubert
4bfaeeb44b Update INSTALL.md 2017-03-17 17:37:35 +01:00
Daniel García Aubert
a094ae7197 Update NEWS 2017-03-17 17:30:58 +01:00
Daniel García Aubert
ef0362d118 Fix windshaft version to 3.0.0 to avoid warning message while starting the service 2017-03-17 17:21:09 +01:00
Daniel García Aubert
5a5763684d Don't provide a npm's shrinkwrap anymore 2017-03-17 17:17:17 +01:00
Daniel García Aubert
6e575300e3 Update yarn.lock 2017-03-17 17:13:49 +01:00
Daniel García Aubert
8109fc4d46 Merge branch 'master' into node-v6 2017-03-17 17:06:58 +01:00
Daniel García Aubert
e0519e7851 Stubs next version 2017-03-17 17:06:39 +01:00
Daniel García Aubert
6334df5f5f Merge branch 'master' into node-v6 2017-03-17 17:03:53 +01:00
Daniel García Aubert
38294d29f5 Release 2.89.0 2017-03-17 16:45:18 +01:00
Daniel
5b131cc8a7 Merge pull request #639 from CartoDB/upgrade-windshaft-to-2.8.0
Upgrade windshaft to 2.8.0
2017-03-17 16:37:07 +01:00
Daniel García Aubert
5dee654132 Upgrade windshaft to 2.8.0 2017-03-17 16:26:26 +01:00
Daniel García Aubert
d902476780 Fix assertions, now MapCofig.getLayer() return {} if layer not found 2017-03-17 11:06:40 +00:00
Ubuntu
bc5dabef3c Revert "Fix assertions, now MapCofig.getLayer() return {} if layer not found"
This reverts commit c839a0b0a3.
2017-03-17 11:04:50 +00:00
Daniel García Aubert
024f1e4851 Fix assertions, now MapCofig.getLayer() return {} if layer not found 2017-03-17 10:45:59 +00:00
Raul Ochoa
5f87417d9e Merge pull request #637 from CartoDB/histogram-type-discovery
Histogram column type discovery query uses non-filtered query
2017-03-17 11:03:15 +01:00
Raul Ochoa
fa94550261 Include changes for overviews implementation 2017-03-16 19:15:34 +01:00
Daniel García Aubert
11efbf034e Drop support for Node 0.10 2017-03-16 17:18:44 +01:00
Daniel García Aubert
c839a0b0a3 Fix assertions, now MapCofig.getLayer() return {} if layer not found 2017-03-16 16:44:41 +01:00
Daniel García Aubert
420b657db8 Upgrade windshaft to 3.0.0 2017-03-16 16:42:43 +01:00
Raul Ochoa
2656a26272 Merge pull request #622 from strk/typo
Trip epoch is over...
2017-03-16 16:26:53 +01:00
Raul Ochoa
8694c120bc Allow to overwrite layers filter in static maps images 2017-03-15 11:00:10 +01:00
Raul Ochoa
992b2b6ba7 Histogram column type discovery query uses non-filtered query
Pass all queries to the dataview and use the no filters one for
discovering what is the column type associated to the histogram dataview.
2017-03-13 18:40:29 +01:00
Raul Ochoa
924f009390 Test for #606: function avg(timestamp with time zone) does not exist 2017-03-13 18:36:43 +01:00
Raul Ochoa
48a1244fa0 Stubs next version 2017-03-10 11:06:47 +01:00
Raul Ochoa
8789a959e5 Release 2.88.4 2017-03-10 11:06:06 +01:00
Raul Ochoa
5765ac59cc Merge pull request #636 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.50.3
2017-03-10 11:05:30 +01:00
Raul Ochoa
3b9bf96431 Upgrades camshaft to 0.50.3 2017-03-10 10:58:07 +01:00
Daniel García Aubert
a5fe5e7052 Update shrinkwrap 2017-03-08 10:56:01 +01:00
Daniel García Aubert
0f96b5a4a5 Update yarn.lock 2017-03-08 10:24:04 +01:00
Daniel García Aubert
25babeae56 Merge branch 'node-v6-yarn' into node-v6 2017-03-07 18:01:16 +01:00
Raul Ochoa
1951e79962 Make assertions compatible 2017-03-07 13:27:13 +01:00
Daniel García Aubert
1e0e31cc1c Merge branch 'node-v6' of github.com:CartoDB/Windshaft-cartodb into node-v6 2017-03-07 13:02:18 +01:00
Daniel García Aubert
8d35f72fcb Back to use current assertions as grainstore implements a fallback mechanism when translates styles 2017-03-07 12:59:52 +01:00
Daniel García Aubert
5f3e515131 Back test to use '=~' operator which is now supported by carto@0.15.1-cdb-3 in windshaft 2017-03-07 12:58:06 +01:00
Raul Ochoa
49236fce86 Upgrade locked deps 2017-03-02 11:38:09 +01:00
Raul Ochoa
9d2dde7a5a Merge branch 'node-v6' into node-v6-yarn 2017-03-02 11:07:52 +01:00
Raul Ochoa
c3e703237c Merge remote-tracking branch 'origin/master' into node-v6 2017-03-02 11:07:43 +01:00
Mario de Frutos
8868066445 Stubs next version 2017-03-02 11:00:53 +01:00
Mario de Frutos
b446c31cbc Other category now uses the selected aggregated function (#633)
* Other category in category widget uses selected aggregation function
Fixes https://github.com/CartoDB/Windshaft-cartodb/issues/628
2017-03-02 10:48:20 +01:00
Raul Ochoa
2d6e7070a6 Stubs next version 2017-02-23 18:12:54 +01:00
Raul Ochoa
473e0cb902 Release 2.88.2 2017-02-23 18:12:14 +01:00
Raul Ochoa
1a8fca0534 Formatting 2017-02-23 18:11:39 +01:00
Raul Ochoa
e24bc12fc9 Merge pull request #632 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.50.2
2017-02-23 18:10:22 +01:00
Raul Ochoa
e77c9141ed Upgrades camshaft to 0.50.2 2017-02-23 18:00:55 +01:00
Raul Ochoa
321157b17b Make target to generate shrinkwrap file applying prune
It removes dev dependencies from the local node_modules
and avoid getting those into shrinkwrap file.
2017-02-23 17:57:52 +01:00
Raul Ochoa
6ac6574b4c clean target to completely delete node_modules dir 2017-02-23 17:57:44 +01:00
Raul Ochoa
70ff0a9b8f Update freezed deps 2017-02-22 19:17:00 +01:00
Raul Ochoa
15bdb57a22 Merge remote-tracking branch 'origin/node-v6' into node-v6-yarn 2017-02-22 19:02:55 +01:00
Raul Ochoa
bb54e5520c Merge remote-tracking branch 'origin/master' into node-v6 2017-02-22 19:02:27 +01:00
Raul Ochoa
933d486a57 Merge pull request #630 from CartoDB/close-response-timer
Close timer for response preparation
2017-02-22 18:46:56 +01:00
Raul Ochoa
8a1c7f5b52 Close timer for response preparation
Timer for affectedTables is taking everything from response timing,
adding a tag to represent all the response preparation.
That way affectedTables only represents the time for retrieving the
affected tables themselves.
2017-02-22 18:38:25 +01:00
Rafa de la Torre
822954be5d Stub next version 2017-02-21 11:06:54 +01:00
Rafa de la Torre
57dc17518c Release 2.88.1 2017-02-21 11:01:15 +01:00
Mario de Frutos
3df8d4844e Stubs next version 2017-02-21 08:17:09 +01:00
Mario de Frutos
5a0443618f Merge pull request #626 from CartoDB/camshaft_v050
Camshaft 0.50.0
2017-02-21 08:08:34 +01:00
Raul Ochoa
8a76cd506f Fix issue with global Promise object 2017-02-20 18:46:48 +01:00
Mario de Frutos
50d05eae47 Version 2.88.0
Update camshaft version to 0.50.0
2017-02-20 18:46:47 +01:00
Raul Ochoa
ca41b3b600 Merge pull request #627 from CartoDB/change_release
We don't announce release deploy in google groups anymore
2017-02-20 10:31:39 +01:00
Mario de Frutos
43a17ddc7d We don't announce release deploy in google groups anymore 2017-02-17 18:01:59 +01:00
Mario de Frutos
dfa347f860 Update camshaft dependency to 0.50 2017-02-17 16:29:34 +01:00
Raul Ochoa
6033027812 Merge branch 'node-v6-shrinkwrap' into node-v6-yarn 2017-02-17 13:42:32 +01:00
Raul Ochoa
9ee6f7fbb8 Regenerate npm-shrinkwrap.json with npm@2.x 2017-02-17 13:41:58 +01:00
Raul Ochoa
60c0754800 Make assertions compatible 2017-02-17 13:36:15 +01:00
Raul Ochoa
a9251c5e71 Fix issue with global Promise object 2017-02-17 13:35:41 +01:00
Raul Ochoa
7daeddc946 Use yarn 2017-02-17 11:27:01 +01:00
Raul Ochoa
dbdb00070e Remove artificial node-zipfile dep 2017-02-17 11:26:46 +01:00
Raul Ochoa
e5c3c282ef Log Node.js version on startup 2017-02-10 10:03:06 +01:00
Raul Ochoa
caba79b5e2 Make target to generate shrinkwrap file applying prune
It removes dev dependencies from the local node_modules
and avoid getting those into shrinkwrap file.
2017-02-07 20:03:47 +01:00
Raul Ochoa
d359ea7fa6 clean target to completely delete node_modules dir 2017-02-07 19:55:37 +01:00
Raul Ochoa
c0abbe570f Add npm-shrinkwrap.json file 2017-02-07 18:56:45 +01:00
Raul Ochoa
229a2c0c3c Remove npm-shrinkwrap.json until we solve the issue associated to it 2017-02-07 18:50:57 +01:00
Daniel García Aubert
3f185c9c69 revert: disable cache for ci builds 2017-02-07 15:28:21 +01:00
Daniel García Aubert
f86f72ab27 disable cache for ci builds 2017-02-07 15:19:05 +01:00
Daniel García Aubert
74af17cc65 Add ubuntu toolchain for builds 2017-02-07 12:12:17 +01:00
Daniel García Aubert
aaa3e34c7f Use gcc 4.9 for build in travis 2017-02-07 11:55:21 +01:00
Daniel García Aubert
a053f198f5 Generate shrinkwrap 2017-02-07 11:45:48 +01:00
Daniel García Aubert
852ba68895 Upgrade redis in dev-dependency 2017-02-07 11:44:53 +01:00
Daniel García Aubert
1b22d176d6 Merge branch 'master' into node-v6 2017-02-06 19:03:16 +01:00
Daniel García Aubert
0ccbedf551 Use updated branch of windshaft 2017-02-06 18:25:32 +01:00
Raul Ochoa
28f1179336 Stubs next version 2017-02-02 16:44:41 +01:00
Raul Ochoa
de4d9e285e Release 2.87.5 2017-02-02 16:43:43 +01:00
Raul Ochoa
e0faaac822 Update news 2017-02-02 16:43:04 +01:00
Raul Ochoa
c84f27dd3f Merge pull request #623 from CartoDB/fix-dataviews-override-params-casting
Cast all dataview overrides values to Number
2017-02-02 16:42:48 +01:00
Raul Ochoa
12279d5c00 Cast dataview override values to Number or throw error
We were letting params expected as Numbers to be passed as any type
when they were not Numbers.
2017-02-02 16:20:16 +01:00
Raul Ochoa
281588abd2 Add test to validate bins param is casted as Number 2017-02-02 16:12:49 +01:00
Sandro Santilli
7e206b84aa Fix typo 2017-01-31 13:16:36 +01:00
Mario de Frutos
f69f999694 Fixed contributing link 2017-01-25 10:43:24 +01:00
Daniel García Aubert
c0c062592f Stubs next version 2017-01-20 11:40:00 +01:00
Daniel García Aubert
06885e2ba3 Release 2.87.4 2017-01-20 11:32:11 +01:00
Daniel
89a268d087 Merge pull request #617 from CartoDB/497-null-category
Be able to not compute NULL categories and null values
2017-01-20 11:26:12 +01:00
Daniel García Aubert
34424e713c Test on Node v6 2017-01-19 12:42:53 +01:00
Daniel García Aubert
89f381439f Pass test 2017-01-19 12:24:04 +01:00
Daniel García Aubert
6a80be9df3 Update windshaft dependency 2017-01-19 12:23:43 +01:00
Daniel García Aubert
fde1923acb Removed invalid selector 2017-01-19 11:31:55 +01:00
Daniel García Aubert
d486e1d34f Use released version of camshaft that supports node v6 2017-01-18 14:43:02 +01:00
csobier
3648b8b0b1 removed "default" from descriptions
As per a customer Support inquiry, I removed "default" from the Static Maps Limits section, as it was confusing to the user that it implied
2017-01-17 11:21:23 -05:00
Daniel García Aubert
83301238d2 Port changes to overviews 2017-01-17 17:10:08 +01:00
Daniel García Aubert
a4a1fb930a Be able to not compute NULL categories and null values wheter aggregation operation is not 'count' 2017-01-17 17:09:17 +01:00
Daniel García Aubert
6555353e0e Improve test to handle NULL values in category and aggregation columns using any operation 2017-01-16 19:23:08 +01:00
Daniel García Aubert
f5f0601e53 Add test to check if NULL category count values properly 2017-01-16 17:00:28 +01:00
Raul Ochoa
2598595e42 Merge pull request #614 from CartoDB/zipfile-cartodb
Use zipfile from cartodb
2016-12-23 14:47:40 +01:00
Raul Ochoa
49b78a85c9 Use zipfile from cartodb
Adding it as dependency in combination with loose definition in
millstone makes it to use the top level defined dependency.
2016-12-22 19:12:30 +01:00
Daniel García Aubert
35b12ebd6c Test unused directive just for mapnik 2.3.x 2016-12-19 17:29:24 +01:00
Javier Goizueta
0918c8e68c Stub next version 2016-12-19 17:20:18 +01:00
Javier Goizueta
1603a07de1 Release 2.87.3 2016-12-19 17:13:12 +01:00
Javier Goizueta
0a37aa4ba1 Merge pull request #604 from CartoDB/fix-overviews-dataviews
Fixes for dataviews using overviews
2016-12-19 16:55:13 +01:00
Javier Goizueta
b721a80fcc Merge branch 'master' into fix-overviews-dataviews 2016-12-19 16:45:28 +01:00
Rafa de la Torre
01365d035e Stub version 2.87.3 2016-12-19 16:38:27 +01:00
Rafa de la Torre
a4f059e20f Merge pull request #605 from CartoDB/update-camshaft-0.48.5
Update camshaft to 0.48.5
2016-12-19 16:33:27 +01:00
Daniel García Aubert
eb758bbf36 Use a valid port from env 2016-12-19 16:19:41 +01:00
Daniel García Aubert
bc2441e66a Use a valid port 2016-12-19 16:17:41 +01:00
Daniel García Aubert
7c1792bbd2 Test regression and unused directives only for mapnik ~2.3.x 2016-12-19 16:16:50 +01:00
Daniel García Aubert
2fdbc3e61c Fix error message in assertion 2016-12-19 16:15:07 +01:00
Daniel García Aubert
2ace705122 Fix error message in assertion 2016-12-19 16:13:55 +01:00
Daniel García Aubert
4b817062d8 Bump version of dependencies to be Node v6 compatible 2016-12-19 16:12:57 +01:00
Rafa de la Torre
79c35118d7 Update camshaft to 0.48.5
Use exception safe Dataservices API functions. See
https://github.com/CartoDB/dataservices-api/issues/314 and
https://github.com/CartoDB/camshaft/issues/242
2016-12-19 15:52:25 +01:00
Javier Goizueta
6a4f5d52ec Don't use overviews for date histograms 2016-12-16 17:51:36 +01:00
Javier Goizueta
ccaae2dd66 Remove spurious parameter from overviews dataviews functions
In the overviews-specialized dataview classes the sql-generating
functions had an unneeded parameter filters.
In some cases, since this parameter was not being paaased from
the base dataviews class it was masking the override parameter.
2016-12-16 17:37:05 +01:00
Raul Ochoa
d335e64f88 Stubs next version 2016-12-13 14:16:49 +01:00
Raul Ochoa
177d7ed07a Release 2.87.1 2016-12-13 14:15:50 +01:00
Raul Ochoa
85a1e15b58 Merge pull request #603 from CartoDB/upgrade-deps
Upgrade windshaft and request deps
2016-12-13 14:15:04 +01:00
Raul Ochoa
432b58a078 Upgrade windshaft and request deps 2016-12-13 14:10:42 +01:00
xavijam
75e3c5daef Ready for next release 2016-12-13 10:43:16 +01:00
Raul Ochoa
deb71c27b0 Merge pull request #601 from CartoDB/update-turbocarto
Update turbocarto package version
2016-12-12 18:56:54 +01:00
Raul Ochoa
8f5e1de6d8 Merge branch 'master' into update-turbocarto 2016-12-12 18:51:04 +01:00
Raul Ochoa
4836d62d7a Merge pull request #602 from CartoDB/travis-improvements
Travis improvements
2016-12-12 18:50:39 +01:00
Raul Ochoa
d27b0617b2 Remove comments 2016-12-12 18:44:25 +01:00
Raul Ochoa
28a2c29a39 Attempt to use postgis 2.3 2016-12-12 18:39:57 +01:00
Raul Ochoa
fcb6478407 Attempt to use postgis 2.2 2016-12-12 18:33:19 +01:00
Raul Ochoa
6d72afe40e Test sudoless travis 2016-12-12 17:30:14 +01:00
Raul Ochoa
e775266c64 Remove notifications 2016-12-12 17:29:32 +01:00
xavijam
12f25b38c0 Updated news 2016-12-12 17:03:56 +01:00
xavijam
c67a1107cb Package version updated with turbo-carto cahnges 2016-12-12 17:02:31 +01:00
xavijam
34bfb0d62c Updated news 2016-12-12 17:02:15 +01:00
Javier Goizueta
ede45cad1f Stub next version 2016-12-02 15:25:52 +01:00
Javier Goizueta
75fe4c8aed Release 2.86.1 2016-12-02 15:19:29 +01:00
Javier Goizueta
12e272a7e5 Merge pull request #599 from CartoDB/597-overviews-sql_wrap
Queries with sql_wrap should not be rewritten
2016-12-02 15:07:59 +01:00
Javier Goizueta
cfcba4e578 Wueries with sql_wrap should not be rewritten 2016-12-02 14:00:21 +01:00
Raul Ochoa
37ab898426 Stubs next version 2016-12-02 10:43:00 +01:00
Raul Ochoa
68865ea929 Release 2.86.0 2016-12-02 10:41:23 +01:00
Raul Ochoa
86674faa22 Update news and bump version 2016-12-02 10:41:02 +01:00
Raul Ochoa
f07947ce45 Merge pull request #597 from CartoDB/upgrade-windshaft
Upgrade windshaft
2016-12-02 10:32:44 +01:00
Raul Ochoa
6a50f59e25 Regenerate npm-shrinkwrap.json 2016-12-01 17:13:32 +01:00
Raul Ochoa
bfacd56800 Allow to use workers for transforming cartocss into mapnik XML 2016-12-01 17:02:40 +01:00
Raul Ochoa
45dea8b0c1 Stubs next version 2016-11-30 11:09:18 +01:00
Raul Ochoa
2f7f8cf2d8 Release 2.85.1 2016-11-30 11:07:29 +01:00
Raul Ochoa
31611b6a28 Upgrades camshaft to 0.48.4 2016-11-30 10:59:44 +01:00
Raul Ochoa
d1cd4b0c2b Stubs next version 2016-11-24 16:15:47 +01:00
Raul Ochoa
c8ba1c3e7c Release 2.85.0 2016-11-24 16:14:48 +01:00
Raul Ochoa
fbc8fe4c2d Update news and bump version 2016-11-24 16:11:08 +01:00
Raul Ochoa
54ec9b48db Ignore vscode settings dir 2016-11-24 15:41:09 +01:00
Raul Ochoa
488698d5e2 Merge pull request #594 from CartoDB/resources-url-templates
Allow to set resource URL templates with substitution tokens
2016-11-24 15:37:23 +01:00
Raul Ochoa
58c407aabb Alternative development example configuration for user in path instead of host 2016-11-24 12:57:45 +01:00
Raul Ochoa
fe750f23bc Closer to reality production example configuration 2016-11-24 12:56:38 +01:00
Raul Ochoa
87a01a5cfd Example configuration with just HTTP 2016-11-24 12:56:02 +01:00
Javier Goizueta
74dd669bb0 Stub next version 2016-11-23 15:29:50 +01:00
Javier Goizueta
36a50389f5 Release 2.84.2 2016-11-23 15:09:24 +01:00
Javier Goizueta
4f2d7434c7 Merge pull request #596 from CartoDB/upgrade-camshaft-to-0.48.3
Upgrade Camshaft version to 0.48.3
2016-11-23 15:05:43 +01:00
Javier Goizueta
b0a0848476 Upgrade Camshaft version to 0.48.3 2016-11-23 13:17:16 +01:00
Javier Goizueta
9fcd897e54 Stub next version 2016-11-23 11:57:05 +01:00
Javier Goizueta
daa8fff21e Release 2.84.1 2016-11-23 11:53:37 +01:00
Javier Goizueta
785229ddea Merge pull request #595 from CartoDB/upgrade-camshaft-to-0.48.2
Upgrade camshaft version to 0.48.2
2016-11-23 11:50:45 +01:00
Javier Goizueta
8bb11bf1d4 Upgrade camshaft version to 0.48.2 2016-11-23 11:36:38 +01:00
Raul Ochoa
1f975e15c1 Default to empty object for cdn URLs 2016-11-22 17:01:34 +01:00
Raul Ochoa
6c69ba54db Use actual CDN url for HTTP and HTTPS 2016-11-22 16:44:06 +01:00
Raul Ochoa
49f9904d00 Allow to set resource URL templates with substitution tokens 2016-11-22 16:41:31 +01:00
Raul Ochoa
7afd0dfa4e Remove prototype reference 2016-11-22 13:38:56 +01:00
Raul Ochoa
b1b6a437a7 Merge pull request #593 from CartoDB/592-doc-preview-layers
Fix DOC for named map  and preview layers
2016-11-22 12:52:24 +01:00
Daniel García Aubert
e4d5006591 Merge branch 'master' into 592-doc-preview-layers 2016-11-22 11:06:18 +01:00
Daniel García Aubert
627b3771d3 Fix doc for layer preview 2016-11-22 11:04:38 +01:00
Raul Ochoa
f4758e84e8 Stubs next version 2016-11-11 16:17:20 +01:00
Raul Ochoa
8dfe2098ed Release 2.84.0 2016-11-11 16:16:21 +01:00
Raul Ochoa
c56a4ee036 Update news and bump version 2016-11-11 16:15:59 +01:00
Raul Ochoa
c32623b821 Stubs next version 2016-11-11 16:15:08 +01:00
Raul Ochoa
3cd0a947f7 Merge pull request #586 from CartoDB/docs-switch-to-builder
switched gui tool from editor to builder
2016-11-11 12:52:38 +01:00
Raul Ochoa
8eea1cf4e7 Merge pull request #590 from CartoDB/analyses-limits-configuration
Analyses limit configuration allows to set other limits than timeout
2016-11-11 12:52:21 +01:00
Javier Goizueta
b5fccd5bbe Merge pull request #589 from CartoDB/upgrade-camshaft-to-0.48.1
Release 2.83.1
2016-11-10 18:48:14 +01:00
Raul Ochoa
e74ce9dfd8 Analyses limit configuration allows to set other limits than timeout
Configuration is now defined as a dictionary instead of just timeouts
per analysis type
2016-11-10 18:41:59 +01:00
Javier Goizueta
3743365a83 Release 2.83.1
Upgrade camshaft to 0.48.1
2016-11-10 18:16:42 +01:00
Javier Goizueta
8aeb2173d1 Release 2.83.0 2016-11-10 13:02:39 +01:00
Javier Goizueta
9a2b17d952 Merge pull request #588 from CartoDB/upgrade-camshaft-to-0.48.0
Upgrade camshaft to 0.48.0
2016-11-10 12:47:18 +01:00
Javier Goizueta
6f54cce01a Upgrade camshaft to 0.48.0
Upgrade camshaft to have analysis limits checking
2016-11-10 12:23:15 +01:00
Daniel García Aubert
6901b2049e Release 2.82.0 2016-11-08 18:48:01 +01:00
Daniel García Aubert
d0dcc027df Upgrade camshaft to version 0.47.0 2016-11-08 18:44:58 +01:00
Daniel García Aubert
b693005118 Stubs next version 2016-11-05 14:41:15 +01:00
Daniel García Aubert
ab4a0e836f Release 2.81.1 2016-11-05 14:36:49 +01:00
Daniel
abe02db6c6 Merge pull request #585 from CartoDB/fix-map-validator-basemap
Fix issues related to rollout
2016-11-05 14:35:06 +01:00
Daniel García Aubert
a2cd5dd32d Upgrade camshaft and windshaft 2016-11-05 14:12:03 +01:00
Daniel García Aubert
49b46a6096 Use address column in styles 2016-11-05 11:43:39 +01:00
csobier
94f420ca3f switched gui tool from editor to builder 2016-11-02 09:34:55 -04:00
Daniel García Aubert
5e530105df Stubs next version 2016-11-02 14:30:11 +01:00
Daniel García Aubert
2f82d34c4b Release 2.81.0 2016-11-02 10:36:19 +01:00
Daniel García Aubert
81fd01d0ac Upgrade camshaft to 0.46.2 2016-11-01 14:49:13 +01:00
Daniel García Aubert
9faac9f9fe Retrieve error with context if map validation fails 2016-11-01 11:00:58 +01:00
Daniel García Aubert
d04787a60c Fix test 2016-10-31 22:48:09 +01:00
Daniel García Aubert
f5dbf94b52 Stubs next version 2016-10-26 14:47:59 +02:00
Daniel García Aubert
5bec2d9b15 Release 2.80.2 2016-10-26 14:34:24 +02:00
Daniel García Aubert
fe64f0c63c Update NEWS 2016-10-26 14:30:56 +02:00
Daniel García Aubert
c20fd9691a Fix order in categories query to make it compatible with lenyends 2016-10-26 13:16:24 +02:00
Daniel García Aubert
eb323fbff9 Merge branch 'master' of github.com:CartoDB/Windshaft-cartodb 2016-10-25 16:28:34 +02:00
Daniel García Aubert
211f6b9a74 Stubs next version 2016-10-25 16:27:53 +02:00
Daniel García Aubert
b6c003ec63 Stubs next version 2016-10-25 16:15:03 +02:00
Daniel García Aubert
93d4bf2a72 Release 2.80.1 2016-10-25 16:02:32 +02:00
Daniel García Aubert
c6cb573383 Since crankshaft is installed by default in template-postgis we have to remove it before running test 2016-10-25 15:55:24 +02:00
Daniel García Aubert
f4ce671ea4 Upgrade camshaft version to 0.46.1 2016-10-25 14:54:52 +02:00
Raul Ochoa
147f7cbabb Stubs next version 2016-10-20 15:24:37 +02:00
Raul Ochoa
b05d5a141e Release 2.80.0 2016-10-20 15:23:17 +02:00
Raul Ochoa
d34e0306f8 Update news 2016-10-20 15:22:16 +02:00
Raul Ochoa
bd9f48dd24 Merge pull request #579 from CartoDB/upgrade-camshaft-to-0.46.0
Upgrade camshaft to 0.46.0
2016-10-20 15:20:14 +02:00
Javier Goizueta
9805990d79 Update npm-shrinkwrap 2016-10-20 15:11:53 +02:00
Raul Ochoa
dbbe60967c Bump version and update news 2016-10-20 15:04:46 +02:00
Raul Ochoa
0ef91c1904 Merge pull request #580 from CartoDB/analyses-config-limits
Default analyses limits can be defined in configuration
2016-10-20 15:02:44 +02:00
Raul Ochoa
376573459c Default analyses limits can be defined in configuration 2016-10-20 14:03:42 +02:00
Javier Goizueta
9c6d7c0ff9 Upgrade camshaft to 0.46.0
This version of camshaft requires a CDB_CheckAnalysisQuota function
to check analysis cache quota.
2016-10-20 12:56:18 +02:00
Raul Ochoa
30a95b7da3 Stubs next version 2016-10-11 16:56:22 +02:00
Raul Ochoa
e6a60aef9a Release 2.79.0 2016-10-11 16:55:15 +02:00
Raul Ochoa
5c2024581f Bump version 2016-10-11 16:55:03 +02:00
Raul Ochoa
f7ea2bb51e Merge pull request #578 from CartoDB/upgrade-turbo-carto
Upgrades turbo-carto to 0.18.0
2016-10-11 16:53:39 +02:00
Raul Ochoa
3e4da8ab57 Upgrades turbo-carto to 0.18.0 2016-10-11 16:41:26 +02:00
Raul Ochoa
7352a28908 Fix variable assigning to itself 2016-10-11 16:01:43 +02:00
Raul Ochoa
d1928ee578 Merge pull request #577 from CartoDB/analysis-limits-configuration
Retrieve analysis limits and pass them into camshaft
2016-10-11 16:00:07 +02:00
Raul Ochoa
cd978d7384 Retrieve analysis limits and pass them into camshaft 2016-10-11 15:46:11 +02:00
Raul Ochoa
cde0d8f5e2 Stubs next version 2016-09-30 18:26:33 +02:00
Raul Ochoa
7bacfcc2e4 Release 2.78.1 2016-09-30 18:25:00 +02:00
Raul Ochoa
241fe36103 Upgrades camshaft to 0.44.2 2016-09-30 18:24:44 +02:00
Raul Ochoa
441714a656 Stubs next version 2016-09-29 11:36:06 +02:00
Raul Ochoa
bd3fdb7f16 Release 2.78.0 2016-09-29 11:35:03 +02:00
Raul Ochoa
775af6feee Merge pull request #575 from CartoDB/cartocss-meta
Add metadata about processed turbo-carto rules
2016-09-28 19:44:52 +02:00
Raul Ochoa
adf5c17e0d Use context from adapters as provider context 2016-09-28 19:22:03 +02:00
Raul Ochoa
beb2d96a32 Upgrades turbo-carto to 0.17.1 2016-09-28 19:21:43 +02:00
Raul Ochoa
2a4ae88bc0 Merge remote-tracking branch 'origin/master' into cartocss-meta 2016-09-28 17:06:36 +02:00
Raul Ochoa
b76098ba45 Upgrades turbo-carto to 0.17.0 2016-09-28 16:57:04 +02:00
Raul Ochoa
c095027f8e Regenerate npm-shrinkwrap.json 2016-09-28 14:45:33 +02:00
Raul Ochoa
9d1db19907 Regenerate npm-shrinkwrap.json for turbo-carto dep 2016-09-28 11:39:58 +02:00
Daniel García Aubert
260e321537 Stub next version 2016-09-28 11:04:03 +02:00
Daniel García Aubert
073603b527 Release 2.77.1 2016-09-28 10:55:50 +02:00
Daniel García Aubert
17b259cf31 Upgrade camshaft to version 0.44.1 2016-09-28 10:54:27 +02:00
Daniel García Aubert
8f0f0026e9 Stubs next version 2016-09-27 12:28:44 +02:00
Daniel García Aubert
59dae2b545 Release 2.77.0 2016-09-26 19:11:12 +02:00
Daniel García Aubert
4670f69ead Upgrade camshaft to version 0.44.0 2016-09-26 19:05:16 +02:00
Daniel
16fbd25a34 Merge pull request #576 from CartoDB/conf-analysis-logger
Pass logger configuration to analysis backend and create a stream
2016-09-26 18:14:52 +02:00
Daniel García Aubert
2d75985cb3 Recreate stream on SIGHUP event 2016-09-26 17:39:27 +02:00
Daniel García Aubert
f963fb321e Set default config of analysis logger for test env 2016-09-23 17:35:46 +02:00
Daniel García Aubert
10feea0d48 Pass logger configuration to analysis backend and create a stream based on config 2016-09-23 17:11:04 +02:00
Raul Ochoa
b6b9b0ac36 Regenerate npm-shrinkwrap 2016-09-21 17:13:59 +02:00
Raul Ochoa
5551e85853 Update news and bump version 2016-09-21 16:06:43 +02:00
Raul Ochoa
1f0fa5031b Rely on turbo-carto metadata branch 2016-09-20 16:19:46 +02:00
Raul Ochoa
263294a3f5 Add metadata only for existing layers in turbocarto context 2016-09-20 16:19:22 +02:00
Raul Ochoa
f9df30f70b Append turbo-carto metadata per layer 2016-09-20 16:09:21 +02:00
Raul Ochoa
61d31ec054 Handle metadata from turbo-carto 2016-09-20 16:08:53 +02:00
Raul Ochoa
c8917bfc4c Return stats in callback 2016-09-20 16:00:33 +02:00
Raul Ochoa
36b69a05e5 Compute some stats in queries 2016-09-20 16:00:06 +02:00
Raul Ochoa
c8d2f66467 Stubs next version 2016-09-15 12:14:12 +02:00
Raul Ochoa
7416bb0e56 Release 2.76.0 2016-09-15 12:13:36 +02:00
Raul Ochoa
9182d0132d Merge pull request #574 from CartoDB/travis-addon
Travis' pg 9.5 addon
2016-09-15 11:17:51 +02:00
Raul Ochoa
9be9357ade Add libpango 2016-09-15 01:57:49 +02:00
Raul Ochoa
7f414f8adf Attempt to use travis' pg 9.5 addon 2016-09-15 01:51:36 +02:00
Raul Ochoa
3af9549939 Merge pull request #573 from CartoDB/external-config
Allow to use `--config /path/to/config.js` to specify configuration file
2016-09-15 01:49:43 +02:00
Raul Ochoa
41f248d731 Use logError 2016-09-15 01:35:38 +02:00
Raul Ochoa
18a517b7bf Allow to use --config /path/to/config.js to specify configuration file 2016-09-15 01:25:33 +02:00
Raul Ochoa
5150204389 Travis' Node.js 0.10 already uses npm 2.x 2016-09-14 21:22:40 +02:00
Raul Ochoa
3b16e7729d Merge pull request #572 from CartoDB/logs-conf
Allow to use absolute paths for log files
2016-09-14 21:04:19 +02:00
Raul Ochoa
76d27c9fce Allow to use absolute paths for log files
Fixes #570
2016-09-14 20:15:38 +02:00
Raul Ochoa
4ce6e41000 Stubs next version 2016-09-14 20:06:05 +02:00
Daniel García Aubert
33260cdbd9 Release 2.75.0 2016-09-14 09:48:20 +02:00
Raul Ochoa
85d81ba7fd Upgrades camshaft to 0.42.2 2016-09-09 13:40:31 +02:00
Raul Ochoa
7e8a3ca21f Stubs next version 2016-09-07 17:01:39 +02:00
Raul Ochoa
e9e4dc1f5c Release 2.74.1 2016-09-07 17:00:23 +02:00
Raul Ochoa
17c30e165a Upgrades camshaft to 0.42.1
Test fixture updated as it no longers generate bounds based on
table estimated bounds
2016-09-07 16:43:18 +02:00
Daniel García Aubert
c45c6ceb15 Stubs next version 2016-09-06 19:10:58 +02:00
Daniel García Aubert
d73c2c465f Release 2.74.0 2016-09-06 19:03:50 +02:00
Daniel
d4fc53939b Merge pull request #568 from CartoDB/567-show-hide-named-maps
Show & hide support in named maps
2016-09-06 18:53:23 +02:00
Daniel García Aubert
4becb65bec Stubs next version 2016-09-06 16:33:21 +02:00
Daniel García Aubert
f64e16c790 Release 2.73.1 2016-09-06 16:27:12 +02:00
Daniel García Aubert
1772011627 Add missinng column in fixture table cdb_analysis_catalog 2016-09-06 16:19:06 +02:00
Raul Ochoa
5b8f785e2b Regenerate npm-shrinkwrap.json 2016-09-06 16:01:05 +02:00
Daniel García Aubert
a0e3b77006 Release 2.73.0 2016-09-06 15:51:03 +02:00
Daniel García Aubert
908070ecd7 Fix jshint issue 2016-09-01 16:53:10 +02:00
Daniel García Aubert
7c6a58cd30 Made explicit to recreate named-map-provider 2016-09-01 16:42:06 +02:00
Daniel García Aubert
b0990a1132 Removed template-maps backend from named-maps controller 2016-09-01 16:31:30 +02:00
Daniel García Aubert
c6988cdb88 Improved and implemented new test for layer visibility suite 2016-09-01 12:37:56 +02:00
Daniel García Aubert
e0d304b033 Applied approach similar to static image options 2016-09-01 12:37:04 +02:00
Daniel García Aubert
e4a9f2d64c Added template map as dependency of named maps controller 2016-09-01 12:35:35 +02:00
Daniel García Aubert
0236fe3ca9 Implemented new scenario 2016-08-31 20:41:07 +02:00
Daniel García Aubert
1bed8623a2 Overwrites rendererparams instead of layergroup in mapconfig 2016-08-31 20:40:55 +02:00
Daniel García Aubert
df7d957914 Implemented acceptance test for layer visibility in previews 2016-08-31 19:41:23 +02:00
Daniel García Aubert
30c4b00f33 New approach: decorates named_map_provider to return the with visible layers 2016-08-31 19:40:00 +02:00
Daniel García Aubert
ab27886460 Renamed option by for name maps template 2016-08-31 19:37:48 +02:00
Daniel García Aubert
31e18d04d7 Undo unneeded optimization 2016-08-31 13:57:28 +02:00
Daniel García Aubert
8155484510 Improved test visibility layer with layerId 2016-08-29 10:46:55 +02:00
Daniel García Aubert
b61f1d2b53 Attached layer_visibility property to the named template 2016-08-26 17:30:03 +02:00
Daniel García Aubert
2e274b936a Improved test to check all possible values of visibility in named maps templates 2016-08-26 15:07:06 +02:00
Daniel García Aubert
bf3e311b57 Avoid unnecessary complexity 2016-08-26 14:46:23 +02:00
Daniel García Aubert
6a7613de6b Improved layergroup instantiation to filter non visible layers 2016-08-26 14:42:33 +02:00
Daniel García Aubert
ee46549e04 First approach 2016-08-25 20:04:23 +02:00
Raul Ochoa
377f3d4aff Removes constraint on filtered mapnik layers 2016-08-25 18:34:19 +02:00
Daniel García Aubert
752d47d71e Stubs next version 2016-08-23 11:25:39 +02:00
Daniel García Aubert
367157b80c Release 2.72.0 2016-08-23 11:19:48 +02:00
Daniel García Aubert
53542f1cd6 Stubs next version 2016-08-17 15:15:18 +02:00
Daniel García Aubert
7a8f156abf Release 2.71.0 2016-08-17 15:12:42 +02:00
Daniel García Aubert
c60cc57a0d Upgrades Windshaft to version 2.5.0 2016-08-17 15:07:29 +02:00
Raul Ochoa
8de6ec9a21 Stubs next version 2016-08-16 12:25:12 +02:00
Raul Ochoa
44b6f4be7e Release 2.70.0 2016-08-16 12:24:23 +02:00
Raul Ochoa
280be1751c Merge pull request #565 from CartoDB/update-camshaft
Upgrade camshaft to 0.40.0
2016-08-16 12:19:25 +02:00
Raul Ochoa
701a73a2c5 Upgrade camshaft to 0.40.0 2016-08-16 11:33:32 +02:00
Raul Ochoa
b578eada07 Stubs next version 2016-08-12 10:34:33 +02:00
Raul Ochoa
8100f155dc Release 2.69.1 2016-08-12 10:33:10 +02:00
Raul Ochoa
9f1a014004 Upgrades windshaft to 2.4.2 2016-08-12 10:24:06 +02:00
Raul Ochoa
e35e0e157c Stubs next version 2016-08-11 12:06:33 +02:00
Raul Ochoa
3aff328af3 Release 2.69.0 2016-08-11 12:05:56 +02:00
Raul Ochoa
ffb086045a Bump version 2016-08-11 12:05:37 +02:00
Raul Ochoa
c0786dfa6f Merge pull request #564 from CartoDB/fix-travis
Avoid 'No such file or directory'
2016-08-10 12:59:29 +02:00
Raul Ochoa
ddc33fa52b Avoid 'No such file or directory' 2016-08-10 10:30:04 +02:00
Raul Ochoa
9f2d6a5d41 Merge pull request #563 from CartoDB/upgrade-camshaft
Upgrade camshaft to 0.39.0
2016-08-09 17:01:09 +02:00
Raul Ochoa
64e884a092 force-yes for postgresql-plpython-9.5 2016-08-09 15:45:21 +02:00
Raul Ochoa
17ec174683 Use --force-yes 2016-08-09 15:41:17 +02:00
Raul Ochoa
3666cbee94 Upgrade camshaft to 0.39.0 2016-08-09 15:29:54 +02:00
Raul Ochoa
25de018f7d Add comment about row_limit config parameter 2016-08-01 12:59:38 +02:00
Raul Ochoa
6597851b48 Stubs next version 2016-07-21 21:04:39 +02:00
Raul Ochoa
0399131968 Release 2.68.0 2016-07-21 21:03:10 +02:00
Raul Ochoa
86836e7f89 Upgrades turbo-carto to 0.16.0 2016-07-21 21:02:06 +02:00
Daniel García Aubert
df346b11d3 Release 2.67.1 2016-07-21 16:05:12 +02:00
Daniel García Aubert
27f74b3fe2 Stubs next version 2016-07-21 10:41:42 +02:00
Daniel García Aubert
87dec64ad1 Release 2.67.0 2016-07-21 10:34:10 +02:00
Daniel García Aubert
54c787162a Update NEWS 2016-07-21 10:27:46 +02:00
Daniel García Aubert
6e92e699dc Upgrades camshaft version to 0.38.0 2016-07-21 10:25:53 +02:00
Raul Ochoa
7950f43db3 Stubs next version 2016-07-20 19:38:09 +02:00
Raul Ochoa
d300677315 Release 2.66.2 2016-07-20 19:26:27 +02:00
Raul Ochoa
bd4d29dd14 Upgrades turbo-carto to 0.15.1 2016-07-20 19:25:53 +02:00
Raul Ochoa
18a84433f4 Merge pull request #562 from CartoDB/git-for-log4js-dep
Use git for log4js dependency
2016-07-20 19:21:02 +02:00
Raul Ochoa
768ebf0ef2 Use git for log4js dependency 2016-07-20 18:34:57 +02:00
Raul Ochoa
1c20cb5478 Stubs next version 2016-07-20 11:20:12 +02:00
Raul Ochoa
279587ea11 Release 2.66.1 2016-07-20 11:16:23 +02:00
Raul Ochoa
25df193390 Merge pull request #560 from CartoDB/upgrade-turbo-carto
Upgrades turbo-carto to 0.15.0
2016-07-19 20:03:30 +02:00
Raul Ochoa
9ce81693bd Merge remote-tracking branch 'origin/master' into upgrade-turbo-carto
Conflicts:
	npm-shrinkwrap.json
2016-07-19 19:46:19 +02:00
Raul Ochoa
16765e092f Upgrades turbo-carto to 0.15.0 2016-07-19 19:28:53 +02:00
Daniel García Aubert
237e1257c4 Stubs next version 2016-07-18 13:34:14 +02:00
Daniel García Aubert
665859b17d Release 2.66.0 2016-07-18 13:31:55 +02:00
Raul Ochoa
b5a6d6974c Do not cast type in category ramp 2016-07-18 11:58:19 +02:00
Raul Ochoa
26bab029f4 Prepare for new turbo-carto versio 2016-07-18 11:57:27 +02:00
Raul Ochoa
ed7bb07b03 Output actual error message 2016-07-18 11:13:37 +02:00
Raul Ochoa
c87277ad01 Adjust to fail in specific scenario 2016-07-18 11:13:01 +02:00
Raul Ochoa
62be259a90 Rename turbo-cartocss -> turbo-carto 2016-07-18 10:29:13 +02:00
Daniel García Aubert
80798f984b Stubs next version 2016-07-15 12:15:47 +02:00
Daniel García Aubert
e32409880c Release 2.65.0 2016-07-15 12:07:37 +02:00
Daniel García Aubert
7b6eb2940e Upgrades camshaft version to 0.37.0 2016-07-15 12:01:29 +02:00
Raul Ochoa
87ad8df22f Merge pull request #557 from CartoDB/upgrade-cartodb-redis
Upgrades cartodb-redis to 0.13.1
2016-07-13 16:19:19 +02:00
Raul Ochoa
9fe20036a1 Upgrades cartodb-redis to 0.13.1
Which removes strftime dependency

Closes #285
2016-07-13 16:05:16 +02:00
Raul Ochoa
2b0d8d43bd Merge pull request #555 from CartoDB/analyses-controller
Add controller to list user analyses
2016-07-12 16:53:43 +02:00
Raul Ochoa
3af340d384 Add controller to list user analyses 2016-07-12 16:08:48 +02:00
Daniel García Aubert
20c1ad8d87 Stubs next version 2016-07-12 11:27:09 +02:00
Daniel García Aubert
8c351c7c46 Release 2.64.0 2016-07-12 11:23:40 +02:00
Daniel
6647e986d9 Merge pull request #554 from CartoDB/546-add-node-id-to-analyis-errors
add node id to analyis errors
2016-07-12 10:40:00 +02:00
Daniel García Aubert
77f691520c Merge branch 'master' into 546-add-node-id-to-analyis-errors 2016-07-11 16:06:58 +02:00
Daniel García Aubert
dfaa6ec024 Fixes #546, added node_id property to analysis errors 2016-07-11 15:48:26 +02:00
Raul Ochoa
41c574f5df Stubs next version 2016-07-11 10:50:49 +02:00
Raul Ochoa
10e901dcaa Release 2.63.0 2016-07-11 10:50:01 +02:00
Raul Ochoa
1d3626b4e1 Bump version 2016-07-11 10:49:45 +02:00
Raul Ochoa
bc419a51d6 Merge pull request #553 from CartoDB/node-error-on-create
Return last error message for failed nodes on map creation
2016-07-11 10:48:10 +02:00
Raul Ochoa
d0980a2872 Return last error message for failed nodes on map creation 2016-07-11 10:42:46 +02:00
Raul Ochoa
74719e48d9 Upgrades camshaft to 0.35.0 2016-07-11 10:42:14 +02:00
Raul Ochoa
d7c6b45438 Merge pull request #552 from CartoDB/upgrade-lzma
Upgrades lzma to 2.3.2
2016-07-08 16:20:07 +02:00
Raul Ochoa
551cfd87ee Upgrades lzma to 2.3.2 2016-07-08 13:52:07 +02:00
Carlos Matallín
ba29873a8e Merge pull request #548 from CartoDB/docs-781
rebranding
2016-07-07 18:49:39 +02:00
Daniel García Aubert
d9e2bb4537 Stubs next version 2016-07-07 18:35:16 +02:00
Daniel García Aubert
16d7b15d67 Release 2.62.0 2016-07-07 18:19:39 +02:00
Daniel García Aubert
b9da97fedd Upgrades camshaft to version 0.34.0 2016-07-07 18:13:19 +02:00
Raul Ochoa
bdf3b0393a Stubs next version 2016-07-07 00:39:49 +02:00
Raul Ochoa
a18f701466 Release 2.61.2 2016-07-07 00:38:58 +02:00
Raul Ochoa
71c7d8a90c Limit analysis creation concurrency 2016-07-07 00:36:59 +02:00
Raul Ochoa
99e766d952 Upgrades camshaft to 0.33.3 2016-07-07 00:36:39 +02:00
Raul Ochoa
fc78a0ed36 Stubs next version 2016-07-06 22:59:51 +02:00
Raul Ochoa
d4d398f583 Release 2.61.1 2016-07-06 22:59:06 +02:00
Raul Ochoa
be766ec803 Merge pull request #547 from CartoDB/mapconfig-dataviews
Use mapconfig to to store/retrieve dataviews queries
2016-07-06 22:58:11 +02:00
Raul Ochoa
57bb8dbbe3 Use mapconfig to to store/retrieve dataviews queries 2016-07-06 22:31:08 +02:00
Raul Ochoa
c539d4fbbd Change camshaft naming from filters 2016-07-06 21:11:39 +02:00
Raul Ochoa
a7dddcebe8 Stubs next version 2016-07-06 18:12:11 +02:00
Raul Ochoa
a9275845ff Release 2.61.0 2016-07-06 18:11:31 +02:00
Raul Ochoa
e5bf9efdb9 Upgrades camshaft to 0.33.2 2016-07-06 18:11:01 +02:00
Raul Ochoa
85073345ec Merge pull request #545 from CartoDB/turbo-carto-multiple-errors
Turbo carto multiple errors
2016-07-06 12:56:12 +02:00
Raul Ochoa
80d5b29902 More clear turbo-carto error messages: no context in message 2016-07-06 12:34:09 +02:00
Raul Ochoa
f55b748d20 Upgrade turbo-carto to 0.14.0 2016-07-06 12:33:08 +02:00
Raul Ochoa
870468ddf7 Merge pull request #543 from CartoDB/turbo-carto-multiple-errors
Return multiple turbo-carto errors
2016-07-06 00:43:00 +02:00
Raul Ochoa
b3107916ce Return multiple turbo-carto errors
Closes #541
2016-07-06 00:32:30 +02:00
Raul Ochoa
9cf856ab78 Merge pull request #542 from CartoDB/upgrade-turbo-carto
Upgrades turbo-carto to 0.13.0
2016-07-05 19:59:06 +02:00
Raul Ochoa
bbd047a940 Upgrades turbo-carto to 0.13.0 2016-07-05 19:53:13 +02:00
Daniel García Aubert
d3dfb0a7ff Stubs next version 2016-07-05 19:24:26 +02:00
Daniel García Aubert
5a8f9db79c Release 2.60.0 2016-07-05 18:39:20 +02:00
Daniel García Aubert
fbe20386b6 Upgrades camshaft version to 0.32.0 2016-07-05 18:31:47 +02:00
Raul Ochoa
6245b40015 Stubs next version 2016-07-05 15:51:36 +02:00
Raul Ochoa
3e959d8dc0 Release 2.59.1 2016-07-05 15:50:57 +02:00
Raul Ochoa
564df920d1 Upgrades camshaft to 0.31.0 2016-07-05 15:50:31 +02:00
Raul Ochoa
7e2c467a4f Stubs next version 2016-07-05 15:25:38 +02:00
Raul Ochoa
3a42305408 Release 2.59.0 2016-07-05 15:25:00 +02:00
Raul Ochoa
09616777e6 Merge pull request #540 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.30.0
2016-07-05 15:24:05 +02:00
Raul Ochoa
c2a5569b8c Upgrades camshaft to 0.30.0 2016-07-05 14:59:09 +02:00
Raul Ochoa
38bea2108b Stubs next version 2016-07-05 12:16:35 +02:00
Raul Ochoa
ab0777b45f Release 2.58.0 2016-07-05 12:15:55 +02:00
Raul Ochoa
962f94387b Fix release date 2016-07-05 12:15:41 +02:00
Raul Ochoa
de5600b4fd Bump version 2016-07-05 12:15:09 +02:00
Raul Ochoa
188a202f02 Merge pull request #538 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.29.2
2016-07-05 12:14:20 +02:00
Raul Ochoa
19f39b87f5 Merge branch 'master' into upgrade-camshaft
Conflicts:
	NEWS.md
2016-07-05 11:42:57 +02:00
Raul Ochoa
c759f314f9 Merge pull request #539 from CartoDB/nodes-metadata-fix
Return full list of nodes in response metadata
2016-07-05 11:42:13 +02:00
Raul Ochoa
6c98f14c64 Return full list of nodes in response metadata 2016-07-05 11:26:52 +02:00
Raul Ochoa
f2348e1b24 Upgrades camshaft to 0.29.2 2016-07-05 11:25:24 +02:00
Raul Ochoa
4b5a10fe61 Upgrades camshaft to 0.29.1 2016-07-05 10:26:48 +02:00
Raul Ochoa
163fa58b5a Merge pull request #537 from CartoDB/analysis-failed-status-error-message
Include error message in node status endpoint
2016-07-05 10:22:43 +02:00
csobier
2bb03225cb updated all api examples with rebranded account url- confirmed by luis 2016-07-04 17:30:16 -04:00
Raul Ochoa
b3bbb6af01 Include error message in node status endpoint 2016-07-04 18:40:11 +02:00
Raul Ochoa
28d711e1f4 Stubs next version 2016-07-04 17:54:39 +02:00
Raul Ochoa
410fdb8343 Release 2.57.0 2016-07-04 17:53:58 +02:00
Raul Ochoa
21c2f3bdd1 Merge pull request #536 from CartoDB/upgrade-camshaft
Upgrade camshaft to 0.28.1
2016-07-04 17:53:20 +02:00
Raul Ochoa
baae080318 Merge remote-tracking branch 'origin/master' into upgrade-camshaft
Conflicts:
	NEWS.md
	package.json
2016-07-04 17:04:54 +02:00
Raul Ochoa
81c0796056 Upgrades camshaft to 0.28.1 2016-07-04 17:03:56 +02:00
Daniel García Aubert
6ea5c5f414 Stubs next version 2016-07-04 16:29:30 +02:00
Daniel García Aubert
7e37705843 Release 2.56.0 2016-07-04 16:08:38 +02:00
Daniel García Aubert
425b5e6b4a Upgrades camshaft version to 0.27.0 2016-07-04 15:56:04 +02:00
Raul Ochoa
8942c72fb2 Stubs next version 2016-07-04 10:28:44 +02:00
Raul Ochoa
e9359fdd73 Release 2.55.0 2016-07-04 10:28:07 +02:00
Raul Ochoa
5c4308abc1 Merge pull request #534 from CartoDB/turbo-carto-valid-ramps
Skip null values for quantification methods
2016-07-04 02:30:23 +02:00
Raul Ochoa
61576b671b Update news 2016-07-04 02:23:48 +02:00
Raul Ochoa
1e4d6bb942 Merge remote-tracking branch 'origin/master' into turbo-carto-valid-ramps 2016-07-04 02:22:41 +02:00
Raul Ochoa
ff6c0addb4 Merge pull request #533 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.26.0
2016-07-04 02:22:24 +02:00
Raul Ochoa
98cd524c07 Skip null values for quantification methods generating null values 2016-07-04 02:15:54 +02:00
Raul Ochoa
746d57ff42 Red: expose issues with some quantification method when query returns empty 2016-07-04 02:11:52 +02:00
Raul Ochoa
7319822419 Upgrades camshaft to 0.26.0 2016-07-04 02:07:12 +02:00
Raul Ochoa
58bcde3818 Merge pull request #532 from CartoDB/upgrade-camshaft
Upgrade camshaft to 0.25.0
2016-07-03 11:51:56 +02:00
Raul Ochoa
b57d08f38e Output nodes for test 2016-07-03 11:45:10 +02:00
Raul Ochoa
739a8cef32 Regenerate npm-shrinkwrap.json for 0.25.0 2016-07-03 11:27:04 +02:00
Raul Ochoa
8a6e31e025 Merge remote-tracking branch 'origin/master' into upgrade-camshaft 2016-07-03 10:59:12 +02:00
Raul Ochoa
616aac9771 Upgrade camshaft to 0.25.0
Use new configuration with user for nodes.
2016-07-03 10:49:45 +02:00
Raul Ochoa
23a1b7484e Merge pull request #531 from CartoDB/pg-9.5
Use postgresql 9.5 in travis
2016-07-02 20:05:55 +02:00
Raul Ochoa
9624ee1c76 Attempt to use postgresql 9.5 2016-07-02 19:54:34 +02:00
Raul Ochoa
4c557be2c2 Update to use latest cdb_analysis_catalog
It avoids to execute queries that are extension specifics
2016-07-02 19:50:59 +02:00
Raul Ochoa
7577ee8015 Stubs next version 2016-07-01 20:17:11 +02:00
Daniel García Aubert
8c73914da4 Release 2.54.0 2016-06-30 15:00:21 +02:00
Raul Ochoa
604ba300aa Bump version 2016-06-30 13:33:54 +02:00
Raul Ochoa
876166ab74 Update news 2016-06-30 13:33:25 +02:00
Raul Ochoa
1bf8fda770 Merge pull request #530 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.23.0
2016-06-30 13:31:01 +02:00
Raul Ochoa
cd32218cea Upgrades camshaft to 0.23.0 2016-06-30 13:14:30 +02:00
Daniel
0fd0974738 Merge pull request #525 from CartoDB/fix-error-context
Fix error context, replaced `turbo-carto` error type by `layer` type
2016-06-29 19:15:44 +02:00
Daniel García Aubert
ed7f95a1a7 Merge branch 'master' into fix-error-context 2016-06-29 19:02:54 +02:00
Daniel García Aubert
a36c1c52ae Fixs typo 2016-06-29 17:19:01 +02:00
Daniel García Aubert
226d948c4d Upgrades windshaft to version 2.4.0 2016-06-29 17:08:55 +02:00
Raul Ochoa
84c67f977e Stubs next version 2016-06-29 16:50:19 +02:00
Raul Ochoa
c09cda84a3 Release 2.53.5 2016-06-29 16:49:34 +02:00
Raul Ochoa
bd36ea1829 news style 2016-06-29 16:49:13 +02:00
Raul Ochoa
01a47925e0 Merge pull request #529 from CartoDB/528-invalid-error-regression
Fixes invalid error on node not found from dataview
2016-06-29 16:47:16 +02:00
Raul Ochoa
dd8a70eb95 Uses node list so identical nodes are not de-duplicated and can be used with different ids
Fixes #528
2016-06-29 16:10:26 +02:00
Raul Ochoa
013bdba4ff Add regression test wheren node id can't be found and it should 2016-06-29 16:08:38 +02:00
Raul Ochoa
c1acc54d55 Add constants for cartocss symbolizers 2016-06-29 16:07:42 +02:00
Raul Ochoa
5f3fb6e5f7 Adds fake CDB_KMeans function 2016-06-29 16:07:01 +02:00
Daniel García Aubert
e3fac9c161 Updated NEWS 2016-06-29 16:03:52 +02:00
Daniel García Aubert
accab9e78a Gets layerId from the layer that raises the error 2016-06-29 12:21:15 +02:00
Raul Ochoa
cb53d140e3 Stubs next version 2016-06-28 19:48:47 +02:00
Raul Ochoa
72986d1946 Release 2.53.4 2016-06-28 19:47:59 +02:00
Raul Ochoa
2195c55518 Upgrades camshaft to 0.22.4 2016-06-28 19:44:55 +02:00
Raul Ochoa
c418ba1908 Stubs next version 2016-06-28 14:39:02 +02:00
Raul Ochoa
934356e5cc Release 2.53.3 2016-06-28 14:38:25 +02:00
Raul Ochoa
c40235a910 Upgrades camshaft to 0.22.3 2016-06-28 14:37:21 +02:00
Raul Ochoa
cd8338196e Stubs next version 2016-06-28 13:08:08 +02:00
Raul Ochoa
2143e87401 Release 2.53.2 2016-06-28 13:07:19 +02:00
Raul Ochoa
f0a536ee1e Upgrades camshaft to 0.22.2 2016-06-28 13:06:46 +02:00
Raul Ochoa
dde4b63c6b Stubs next version 2016-06-28 00:25:29 +02:00
Raul Ochoa
0e7bcc4b56 Release 2.53.1 2016-06-28 00:24:40 +02:00
Raul Ochoa
e4816b4322 Merge pull request #527 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.22.1
2016-06-28 00:21:33 +02:00
Raul Ochoa
af4f29c538 Upgrades camshaft to 0.22.1 2016-06-28 00:17:33 +02:00
Daniel García Aubert
016adb64ef Fix error context, replaced turbo-carto error type by layer type. Context is no longer used, custom property for each type will be used instead. 2016-06-26 18:43:04 +02:00
Raul Ochoa
7cedccedcd Stubs next version 2016-06-24 14:59:23 +02:00
Raul Ochoa
a9c12d4534 Release 2.53.0 2016-06-24 14:58:44 +02:00
Raul Ochoa
77f71b1978 Merge pull request #523 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.22.0
2016-06-24 14:56:05 +02:00
Raul Ochoa
1c029fbc7b Upgrades camshaft to 0.22.0 2016-06-24 14:51:44 +02:00
Raul Ochoa
2bc0d8d145 Stubs next version 2016-06-23 19:09:16 +02:00
Raul Ochoa
4c2af88f92 Release 2.52.0 2016-06-23 19:08:36 +02:00
Raul Ochoa
ddd5d2a0b0 Bump version 2016-06-23 19:08:10 +02:00
Raul Ochoa
d5cb59dc84 Merge pull request #521 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.21.0
2016-06-23 19:06:25 +02:00
Raul Ochoa
f21581630a Upgrades camshaft to 0.21.0 2016-06-23 19:01:59 +02:00
Raul Ochoa
3fef37d06b Stubs next version 2016-06-22 17:23:04 +02:00
Raul Ochoa
a8b93896ed Release 2.51.0 2016-06-22 17:22:20 +02:00
Raul Ochoa
6c1e9bf0ca Bump version 2016-06-22 17:21:58 +02:00
Raul Ochoa
1d8947d404 Merge pull request #520 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.20.0
2016-06-22 15:13:17 +02:00
Raul Ochoa
834377b342 Upgrades camshaft to 0.20.0 2016-06-22 15:03:26 +02:00
Daniel García Aubert
c2e0eb05e5 Updated NEWS. #519 2016-06-21 18:43:27 +02:00
Daniel
256032ca4a Merge pull request #519 from CartoDB/fix-error-with-context
Now errors with context have the same schema.
2016-06-21 18:41:46 +02:00
Daniel García Aubert
d80f2b9566 Now errors with context have the same schema. 2016-06-21 18:26:10 +02:00
Raul Ochoa
9e2f0371ba Merge pull request #518 from CartoDB/better-analyses-errors
Improve error messages for missing analyses for layers and dataviews
2016-06-21 17:34:44 +02:00
Raul Ochoa
a2e74a3e1b Improve error messages for missing analyses for layers and dataviews 2016-06-21 17:25:28 +02:00
Raul Ochoa
f04a5a1ab9 Merge pull request #517 from CartoDB/turbo-carto-datasource-improvements
Split turbo-carto adapter substitutions tokens query
2016-06-21 15:48:07 +02:00
Raul Ochoa
7114311b75 Split turbo-carto adapter substitutions tokens query 2016-06-21 15:05:44 +02:00
Daniel García Aubert
1e9e092dc3 Stubs next version 2016-06-21 14:52:27 +02:00
Daniel García Aubert
98b3a5ba23 Release 2.50.0 2016-06-21 14:41:52 +02:00
Daniel García Aubert
200966e806 Merge branch 'upgrade-camshaft-0.19.0' 2016-06-21 14:34:28 +02:00
Daniel García Aubert
407430b81e Updated shrinkwrap 2016-06-21 14:20:54 +02:00
Raul Ochoa
c4b1fc039c Merge pull request #516 from CartoDB/turbo-carto-datasource-improvements
Pixel size query for turbo-carto adapter using radians and degrees
2016-06-21 14:12:41 +02:00
Raul Ochoa
d00379af6b Pixel size query for turbo-carto adapter using radians and degrees instead of meters 2016-06-21 14:01:43 +02:00
Raul Ochoa
7cee0f3ee3 Merge pull request #515 from CartoDB/turbo-carto-datasource-improvements
Use psql client instead of pg query runner to use proper params
2016-06-21 13:24:36 +02:00
Daniel García Aubert
2588346f1b Bumped camshaft version to 0.19.0 2016-06-21 13:19:01 +02:00
Raul Ochoa
863128013d Use psql client instead of pg query runner to use proper params 2016-06-21 12:08:40 +02:00
Raul Ochoa
51eb8eb67f Upgrades camshaft to 0.18.0 2016-06-20 17:09:55 +02:00
Raul Ochoa
28e01fd8ac Bump version 2016-06-20 16:47:38 +02:00
Raul Ochoa
726e153ad5 Merge pull request #514 from CartoDB/dataview-aggregation-operations
Add support for min, max, and avg operations in aggregation dataview
2016-06-20 16:40:55 +02:00
Raul Ochoa
e8df09c85b Add support for min, max, and avg operations in aggregation dataview 2016-06-20 16:26:24 +02:00
Raul Ochoa
2b4fb2971d Stubs next version 2016-06-20 13:44:24 +02:00
Raul Ochoa
933b36cca0 Release 2.49.1 2016-06-20 13:35:59 +02:00
Raul Ochoa
37a7cfb6ba Update news 2016-06-20 13:35:38 +02:00
Raul Ochoa
8a1cda159c Merge pull request #512 from CartoDB/turbo-carto-datasource-fixes
Use an empty array as default value for falsy ramps
2016-06-20 13:33:02 +02:00
Raul Ochoa
403dcbebcd Use an empty array as default value for falsy ramps
Fixes #507
2016-06-20 13:27:39 +02:00
Raul Ochoa
373ad69306 Merge branch 'master' into turbo-carto-datasource-fixes 2016-06-20 13:27:02 +02:00
Raul Ochoa
b2029e09f5 Add CDB_OverviewsSupport sql from extension to fix CDB_Overviews calls 2016-06-20 13:26:30 +02:00
Raul Ochoa
4f37d2d0c2 Empty results should keep working, going red 2016-06-20 13:09:01 +02:00
Raul Ochoa
a5b07bc2a8 Upgrades turbo-carto to 0.12.1 2016-06-20 13:07:51 +02:00
Raul Ochoa
1544a5622d Merge pull request #511 from CartoDB/dataview-the_geom-query
Dataview the geom query
2016-06-17 17:08:48 +02:00
Raul Ochoa
d49a877771 Fix reversed own filter option 2016-06-17 16:26:45 +02:00
Raul Ochoa
0f4747743c Merge branch 'master' into dataview-the_geom-query 2016-06-17 15:55:07 +02:00
Raul Ochoa
368e4522e7 Merge pull request #510 from CartoDB/updated-at-from-analyses-result
Pick last update time for layergroupid from analyses results
2016-06-17 15:44:11 +02:00
Raul Ochoa
cb1d1bb115 Pick last update time for layergroupid from analyses results 2016-06-17 14:46:22 +02:00
Raul Ochoa
612cc3dd41 Use the_geom for intermediate dataviews 2016-06-16 17:27:00 +02:00
Raul Ochoa
bff082e577 Stubs next version 2016-06-15 19:27:48 +02:00
Raul Ochoa
ea41750a14 Release 2.49.0 2016-06-15 19:26:25 +02:00
Raul Ochoa
458376a665 Merge pull request #506 from CartoDB/upgrade-camshaft
Upgrade camshaft to 0.17.1
2016-06-15 19:24:48 +02:00
Raul Ochoa
f0284907c4 Upgrade camshaft to 0.17.1 2016-06-15 19:13:37 +02:00
Raul Ochoa
ad0385ccf7 Merge pull request #505 from CartoDB/upgrade-camshaft
Upgrade camshaft to 0.17.0
2016-06-15 16:58:23 +02:00
Raul Ochoa
4350fc3c65 Upgrade camshaft to 0.17.0 2016-06-15 16:48:00 +02:00
Raul Ochoa
fc3422b9e5 Merge pull request #503 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.16.0
2016-06-15 11:13:50 +02:00
Raul Ochoa
9703c19fb4 Upgrades camshaft to 0.16.0 2016-06-15 11:01:11 +02:00
Daniel García Aubert
d36f2fb354 Stubs next version 2016-06-14 17:50:40 +02:00
Daniel García Aubert
c837785314 Release 2.48.0 2016-06-14 17:48:07 +02:00
Daniel
33014a9f45 Merge pull request #500 from CartoDB/478-error-context
Adds more error information when either analysis or turbo-carto is not well formed
2016-06-14 15:56:00 +02:00
Daniel García Aubert
c16d0b8605 Fixed broken tests 2016-06-14 10:50:50 +02:00
Daniel García Aubert
c88e4c5173 Merge branch 'master' into 478-error-context 2016-06-14 10:43:00 +02:00
Daniel García Aubert
0540696c3e Avoid to expose internal naming 2016-06-14 10:27:35 +02:00
Raul Ochoa
5f59a97a02 Merge pull request #502 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.15.1
2016-06-14 01:41:41 +02:00
Raul Ochoa
d3b815c3c7 Upgrades camshaft to 0.15.1 2016-06-14 01:36:15 +02:00
Raul Ochoa
d2a8dcbede Merge pull request #501 from CartoDB/upgrade-camshaft
Upgrades camshaft to 0.15.0
2016-06-13 22:14:47 +02:00
Daniel García Aubert
4854e879a6 Updated npm-shrinkwrap 2016-06-13 19:49:20 +02:00
Daniel García Aubert
ddc99cebff Upgrades turbo-carto to 0.12.0 2016-06-13 18:40:14 +02:00
Raul Ochoa
47470d4f2b Upgrades camshaft to 0.15.0 2016-06-13 18:04:48 +02:00
Daniel García Aubert
d9297d54de made error_with_context non optional and adapted test's assertion 2016-06-13 16:14:01 +02:00
Daniel García Aubert
2d821f957e Merge branch 'master' into 478-error-context 2016-06-13 12:29:00 +02:00
Daniel García Aubert
c0ce6e7a8a WIP fixes 478, adds more error information when either analysis or turbo-carto is not well formed. 2016-06-13 12:20:56 +02:00
Raul Ochoa
3f620c6cdd Stubs next version 2016-06-13 10:47:15 +02:00
Raul Ochoa
9160d8018d Release 2.47.1 2016-06-13 10:43:45 +02:00
Raul Ochoa
51307bcc69 Upgrades camshaft to 0.14.1 2016-06-10 18:38:49 +02:00
Raul Ochoa
d29651ee80 Stubs next version 2016-06-10 14:41:08 +02:00
csobier
9acb980b82 more reverted code applied 2016-06-02 13:22:07 -04:00
csobier
7d623faf4b reverted rebranded coe, as instructed. Legacy cartodb code appears instead. Also applied ALL CAPS for rebranded name, as instructed 2016-05-31 13:40:41 -04:00
csobier
0f2401b0cc docs 781 applied to windshaft-api docs 2016-05-26 10:22:52 -04:00
115 changed files with 6880 additions and 5402 deletions

2
.gitignore vendored
View File

@@ -2,6 +2,8 @@ node_modules*
config.status*
config/environments/*.js
.idea
.vscode
.nvmrc
tools/munin/windshaft.conf
logs/
pids/

View File

@@ -1,30 +1,27 @@
sudo: false
dist: trusty
addons:
postgresql: "9.4"
postgresql: "9.5"
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- postgresql-plpython-9.4
- postgresql-9.5-postgis-2.3
- postgresql-plpython-9.5
- pkg-config
- libcairo2-dev
- libjpeg8-dev
- libgif-dev
- libpango1.0-dev
- g++-4.9
before_install:
- npm install -g npm@2
- createdb template_postgis
- createuser publicuser
- psql -c "CREATE EXTENSION postgis" template_postgis
env:
- NPROCS=1 JOBS=1 PGUSER=postgres
- NPROCS=1 JOBS=1 PGUSER=postgres CXX=g++-4.9
language: node_js
node_js:
- "0.10"
notifications:
irc:
channels:
- "irc.freenode.org#cartodb"
use_notice: true
- "6"

View File

@@ -8,4 +8,4 @@ We love pull requests from everyone, see [Contributing to Open Source on GitHub]
## Submitting Contributions
* You will need to sign a Contributor License Agreement (CLA) before making a submission. [Learn more here](https://cartodb.com/contributing).
* You will need to sign a Contributor License Agreement (CLA) before making a submission. [Learn more here](https://carto.com/contributions).

View File

@@ -1,11 +1,10 @@
1. Test (make clean all check), fix if broken before proceeding
2. Ensure proper version in package.json
2. Ensure proper version in package.json
3. Ensure NEWS section exists for the new version, review it, add release date
4. Recreate npm-shrinkwrap.json with: `npm install --no-shrinkwrap && npm shrinkwrap`
5. Commit package.json, npm-shrinwrap.json, NEWS
4. Recreate yarn.lock with: `yarn upgrade`
5. Commit package.json, yarn.lock, NEWS
6. git tag -a Major.Minor.Patch # use NEWS section as content
7. Announce on cartodb@googlegroups.com
8. Stub NEWS/package for next version
7. Stub NEWS/package for next version
Versions:

View File

@@ -4,11 +4,11 @@
Make sure that you have the requirements needed. These are
- Core
- Node.js >=0.8
- npm >=1.2.1 <2.0.0
- Node.js >=6.9.x
- yarn >=0.21.3
- PostgreSQL >8.3.x, PostGIS >1.5.x
- Redis >2.4.0 (http://www.redis.io)
- Mapnik 2.0.1, 2.0.2, 2.1.0, 2.2.0, 2.3.0. See [Installing Mapnik](https://github.com/CartoDB/Windshaft#installing-mapnik).
- Mapnik >3.x. See [Installing Mapnik](https://github.com/CartoDB/Windshaft#installing-mapnik).
- Windshaft: check [Windshaft dependencies and installation notes](https://github.com/CartoDB/Windshaft#dependencies)
- libcairo2-dev, libpango1.0-dev, libjpeg8-dev and libgif-dev for server side canvas support
@@ -43,11 +43,11 @@ psql -d template_postgis -c 'CREATE EXTENSION postgis;'
To fetch and build all node-based dependencies, run:
```
npm install
yarn
```
Note that the ```npm install``` step will populate the node_modules/
Note that the ```yarn``` step will populate the node_modules/
directory with modules, some of which being compiled on demand. If you
happen to have startup errors you may need to force rebuilding those
modules. At any time just wipe out the node_modules/ directory and run
```npm install``` again.
```yarn``` again.

View File

@@ -7,7 +7,7 @@ all:
@$(SHELL) ./scripts/install.sh
clean:
rm -rf node_modules/*
rm -rf node_modules/
distclean: clean
rm config.status*

715
NEWS.md
View File

@@ -1,5 +1,720 @@
# Changelog
## 3.4.0
Released 2017-04-03
Announcements:
- Upgrades camshaft to [0.51.0](https://github.com/CartoDB/camshaft/releases/tag/0.51.0).
## 3.3.0
Released 2017-04-03
New features:
- Static map endpoints allow specifying the layers to render #653.
## 3.2.0
Released 2017-03-30
Announcements:
- Upgrades windshaft to [3.1.0](https://github.com/CartoDB/windshaft/releases/tag/3.1.0).
- Active GC interval.
## 3.1.1
Released 2017-03-23
Bug fixes:
- Use crc32 instead of md5 for computing subdomain candidate #642
## 3.1.0
Released 2017-03-22
Features:
- Generate URLs for resources based on CDN and template rules
## 3.0.2
Released 2017-03-22
Bug fixes:
- Upgrade dependencies
- Improve docs: remove mentions to NPM and use yarn instead
- Remove script to generate npm-shrinkwrap file
## 3.0.1
Released 2017-03-21
Announcements:
- Upgrades windshaft to [3.0.1](https://github.com/CartoDB/windshaft/releases/tag/3.0.1).
## 3.0.0
Released 2017-03-21
Announcements:
- Supports Node v6.9.x
- Drops support for Node v0.10.x
- Upgrades windshaft to 3.0.0
- Upgrades cartodb-query-tables to 0.2.0
- Upgrades cartodb-redis to 0.13.2
- Upgrades redis-mpool to 0.4.1
**Note**: Due to this [issue](https://github.com/npm/npm/issues/15713), Windshaft-cartodb must be installed with `yarn` instead of `npm` providing just a `yarn.lock` to get consistent installs across machines.
## 2.89.0
Released 2017-03-17
**Deprecation warning**: v2.89.0 is the last release that supports Node v0.10.x. Next mayor release will support Node v6.9.x and further versions.
Announcements:
- Upgrades windshaft to [2.8.0](https://github.com/CartoDB/windshaft/releases/tag/2.8.0).
Bug fixes:
- Histogram column type discovery query uses non-filtered query #637
## 2.88.4
Released 2017-03-10
Announcements:
- Upgrades camshaft to [0.50.3](https://github.com/CartoDB/camshaft/releases/tag/0.50.3).
## 2.88.3
Released 2017-03-02
Bug fixes:
- Category dataviews now uses the proper aggregation function for the 'Other' category. See https://github.com/CartoDB/Windshaft-cartodb/issues/628
## 2.88.2
Released 2017-02-23
Announcements:
- Upgrades camshaft to [0.50.2](https://github.com/CartoDB/camshaft/releases/tag/0.50.2).
## 2.88.1
Released 2017-02-21
Announcements:
- Upgrades camshaft to [0.50.1](https://github.com/CartoDB/camshaft/releases/tag/0.50.1)
## 2.88.0
Released 2017-02-21
Announcements:
- Upgrades camshaft to [0.50.0](https://github.com/CartoDB/camshaft/releases/tag/0.50.0).
- Upgrades cartodb-psql to [0.7.1](https://github.com/CartoDB/node-cartodb-psql/releases/tag/0.7.1).
- Upgrades windshaft to [2.7.0](https://github.com/CartoDB/windshaft/releases/tag/2.7.0).
## 2.87.5
Released 2017-02-02
Bug fixes:
- Cast dataview override values to Number or throw error.
## 2.87.4
Released 2017-01-20
Bug fixes:
- Be able to not compute NULL categories and null values in aggregation dataviews #617.
## 2.87.3
Released 2016-12-19
Bug fixes:
- Fix overviews-related dataviews problems. See https://github.com/CartoDB/Windshaft-cartodb/pull/604
## 2.87.2
Released 2016-12-19
- Use exception safe Dataservices API functions. See https://github.com/CartoDB/dataservices-api/issues/314 and https://github.com/CartoDB/camshaft/issues/242
## 2.87.1
Released 2016-12-13
Announcements:
- Upgrades windshaft to [2.6.4](https://github.com/CartoDB/Windshaft/releases/tag/2.6.4).
- Upgrades request dependency.
- Regenerate npm-shrinkwrap.json: missing dependency updates.
## 2.87.0
Released 2016-12-12
Enhancements:
- Upgrade turbo-carto dependency to version 0.19.0.
## 2.86.1
Released 2016-12-02
Bug fixes:
- Maps with analyses and `sql_wrap` were broken #599.
## 2.86.0
Released 2016-12-02
Announcements:
- Upgrades windshaft to [2.6.3](https://github.com/CartoDB/Windshaft/releases/tag/2.6.3).
## 2.85.1
Released 2016-11-30
Announcements:
- Upgrades camshaft to [0.48.4](https://github.com/CartoDB/camshaft/releases/tag/0.48.4).
## 2.85.0
Released 2016-11-24
New features:
- Allow to set resource URL templates with substitution tokens #594.
## 2.84.2
Released 2016-11-23
Announcements:
- Upgrades camshaft to [0.48.3](https://github.com/CartoDB/camshaft/releases/tag/0.48.3).
## 2.84.1
Released 2016-11-23
Announcements:
- Upgrades camshaft to [0.48.2](https://github.com/CartoDB/camshaft/releases/tag/0.48.2).
## 2.84.0
Released 2016-11-11
New features:
- Analyses limit configuration allows to set other limits than timeout.
## 2.83.1
Released 2016-11-10
Announcements:
- Upgrades camshaft to [0.48.1](https://github.com/CartoDB/camshaft/releases/tag/0.48.1).
## 2.83.0
Released 2016-11-10
Announcements:
- Upgrades camshaft to [0.48.0](https://github.com/CartoDB/camshaft/releases/tag/0.48.0).
## 2.82.0
Released 2016-11-08
Announcements:
- Upgrades camshaft to [0.47.0](https://github.com/CartoDB/camshaft/releases/tag/0.47.0).
## 2.81.1
Released 2016-11-05
Announcements:
- Upgrades windshaft to [2.6.2](https://github.com/CartoDB/windshaft/releases/tag/2.6.2).
- Upgrades camshaft to [0.46.3](https://github.com/CartoDB/camshaft/releases/tag/0.46.3).
## 2.81.0
Released 2016-11-02
Enhancements:
- Returns errors with context when query layer does not retrieve geometry column
Announcements:
- Upgrades windshaft to [2.6.1](https://github.com/CartoDB/windshaft/releases/tag/2.6.1).
- Upgrades camshaft to [0.46.2](https://github.com/CartoDB/camshaft/releases/tag/0.46.2).
## 2.80.2
Released 2016-10-26
Bug fixes:
- Fix order in categories query to get ramps
## 2.80.1
Released 2016-10-25
Announcements:
- Upgrades camshaft to [0.46.1](https://github.com/CartoDB/camshaft/releases/tag/0.46.1).
## 2.80.0
Released 2016-10-20
Announcements:
- Upgrades camshaft to [0.46.0](https://github.com/CartoDB/camshaft/releases/tag/0.46.0).
New features:
- Default analyses limits can be defined in configuration.
## 2.79.0
Released 2016-10-11
New features:
- Retrieve analysis limits and pass them into camshaft.
Announcements:
- Upgrades turbo-carto to [0.18.0](https://github.com/CartoDB/turbo-carto/releases/tag/0.18.0).
- Upgrades camshaft to [0.45.0](https://github.com/CartoDB/camshaft/releases/tag/0.45.0).
## 2.78.1
Released 2016-09-30
Announcements:
- Upgrades camshaft to [0.44.2](https://github.com/CartoDB/camshaft/releases/tag/0.44.2).
## 2.78.0
Released 2016-09-29
New features:
- Add metadata about processed turbo-carto rules.
Announcements:
- Upgrades turbo-carto to [0.17.1](https://github.com/CartoDB/turbo-carto/releases/tag/0.17.1).
## 2.77.1
Released 2016-09-28
Announcements:
- Upgrades camshaft to [0.44.1](https://github.com/CartoDB/camshaft/releases/tag/0.44.1).
## 2.77.0
Released 2016-09-26
Announcements:
- Upgrades camshaft to [0.44.0](https://github.com/CartoDB/camshaft/releases/tag/0.44.0).
- Adds a new configuration for camshaft: logger stream.
## 2.76.0
Released 2016-09-15
New features:
- Allow to use `--config /path/to/config.js` to specify configuration file.
- Environment will be loaded from config file if `environment` key is present, otherwise it keeps current behaviour.
Bug fixes:
- Allow to use absolute paths for log files #570.
## 2.75.0
Released 2016-09-14
Announcements:
- Upgrades camshaft to [0.43.0](https://github.com/CartoDB/camshaft/releases/tag/0.43.0).
## 2.74.1
Released 2016-09-07
Announcements:
- Upgrades camshaft to [0.42.1](https://github.com/CartoDB/camshaft/releases/tag/0.42.1).
## 2.74.0
Released 2016-09-06
Enhancements:
- Layers in previews can be shown or hidden using `preview_layers` property in template map
## 2.73.1
Released 2016-09-06
Bug fixes:
- Fixes missing column in fixture table `cdb_analysis_catalog`.
## 2.73.0
Released 2016-09-06
Announcements:
- Upgrades camshaft to [0.42.0](https://github.com/CartoDB/camshaft/releases/tag/0.42.0).
## 2.72.0
Released 2016-08-23
Announcements:
- Upgrades camshaft to [0.41.0](https://github.com/CartoDB/camshaft/releases/tag/0.41.0).
## 2.71.0
Released 2016-08-17
Announcements:
- Upgrades windshaft to [2.5.0](https://github.com/CartoDB/windshaft/releases/tag/2.5.0).
## 2.70.0
Released 2016-08-16
Announcements:
- Upgrades camshaft to [0.40.0](https://github.com/CartoDB/camshaft/releases/tag/0.40.0).
## 2.69.1
Released 2016-08-12
Announcements:
- Upgrades windshaft to [2.4.2](https://github.com/CartoDB/windshaft/releases/tag/2.4.2).
## 2.69.0
Released 2016-08-11
Announcements:
- Upgrades camshaft to [0.39.0](https://github.com/CartoDB/camshaft/releases/tag/0.39.0).
## 2.68.0
Released 2016-07-21
Announcements:
- Upgrades turbo-carto to [0.16.0](https://github.com/CartoDB/turbo-carto/releases/tag/0.16.0).
## 2.67.1
Released 2016-07-21
Announcements:
- Upgrades camshaft to [0.38.1](https://github.com/CartoDB/camshaft/releases/tag/0.38.1).
## 2.67.0
Released 2016-07-21
Announcements:
- Upgrades camshaft to [0.38.0](https://github.com/CartoDB/camshaft/releases/tag/0.38.0).
## 2.66.2
Released 2016-07-20
Announcements:
- Upgrades turbo-carto to [0.15.1](https://github.com/CartoDB/turbo-carto/releases/tag/0.15.1).
## 2.66.1
Released 2016-07-20
Announcements:
- Upgrades turbo-carto to [0.15.0](https://github.com/CartoDB/turbo-carto/releases/tag/0.15.0).
## 2.66.0
Released 2016-07-18
Announcements:
- Available new endpoint to check user analyses.
- Upgrades camshaft to [0.37.1](https://github.com/CartoDB/camshaft/releases/tag/0.37.1).
## 2.65.0
Released 2016-07-15
Announcements:
- Upgrades cartodb-redis to 0.13.1.
- Upgrades camshaft to [0.37.0](https://github.com/CartoDB/camshaft/releases/tag/0.37.0).
## 2.64.0
Released 2016-07-12
Announcements:
- Upgrades camshaft to [0.36.0](https://github.com/CartoDB/camshaft/releases/tag/0.36.0).
## 2.63.0
Released 2016-07-11
Enhancements:
- Return last error message for failed nodes on map creation.
Announcements:
- Upgrades camshaft to [0.35.0](https://github.com/CartoDB/camshaft/releases/tag/0.35.0).
- Upgrades lzma to 2.3.2.
## 2.62.0
Released 2016-07-07
Announcements:
- Upgrades camshaft to [0.34.0](https://github.com/CartoDB/camshaft/releases/tag/0.34.0).
## 2.61.2
Released 2016-07-07
Announcements:
- Limit analysis creation concurrency.
- Upgrades camshaft to [0.33.3](https://github.com/CartoDB/camshaft/releases/tag/0.33.3).
## 2.61.1
Released 2016-07-06
Enhancements:
- Dataviews use mapconfig to store/retrieve their queries instead of instantiating analyses again.
## 2.61.0
Released 2016-07-06
Enhancements:
- More clear turbo-carto error messages: no context in message.
- Return multiple turbo-carto errors #541.
Announcements:
- Upgrades turbo-carto to [0.14.0](https://github.com/CartoDB/turbo-carto/releases/tag/0.14.0).
- Upgrades camshaft to [0.33.2](https://github.com/CartoDB/camshaft/releases/tag/0.33.2).
## 2.60.0
Released 2016-07-05
Announcements:
- Upgrades camshaft to [0.32.0](https://github.com/CartoDB/camshaft/releases/tag/0.32.0).
## 2.59.1
Released 2016-07-05
Announcements:
- Upgrades camshaft to [0.31.0](https://github.com/CartoDB/camshaft/releases/tag/0.31.0).
## 2.59.0
Released 2016-07-05
Announcements:
- Upgrades camshaft to [0.30.0](https://github.com/CartoDB/camshaft/releases/tag/0.30.0).
## 2.58.0
Released 2016-07-05
Announcements:
- Upgrades camshaft to [0.29.2](https://github.com/CartoDB/camshaft/releases/tag/0.29.2).
Bug fixes:
- Return full list of nodes in response metadata.
## 2.57.0
Released 2016-07-04
Announcements:
- Upgrades camshaft to [0.28.1](https://github.com/CartoDB/camshaft/releases/tag/0.28.1).
## 2.56.0
Released 2016-07-04
Announcements:
- Upgrades camshaft to [0.27.0](https://github.com/CartoDB/camshaft/releases/tag/0.27.0).
## 2.55.0
Released 2016-07-04
Enhancements:
- Skip null values for quantification methods generating null values.
Announcements:
- Uses new configuration for camshaft: analysis node has an associated user/owner.
- Upgrades camshaft to [0.26.0](https://github.com/CartoDB/camshaft/releases/tag/0.26.0).
## 2.54.0
Released 2016-06-30
Improvements:
- Errors with context: replaced `turbo-carto` error type by `layer` type.
Announcements:
- Upgrades camshaft to [0.23.0](https://github.com/CartoDB/camshaft/releases/tag/0.23.0)
## 2.53.5
Released 2016-06-29
Bug fixes:
- Uses node list so identical nodes are not de-duplicated and can be used with different ids #528.
## 2.53.4
Released 2016-06-28
Announcements:
- Upgrades camshaft to [0.22.4](https://github.com/CartoDB/camshaft/releases/tag/0.22.4)
## 2.53.3
Released 2016-06-28
Announcements:
- Upgrades camshaft to [0.22.3](https://github.com/CartoDB/camshaft/releases/tag/0.22.3)
## 2.53.2
Released 2016-06-28
Announcements:
- Upgrades camshaft to [0.22.2](https://github.com/CartoDB/camshaft/releases/tag/0.22.2)
## 2.53.1
Released 2016-06-28
Announcements:
- Upgrades camshaft to [0.22.1](https://github.com/CartoDB/camshaft/releases/tag/0.22.1)
## 2.53.0
Released 2016-06-24
Announcements:
- Upgrades camshaft to [0.22.0](https://github.com/CartoDB/camshaft/releases/tag/0.22.0)
## 2.52.0
Released 2016-06-23
Announcements:
- Upgrades camshaft to [0.21.0](https://github.com/CartoDB/camshaft/releases/tag/0.21.0)
## 2.51.0
Released 2016-06-21
Enhancements:
- Split turbo-carto adapter substitutions tokens query.
- Now errors with context have the same schema. #519
- Responses with error now return the layer-id to give more info to the user.
Announcements:
- Upgrades camshaft to [0.20.0](https://github.com/CartoDB/camshaft/releases/tag/0.20.0)
## 2.50.0
Released 2016-06-21
Bug fixes:
- Pixel size query for turbo-carto adapter using radians and degrees instead of meters.
New features:
- Add support for min, max, and avg operations in aggregation dataview #513.
Announcements:
- Upgrades camshaft to [0.19.0](https://github.com/CartoDB/camshaft/releases/tag/0.19.0)
## 2.49.1
Released 2016-06-20
Announcements:
- Upgrades turbo-carto to [0.12.1](https://github.com/CartoDB/turbo-carto/releases/tag/0.12.1).
Bug fixes:
- Use an empty array as default value for falsy ramps #512.
- Use the_geom for intermediate dataviews #511.
- Pick last update time for layergroupid from analyses results #510.
## 2.49.0
Released 2016-06-15
Announcements:
- Upgrades camshaft to [0.17.1](https://github.com/CartoDB/camshaft/releases/tag/0.17.1)
## 2.48.0
Released 2016-06-14
Announcements:
- Upgrades camshaft to [0.15.1](https://github.com/CartoDB/camshaft/releases/tag/0.15.1)
- Responses with more context info if analysis or turbo-carto fails during map creation.
## 2.47.1
Released 2016-06-13
Announcements:
- Upgrades camshaft to [0.14.1](https://github.com/CartoDB/camshaft/releases/tag/0.14.1)
## 2.47.0
Released 2016-06-10

View File

@@ -32,14 +32,14 @@ Upgrading
Checkout your commit/branch. If you need to reinstall dependencies (you can check [NEWS](NEWS.md)) do the following:
```
rm -rf node_modules; npm install
rm -rf node_modules; yarn
```
Run
---
```
node app.js <env>
node app.js <env>
```
Where <env> is the name of a configuration file under config/environments/.
@@ -71,12 +71,12 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
### Developing with a custom windshaft version
If you plan or want to use a custom / not released yet version of windshaft (or any other dependency) the best option is
to use `npm link`. You can read more about it at [npm-link: Symlink a package folder](https://docs.npmjs.com/cli/link).
to use `yarn link`. You can read more about it at [yarn-link: Symlink a package folder](https://yarnpkg.com/en/docs/cli/link).
**Quick start**:
```shell
~/windshaft-directory $ npm install
~/windshaft-directory $ npm link
~/windshaft-cartodb-directory $ npm link windshaft
~/windshaft-directory $ yarn
~/windshaft-directory $ yarn link
~/windshaft-cartodb-directory $ yarn link windshaft
```

97
app.js
View File

@@ -5,20 +5,35 @@ var fs = require('fs');
var _ = require('underscore');
var ENVIRONMENT;
if ( process.argv[2] ) {
ENVIRONMENT = process.argv[2];
} else if ( process.env.NODE_ENV ) {
ENVIRONMENT = process.env.NODE_ENV;
} else {
ENVIRONMENT = 'development';
}
// jshint undef:false
var log = console.log.bind(console);
var logError = console.error.bind(console);
// jshint undef:true
var argv = require('yargs')
.usage('Usage: $0 <environment> [options]')
.help('h')
.example(
'$0 production -c /etc/sql-api/config.js',
'start server in production environment with /etc/sql-api/config.js as config file'
)
.alias('h', 'help')
.alias('c', 'config')
.nargs('c', 1)
.describe('c', 'Load configuration from path')
.argv;
var environmentArg = argv._[0] || process.env.NODE_ENV || 'development';
var configurationFile = path.resolve(argv.config || './config/environments/' + environmentArg + '.js');
if (!fs.existsSync(configurationFile)) {
logError('Configuration file "%s" does not exist', configurationFile);
process.exit(1);
}
global.environment = require(configurationFile);
var ENVIRONMENT = argv._[0] || process.env.NODE_ENV || global.environment.environment;
process.env.NODE_ENV = ENVIRONMENT;
var availableEnvironments = {
production: true,
staging: true,
@@ -33,16 +48,6 @@ if (!availableEnvironments[ENVIRONMENT]){
}
process.env.NODE_ENV = ENVIRONMENT;
// set environment specific variables
global.environment = require('./config/environments/' + ENVIRONMENT);
global.log4js = require('log4js');
var log4js_config = {
appenders: [],
replaceConsole: true
};
if (global.environment.uv_threadpool_size) {
process.env.UV_THREADPOOL_SIZE = global.environment.uv_threadpool_size;
}
@@ -58,25 +63,31 @@ var agentOptions = _.defaults(global.environment.httpAgent || {}, {
http.globalAgent = new http.Agent(agentOptions);
https.globalAgent = new https.Agent(agentOptions);
global.log4js = require('log4js');
var log4jsConfig = {
appenders: [],
replaceConsole: true
};
if ( global.environment.log_filename ) {
var logdir = path.dirname(global.environment.log_filename);
// See cwd inlog4js.configure call below
logdir = path.resolve(__dirname, logdir);
if ( ! fs.existsSync(logdir) ) {
logError("Log filename directory does not exist: " + logdir);
process.exit(1);
}
log("Logs will be written to " + global.environment.log_filename);
log4js_config.appenders.push(
{ type: "file", filename: global.environment.log_filename }
);
var logFilename = path.resolve(global.environment.log_filename);
var logDirectory = path.dirname(logFilename);
if (!fs.existsSync(logDirectory)) {
logError("Log filename directory does not exist: " + logDirectory);
process.exit(1);
}
log("Logs will be written to " + logFilename);
log4jsConfig.appenders.push(
{ type: "file", absolute: true, filename: logFilename }
);
} else {
log4js_config.appenders.push(
{ type: "console", layout: { type:'basic' } }
);
log4jsConfig.appenders.push(
{ type: "console", layout: { type:'basic' } }
);
}
global.log4js.configure(log4js_config, { cwd: __dirname });
global.log4js.configure(log4jsConfig);
global.logger = global.log4js.getLogger();
global.environment.api_hostname = require('os').hostname().split('.')[0];
@@ -99,6 +110,8 @@ var listener = server.listen(serverOptions.bind.port, serverOptions.bind.host, b
var version = require("./package").version;
listener.on('listening', function() {
log("Using Node.js %s", process.version);
log('Using configuration file "%s"', configurationFile);
log(
"Windshaft tileserver %s started on %s:%s PID=%d (%s)",
version, serverOptions.bind.host, serverOptions.bind.port, process.pid, ENVIRONMENT
@@ -114,7 +127,7 @@ setInterval(function() {
process.on('SIGHUP', function() {
global.log4js.clearAndShutdownAppenders(function() {
global.log4js.configure(log4js_config);
global.log4js.configure(log4jsConfig);
global.logger = global.log4js.getLogger();
log('Log files reloaded');
});
@@ -123,3 +136,17 @@ process.on('SIGHUP', function() {
process.on('uncaughtException', function(err) {
global.logger.error('Uncaught exception: ' + err.stack);
});
if (global.gc) {
var gcInterval = Number.isFinite(global.environment.gc_interval) ?
global.environment.gc_interval :
10000;
if (gcInterval > 0) {
setInterval(function gcForcedCycle() {
var start = Date.now();
global.gc();
global.statsClient.timing('windshaft.gc', Date.now() - start);
}, gcInterval);
}
}

View File

@@ -23,6 +23,21 @@ var config = {
// "tiles/layergroup" is for compatibility with versions up to 1.6.x
,base_url_detached: '(?:/api/v1/map|/user/:user/api/v1/map|/tiles/layergroup)'
// Resource URLs expose endpoints to request/retrieve metadata associated to Maps: dataviews, analysis node status.
//
// This URLs depend on how `base_url_detached` and `user_from_host` are configured: the application can be
// configured to accept request with the {user} in the header host or in the request path.
// It also might depend on the configured cdn_url via `serverMetadata.cdn_url`.
//
// This template allows to make the endpoints generation more flexible, the template exposes the following params:
// 1. {{=it.cdn_url}}: will be used when `serverMetadata.cdn_url` exists.
// 2. {{=it.user}}: will use the username as extraced from `user_from_host` or `base_url_detached`.
// 3. {{=it.port}}: will use the `port` from this very same configuration file.
,resources_url_templates: {
http: 'http://{{=it.user}}.localhost.lan:{{=it.port}}/api/v1/map',
https: 'http://localhost.lan:{{=it.port}}/user/{{=it.user}}/api/v1/map'
}
// Maximum number of connections for one process
// 128 is a good value with a limit of 1024 open file descriptors
,maxConnections:128
@@ -62,6 +77,7 @@ var config = {
extent: "-180,-90,180,90",
srid: 4326,
*/
// max number of rows to return when querying data, 0 means no limit
row_limit: 65535,
simplify_geometries: true,
use_overviews: true, // use overviews to retrieve raster
@@ -95,6 +111,10 @@ var config = {
// Important: check the configuration of uv_threadpool_size to use suitable value
poolSize: 8,
// Whether grainstore will use a child process or not to transform CartoCSS into Mapnik XML.
// This will prevent blocking the main thread.
useCartocssWorkers: false,
// Metatile is the number of tiles-per-side that are going
// to be rendered at once. If all of them will be requested
// we'd have saved time. If only one will be used, we'd have
@@ -209,6 +229,18 @@ var config = {
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
// the template to use for adding the host header in the batch api requests
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
},
logger: {
// If filename is given logs comming from analysis client will be written
// there, in append mode. Otherwise 'log_filename' is used. Otherwise stdout is used (default).
// Log file will be re-opened on receiving the HUP signal
filename: '/tmp/analysis.log'
},
// Define max execution time in ms for analyses or tags
// If analysis or tag are not found in redis this values will be used as default.
limits: {
moran: { timeout: 120000, maxNumberOfRows: 1e5 },
cpu2x: { timeout: 60000 }
}
}
,millstone: {

View File

@@ -23,6 +23,21 @@ var config = {
// "tiles/layergroup" is for compatibility with versions up to 1.6.x
,base_url_detached: '(?:/api/v1/map|/user/:user/api/v1/map|/tiles/layergroup)'
// Resource URLs expose endpoints to request/retrieve metadata associated to Maps: dataviews, analysis node status.
//
// This URLs depend on how `base_url_detached` and `user_from_host` are configured: the application can be
// configured to accept request with the {user} in the header host or in the request path.
// It also might depend on the configured cdn_url via `serverMetadata.cdn_url`.
//
// This template allows to make the endpoints generation more flexible, the template exposes the following params:
// 1. {{=it.cdn_url}}: will be used when `serverMetadata.cdn_url` exists.
// 2. {{=it.user}}: will use the username as extraced from `user_from_host` or `base_url_detached`.
// 3. {{=it.port}}: will use the `port` from this very same configuration file.
,resources_url_templates: {
http: 'http://{{=it.cdn_url}}/{{=it.user}}/api/v1/map',
https: 'https://{{=it.cdn_url}}/{{=it.user}}/api/v1/map'
}
// Maximum number of connections for one process
// 128 is a good value with a limit of 1024 open file descriptors
,maxConnections:128
@@ -56,6 +71,7 @@ var config = {
host: '127.0.0.1',
port: 6432,
extent: "-20037508.3,-20037508.3,20037508.3,20037508.3",
// max number of rows to return when querying data, 0 means no limit
row_limit: 65535,
/*
* Set persist_connection to false if you want
@@ -89,6 +105,10 @@ var config = {
// Important: check the configuration of uv_threadpool_size to use suitable value
poolSize: 8,
// Whether grainstore will use a child process or not to transform CartoCSS into Mapnik XML.
// This will prevent blocking the main thread.
useCartocssWorkers: false,
// Metatile is the number of tiles-per-side that are going
// to be rendered at once. If all of them will be requested
// we'd have saved time. If only one will be used, we'd have
@@ -203,6 +223,18 @@ var config = {
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
// the template to use for adding the host header in the batch api requests
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
},
logger: {
// If filename is given logs comming from analysis client will be written
// there, in append mode. Otherwise 'log_filename' is used. Otherwise stdout is used (default).
// Log file will be re-opened on receiving the HUP signal
filename: 'logs/analysis.log'
},
// Define max execution time in ms for analyses or tags
// If analysis or tag are not found in redis this values will be used as default.
limits: {
moran: { timeout: 120000, maxNumberOfRows: 1e5 },
cpu2x: { timeout: 60000 }
}
}
,millstone: {

View File

@@ -23,6 +23,21 @@ var config = {
// "/tiles/layergroup" is for compatibility with versions up to 1.6.x
,base_url_detached: '(?:/api/v1/map|/user/:user/api/v1/map|/tiles/layergroup)'
// Resource URLs expose endpoints to request/retrieve metadata associated to Maps: dataviews, analysis node status.
//
// This URLs depend on how `base_url_detached` and `user_from_host` are configured: the application can be
// configured to accept request with the {user} in the header host or in the request path.
// It also might depend on the configured cdn_url via `serverMetadata.cdn_url`.
//
// This template allows to make the endpoints generation more flexible, the template exposes the following params:
// 1. {{=it.cdn_url}}: will be used when `serverMetadata.cdn_url` exists.
// 2. {{=it.user}}: will use the username as extraced from `user_from_host` or `base_url_detached`.
// 3. {{=it.port}}: will use the `port` from this very same configuration file.
,resources_url_templates: {
http: 'http://{{=it.user}}.localhost.lan:{{=it.port}}/api/v1/map',
https: 'https://{{=it.cdn_url}}/{{=it.user}}/api/v1/map'
}
// Maximum number of connections for one process
// 128 is a good value with a limit of 1024 open file descriptors
,maxConnections:128
@@ -56,6 +71,7 @@ var config = {
host: '127.0.0.1',
port: 6432,
extent: "-20037508.3,-20037508.3,20037508.3,20037508.3",
// max number of rows to return when querying data, 0 means no limit
row_limit: 65535,
simplify_geometries: true,
use_overviews: true, // use overviews to retrieve raster
@@ -89,6 +105,10 @@ var config = {
// Important: check the configuration of uv_threadpool_size to use suitable value
poolSize: 8,
// Whether grainstore will use a child process or not to transform CartoCSS into Mapnik XML.
// This will prevent blocking the main thread.
useCartocssWorkers: false,
// Metatile is the number of tiles-per-side that are going
// to be rendered at once. If all of them will be requested
// we'd have saved time. If only one will be used, we'd have
@@ -203,6 +223,18 @@ var config = {
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
// the template to use for adding the host header in the batch api requests
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
},
logger: {
// If filename is given logs comming from analysis client will be written
// there, in append mode. Otherwise 'log_filename' is used. Otherwise stdout is used (default).
// Log file will be re-opened on receiving the HUP signal
filename: 'logs/analysis.log'
},
// Define max execution time in ms for analyses or tags
// If analysis or tag are not found in redis this values will be used as default.
limits: {
moran: { timeout: 120000, maxNumberOfRows: 1e5 },
cpu2x: { timeout: 60000 }
}
}
,millstone: {

View File

@@ -23,6 +23,20 @@ var config = {
// "tiles/layergroup" is for compatibility with versions up to 1.6.x
,base_url_detached: '(?:/api/v1/map|/user/:user/api/v1/map|/tiles/layergroup)'
// Resource URLs expose endpoints to request/retrieve metadata associated to Maps: dataviews, analysis node status.
//
// This URLs depend on how `base_url_detached` and `user_from_host` are configured: the application can be
// configured to accept request with the {user} in the header host or in the request path.
// It also might depend on the configured cdn_url via `serverMetadata.cdn_url`.
//
// This template allows to make the endpoints generation more flexible, the template exposes the following params:
// 1. {{=it.cdn_url}}: will be used when `serverMetadata.cdn_url` exists.
// 2. {{=it.user}}: will use the username as extraced from `user_from_host` or `base_url_detached`.
// 3. {{=it.port}}: will use the `port` from this very same configuration file.
,resources_url_templates: {
http: 'http://{{=it.user}}.localhost.lan:{{=it.port}}/api/v1/map'
}
// Maximum number of connections for one process
// 128 is a good value with a limit of 1024 open file descriptors
,maxConnections:128
@@ -56,6 +70,7 @@ var config = {
host: '127.0.0.1',
port: 5432,
extent: "-20037508.3,-20037508.3,20037508.3,20037508.3",
// max number of rows to return when querying data, 0 means no limit
row_limit: 65535,
simplify_geometries: true,
use_overviews: true, // use overviews to retrieve raster
@@ -89,6 +104,10 @@ var config = {
// Important: check the configuration of uv_threadpool_size to use suitable value
poolSize: 8,
// Whether grainstore will use a child process or not to transform CartoCSS into Mapnik XML.
// This will prevent blocking the main thread.
useCartocssWorkers: false,
// Metatile is the number of tiles-per-side that are going
// to be rendered at once. If all of them will be requested
// we'd have saved time. If only one will be used, we'd have
@@ -204,6 +223,18 @@ var config = {
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
// the template to use for adding the host header in the batch api requests
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
},
logger: {
// If filename is given logs comming from analysis client will be written
// there, in append mode. Otherwise 'log_filename' is used. Otherwise stdout is used (default).
// Log file will be re-opened on receiving the HUP signal
filename: 'node-windshaft.log'
},
// Define max execution time in ms for analyses or tags
// If analysis or tag are not found in redis this values will be used as default.
limits: {
moran: { timeout: 120000, maxNumberOfRows: 1e5 },
cpu2x: { timeout: 60000 }
}
}
,millstone: {

View File

@@ -1,11 +1,11 @@
# Maps API
The CartoDB Maps API allows you to generate maps based on data hosted in your CartoDB account and apply custom SQL and CartoCSS to the data. The API generates a XYZ-based URL to fetch Web Mercator projected tiles, using web clients such as [Leaflet](http://leafletjs.com), [Google Maps](https://developers.google.com/maps/), or [OpenLayers](http://openlayers.org/).
The CARTO Maps API allows you to generate maps based on data hosted in your CARTO account and apply custom SQL and CartoCSS to the data. The API generates a XYZ-based URL to fetch Web Mercator projected tiles, using web clients such as [Leaflet](http://leafletjs.com), [Google Maps](https://developers.google.com/maps/), or [OpenLayers](http://openlayers.org/).
You can create two types of maps with the Maps API:
- **Anonymous Maps**
You can create maps using your CartoDB public data. Any client can change the read-only SQL and CartoCSS parameters that generate the map tiles. These maps can be created from a JavaScript application alone and no authenticated calls are needed. See [this CartoDB.js example](/cartodb-platform/cartodb-js/getting-started/).
You can create maps using your CARTO public data. Any client can change the read-only SQL and CartoCSS parameters that generate the map tiles. These maps can be created from a JavaScript application alone and no authenticated calls are needed. See [this CARTO.js example](/carto-engine/carto-js/getting-started/).
- **Named Maps**
There are also maps that have access to your private data. These maps require an owner to setup and modify any SQL and CartoCSS parameters and are not modifiable without new setup calls.

View File

@@ -28,7 +28,7 @@ POST /api/v1/map
}
```
See [MapConfig File Formats](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/) for details.
See [MapConfig File Formats](http://docs.carto.com/carto-engine/maps-api/mapconfig/) for details.
#### Response
@@ -36,7 +36,7 @@ The response includes:
Attributes | Description
--- | ---
layergroupid | The ID for that map, used to compose the URL for the tiles. The final URL is: `https://{username}.cartodb.com/api/v1/map/{layergroupid}/{z}/{x}/{y}.png`
layergroupid | The ID for that map, used to compose the URL for the tiles. The final URL is: `https://{username}.carto.com/api/v1/map/{layergroupid}/{z}/{x}/{y}.png`
updated_at | The ISO date of the last time the data involved in the query was updated.
metadata | Includes information about the layers.
cdn_url | URLs to fetch the data using the best CDN for your zone.
@@ -46,7 +46,7 @@ cdn_url | URLs to fetch the data using the best CDN for your zone.
#### Call
```bash
curl 'https://{username}.cartodb.com/api/v1/map' -H 'Content-Type: application/json' -d @mapconfig.json
curl 'https://{username}.carto.com/api/v1/map' -H 'Content-Type: application/json' -d @mapconfig.json
```
#### Response
@@ -79,7 +79,7 @@ When you have a layergroup, there are several resources for retrieving layergoup
These tiles will get just the Mapnik layers. To get individual layers, see the following section.
```bash
https://{username}.cartodb.com/api/v1/map/{layergroupid}/{z}/{x}/{y}.png
https://{username}.carto.com/api/v1/map/{layergroupid}/{z}/{x}/{y}.png
```
#### Individual layers
@@ -89,7 +89,7 @@ The MapConfig specification holds the layers definition in a 0-based index. Laye
Individual layers can be accessed using that 0-based index. For UTF grid tiles:
```bash
https://{username}.cartodb.com/api/v1/map/{layergroupid}/{layer}/{z}/{x}/{y}.grid.json
https://{username}.carto.com/api/v1/map/{layergroupid}/{layer}/{z}/{x}/{y}.grid.json
```
In this case, `layer` as 0 returns the UTF grid tiles/attributes for layer 0, the only layer in the example MapConfig.
@@ -97,13 +97,13 @@ In this case, `layer` as 0 returns the UTF grid tiles/attributes for layer 0, th
If the MapConfig had a Torque layer at index 1 it could be possible to request it with:
```bash
https://{username}.cartodb.com/api/v1/map/{layergroupid}/1/{z}/{x}/{y}.torque.json
https://{username}.carto.com/api/v1/map/{layergroupid}/1/{z}/{x}/{y}.torque.json
```
#### Attributes defined in `attributes` section
```bash
https://{username}.cartodb.com/api/v1/map/{layergroupid}/{layer}/attributes/{feature_id}
https://{username}.carto.com/api/v1/map/{layergroupid}/{layer}/attributes/{feature_id}
```
Which returns JSON with the attributes defined, like:
@@ -115,7 +115,7 @@ Which returns JSON with the attributes defined, like:
#### Blending and layer selection
```bash
https://{username}.cartodb.com/api/v1/map/{layergroupid}/{layer_filter}/{z}/{x}/{y}.png
https://{username}.carto.com/api/v1/map/{layergroupid}/{layer_filter}/{z}/{x}/{y}.png
```
Note: currently format is limited to `png`.
@@ -127,7 +127,7 @@ Note: currently format is limited to `png`.
Using `all` as `layer_filter` will blend all layers in the layergroup
```bash
https://{username}.cartodb.com/api/v1/map/{layergroupid}/all/{z}/{x}/{y}.png
https://{username}.carto.com/api/v1/map/{layergroupid}/all/{z}/{x}/{y}.png
```
- Filter by layer index
@@ -135,15 +135,12 @@ https://{username}.cartodb.com/api/v1/map/{layergroupid}/all/{z}/{x}/{y}.png
A list of comma separated layer indexes can be used to just render a subset of layers. For example `0,3,4` will filter and blend layers with indexes 0, 3, and 4.
```bash
https://{username}.cartodb.com/api/v1/map/{layergroupid}/0,3,4/{z}/{x}/{y}.png
https://{username}.carto.com/api/v1/map/{layergroupid}/0,3,4/{z}/{x}/{y}.png
```
Some notes about filtering:
- Invalid index values or out of bounds indexes will end in `Invalid layer filtering` errors.
- Once a Mapnik layer is selected, all Mapnik layers will get blended. As this may change in the future **it is
recommended** to always select all Mapnik layers if you want to select at least one so you will get a consistent
behavior in the future.
- Ordering is not considered. So right now filtering layers 0,3,4 is the very same thing as filtering 3,4,0. As this
may change in the future **it is recommended** to always select the layers in ascending order so you will get a
consistent behavior in the future.
@@ -172,7 +169,7 @@ callback | JSON callback name.
#### Call
```bash
curl "https://{username}.cartodb.com/api/v1/map?callback=callback&config=%7B%22version%22%3A%221.0.1%22%2C%22layers%22%3A%5B%7B%22type%22%3A%22cartodb%22%2C%22options%22%3A%7B%22sql%22%3A%22select+%2A+from+european_countries_e%22%2C%22cartocss%22%3A%22%23european_countries_e%7B+polygon-fill%3A+%23FF6600%3B+%7D%22%2C%22cartocss_version%22%3A%222.3.0%22%2C%22interactivity%22%3A%5B%22cartodb_id%22%5D%7D%7D%5D%7D"
curl "https://{username}.carto.com/api/v1/map?callback=callback&config=%7B%22version%22%3A%221.0.1%22%2C%22layers%22%3A%5B%7B%22type%22%3A%22cartodb%22%2C%22options%22%3A%7B%22sql%22%3A%22select+%2A+from+european_countries_e%22%2C%22cartocss%22%3A%22%23european_countries_e%7B+polygon-fill%3A+%23FF6600%3B+%7D%22%2C%22cartocss_version%22%3A%222.3.0%22%2C%22interactivity%22%3A%5B%22cartodb_id%22%5D%7D%7D%5D%7D"
```
#### Response

View File

@@ -4,7 +4,7 @@ The following concepts are the same for every endpoint in the API except when it
## Auth
By default, users do not have access to private tables in CartoDB. In order to instantiate a map from private table data an API Key is required. Additionally, to include some endpoints, an API Key must be included (e.g. creating a Named Map).
By default, users do not have access to private tables in CARTO. In order to instantiate a map from private table data an API Key is required. Additionally, to include some endpoints, an API Key must be included (e.g. creating a Named Map).
To execute an authorized request, `api_key=YOURAPIKEY` should be added to the request URL. The param can be also passed as POST param. Using HTTPS is mandatory when you are performing requests that include your `api_key`.

View File

@@ -1,12 +1,12 @@
# Named Maps
Named Maps are essentially the same as Anonymous Maps except the MapConfig is stored on the server, and the map is given a unique name. You can create Named Maps from private data, and users without an API Key can view your Named Map (while keeping your data private).
Named Maps are essentially the same as Anonymous Maps except the MapConfig is stored on the server, and the map is given a unique name. You can create Named Maps from private data, and users without an API Key can view your Named Map (while keeping your data private).
The Named Map workflow consists of uploading a MapConfig file to CartoDB servers, to select data from your CartoDB user database by using SQL, and specifying the CartoCSS for your map.
The Named Map workflow consists of uploading a MapConfig file to CARTO servers, to select data from your CARTO user database by using SQL, and specifying the CartoCSS for your map.
The response back from the API provides the template_id of your Named Map as the `name` (the identifier of your Named Map), which is the name that you specified in the MapConfig. You can which you can then use to create your Named Map details, or [fetch XYZ tiles](#fetching-xyz-tiles-for-named-maps) directly for Named Maps.
The response back from the API provides the template_id of your Named Map as the `name` (the identifier of your Named Map), which is the name that you specified in the MapConfig. You can which you can then use to create your Named Map details, or [fetch XYZ tiles](#fetching-xyz-tiles-for-named-maps) directly for Named Maps.
**Tip:** You can also use a Named Map that you created (which is defined by its `name`), to create a map using CartoDB.js. This is achieved by adding the [`namedmap` type](http://docs.cartodb.com/cartodb-platform/cartodb-js/layer-source-object/#named-maps-layer-source-object-type-namedmap) layer source object to draw the Named Map.
**Tip:** You can also use a Named Map that you created (which is defined by its `name`), to create a map using CARTO.js. This is achieved by adding the [`namedmap` type](http://docs.carto.com/carto-engine/carto-js/layer-source-object/#named-maps-layer-source-object-type-namedmap) layer source object to draw the Named Map.
The main differences, compared to Anonymous Maps, is that Named Maps include:
@@ -14,11 +14,11 @@ The main differences, compared to Anonymous Maps, is that Named Maps include:
This allows you to control who is able to see the map based on an auth token, and create a secure Named Map with password-protection.
- **template map**
The template map is static and may contain placeholders, enabling you to modify your maps appearance by using variables. Templates maps are persistent with no preset expiration. They can only be created, or deleted, by a CartoDB user with a valid API KEY (See [auth argument](#arguments)).
The template map is static and may contain placeholders, enabling you to modify your maps appearance by using variables. Templates maps are persistent with no preset expiration. They can only be created, or deleted, by a CARTO user with a valid API KEY (See [auth argument](#arguments)).
Uploading a MapConfig creates a Named Map. MapConfigs are uploaded to the server by sending the server a "template".json file, which contain the [MapConfig specifications](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/).
Uploading a MapConfig creates a Named Map. MapConfigs are uploaded to the server by sending the server a "template".json file, which contain the [MapConfig specifications](http://docs.carto.com/carto-engine/maps-api/mapconfig/).
**Note:** There is a limit of 4,096 Named Maps allowed per account. If you need to create more Named Maps, it is recommended to use a single Named Map and change the variables using [placeholders](#placeholder-format), instead of uploading multiple [Named Map MapConfigs](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/#named-map-layer-options).
**Note:** There is a limit of 4,096 Named Maps allowed per account. If you need to create more Named Maps, it is recommended to use a single Named Map and change the variables using [placeholders](#placeholder-format), instead of uploading multiple [Named Map MapConfigs](http://docs.carto.com/carto-engine/maps-api/mapconfig/#named-map-layer-options).
## Create
@@ -33,7 +33,7 @@ POST /api/v1/map/named
Params | Description
--- | ---
api_key | is required
MapConfig | a [Named Map MapConfig](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/#named-map-layer-options) is required to create a Named Map
MapConfig | a [Named Map MapConfig](http://docs.carto.com/carto-engine/maps-api/mapconfig/#named-map-layer-options) is required to create a Named Map
#### template.json
@@ -84,6 +84,10 @@ The `name` argument defines how to name this "template_name".json. Note that the
"south": -45,
"east": 45,
"north": 45
},
"preview_layers": {
"0": true,
"layer1": false
}
}
}
@@ -95,22 +99,22 @@ Params | Description
--- | ---
name | There can only be _one_ template with the same name for any user. Valid names start with a letter or a number, and only contain letters, numbers, dashes (-), or underscores (_). _This is specific to the name of your Named Map that is specified in the `name` property of the template file_.
auth |
auth |
--- | ---
&#124;_ method | `"token"` or `"open"` (`"open"` is the default if no method is specified. Use `"token"` to password-protect your map)
&#124;_ valid_tokens | when `"method"` is set to `"token"`, the values listed here allow you to instantiate the Named Map. See this [example](http://docs.cartodb.com/faqs/manipulating-your-data/#how-to-create-a-password-protected-named-map) for how to create a password-protected map.
&#124;_ valid_tokens | when `"method"` is set to `"token"`, the values listed here allow you to instantiate the Named Map. See this [example](http://docs.carto.com/faqs/manipulating-your-data/#how-to-create-a-password-protected-named-map) for how to create a password-protected map.
placeholders | Placeholders are variables that can be placed in your template.json file's SQL or CartoCSS.
layergroup | the layergroup configurations, as specified in the template. See [MapConfig File Format](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/) for more information.
view (optional) | extra keys to specify the view area for the map. It can be used to have a static preview of a Named Map without having to instantiate it. It is possible to specify it with `center` + `zoom` or with a bounding box `bbox`. Center+zoom takes precedence over bounding box.
layergroup | the layergroup configurations, as specified in the template. See [MapConfig File Format](http://docs.carto.com/carto-engine/maps-api/mapconfig/) for more information.
view (optional) | extra keys to specify the view area for the map. It can be used to have a static preview of a Named Map without having to instantiate it. It is possible to specify it with `center` + `zoom` or with a bounding box `bbox`. Center+zoom takes precedence over bounding box. Also it is possible to choose which layers are visible or not with `preview_layers` indicating its visibility by layer index or id (visible by default).
--- | ---
&#124;_ zoom | The zoom level to use
&#124;_ center |
&#124;_ center |
--- | ---
&#124;_ &#124;_ lng | The longitude to use for the center
&#124;_ &#124;_ lat | The latitude to use for the center
&#124;_ bounds |
&#124;_ bounds |
--- | ---
&#124;_ &#124;_ west | LowerCorner longitude for the bounding box, in decimal degrees (aka most western)
&#124;_ &#124;_ south | LowerCorner latitude for the bounding box, in decimal degrees (aka most southern)
@@ -120,7 +124,7 @@ view (optional) | extra keys to specify the view area for the map. It can be use
### Placeholder Format
Placeholders are variables that can be placed in your template.json file. Placeholders need to be defined with a `type` and a default value for MapConfigs. See details about defining a MapConfig `type` for [Layergoup configurations](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/#layergroup-configurations).
Placeholders are variables that can be placed in your template.json file. Placeholders need to be defined with a `type` and a default value for MapConfigs. See details about defining a MapConfig `type` for [Layergroup configurations](http://docs.carto.com/carto-engine/maps-api/mapconfig/#layergroup-configurations).
Valid placeholder names start with a letter and can only contain letters, numbers, or underscores. They have to be written between the `<%=` and `%>` strings in order to be replaced inside the Named Maps API.
@@ -155,12 +159,12 @@ This is the call for creating the Named Map. It is sending the template.json fil
curl -X POST \
-H 'Content-Type: application/json' \
-d @template.json \
'https://{username}.cartodb.com/api/v1/map/named?api_key={api_key}'
'https://{username}.carto.com/api/v1/map/named?api_key={api_key}'
```
#### Response
The response back from the API provides the name of your MapConfig as a template, enabling you to edit the Named Map details by inserting your variables into the template where placeholders are defined, and create custom queries using SQL.
The response back from the API provides the name of your MapConfig as a template, enabling you to edit the Named Map details by inserting your variables into the template where placeholders are defined, and create custom queries using SQL.
```javascript
{
@@ -170,7 +174,7 @@ The response back from the API provides the name of your MapConfig as a template
## Instantiate
Instantiating a Named Map allows you to fetch the map tiles. You can use the Maps API to instantiate, or use the CartoDB.js `createLayer()` function. The result is an Anonymous Map.
Instantiating a Named Map allows you to fetch the map tiles. You can use the Maps API to instantiate, or use the CARTO.js `createLayer()` function. The result is an Anonymous Map.
#### Definition
@@ -209,7 +213,7 @@ Valid auth token will be needed, if required by the template.
curl -X POST \
-H 'Content-Type: application/json' \
-d @params.json \
'https://{username}.cartodb.com/api/v1/map/named/{template_name}?auth_token={auth_token}'
'https://{username}.carto.com/api/v1/map/named/{template_name}?auth_token={auth_token}'
```
#### Response
@@ -229,7 +233,7 @@ curl -X POST \
}
```
You can then use the `layergroupid` for fetching tiles and grids as you would normally (see [Anonymous Maps](http://docs.cartodb.com/cartodb-platform/maps-api/anonymous-maps/)).
You can then use the `layergroupid` for fetching tiles and grids as you would normally (see [Anonymous Maps](http://docs.carto.com/carto-engine/maps-api/anonymous-maps/)).
## Update
@@ -261,7 +265,7 @@ Updating a Named Map removes all the Named Map instances, so they need to be ini
curl -X PUT \
-H 'Content-Type: application/json' \
-d @template.json \
'https://{username}.cartodb.com/api/v1/map/named/{template_name}?api_key={api_key}'
'https://{username}.carto.com/api/v1/map/named/{template_name}?api_key={api_key}'
```
#### Response
@@ -303,7 +307,7 @@ api_key | is required
#### Call
```bash
curl -X DELETE 'https://{username}.cartodb.com/api/v1/map/named/{template_name}?api_key={api_key}'
curl -X DELETE 'https://{username}.carto.com/api/v1/map/named/{template_name}?api_key={api_key}'
```
#### Response
@@ -337,7 +341,7 @@ api_key | is required
#### Call
```bash
curl -X GET 'https://{username}.cartodb.com/api/v1/map/named?api_key={api_key}'
curl -X GET 'https://{username}.carto.com/api/v1/map/named?api_key={api_key}'
```
#### Response
@@ -377,7 +381,7 @@ api_key | is required
#### Call
```bash
curl -X GET 'https://{username}.cartodb.com/api/v1/map/named/{template_name}?api_key={api_key}'
curl -X GET 'https://{username}.carto.com/api/v1/map/named/{template_name}?api_key={api_key}'
```
#### Response
@@ -418,7 +422,7 @@ callback | JSON callback name
#### Call
```bash
curl 'https://{username}.cartodb.com/api/v1/map/named/{template_name}/jsonp?auth_token={auth_token}&callback=callback&config=template_params_json'
curl 'https://{username}.carto.com/api/v1/map/named/{template_name}/jsonp?auth_token={auth_token}&callback=callback&config=template_params_json'
```
#### Response
@@ -450,9 +454,9 @@ callback({
})
```
## CartoDB.js for Named Maps
## CARTO.js for Named Maps
You can use a Named Map that you created (which is defined by its `name`), to create a map using CartoDB.js. This is achieved by adding the [`namedmap` type](http://docs.cartodb.com/cartodb-platform/cartodb-js/layer-source-object/#named-maps-layer-source-object-type-namedmap) layer source object to draw the Named Map.
You can use a Named Map that you created (which is defined by its `name`), to create a map using CARTO.js. This is achieved by adding the [`namedmap` type](http://docs.carto.com/carto-engine/carto-js/layer-source-object/#named-maps-layer-source-object-type-namedmap) layer source object to draw the Named Map.
```javascript
{
@@ -482,17 +486,17 @@ You can use a Named Map that you created (which is defined by its `name`), to cr
**Note:** Instantiating a Named Map over a `createLayer` does not require an API Key and by default, does not include auth tokens. _If_ you defined auth tokens for the Named Map configuration, then you will have to include them.
[CartoDB.js](http://docs.cartodb.com/cartodb-platform/cartodb-js/) has methods for accessing your Named Maps.
[CARTO.js](http://docs.carto.com/carto-engine/carto-js/) has methods for accessing your Named Maps.
1. [layer.setParams()](http://docs.cartodb.com/cartodb-platform/cartodb-js/api-methods/#layersetparamskey-value) allows you to change the template variables (in the placeholders object) via JavaScript
1. [layer.setParams()](http://docs.carto.com/carto-engine/carto-js/api-methods/#layersetparamskey-value) allows you to change the template variables (in the placeholders object) via JavaScript
**Note:** The CartoDB.js `layer.setParams()` function is not supported when using Named Maps for Torque. Alternatively, you can create a [Torque layer in a Named Map](http://bl.ocks.org/iriberri/de37be6406f9cc7cfe5a)
**Note:** The CARTO.js `layer.setParams()` function is not supported when using Named Maps for Torque. Alternatively, you can create a [Torque layer in a Named Map](http://bl.ocks.org/iriberri/de37be6406f9cc7cfe5a)
2. [layer.setAuthToken()](http://docs.cartodb.com/cartodb-platform/cartodb-js/api-methods/#layersetauthtokenauthtoken) allows you to set the auth tokens to create the layer
2. [layer.setAuthToken()](http://docs.carto.com/carto-engine/carto-js/api-methods/#layersetauthtokenauthtoken) allows you to set the auth tokens to create the layer
### Torque Layer in a Named Map
If you are creating a Torque layer in a Named Map without using the Torque.js library, you can apply the Torque layer by applying the following code with CartoDBjs:
If you are creating a Torque layer in a Named Map without using the Torque.js library, you can apply the Torque layer by applying the following code with CARTO.js:
```javascript
// add cartodb layer with one sublayer
@@ -516,18 +520,18 @@ If you are creating a Torque layer in a Named Map without using the Torque.js li
})
.addTo(map)
.done(function(layer) {
});
}
```
#### Examples of Named Maps created with CartoDB.js
#### Examples of Named Maps created with CARTO.js
- [Named Map selectors with interaction](http://bl.ocks.org/ohasselblad/515a8af1f99d5e690484)
- [Named Map selectors with interaction](http://bl.ocks.org/andy-esch/515a8af1f99d5e690484)
- [Named Map with interactivity](http://bl.ocks.org/ohasselblad/d1a45b8ff5e7bd90cd68)
- [Named Map with interactivity](http://bl.ocks.org/andy-esch/d1a45b8ff5e7bd90cd68)
- [Toggling sublayers in a Named Map](http://bl.ocks.org/ohasselblad/c1a0f4913610eec53cd3)
- [Toggling sublayers in a Named Map](http://bl.ocks.org/andy-esch/c1a0f4913610eec53cd3)
## Fetching XYZ Tiles for Named Maps
@@ -535,7 +539,7 @@ Optionally, authenticated users can fetch projected tiles (XYZ tiles or Mapnik R
### Fetch XYZ Tiles Directly with a URL
Authenticated users, with an auth token, can use XYZ-based URLs to fetch tiles directly, and instantiate the Named Map as part of the request to your application. You do not have to do any other steps to initialize your map.
Authenticated users, with an auth token, can use XYZ-based URLs to fetch tiles directly, and instantiate the Named Map as part of the request to your application. You do not have to do any other steps to initialize your map.
To call a template_id in a URL:
@@ -543,21 +547,21 @@ To call a template_id in a URL:
For example, a complete URL might appear as:
"https://{username}.cartodb.com/api/v1/map/named/{template_id}/{layer}/{z}/{x}/{y}.png"
"https://{username}.carto.com/api/v1/map/named/{template_id}/{layer}/{z}/{x}/{y}.png"
The placeholders indicate the following:
- [`template_id`](http://docs.cartodb.com/cartodb-platform/maps-api/named-maps/#response) is the response of your Named Map.
- [`template_id`](http://docs.carto.com/carto-engine/maps-api/named-maps/#response) is the response of your Named Map.
- layers can be a number (referring to the # layer of your map), all layers of your map, or a list of layers.
- To show just the basemap layer, enter the number value `0` in the layer placeholder "https://{username}.cartodb.com/api/v1/map/named/{template_id}/0/{z}/{x}/{y}.png"
- To show the first layer, enter the number value `1` in the layer placeholder "https://{username}.cartodb.com/api/v1/map/named/{template_id}/1/{z}/{x}/{y}.png"
- To show all layers, enter the value `all` for the layer placeholder "https://{username}.cartodb.com/api/v1/map/named/{template_id}/all/{z}/{x}/{y}.png"
- To show a [list of layers](http://docs.cartodb.com/cartodb-platform/maps-api/anonymous-maps/#blending-and-layer-selection), enter the comma separated layer value as 0,1,2 in the layer placeholder. For example, to show the basemap and the first layer, "https://{username}.cartodb.com/api/v1/map/named/{template_id}/0,1/{z}/{x}/{y}.png"
- To show just the basemap layer, enter the number value `0` in the layer placeholder "https://{username}.carto.com/api/v1/map/named/{template_id}/0/{z}/{x}/{y}.png"
- To show the first layer, enter the number value `1` in the layer placeholder "https://{username}.carto.com/api/v1/map/named/{template_id}/1/{z}/{x}/{y}.png"
- To show all layers, enter the value `all` for the layer placeholder "https://{username}.carto.com/api/v1/map/named/{template_id}/all/{z}/{x}/{y}.png"
- To show a [list of layers](http://docs.carto.com/carto-engine/maps-api/anonymous-maps/#blending-and-layer-selection), enter the comma separated layer value as 0,1,2 in the layer placeholder. For example, to show the basemap and the first layer, "https://{username}.carto.com/api/v1/map/named/{template_id}/0,1/{z}/{x}/{y}.png"
### Get Mapnik Retina Tiles
Mapnik Retina tiles are not directly supported for Named Maps, so you cannot use the Named Map template_id. To fetch Mapnik Retina tiles, get the [layergroupid](http://docs.cartodb.com/cartodb-platform/maps-api/named-maps/#response-1) to initialize the map.
Mapnik Retina tiles are not directly supported for Named Maps, so you cannot use the Named Map template_id. To fetch Mapnik Retina tiles, get the [layergroupid](http://docs.carto.com/carto-engine/maps-api/named-maps/#response-1) to initialize the map.
Instantiate the map by using your `layergroupid` in the token placeholder:

View File

@@ -22,10 +22,10 @@ $.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'https://{username}.cartodb.com/api/v1/map',
url: 'https://{username}.carto.com/api/v1/map',
data: JSON.stringify(mapconfig),
success: function(data) {
var templateUrl = 'https://{username}.cartodb.com/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png'
var templateUrl = 'https://{username}.carto.com/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png'
console.log(templateUrl);
}
})
@@ -33,7 +33,7 @@ $.ajax({
## Named Maps
Let's create a Named Map using some private tables in a CartoDB account.
Let's create a Named Map using some private tables in a CARTO account.
The following map config sets up a map of European countries that have a white fill color:
```javascript
@@ -56,12 +56,12 @@ The following map config sets up a map of European countries that have a white f
}
```
The MapConfig needs to be sent to CartoDB's Map API using an authenticated call. Here we will use a command line tool called `curl`. For more info about this tool, see [this blog post](http://quickleft.com/blog/command-line-tutorials-curl), or type `man curl` in bash. Using `curl`, and storing the config from above in a file `MapConfig.json`, the call would look like:
The MapConfig needs to be sent to CARTO's Map API using an authenticated call. Here we will use a command line tool called `curl`. For more info about this tool, see [this blog post](http://quickleft.com/blog/command-line-tutorials-curl), or type `man curl` in bash. Using `curl`, and storing the config from above in a file `MapConfig.json`, the call would look like:
#### Call
```bash
curl 'https://{username}.cartodb.com/api/v1/map/named?api_key={api_key}' -H 'Content-Type: application/json' -d @mapconfig.json
curl 'https://{username}.carto.com/api/v1/map/named?api_key={api_key}' -H 'Content-Type: application/json' -d @mapconfig.json
```
To get the `URL` to fetch the tiles you need to instantiate the map, where `template_id` is the template name from the previous response.
@@ -69,7 +69,7 @@ To get the `URL` to fetch the tiles you need to instantiate the map, where `temp
#### Call
```bash
curl -X POST 'https://{username}.cartodb.com/api/v1/map/named/{template_id}' -H 'Content-Type: application/json'
curl -X POST 'https://{username}.carto.com/api/v1/map/named/{template_id}' -H 'Content-Type: application/json'
```
The response will return JSON with properties for the `layergroupid`, the timestamp (`last_updated`) of the last data modification and some key/value pairs with `metadata` for the `layers`.
@@ -96,5 +96,5 @@ Note: all `layers` in `metadata` will always have a `type` string and a `meta` d
You can use the `layergroupid` to instantiate a URL template for accessing tiles on the client. Here we use the `layergroupid` from the example response above in this URL template:
```bash
https://{username}.cartodb.com/api/v1/map/{layergroupid}/{z}/{x}/{y}.png
https://{username}.carto.com/api/v1/map/{layergroupid}/{z}/{x}/{y}.png
```

View File

@@ -78,7 +78,7 @@ format | the format for the image, supported types: `png`, `jpg`
--- | ---
&#124;_ jpg | will have a default quality of 85.
A Named Maps static image will get its constraints from the [`view` argument of the Create Named Map function](http://docs.cartodb.com/cartodb-platform/maps-api/named-maps/#arguments). If `view` is not defined, it will estimate the extent based on the involved tables, otherwise it fallbacks to `"zoom": 1`, `"lng": 0` and `"lat": 0`.
A Named Maps static image will get its constraints from the [`view` argument of the Create Named Map function](http://docs.carto.com/carto-engine/maps-api/named-maps/#arguments). If `view` is not defined, it will estimate the extent based on the involved tables, otherwise it fallbacks to `"zoom": 1`, `"lng": 0` and `"lat": 0`.
#### Layers
@@ -122,9 +122,9 @@ By manipulating the `"urlTemplate"` custom basemaps can be used in generating st
},
```
**CartoDB**
**CARTO**
As described in the [MapConfig File Format](http://docs.cartodb.com/cartodb-platform/maps-api/mapconfig/), a "cartodb" type layer is now just an alias to a "mapnik" type layer as above, intended for backwards compatibility.
As described in the [MapConfig File Format](http://docs.carto.com/carto-engine/maps-api/mapconfig/), a "cartodb" type layer is now just an alias to a "mapnik" type layer as above, intended for backwards compatibility.
```javascript
{
@@ -142,18 +142,18 @@ Additionally, static images from Torque maps and other map layers can be used to
### Caching
It is important to note that generated images are cached from the live data referenced with the `layergroupid token` on the specified CartoDB account. This means that if the data changes, the cached image will also change. When linking dynamically, it is important to take into consideration the state of the data and longevity of the static image to avoid broken images or changes in how the image is displayed. To obtain a static snapshot of the map as it is today and preserve the image long-term regardless of changes in data, the image must be saved and stored locally.
It is important to note that generated images are cached from the live data referenced with the `layergroupid token` on the specified CARTO account. This means that if the data changes, the cached image will also change. When linking dynamically, it is important to take into consideration the state of the data and longevity of the static image to avoid broken images or changes in how the image is displayed. To obtain a static snapshot of the map as it is today and preserve the image long-term regardless of changes in data, the image must be saved and stored locally.
### Limits
* While images can encompass an entirety of a map, the default limit for pixel range is 8192 x 8192.
* Image resolution by default is set to 72 DPI
* JPEG quality by default is 85%
* Timeout limits for generating static maps are the same across the CartoDB Editor and Platform. It is important to ensure timely processing of queries.
* While images can encompass an entirety of a map, the limit for pixel range is 8192 x 8192.
* Image resolution is set to 72 DPI
* JPEG quality is 85%
* Timeout limits for generating static maps are the same across CARTO Builder and CARTO Engine. It is important to ensure timely processing of queries.
## Examples
After instantiating a map from a CartoDB account:
After instantiating a map from a CARTO account:
#### Call

View File

@@ -95,9 +95,7 @@ AuthApi.prototype.authorize = function(req, callback) {
self.authorizedByAPIKey(user, req, this);
},
function checkApiKey(err, authorized){
if (req.profiler) {
req.profiler.done('authorizedByAPIKey');
}
req.profiler.done('authorizedByAPIKey');
assert.ifError(err);
// if not authorized by api_key, continue
@@ -131,9 +129,7 @@ AuthApi.prototype.authorize = function(req, callback) {
}
self.pgConnection.setDBAuth(user, req.params, function(err) {
if (req.profiler) {
req.profiler.done('setDBAuth');
}
req.profiler.done('setDBAuth');
callback(err, true); // authorized (or error)
});
}

View File

@@ -1,6 +1,6 @@
var _ = require('underscore');
var step = require('step');
var CamshaftFilter = require('../models/filter/camshaft');
var AnalysisFilter = require('../models/filter/analysis');
function FilterStatsApi(pgQueryRunner) {
this.pgQueryRunner = pgQueryRunner;
@@ -40,8 +40,8 @@ FilterStatsApi.prototype.getFilterStats = function (username, unfiltered_query,
},
function getFilteredRows() {
if ( filters && !_.isEmpty(filters)) {
var camshaftFilter = new CamshaftFilter(filters);
var query = camshaftFilter.sql(unfiltered_query);
var analysisFilter = new AnalysisFilter(filters);
var query = analysisFilter.sql(unfiltered_query);
getEstimatedRows(self.pgQueryRunner, username, query, this);
} else {
this(null, null);

View File

@@ -9,7 +9,10 @@ module.exports = AnalysisStatusBackend;
AnalysisStatusBackend.prototype.getNodeStatus = function (params, callback) {
var nodeId = params.nodeId;
var statusQuery = 'SELECT node_id, status, updated_at FROM cdb_analysis_catalog where node_id = \'' + nodeId + '\'';
var statusQuery = [
'SELECT node_id, status, updated_at, last_error_message as error_message',
'FROM cdb_analysis_catalog where node_id = \'' + nodeId + '\''
].join(' ');
var pg = new PSQL(dbParamsFromReqParams(params));
pg.query(statusQuery, function(err, result) {
@@ -21,10 +24,16 @@ AnalysisStatusBackend.prototype.getNodeStatus = function (params, callback) {
var rows = result.rows || [];
return callback(null, rows[0] || {
var statusResponse = rows[0] || {
node_id: nodeId,
status: 'unknown'
});
};
if (statusResponse.status !== 'failed') {
delete statusResponse.error_message;
}
return callback(null, statusResponse);
}, true); // use read-only transaction
};

View File

@@ -1,19 +1,93 @@
var camshaft = require('camshaft');
'use strict';
function AnalysisBackend(options) {
var batchConfig = options.batch || {};
var _ = require('underscore');
var camshaft = require('camshaft');
var fs = require('fs');
var REDIS_LIMITS = {
DB: 5,
PREFIX: 'limits:analyses:' // + username
};
function AnalysisBackend (metadataBackend, options) {
this.metadataBackend = metadataBackend;
this.options = options || {};
this.options.limits = this.options.limits || {};
this.setBatchConfig(this.options.batch);
this.setLoggerConfig(this.options.logger);
}
module.exports = AnalysisBackend;
AnalysisBackend.prototype.setBatchConfig = function (options) {
var batchConfig = options || {};
batchConfig.endpoint = batchConfig.endpoint || 'http://127.0.0.1:8080/api/v1/sql/job';
batchConfig.inlineExecution = batchConfig.inlineExecution || false;
batchConfig.hostHeaderTemplate = batchConfig.hostHeaderTemplate || '{{=it.username}}.localhost.lan';
this.batchConfig = batchConfig;
}
};
module.exports = AnalysisBackend;
AnalysisBackend.prototype.setLoggerConfig = function (options) {
this.loggerConfig = options || {};
if (this.loggerConfig.filename) {
this.stream = fs.createWriteStream(this.loggerConfig.filename, { flags: 'a', encoding: 'utf8' });
process.on('SIGHUP', function () {
if (this.stream) {
this.stream.destroy();
}
this.stream = fs.createWriteStream(this.loggerConfig.filename, { flags: 'a', encoding: 'utf8' });
}.bind(this));
}
};
AnalysisBackend.prototype.create = function(analysisConfiguration, analysisDefinition, callback) {
analysisConfiguration.batch.endpoint = this.batchConfig.endpoint;
analysisConfiguration.batch.inlineExecution = this.batchConfig.inlineExecution;
analysisConfiguration.batch.hostHeaderTemplate = this.batchConfig.hostHeaderTemplate;
camshaft.create(analysisConfiguration, analysisDefinition, callback);
analysisConfiguration.logger = {
stream: this.stream ? this.stream : process.stdout
};
this.getAnalysesLimits(analysisConfiguration.user, function(err, limits) {
analysisConfiguration.limits = limits || {};
camshaft.create(analysisConfiguration, analysisDefinition, callback);
});
};
AnalysisBackend.prototype.getAnalysesLimits = function(username, callback) {
var self = this;
var analysesLimits = {
analyses: {
// buffer: {
// timeout: 1000,
// maxNumberOfRows: 1e6
// }
}
};
Object.keys(self.options.limits).forEach(function(analysisTypeOrTag) {
analysesLimits.analyses[analysisTypeOrTag] = _.extend({}, self.options.limits[analysisTypeOrTag]);
});
var analysesLimitsKey = REDIS_LIMITS.PREFIX + username;
this.metadataBackend.redisCmd(REDIS_LIMITS.DB, 'HGETALL', [analysesLimitsKey], function(err, analysesTimeouts) {
// analysesTimeouts wil be something like: { moran: 3000, intersection: 5000 }
analysesTimeouts = analysesTimeouts || {};
Object.keys(analysesTimeouts).forEach(function(analysisType) {
analysesLimits.analyses[analysisType] = _.defaults(
{
timeout: Number.isFinite(+analysesTimeouts[analysisType]) ? +analysesTimeouts[analysisType] : 0
},
analysesLimits.analyses[analysisType]
);
});
return callback(null, analysesLimits);
});
};

View File

@@ -2,11 +2,8 @@ var assert = require('assert');
var _ = require('underscore');
var PSQL = require('cartodb-psql');
var camshaft = require('camshaft');
var step = require('step');
var Timer = require('../stats/timer');
var BBoxFilter = require('../models/filter/bbox');
var DataviewFactory = require('../models/dataview/factory');
@@ -16,6 +13,9 @@ var overviewsQueryRewriter = new OverviewsQueryRewriter({
zoom_level: 'CDB_ZoomFromScale(!scale_denominator!)'
});
var dot = require('dot');
dot.templateSettings.strip = false;
function DataviewBackend(analysisBackend) {
this.analysisBackend = analysisBackend;
}
@@ -23,117 +23,36 @@ function DataviewBackend(analysisBackend) {
module.exports = DataviewBackend;
DataviewBackend.prototype.getDataview = function (mapConfigProvider, user, params, callback) {
var self = this;
var timer = new Timer();
var dataviewName = params.dataviewName;
var mapConfig;
var dataviewDefinition;
step(
function getMapConfig() {
mapConfigProvider.getMapConfig(this);
},
function _getDataviewDefinition(err, _mapConfig) {
function runDataviewQuery(err, mapConfig) {
assert.ifError(err);
mapConfig = _mapConfig;
var _dataviewDefinition = getDataviewDefinition(mapConfig.obj(), dataviewName);
if (!_dataviewDefinition) {
var dataviewDefinition = getDataviewDefinition(mapConfig.obj(), dataviewName);
if (!dataviewDefinition) {
throw new Error("Dataview '" + dataviewName + "' does not exists");
}
dataviewDefinition = _dataviewDefinition;
return dataviewDefinition;
},
function loadAnalysis(err) {
assert.ifError(err);
var analysisConfiguration = {
db: {
host: params.dbhost,
port: params.dbport,
dbname: params.dbname,
user: params.dbuser,
pass: params.dbpassword
},
batch: {
username: user,
apiKey: params.api_key
}
};
var sourceId = dataviewDefinition.source.id;
var analysisDefinition = getAnalysisDefinition(mapConfig.obj().analyses, sourceId);
var next = this;
self.analysisBackend.create(analysisConfiguration, analysisDefinition, function(err, analysis) {
if (err) {
return next(err);
}
var sourceId2Node = {};
var rootNode = analysis.getRoot();
if (rootNode.params && rootNode.params.id) {
sourceId2Node[rootNode.params.id] = rootNode;
}
analysis.getSortedNodes().forEach(function(node) {
if (node.params && node.params.id) {
sourceId2Node[node.params.id] = node;
}
});
var node = sourceId2Node[sourceId];
if (!node) {
return next(new Error('Analysis node not found for dataview'));
}
return next(null, node);
});
},
function runDataviewQuery(err, node) {
assert.ifError(err);
var pg = new PSQL(dbParamsFromReqParams(params));
var ownFilter = +params.own_filter;
ownFilter = !!ownFilter;
var query;
if (ownFilter) {
query = node.getQuery();
} else {
var applyFilters = {};
applyFilters[dataviewName] = false;
query = node.getQuery(applyFilters);
}
var query = (ownFilter) ? dataviewDefinition.sql.own_filter_on : dataviewDefinition.sql.own_filter_off;
var sourceId = dataviewDefinition.source.id; // node.id
var layer = _.find(
mapConfig.obj().layers,
function(l){ return l.options.source && (l.options.source.id === sourceId); }
);
var layer = _.find(mapConfig.obj().layers, function(l) {
return l.options.source && (l.options.source.id === sourceId);
});
var queryRewriteData = layer && layer.options.query_rewrite_data;
if ( queryRewriteData ) {
if ( node.type === 'source' ) {
var filters = node.getFilters();
var filters_disabler = Object.keys(filters).reduce(
function(disabler, filter_id){ disabler[filter_id] = false; return disabler; },
{}
);
var unfiltered_query = node.getQuery(filters_disabler);
queryRewriteData = _.extend(
{},
queryRewriteData, { filters: filters, unfiltered_query: unfiltered_query }
);
}
if (queryRewriteData && dataviewDefinition.node.type === 'source') {
queryRewriteData = _.extend({}, queryRewriteData, {
filters: dataviewDefinition.node.filters,
unfiltered_query: dataviewDefinition.sql.own_filter_on
});
}
if (params.bbox) {
@@ -160,7 +79,10 @@ DataviewBackend.prototype.getDataview = function (mapConfigProvider, user, param
var overrideParams = _.reduce(_.pick(params, 'start', 'end', 'bins'),
function castNumbers(overrides, val, k) {
overrides[k] = Number.isFinite(+val) ? +val : val;
if (!Number.isFinite(+val)) {
throw new Error('Invalid number format for parameter \'' + k + '\'');
}
overrides[k] = +val;
return overrides;
},
{ownFilter: ownFilter}
@@ -170,104 +92,32 @@ DataviewBackend.prototype.getDataview = function (mapConfigProvider, user, param
dataview.getResult(pg, overrideParams, this);
},
function returnCallback(err, result) {
return callback(err, result, timer.getTimes());
return callback(err, result);
}
);
};
DataviewBackend.prototype.search = function (mapConfigProvider, user, params, callback) {
var self = this;
var timer = new Timer();
var dataviewName = params.dataviewName;
var mapConfig;
var dataviewDefinition;
step(
function getMapConfig() {
mapConfigProvider.getMapConfig(this);
},
function _getDataviewDefinition(err, _mapConfig) {
function runDataviewSearchQuery(err, mapConfig) {
assert.ifError(err);
mapConfig = _mapConfig;
var _dataviewDefinition = getDataviewDefinition(mapConfig.obj(), dataviewName);
if (!_dataviewDefinition) {
var dataviewDefinition = getDataviewDefinition(mapConfig.obj(), dataviewName);
if (!dataviewDefinition) {
throw new Error("Dataview '" + dataviewName + "' does not exists");
}
dataviewDefinition = _dataviewDefinition;
return dataviewDefinition;
},
function loadAnalysis(err) {
assert.ifError(err);
var analysisConfiguration = {
db: {
host: params.dbhost,
port: params.dbport,
dbname: params.dbname,
user: params.dbuser,
pass: params.dbpassword
},
batch: {
// TODO load this from configuration
endpoint: 'http://127.0.0.1:8080/api/v1/sql/job',
username: user,
apiKey: params.api_key
}
};
var sourceId = dataviewDefinition.source.id;
var analysisDefinition = getAnalysisDefinition(mapConfig.obj().analyses, sourceId);
var next = this;
self.analysisBackend.create(analysisConfiguration, analysisDefinition, function(err, analysis) {
if (err) {
return next(err);
}
var sourceId2Node = {};
var rootNode = analysis.getRoot();
if (rootNode.params && rootNode.params.id) {
sourceId2Node[rootNode.params.id] = rootNode;
}
analysis.getSortedNodes().forEach(function(node) {
if (node.params && node.params.id) {
sourceId2Node[node.params.id] = node;
}
});
var node = sourceId2Node[sourceId];
if (!node) {
return next(new Error('Analysis node not found for dataview'));
}
return next(null, node);
});
},
function runDataviewQuery(err, node) {
assert.ifError(err);
var pg = new PSQL(dbParamsFromReqParams(params));
var ownFilter = +params.own_filter;
ownFilter = !!ownFilter;
var query;
if (ownFilter) {
query = node.getQuery();
} else {
var applyFilters = {};
applyFilters[dataviewName] = false;
query = node.getQuery(applyFilters);
}
var query = (ownFilter) ? dataviewDefinition.sql.own_filter_on : dataviewDefinition.sql.own_filter_off;
if (params.bbox) {
var bboxFilter = new BBoxFilter({column: 'the_geom', srid: 4326}, {bbox: params.bbox});
@@ -280,23 +130,11 @@ DataviewBackend.prototype.search = function (mapConfigProvider, user, params, ca
dataview.search(pg, userQuery, this);
},
function returnCallback(err, result) {
return callback(err, result, timer.getTimes());
return callback(err, result);
}
);
};
function getAnalysisDefinition(mapConfigAnalyses, sourceId) {
mapConfigAnalyses = mapConfigAnalyses || [];
for (var i = 0; i < mapConfigAnalyses.length; i++) {
var analysisGraph = new camshaft.reference.AnalysisGraph(mapConfigAnalyses[i]);
var nodes = analysisGraph.getNodesWithId();
if (nodes.hasOwnProperty(sourceId)) {
return mapConfigAnalyses[i];
}
}
throw new Error('There is no associated analysis for the dataview source id');
}
function getDataviewDefinition(mapConfig, dataviewName) {
var dataviews = mapConfig.dataviews || {};
return dataviews[dataviewName];

View File

@@ -55,11 +55,9 @@ util.inherits(TemplateMaps, EventEmitter);
module.exports = TemplateMaps;
var o = TemplateMaps.prototype;
//--------------- PRIVATE METHODS --------------------------------
o._userTemplateLimit = function() {
TemplateMaps.prototype._userTemplateLimit = function() {
return this.opts.max_user_templates || 0;
};
@@ -70,7 +68,7 @@ o._userTemplateLimit = function() {
* @param redisArgs - the arguments for the redis function in an array
* @param callback - function to pass results too.
*/
o._redisCmd = function(redisFunc, redisArgs, callback) {
TemplateMaps.prototype._redisCmd = function(redisFunc, redisArgs, callback) {
var redisClient;
var that = this;
var db = that.db_signatures;
@@ -97,7 +95,7 @@ o._redisCmd = function(redisFunc, redisArgs, callback) {
var _reValidNameIdentifier = /^[a-z0-9][0-9a-z_\-]*$/i;
var _reValidPlaceholderIdentifier = /^[a-z][0-9a-z_]*$/i;
// jshint maxcomplexity:15
o._checkInvalidTemplate = function(template) {
TemplateMaps.prototype._checkInvalidTemplate = function(template) {
if ( template.version !== '0.0.1' ) {
return new Error("Unsupported template version " + template.version);
}
@@ -200,7 +198,7 @@ function templateDefaults(template) {
// @param callback function(err, tpl_id)
// Return template identifier (only valid for given user)
//
o.addTemplate = function(owner, template, callback) {
TemplateMaps.prototype.addTemplate = function(owner, template, callback) {
var self = this;
template = templateDefaults(template);
@@ -258,7 +256,7 @@ o.addTemplate = function(owner, template, callback) {
//
// @param callback function(err)
//
o.delTemplate = function(owner, tpl_id, callback) {
TemplateMaps.prototype.delTemplate = function(owner, tpl_id, callback) {
var self = this;
step(
function deleteTemplate() {
@@ -297,7 +295,8 @@ o.delTemplate = function(owner, tpl_id, callback) {
//
// @param callback function(err)
//
o.updTemplate = function(owner, tpl_id, template, callback) {
TemplateMaps.prototype.updTemplate = function(owner, tpl_id, template, callback) {
var self = this;
template = templateDefaults(template);
@@ -356,7 +355,7 @@ o.updTemplate = function(owner, tpl_id, template, callback) {
// @param callback function(err, tpl_id_list)
// Returns a list of template identifiers
//
o.listTemplates = function(owner, callback) {
TemplateMaps.prototype.listTemplates = function(owner, callback) {
this._redisCmd('HKEYS', [ this.key_usr_tpl({owner:owner}) ], callback);
};
@@ -370,7 +369,7 @@ o.listTemplates = function(owner, callback) {
// @param callback function(err, template)
// Return full template definition
//
o.getTemplate = function(owner, tpl_id, callback) {
TemplateMaps.prototype.getTemplate = function(owner, tpl_id, callback) {
var self = this;
step(
function getTemplate() {
@@ -386,7 +385,7 @@ o.getTemplate = function(owner, tpl_id, callback) {
);
};
o.isAuthorized = function(template, authTokens) {
TemplateMaps.prototype.isAuthorized = function(template, authTokens) {
if (!template) {
return false;
}
@@ -438,7 +437,7 @@ function _replaceVars (str, params) {
});
return str;
}
o.instance = function(template, params) {
TemplateMaps.prototype.instance = function(template, params) {
var all_params = {};
var phold = template.placeholders || {};
Object.keys(phold).forEach(function(k) {
@@ -500,7 +499,7 @@ o.instance = function(template, params) {
};
// Return a fingerPrint of the object
o.fingerPrint = function(template) {
TemplateMaps.prototype.fingerPrint = function(template) {
return crypto.createHash('md5')
.update(JSON.stringify(template))
.digest('hex')

View File

@@ -6,6 +6,9 @@ dot.templateSettings.strip = false;
function createTemplate(method) {
return dot.template([
'SELECT',
'min({{=it._column}}) min_val,',
'max({{=it._column}}) max_val,',
'avg({{=it._column}}) avg_val,',
method,
'FROM ({{=it._sql}}) _table_sql WHERE {{=it._column}} IS NOT NULL'
].join('\n'));
@@ -29,17 +32,12 @@ methodTemplates.category = dot.template([
' SELECT {{=it._column}} AS category, count(1) AS value, row_number() OVER (ORDER BY count(1) desc) as rank',
' FROM ({{=it._sql}}) _cdb_aggregation_all',
' GROUP BY {{=it._column}}',
' ORDER BY 2 DESC',
' ORDER BY 2 DESC, 1 ASC',
'),',
'agg_categories AS (',
' SELECT \'__other\' category',
' SELECT category',
' FROM categories',
' WHERE rank >= {{=it._buckets}}',
' GROUP BY 1',
' UNION ALL',
' SELECT CAST(category AS text)',
' FROM categories',
' WHERE rank < {{=it._buckets}}',
' WHERE rank <= {{=it._buckets}}',
')',
'SELECT array_agg(category) AS category FROM agg_categories'
].join('\n'));
@@ -54,9 +52,8 @@ var method2strategy = {
category: STRATEGY.EXACT
};
function PostgresDatasource (pgQueryRunner, username, query) {
this.pgQueryRunner = pgQueryRunner;
this.username = username;
function PostgresDatasource (psql, query) {
this.psql = psql;
this.query = query;
}
@@ -75,21 +72,39 @@ PostgresDatasource.prototype.getRamp = function (column, buckets, method, callba
var query = template({ _column: column, _sql: this.query, _buckets: buckets });
this.pgQueryRunner.run(this.username, query, function (err, result) {
this.psql.query(query, function (err, resultSet) {
if (err) {
return callback(err);
}
var result = getResult(resultSet);
var strategy = method2strategy[methodName];
var ramp = result[0][methodName];
var ramp = result[methodName] || [];
var stats = {
min_val: result.min_val,
max_val: result.max_val,
avg_val: result.avg_val
};
// Skip null values from ramp
// Generated turbo-carto won't be correct, but better to keep it working than failing
// TODO fix cartodb-postgres extension quantification functions
ramp = ramp.filter(function(value) { return value !== null; });
if (strategy !== STRATEGY.EXACT) {
ramp = ramp.sort(function(a, b) {
return a - b;
});
}
return callback(null, { ramp: ramp, strategy: strategy });
});
return callback(null, { ramp: ramp, strategy: strategy, stats: stats });
}, true); // use read-only transaction
};
function getResult(resultSet) {
resultSet = resultSet || {};
var result = resultSet.rows || [];
result = result[0] || {};
return result;
}
module.exports = PostgresDatasource;

View File

@@ -0,0 +1,169 @@
var step = require('step');
var assert = require('assert');
var dot = require('dot');
dot.templateSettings.strip = false;
var PSQL = require('cartodb-psql');
var util = require('util');
var BaseController = require('./base');
var cors = require('../middleware/cors');
var userMiddleware = require('../middleware/user');
function AnalysesController(authApi, pgConnection) {
BaseController.call(this, authApi, pgConnection);
}
util.inherits(AnalysesController, BaseController);
module.exports = AnalysesController;
AnalysesController.prototype.register = function(app) {
app.get(app.base_url_mapconfig + '/analyses/catalog', cors(), userMiddleware, this.catalog.bind(this));
};
AnalysesController.prototype.sendResponse = function(req, res, resource) {
res.set('Cache-Control', 'public,max-age=10,must-revalidate');
this.send(req, res, resource, 200);
};
AnalysesController.prototype.catalog = function(req, res) {
var self = this;
var username = req.context.user;
step(
function reqParams() {
self.req2params(req, this);
},
function catalogQuery(err) {
assert.ifError(err);
var pg = new PSQL(dbParamsFromReqParams(req.params));
getMetadata(username, pg, this);
},
function prepareResponse(err, results) {
assert.ifError(err);
var analysisIdToTable = results.tables.reduce(function(analysisIdToTable, table) {
var analysisId = table.relname.split('_')[2];
if (analysisId && analysisId.length === 40) {
analysisIdToTable[analysisId] = table;
}
return analysisIdToTable;
}, {});
var catalogWithTables = results.catalog.map(function(analysis) {
if (analysisIdToTable.hasOwnProperty(analysis.node_id)) {
analysis.table = analysisIdToTable[analysis.node_id];
}
return analysis;
});
return catalogWithTables.sort(function(analysisA, analysisB) {
if (!!analysisA.table && !!analysisB.table) {
return analysisB.table.size - analysisA.table.size;
}
if (!!analysisA.table) {
return -1;
}
if (!!analysisB.table) {
return 1;
}
return -1;
});
},
function sendResponse(err, catalogWithTables) {
if (err) {
if (err.message.match(/permission\sdenied/)) {
err = new Error('Unauthorized');
err.http_status = 401;
}
self.sendError(req, res, err);
} else {
self.sendResponse(req, res, { catalog: catalogWithTables });
}
}
);
};
var catalogQueryTpl = dot.template(
'SELECT analysis_def->>\'type\' as type, * FROM cartodb.cdb_analysis_catalog WHERE username = \'{{=it._username}}\''
);
var tablesQueryTpl = dot.template([
"WITH analysis_tables AS (",
" SELECT",
" n.nspname AS nspname,",
" c.relname AS relname,",
" pg_total_relation_size(",
" format('%s.%s', pg_catalog.quote_ident(n.nspname), pg_catalog.quote_ident(c.relname))",
" ) AS size,",
" format('%s.%s', pg_catalog.quote_ident(nspname), pg_catalog.quote_ident(relname)) AS fully_qualified_name",
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n",
" WHERE c.relnamespace = n.oid",
" AND pg_catalog.quote_ident(c.relname) ~ '^analysis_[a-z0-9]{10}_[a-z0-9]{40}$'",
" AND n.nspname IN ('{{=it._username}}', 'public')",
")",
"SELECT *, pg_size_pretty(size) as size_pretty",
"FROM analysis_tables",
"ORDER BY size DESC"
].join('\n'));
function getMetadata(username, pg, callback) {
var results = {
catalog: [],
tables: []
};
step(
function getCatalog() {
pg.query(catalogQueryTpl({_username: username}), this, true); // use read-only transaction
},
function handleCatalog(err, resultSet) {
assert.ifError(err);
resultSet = resultSet || {};
results.catalog = resultSet.rows || [];
this();
},
function getTables(err) {
assert.ifError(err);
pg.query(tablesQueryTpl({_username: username}), this, true); // use read-only transaction
},
function handleTables(err, resultSet) {
assert.ifError(err);
resultSet = resultSet || {};
results.tables = resultSet.rows || [];
this();
},
function finish(err) {
if (err) {
return callback(err);
}
return callback(null, results);
}
);
}
function dbParamsFromReqParams(params) {
var dbParams = {};
if ( params.dbuser ) {
dbParams.user = params.dbuser;
}
if ( params.dbpassword ) {
dbParams.pass = params.dbpassword;
}
if ( params.dbhost ) {
dbParams.host = params.dbhost;
}
if ( params.dbport ) {
dbParams.port = params.dbport;
}
if ( params.dbname ) {
dbParams.dbname = params.dbname;
}
return dbParams;
}

View File

@@ -36,7 +36,7 @@ function BaseController(authApi, pgConnection) {
module.exports = BaseController;
// jshint maxcomplexity:9
// jshint maxcomplexity:10
/**
* Whitelist input and get database name & default geometry type from
* subdomain/user metadata held in CartoDB Redis
@@ -61,9 +61,7 @@ BaseController.prototype.req2params = function(req, callback){
lzmaWorker.decompress(
lzma,
function(result) {
if (req.profiler) {
req.profiler.done('lzma');
}
req.profiler.done('lzma');
try {
delete req.query.lzma;
_.extend(req.query, JSON.parse(result));
@@ -77,7 +75,11 @@ BaseController.prototype.req2params = function(req, callback){
return;
}
req.query = _.pick(req.query, REQUEST_QUERY_PARAMS_WHITELIST);
var allowedQueryParams = REQUEST_QUERY_PARAMS_WHITELIST;
if (Array.isArray(req.context.allowedQueryParams)) {
allowedQueryParams = allowedQueryParams.concat(req.context.allowedQueryParams);
}
req.query = _.pick(req.query, allowedQueryParams);
req.params = _.extend({}, req.params); // shuffle things as request is a strange array/object
var user = req.context.user;
@@ -115,18 +117,14 @@ BaseController.prototype.req2params = function(req, callback){
// bring all query values onto req.params object
_.extend(req.params, req.query);
if (req.profiler) {
req.profiler.done('req2params.setup');
}
req.profiler.done('req2params.setup');
step(
function getPrivacy(){
self.authApi.authorize(req, this);
},
function validateAuthorization(err, authorized) {
if (req.profiler) {
req.profiler.done('authorize');
}
req.profiler.done('authorize');
assert.ifError(err);
if(!authorized) {
err = new Error("Sorry, you are unauthorized (permission denied)");
@@ -167,9 +165,7 @@ BaseController.prototype.send = function(req, res, body, status, headers) {
res.set('X-Served-By-DB-Host', req.params.dbhost);
}
if (req.profiler) {
res.set('X-Tiler-Profiler', req.profiler.toJSONString());
}
res.set('X-Tiler-Profiler', req.profiler.toJSONString());
if (headers) {
res.set(headers);
@@ -187,14 +183,12 @@ BaseController.prototype.send = function(req, res, body, status, headers) {
res.send(body);
}
if (req.profiler) {
try {
// May throw due to dns, see
// See http://github.com/CartoDB/Windshaft/issues/166
req.profiler.sendStats();
} catch (err) {
debug("error sending profiling stats: " + err);
}
try {
// May throw due to dns, see
// See http://github.com/CartoDB/Windshaft/issues/166
req.profiler.sendStats();
} catch (err) {
debug("error sending profiling stats: " + err);
}
};
// jshint maxcomplexity:6
@@ -214,15 +208,15 @@ BaseController.prototype.sendError = function(req, res, err, label) {
statusCode = 200;
}
var errorResponseBody = { errors: allErrors.map(errorMessage) };
var errorResponseBody = {
errors: allErrors.map(errorMessage),
errors_with_context: allErrors.map(errorMessageWithContext)
};
this.send(req, res, errorResponseBody, statusCode);
};
function errorMessage(err) {
// See https://github.com/Vizzuality/Windshaft-cartodb/issues/68
var message = (_.isString(err) ? err : err.message) || 'Unknown error';
function stripConnectionInfo(message) {
// Strip connection info, if any
return message
// See https://github.com/CartoDB/Windshaft/issues/173
@@ -230,6 +224,32 @@ function errorMessage(err) {
// See https://travis-ci.org/CartoDB/Windshaft/jobs/20703062#L1644
.replace(/is the server.*encountered/im, 'encountered');
}
function errorMessage(err) {
// See https://github.com/Vizzuality/Windshaft-cartodb/issues/68
var message = (_.isString(err) ? err : err.message) || 'Unknown error';
return stripConnectionInfo(message);
}
function errorMessageWithContext(err) {
// See https://github.com/Vizzuality/Windshaft-cartodb/issues/68
var message = (_.isString(err) ? err : err.message) || 'Unknown error';
var error = {
type: err.type || 'unknown',
message: stripConnectionInfo(message),
};
for (var prop in err) {
// type & message are properties from Error's prototype and will be skipped
if (err.hasOwnProperty(prop)) {
error[prop] = err[prop];
}
}
return error;
}
module.exports.errorMessage = errorMessage;
function findStatusCode(err) {

View File

@@ -1,4 +1,5 @@
module.exports = {
Analyses: require('./analyses'),
Layergroup: require('./layergroup'),
Map: require('./map'),
NamedMaps: require('./named_maps'),

View File

@@ -6,6 +6,7 @@ var BaseController = require('./base');
var cors = require('../middleware/cors');
var userMiddleware = require('../middleware/user');
var allowQueryParams = require('../middleware/allow-query-params');
var DataviewBackend = require('../backends/dataview');
var AnalysisStatusBackend = require('../backends/analysis-status');
@@ -67,11 +68,13 @@ LayergroupController.prototype.register = function(app) {
this.attributes.bind(this));
app.get(app.base_url_mapconfig +
'/static/center/:token/:z/:lat/:lng/:width/:height.:format', cors(), userMiddleware,
'/static/center/:token/:z/:lat/:lng/:width/:height.:format',
cors(), userMiddleware, allowQueryParams(['layer']),
this.center.bind(this));
app.get(app.base_url_mapconfig +
'/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format', cors(), userMiddleware,
'/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format',
cors(), userMiddleware, allowQueryParams(['layer']),
this.bbox.bind(this));
// Undocumented/non-supported API endpoint methods.
@@ -338,6 +341,8 @@ LayergroupController.prototype.staticMap = function(req, res, width, height, zoo
LayergroupController.prototype.sendResponse = function(req, res, body, status, headers) {
var self = this;
req.profiler.done('res');
res.set('Cache-Control', 'public,max-age=31536000');
// Set Last-Modified header

View File

@@ -4,6 +4,8 @@ var step = require('step');
var windshaft = require('windshaft');
var QueryTables = require('cartodb-query-tables');
var ResourceLocator = require('../models/resource-locator');
var util = require('util');
var BaseController = require('./base');
@@ -44,6 +46,7 @@ function MapController(authApi, pgConnection, templateMaps, mapBackend, metadata
this.layergroupAffectedTables = layergroupAffectedTables;
this.mapConfigAdapter = mapConfigAdapter;
this.resourceLocator = new ResourceLocator(global.environment);
}
util.inherits(MapController, BaseController);
@@ -84,9 +87,7 @@ MapController.prototype.createPost = function(req, res) {
};
MapController.prototype.instantiate = function(req, res) {
if (req.profiler) {
req.profiler.start('windshaft-cartodb.instance_template_post');
}
req.profiler.start('windshaft-cartodb.instance_template_post');
this.instantiateTemplate(req, res, function prepareTemplateParams(callback) {
if (!req.is('application/json')) {
@@ -97,9 +98,7 @@ MapController.prototype.instantiate = function(req, res) {
};
MapController.prototype.jsonp = function(req, res) {
if (req.profiler) {
req.profiler.start('windshaft-cartodb.instance_template_get');
}
req.profiler.start('windshaft-cartodb.instance_template_get');
this.instantiateTemplate(req, res, function prepareJsonTemplateParams(callback) {
var err = null;
@@ -135,6 +134,7 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
function prepareAdapterMapConfig(err, requestMapConfig) {
assert.ifError(err);
context.analysisConfiguration = {
user: req.context.user,
db: {
host: req.params.dbhost,
port: req.params.dbport,
@@ -161,15 +161,34 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
},
function afterLayergroupCreate(err, layergroup) {
assert.ifError(err);
self.afterLayergroupCreate(req, res, mapConfig, layergroup, this);
self.afterLayergroupCreate(req, res, mapConfig, layergroup, context.analysesResults, this);
},
function finish(err, layergroup) {
if (err) {
if (Number.isFinite(err.layerIndex)) {
var error = new Error(err.message);
error.http_status = err.http_status;
if (!err.http_status && err.message.indexOf('column "the_geom_webmercator" does not exist') >= 0) {
error.http_status = 400;
}
error.type = 'layer';
error.subtype = err.message.indexOf('Postgis Plugin') >= 0 ? 'query' : undefined;
error.layer = {
id: mapConfig.getLayerId(err.layerIndex),
index: err.layerIndex,
type: mapConfig.layerType(err.layerIndex)
};
err = error;
}
self.sendError(req, res, err, 'ANONYMOUS LAYERGROUP');
} else {
var analysesResults = context.analysesResults || [];
addDataviewsAndWidgetsUrls(req.context.user, layergroup, mapConfig.obj());
addAnalysesMetadata(req.context.user, layergroup, analysesResults, true);
self.addDataviewsAndWidgetsUrls(req.context.user, layergroup, mapConfig.obj());
self.addAnalysesMetadata(req.context.user, layergroup, analysesResults, true);
addContextMetadata(layergroup, mapConfig.obj(), context);
res.set('X-Layergroup-Id', layergroup.layergroupid);
self.send(req, res, layergroup, 200);
}
@@ -177,6 +196,17 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
);
};
function addContextMetadata(layergroup, mapConfig, context) {
if (layergroup.metadata && Array.isArray(layergroup.metadata.layers) && Array.isArray(mapConfig.layers)) {
layergroup.metadata.layers = layergroup.metadata.layers.map(function(layer, layerIndex) {
if (context.turboCarto && Array.isArray(context.turboCarto.layers)) {
layer.meta.cartocss_meta = context.turboCarto.layers[layerIndex];
}
return layer;
});
}
}
MapController.prototype.instantiateTemplate = function(req, res, prepareParamsFn) {
var self = this;
@@ -219,7 +249,7 @@ MapController.prototype.instantiateTemplate = function(req, res, prepareParamsFn
},
function afterLayergroupCreate(err, layergroup) {
assert.ifError(err);
self.afterLayergroupCreate(req, res, mapConfig, layergroup, this);
self.afterLayergroupCreate(req, res, mapConfig, layergroup, mapConfigProvider.analysesResults, this);
},
function finishTemplateInstantiation(err, layergroup) {
if (err) {
@@ -228,8 +258,10 @@ MapController.prototype.instantiateTemplate = function(req, res, prepareParamsFn
var templateHash = self.templateMaps.fingerPrint(mapConfigProvider.template).substring(0, 8);
layergroup.layergroupid = cdbuser + '@' + templateHash + '@' + layergroup.layergroupid;
addDataviewsAndWidgetsUrls(cdbuser, layergroup, mapConfig.obj());
addAnalysesMetadata(cdbuser, layergroup, mapConfigProvider.analysesResults);
var _mapConfig = mapConfig.obj();
self.addDataviewsAndWidgetsUrls(cdbuser, layergroup, _mapConfig);
self.addAnalysesMetadata(cdbuser, layergroup, mapConfigProvider.analysesResults);
addContextMetadata(layergroup, _mapConfig, mapConfigProvider.context);
res.set('X-Layergroup-Id', layergroup.layergroupid);
self.surrogateKeysCache.tag(res, new NamedMapsCacheEntry(cdbuser, mapConfigProvider.getTemplateName()));
@@ -240,7 +272,7 @@ MapController.prototype.instantiateTemplate = function(req, res, prepareParamsFn
);
};
MapController.prototype.afterLayergroupCreate = function(req, res, mapconfig, layergroup, callback) {
MapController.prototype.afterLayergroupCreate = function(req, res, mapconfig, layergroup, analysesResults, callback) {
var self = this;
var username = req.context.user;
@@ -267,9 +299,7 @@ MapController.prototype.afterLayergroupCreate = function(req, res, mapconfig, la
// take place before proceeding. Error will be logged
// asynchronously
this.metadataBackend.incMapviewCount(username, mapconfig.obj().stat_tag, function(err) {
if (req.profiler) {
req.profiler.done('incMapviewCount');
}
req.profiler.done('incMapviewCount');
if ( err ) {
global.logger.log("ERROR: failed to increment mapview count for user '" + username + "': " + err);
}
@@ -292,16 +322,17 @@ MapController.prototype.afterLayergroupCreate = function(req, res, mapconfig, la
QueryTables.getAffectedTablesFromQuery(connection, sql, this);
},
function handleAffectedTablesAndLastUpdatedTime(err, result) {
if (req.profiler) {
req.profiler.done('queryTablesAndLastUpdated');
}
req.profiler.done('queryTablesAndLastUpdated');
assert.ifError(err);
// feed affected tables cache so it can be reused from, for instance, layergroup controller
self.layergroupAffectedTables.set(dbName, layergroupId, result);
var lastUpdateTime = result.getLastUpdatedAt();
lastUpdateTime = getLastUpdatedTime(analysesResults, lastUpdateTime) || lastUpdateTime;
// last update for layergroup cache buster
layergroup.layergroupid = layergroup.layergroupid + ':' + result.getLastUpdatedAt();
layergroup.last_updated = new Date(result.getLastUpdatedAt()).toISOString();
layergroup.layergroupid = layergroup.layergroupid + ':' + lastUpdateTime;
layergroup.last_updated = new Date(lastUpdateTime).toISOString();
if (req.method === 'GET') {
var ttl = global.environment.varnish.layergroupTtl || 86400;
@@ -321,51 +352,68 @@ MapController.prototype.afterLayergroupCreate = function(req, res, mapconfig, la
);
};
function addAnalysesMetadata(username, layergroup, analysesResults, includeQuery) {
function getLastUpdatedTime(analysesResults, lastUpdateTime) {
if (!Array.isArray(analysesResults)) {
return lastUpdateTime;
}
return analysesResults.reduce(function(lastUpdateTime, analysis) {
return analysis.getNodes().reduce(function(lastNodeUpdatedAtTime, node) {
var nodeUpdatedAtDate = node.getUpdatedAt();
var nodeUpdatedTimeAt = (nodeUpdatedAtDate && nodeUpdatedAtDate.getTime()) || 0;
return nodeUpdatedTimeAt > lastNodeUpdatedAtTime ? nodeUpdatedTimeAt : lastNodeUpdatedAtTime;
}, lastUpdateTime);
}, lastUpdateTime);
}
MapController.prototype.addAnalysesMetadata = function(username, layergroup, analysesResults, includeQuery) {
includeQuery = includeQuery || false;
analysesResults = analysesResults || [];
layergroup.metadata.analyses = [];
analysesResults.forEach(function(analysis) {
var nodes = analysis.getSortedNodes();
var nodes = analysis.getNodes();
layergroup.metadata.analyses.push({
nodes: nodes.reduce(function(nodesIdMap, node) {
if (node.params.id) {
var nodeResource = layergroup.layergroupid + '/analysis/node/' + node.id();
nodesIdMap[node.params.id] = {
var nodeRepr = {
status: node.getStatus(),
url: getUrls(username, nodeResource)
url: this.resourceLocator.getUrls(username, nodeResource)
};
if (includeQuery) {
nodesIdMap[node.params.id].query = node.getQuery();
nodeRepr.query = node.getQuery();
}
if (node.getStatus() === 'failed') {
nodeRepr.error_message = node.getErrorMessage();
}
nodesIdMap[node.params.id] = nodeRepr;
}
return nodesIdMap;
}, {})
}.bind(this), {})
});
});
}
}.bind(this));
};
// TODO this should take into account several URL patterns
function addDataviewsAndWidgetsUrls(username, layergroup, mapConfig) {
addDataviewsUrls(username, layergroup, mapConfig);
addWidgetsUrl(username, layergroup, mapConfig);
}
MapController.prototype.addDataviewsAndWidgetsUrls = function(username, layergroup, mapConfig) {
this.addDataviewsUrls(username, layergroup, mapConfig);
this.addWidgetsUrl(username, layergroup, mapConfig);
};
function addDataviewsUrls(username, layergroup, mapConfig) {
MapController.prototype.addDataviewsUrls = function(username, layergroup, mapConfig) {
layergroup.metadata.dataviews = layergroup.metadata.dataviews || {};
var dataviews = mapConfig.dataviews || {};
Object.keys(dataviews).forEach(function(dataviewName) {
var resource = layergroup.layergroupid + '/dataview/' + dataviewName;
layergroup.metadata.dataviews[dataviewName] = {
url: getUrls(username, resource)
url: this.resourceLocator.getUrls(username, resource)
};
});
}
}.bind(this));
};
function addWidgetsUrl(username, layergroup, mapConfig) {
MapController.prototype.addWidgetsUrl = function(username, layergroup, mapConfig) {
if (layergroup.metadata && Array.isArray(layergroup.metadata.layers) && Array.isArray(mapConfig.layers)) {
layergroup.metadata.layers = layergroup.metadata.layers.map(function(layer, layerIndex) {
var mapConfigLayer = mapConfig.layers[layerIndex];
@@ -375,26 +423,11 @@ function addWidgetsUrl(username, layergroup, mapConfig) {
var resource = layergroup.layergroupid + '/' + layerIndex + '/widget/' + widgetName;
layer.widgets[widgetName] = {
type: mapConfigLayer.options.widgets[widgetName].type,
url: getUrls(username, resource)
url: this.resourceLocator.getUrls(username, resource)
};
});
}.bind(this));
}
return layer;
});
}.bind(this));
}
}
function getUrls(username, resource) {
var cdnUrl = global.environment.serverMetadata && global.environment.serverMetadata.cdn_url;
if (cdnUrl) {
return {
http: 'http://' + cdnUrl.http + '/' + username + '/api/v1/map/' + resource,
https: 'https://' + cdnUrl.https + '/' + username + '/api/v1/map/' + resource
};
} else {
var port = global.environment.port;
return {
http: 'http://' + username + '.' + 'localhost.lan:' + port + '/api/v1/map/' + resource
};
}
}
};

View File

@@ -8,6 +8,7 @@ var BaseController = require('./base');
var cors = require('../middleware/cors');
var userMiddleware = require('../middleware/user');
var allowQueryParams = require('../middleware/allow-query-params');
function NamedMapsController(authApi, pgConnection, namedMapProviderCache, tileBackend, previewBackend,
surrogateKeysCache, tablesExtentApi, metadataBackend) {
@@ -31,7 +32,7 @@ NamedMapsController.prototype.register = function(app) {
this.tile.bind(this));
app.get(app.base_url_mapconfig +
'/static/named/:template_id/:width/:height.:format', cors(), userMiddleware,
'/static/named/:template_id/:width/:height.:format', cors(), userMiddleware, allowQueryParams(['layer']),
this.staticMap.bind(this));
};
@@ -100,9 +101,7 @@ NamedMapsController.prototype.tile = function(req, res) {
self.tileBackend.getTile(namedMapProvider, req.params, this);
},
function handleImage(err, tile, headers, stats) {
if (req.profiler) {
req.profiler.add(stats);
}
req.profiler.add(stats);
if (err) {
self.sendError(req, res, err, 'NAMED_MAP_TILE');
} else {
@@ -137,9 +136,15 @@ NamedMapsController.prototype.staticMap = function(req, res) {
this
);
},
function prepareImageOptions(err, _namedMapProvider) {
function prepareLayerVisibility(err, _namedMapProvider) {
assert.ifError(err);
namedMapProvider = _namedMapProvider;
self.prepareLayerFilterFromPreviewLayers(cdbUser, req, namedMapProvider, this);
},
function prepareImageOptions(err) {
assert.ifError(err);
self.getStaticImageOptions(cdbUser, req.params, namedMapProvider, this);
},
function getImage(err, imageOpts) {
@@ -170,10 +175,8 @@ NamedMapsController.prototype.staticMap = function(req, res) {
});
},
function handleImage(err, image, headers, stats) {
if (req.profiler) {
req.profiler.done('render-' + format);
req.profiler.add(stats || {});
}
req.profiler.done('render-' + format);
req.profiler.add(stats || {});
if (err) {
self.sendError(req, res, err, 'STATIC_VIZ_MAP');
@@ -184,6 +187,45 @@ NamedMapsController.prototype.staticMap = function(req, res) {
);
};
NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (user, req, namedMapProvider, callback) {
var self = this;
namedMapProvider.getTemplate(function (err, template) {
if (err) {
return callback(err);
}
if (!template || !template.view || !template.view.preview_layers) {
return callback();
}
var previewLayers = template.view.preview_layers;
var layerVisibilityFilter = [];
template.layergroup.layers.forEach(function (layer, index) {
if (previewLayers[''+index] !== false && previewLayers[layer.id] !== false) {
layerVisibilityFilter.push(''+index);
}
});
if (!layerVisibilityFilter.length) {
return callback();
}
// overwrites 'all' default filter
req.params.layer = layerVisibilityFilter.join(',');
// recreates the provider
self.namedMapProviderCache.get(
user,
req.params.template_id,
req.query.config,
req.query.auth_token,
req.params,
callback
);
});
};
var DEFAULT_ZOOM_CENTER = {
zoom: 1,
center: {

View File

@@ -91,9 +91,7 @@ NamedMapsAdminController.prototype.update = function(req, res) {
NamedMapsAdminController.prototype.retrieve = function(req, res) {
var self = this;
if (req.profiler) {
req.profiler.start('windshaft-cartodb.get_template');
}
req.profiler.start('windshaft-cartodb.get_template');
var cdbuser = req.context.user;
var tpl_id;
@@ -127,9 +125,7 @@ NamedMapsAdminController.prototype.retrieve = function(req, res) {
NamedMapsAdminController.prototype.destroy = function(req, res) {
var self = this;
if (req.profiler) {
req.profiler.start('windshaft-cartodb.delete_template');
}
req.profiler.start('windshaft-cartodb.delete_template');
var cdbuser = req.context.user;
var tpl_id;
@@ -154,9 +150,7 @@ NamedMapsAdminController.prototype.destroy = function(req, res) {
NamedMapsAdminController.prototype.list = function(req, res) {
var self = this;
if ( req.profiler ) {
req.profiler.start('windshaft-cartodb.get_template_list');
}
req.profiler.start('windshaft-cartodb.get_template_list');
var cdbuser = req.context.user;

View File

@@ -0,0 +1,9 @@
module.exports = function allowQueryParams(params) {
if (!Array.isArray(params)) {
throw new Error('allowQueryParams must receive an Array of params');
}
return function allowQueryParamsMiddleware(req, res, next) {
req.context.allowedQueryParams = params;
next();
};
};

View File

@@ -19,25 +19,38 @@ var rankedCategoriesQueryTpl = dot.template([
' SELECT {{=it._column}} AS category, {{=it._aggregation}} AS value,',
' row_number() OVER (ORDER BY {{=it._aggregation}} desc) as rank',
' FROM ({{=it._query}}) _cdb_aggregation_all',
' {{?it._aggregationColumn!==null}}WHERE {{=it._aggregationColumn}} IS NOT NULL{{?}}',
' GROUP BY {{=it._column}}',
' ORDER BY 2 DESC',
')'
].join('\n'));
var categoriesSummaryQueryTpl = dot.template([
'categories_summary AS(',
' SELECT count(1) categories_count, max(value) max_val, min(value) min_val',
var categoriesSummaryMinMaxQueryTpl = dot.template([
'categories_summary_min_max AS(',
' SELECT max(value) max_val, min(value) min_val',
' FROM categories',
')'
].join('\n'));
var categoriesSummaryCountQueryTpl = dot.template([
'categories_summary_count AS(',
' SELECT count(1) AS categories_count',
' FROM (',
' SELECT {{=it._column}} AS category',
' FROM ({{=it._query}}) _cdb_categories',
' GROUP BY {{=it._column}}',
' ) _cdb_categories_count',
')'
].join('\n'));
var rankedAggregationQueryTpl = dot.template([
'SELECT CAST(category AS text), value, false as agg, nulls_count, min_val, max_val, count, categories_count',
' FROM categories, summary, categories_summary',
' FROM categories, summary, categories_summary_min_max, categories_summary_count',
' WHERE rank < {{=it._limit}}',
'UNION ALL',
'SELECT \'Other\' category, sum(value), true as agg, nulls_count, min_val, max_val, count, categories_count',
' FROM categories, summary, categories_summary',
'SELECT \'Other\' category, {{=it._aggregationFn}}(value) as value, true as agg, nulls_count, min_val, max_val,',
' count, categories_count',
' FROM categories, summary, categories_summary_min_max, categories_summary_count',
' WHERE rank >= {{=it._limit}}',
'GROUP BY nulls_count, min_val, max_val, count, categories_count'
].join('\n'));
@@ -45,7 +58,7 @@ var rankedAggregationQueryTpl = dot.template([
var aggregationQueryTpl = dot.template([
'SELECT CAST({{=it._column}} AS text) AS category, {{=it._aggregation}} AS value, false as agg,',
' nulls_count, min_val, max_val, count, categories_count',
'FROM ({{=it._query}}) _cdb_aggregation_all, summary, categories_summary',
'FROM ({{=it._query}}) _cdb_aggregation_all, summary, categories_summary_min_max, categories_summary_count',
'GROUP BY category, nulls_count, min_val, max_val, count, categories_count',
'ORDER BY value DESC'
].join('\n'));
@@ -54,7 +67,10 @@ var CATEGORIES_LIMIT = 6;
var VALID_OPERATIONS = {
count: [],
sum: ['aggregationColumn']
sum: ['aggregationColumn'],
avg: ['aggregationColumn'],
min: ['aggregationColumn'],
max: ['aggregationColumn']
};
var TYPE = 'aggregation';
@@ -111,24 +127,10 @@ Aggregation.prototype.sql = function(psql, override, callback) {
var _query = this.query;
var aggregationSql;
if (!!override.ownFilter) {
aggregationSql = [
"WITH",
[
summaryQueryTpl({
_query: _query,
_column: this.column
}),
rankedCategoriesQueryTpl({
_query: _query,
_column: this.column,
_aggregation: this.getAggregationSql()
}),
categoriesSummaryQueryTpl({
_query: _query,
_column: this.column
})
].join(',\n'),
this.getCategoriesCTESql(_query, this.column, this.aggregation, this.aggregationColumn),
aggregationQueryTpl({
_query: _query,
_column: this.column,
@@ -138,25 +140,11 @@ Aggregation.prototype.sql = function(psql, override, callback) {
].join('\n');
} else {
aggregationSql = [
"WITH",
[
summaryQueryTpl({
_query: _query,
_column: this.column
}),
rankedCategoriesQueryTpl({
_query: _query,
_column: this.column,
_aggregation: this.getAggregationSql()
}),
categoriesSummaryQueryTpl({
_query: _query,
_column: this.column
})
].join(',\n'),
this.getCategoriesCTESql(_query, this.column, this.aggregation, this.aggregationColumn),
rankedAggregationQueryTpl({
_query: _query,
_column: this.column,
_aggregationFn: this.aggregation !== 'count' ? this.aggregation : 'sum',
_limit: CATEGORIES_LIMIT
})
].join('\n');
@@ -167,6 +155,32 @@ Aggregation.prototype.sql = function(psql, override, callback) {
return callback(null, aggregationSql);
};
Aggregation.prototype.getCategoriesCTESql = function(query, column, aggregation, aggregationColumn) {
return [
"WITH",
[
summaryQueryTpl({
_query: query,
_column: column
}),
rankedCategoriesQueryTpl({
_query: query,
_column: column,
_aggregation: this.getAggregationSql(),
_aggregationColumn: aggregation !== 'count' ? aggregationColumn : null
}),
categoriesSummaryMinMaxQueryTpl({
_query: query,
_column: column
}),
categoriesSummaryCountQueryTpl({
_query: query,
_column: column
})
].join(',\n')
].join('\n');
};
var aggregationFnQueryTpl = dot.template('{{=it._aggregationFn}}({{=it._aggregationColumn}})');
Aggregation.prototype.getAggregationSql = function() {
return aggregationFnQueryTpl({
@@ -198,6 +212,7 @@ Aggregation.prototype.format = function(result) {
}
return {
aggregation: this.aggregation,
count: count,
nulls: nulls,
min: minValue,

View File

@@ -11,7 +11,7 @@ var DataviewFactory = {
if (!this.dataviews[type]) {
throw new Error('Invalid dataview type: "' + type + '"');
}
return new this.dataviews[type](query, dataviewDefinition.options);
return new this.dataviews[type](query, dataviewDefinition.options, dataviewDefinition.sql);
}
};

View File

@@ -109,12 +109,13 @@ var TYPE = 'histogram';
}
}
*/
function Histogram(query, options) {
function Histogram(query, options, queries) {
if (!_.isString(options.column)) {
throw new Error('Histogram expects `column` in widget options');
}
this.query = query;
this.queries = queries;
this.column = options.column;
this.bins = options.bins;
@@ -143,7 +144,7 @@ Histogram.prototype.sql = function(psql, override, callback) {
var _column = this.column;
var columnTypeQuery = columnTypeQueryTpl({
column: _column, query: this.query
column: _column, query: this.queries.no_filters
});
if (this._columnType === null) {

View File

@@ -18,25 +18,37 @@ var rankedCategoriesQueryTpl = dot.template([
' SELECT {{=it._column}} AS category, {{=it._aggregation}} AS value,',
' row_number() OVER (ORDER BY {{=it._aggregation}} desc) as rank',
' FROM ({{=it._query}}) _cdb_aggregation_all',
' {{?it._aggregationColumn!==null}}WHERE {{=it._aggregationColumn}} IS NOT NULL{{?}}',
' GROUP BY {{=it._column}}',
' ORDER BY 2 DESC',
')'
].join('\n'));
var categoriesSummaryQueryTpl = dot.template([
'categories_summary AS(',
' SELECT count(1) categories_count, max(value) max_val, min(value) min_val',
var categoriesSummaryMinMaxQueryTpl = dot.template([
'categories_summary_min_max AS(',
' SELECT max(value) max_val, min(value) min_val',
' FROM categories',
')'
].join('\n'));
var categoriesSummaryCountQueryTpl = dot.template([
'categories_summary_count AS(',
' SELECT count(1) AS categories_count',
' FROM (',
' SELECT {{=it._column}} AS category',
' FROM ({{=it._query}}) _cdb_categories',
' GROUP BY {{=it._column}}',
' ) _cdb_categories_count',
')'
].join('\n'));
var rankedAggregationQueryTpl = dot.template([
'SELECT CAST(category AS text), value, false as agg, nulls_count, min_val, max_val, count, categories_count',
' FROM categories, summary, categories_summary',
' FROM categories, summary, categories_summary_min_max, categories_summary_count',
' WHERE rank < {{=it._limit}}',
'UNION ALL',
'SELECT \'Other\' category, sum(value), true as agg, nulls_count, min_val, max_val, count, categories_count',
' FROM categories, summary, categories_summary',
' FROM categories, summary, categories_summary_min_max, categories_summary_count',
' WHERE rank >= {{=it._limit}}',
'GROUP BY nulls_count, min_val, max_val, count, categories_count'
].join('\n'));
@@ -44,7 +56,7 @@ var rankedAggregationQueryTpl = dot.template([
var aggregationQueryTpl = dot.template([
'SELECT CAST({{=it._column}} AS text) AS category, {{=it._aggregation}} AS value, false as agg,',
' nulls_count, min_val, max_val, count, categories_count',
'FROM ({{=it._query}}) _cdb_aggregation_all, summary, categories_summary',
'FROM ({{=it._query}}) _cdb_aggregation_all, summary, categories_summary_min_max, categories_summary_count',
'GROUP BY category, nulls_count, min_val, max_val, count, categories_count',
'ORDER BY value DESC'
].join('\n'));
@@ -65,7 +77,7 @@ Aggregation.prototype.constructor = Aggregation;
module.exports = Aggregation;
Aggregation.prototype.sql = function(psql, filters, override, callback) {
Aggregation.prototype.sql = function(psql, override, callback) {
if (!callback) {
callback = override;
override = {};
@@ -85,9 +97,14 @@ Aggregation.prototype.sql = function(psql, filters, override, callback) {
rankedCategoriesQueryTpl({
_query: _query,
_column: this.column,
_aggregation: this.getAggregationSql()
_aggregation: this.getAggregationSql(),
_aggregationColumn: this.aggregation !== 'count' ? this.aggregationColumn : null
}),
categoriesSummaryQueryTpl({
categoriesSummaryMinMaxQueryTpl({
_query: _query,
_column: this.column
}),
categoriesSummaryCountQueryTpl({
_query: _query,
_column: this.column
})
@@ -110,9 +127,14 @@ Aggregation.prototype.sql = function(psql, filters, override, callback) {
rankedCategoriesQueryTpl({
_query: _query,
_column: this.column,
_aggregation: this.getAggregationSql()
_aggregation: this.getAggregationSql(),
_aggregationColumn: this.aggregation !== 'count' ? this.aggregationColumn : null
}),
categoriesSummaryQueryTpl({
categoriesSummaryMinMaxQueryTpl({
_query: _query,
_column: this.column
}),
categoriesSummaryCountQueryTpl({
_query: _query,
_column: this.column
})

View File

@@ -55,20 +55,20 @@ BaseOverviewsDataview.prototype.rewrittenQuery = function(query) {
};
// Default behaviour
BaseOverviewsDataview.prototype.defaultSql = function(psql, filters, override, callback) {
BaseOverviewsDataview.prototype.defaultSql = function(psql, override, callback) {
var query = this.query;
var dataview = this.baseDataview;
if ( SETTINGS.defaultOverviews ) {
query = this.rewrittenQuery(query);
dataview = new this.BaseDataview(query, this.queryOptions);
}
return dataview.sql(psql, filters, override, callback);
return dataview.sql(psql, override, callback);
};
// default implementation that can be override in derived classes:
BaseOverviewsDataview.prototype.sql = function(psql, filters, override, callback) {
return this.defaultSql(psql, filters, override, callback);
BaseOverviewsDataview.prototype.sql = function(psql, override, callback) {
return this.defaultSql(psql, override, callback);
};
BaseOverviewsDataview.prototype.search = function(psql, userQuery, callback) {

View File

@@ -14,7 +14,8 @@ OverviewsDataviewFactory.prototype.getDataview = function(query, dataviewDefinit
return parentFactory.getDataview(query, dataviewDefinition);
}
return new dataviews[type](
query, dataviewDefinition.options, this.queryRewriter, this.queryRewriteData, this.options
query, dataviewDefinition.options, this.queryRewriter, this.queryRewriteData, this.options,
dataviewDefinition.sql
);
};

View File

@@ -36,7 +36,7 @@ Formula.prototype.constructor = Formula;
module.exports = Formula;
Formula.prototype.sql = function(psql, filters, override, callback) {
Formula.prototype.sql = function(psql, override, callback) {
var formulaQueryTpl = formulaQueryTpls[this.operation];
if ( formulaQueryTpl ) {
@@ -52,5 +52,5 @@ Formula.prototype.sql = function(psql, filters, override, callback) {
}
// default behaviour
return this.defaultSql(psql, filters, override, callback);
return this.defaultSql(psql, override, callback);
};

View File

@@ -8,7 +8,6 @@ dot.templateSettings.strip = false;
var columnTypeQueryTpl = dot.template(
'SELECT pg_typeof({{=it.column}})::oid FROM ({{=it.query}}) _cdb_histogram_column_type limit 1'
);
var columnCastTpl = dot.template("date_part('epoch', {{=it.column}})");
var BIN_MIN_NUMBER = 6;
var BIN_MAX_NUMBER = 48;
@@ -97,10 +96,11 @@ var histogramQueryTpl = dot.template([
'ORDER BY bin'
].join('\n'));
function Histogram(query, options, queryRewriter, queryRewriteData, params) {
function Histogram(query, options, queryRewriter, queryRewriteData, params, queries) {
BaseOverviewsDataview.call(this, query, options, BaseDataview, queryRewriter, queryRewriteData, params);
this.query = query;
this.queries = queries;
this.column = options.column;
this.bins = options.bins;
@@ -130,7 +130,7 @@ Histogram.prototype.sql = function(psql, override, callback) {
var _column = this.column;
var columnTypeQuery = columnTypeQueryTpl({
column: _column, query: this.rewrittenQuery(this.query)
column: _column, query: this.rewrittenQuery(this.queries.no_filters)
});
if (this._columnType === null) {
@@ -149,7 +149,9 @@ Histogram.prototype.sql = function(psql, override, callback) {
}
if (this._columnType === 'date') {
_column = columnCastTpl({column: _column});
// overviews currently aggregate dates to NULL
// to avoid problem we don't use overviews for histograms of date columns
return this.defaultSql(psql, override, callback);
}
var _query = this.rewrittenQuery(this.query);

View File

@@ -1,6 +1,6 @@
var filters = {
category: require('./camshaft/category'),
range: require('./camshaft/range')
category: require('./analysis/category'),
range: require('./analysis/range')
};
function createFilter(filterDefinition) {
@@ -11,11 +11,11 @@ function createFilter(filterDefinition) {
return new filters[filterType](filterDefinition.column, filterDefinition.params);
}
function CamshaftFilters(filters) {
function AnalysisFilters(filters) {
this.filters = filters;
}
CamshaftFilters.prototype.sql = function(rawSql) {
AnalysisFilters.prototype.sql = function(rawSql) {
var filters = this.filters || {};
var applyFilters = {};
@@ -32,4 +32,4 @@ CamshaftFilters.prototype.sql = function(rawSql) {
}, rawSql);
};
module.exports = CamshaftFilters;
module.exports = AnalysisFilters;

View File

@@ -6,7 +6,7 @@ dot.templateSettings.strip = false;
var filterQueryTpl = dot.template([
'SELECT *',
'FROM ({{=it._sql}}) _camshaft_category_filter',
'FROM ({{=it._sql}}) _analysis_category_filter',
'WHERE {{=it._filters}}'
].join('\n'));
var escapeStringTpl = dot.template('$escape_{{=it._i}}${{=it._value}}$escape_{{=it._i}}$');

View File

@@ -6,7 +6,7 @@ dot.templateSettings.strip = false;
var betweenFilterTpl = dot.template('{{=it._column}} BETWEEN {{=it._min}} AND {{=it._max}}');
var minFilterTpl = dot.template('{{=it._column}} >= {{=it._min}}');
var maxFilterTpl = dot.template('{{=it._column}} <= {{=it._max}}');
var filterQueryTpl = dot.template('SELECT * FROM ({{=it._sql}}) _camshaft_range_filter WHERE {{=it._filter}}');
var filterQueryTpl = dot.template('SELECT * FROM ({{=it._sql}}) _analysis_range_filter WHERE {{=it._filter}}');
function Range(column, filterParams) {
this.column = column;

View File

@@ -59,10 +59,23 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfi
requestMapConfig = appendFiltersToNodes(requestMapConfig, dataviewsFiltersBySourceId);
function createAnalysis(analysisDefinition, done) {
self.analysisBackend.create(analysisConfiguration, analysisDefinition, done);
self.analysisBackend.create(analysisConfiguration, analysisDefinition, function (err, analysis) {
if (err) {
var error = new Error(err.message);
error.type = 'analysis';
error.analysis = {
id: analysisDefinition.id,
node_id: err.node_id,
type: analysisDefinition.type
};
return done(error);
}
done(null, analysis);
});
}
var analysesQueue = queue(requestMapConfig.analyses.length);
var analysesQueue = queue(1);
requestMapConfig.analyses.forEach(function(analysis) {
analysesQueue.defer(createAnalysis, analysis);
});
@@ -78,7 +91,7 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfi
sourceId2Query[rootNode.params.id] = rootNode;
}
analysis.getSortedNodes().forEach(function(node) {
analysis.getNodes().forEach(function(node) {
if (node.params && node.params.id) {
sourceId2Query[node.params.id] = node;
}
@@ -111,12 +124,37 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfi
return layer;
});
debug('mapconfig output', JSON.stringify(requestMapConfig, null, 4));
if (missingNodesErrors.length > 0) {
return callback(missingNodesErrors);
var missingDataviewsNodesErrors = getMissingDataviewsSourceIds(dataviews, sourceId2Node);
if (missingNodesErrors.length > 0 || missingDataviewsNodesErrors.length > 0) {
return callback(missingNodesErrors.concat(missingDataviewsNodesErrors));
}
// Augment dataviews with sql from analyses
Object.keys(dataviews).forEach(function(dataviewName) {
var dataview = requestMapConfig.dataviews[dataviewName];
var dataviewSourceId = dataview.source.id;
var dataviewNode = sourceId2Node[dataviewSourceId];
dataview.node = {
type: dataviewNode.type,
filters: dataviewNode.getFilters()
};
dataview.sql = {
own_filter_on: dataviewQuery(dataviewNode, dataviewName, true),
own_filter_off: dataviewQuery(dataviewNode, dataviewName, false),
no_filters: dataviewNode.getQuery(Object.keys(dataviewNode.getFilters())
.reduce(function(applyFilters, filterId) {
applyFilters[filterId] = false;
return applyFilters;
}, {})
)
};
});
if (Object.keys(dataviews).length > 0) {
requestMapConfig.dataviews = dataviews;
}
debug('mapconfig output', JSON.stringify(requestMapConfig, null, 4));
context.analysesResults = analysesResults;
return callback(null, requestMapConfig);
@@ -133,7 +171,7 @@ function skipColumns(columnNames) {
.filter(function(columnName) { return !SKIP_COLUMNS[columnName]; });
}
var layerQueryTemplate = dot.template([
var wrappedQueryTpl = dot.template([
'SELECT {{=it._columns}}',
'FROM ({{=it._query}}) _cdb_analysis_query'
].join('\n'));
@@ -143,7 +181,20 @@ function layerQuery(node) {
return node.getQuery();
}
var _columns = ['ST_Transform(the_geom, 3857) the_geom_webmercator'].concat(skipColumns(node.getColumns()));
return layerQueryTemplate({ _query: node.getQuery(), _columns: _columns.join(', ') });
return wrappedQueryTpl({ _query: node.getQuery(), _columns: _columns.join(', ') });
}
function dataviewQuery(node, dataviewName, ownFilter) {
var applyFilters = {};
if (!ownFilter) {
applyFilters[dataviewName] = false;
}
if (node.type === 'source') {
return node.getQuery(applyFilters);
}
var _columns = ['ST_Transform(the_geom, 3857) the_geom_webmercator'].concat(skipColumns(node.getColumns()));
return wrappedQueryTpl({ _query: node.getQuery(applyFilters), _columns: _columns.join(', ') });
}
function appendFiltersToNodes(requestMapConfig, dataviewsFiltersBySourceId) {
@@ -163,8 +214,9 @@ function appendFiltersToNodes(requestMapConfig, dataviewsFiltersBySourceId) {
}
function shouldAdaptLayers(requestMapConfig) {
return Array.isArray(requestMapConfig.layers) &&
Array.isArray(requestMapConfig.analyses) && requestMapConfig.analyses.length > 0;
return Array.isArray(requestMapConfig.layers) && requestMapConfig.layers.some(getLayerSourceId) ||
(Array.isArray(requestMapConfig.analyses) && requestMapConfig.analyses.length > 0) ||
requestMapConfig.dataviews;
}
var DATAVIEW_TYPE_2_FILTER_TYPE = {
@@ -256,3 +308,26 @@ function getDataviewsErrors(dataviews) {
return errors;
}
function getMissingDataviewsSourceIds(dataviews, sourceId2Node) {
var missingDataviewsSourceIds = [];
Object.keys(dataviews).forEach(function(dataviewName) {
var dataview = dataviews[dataviewName];
var dataviewSourceId = getDataviewSourceId(dataview);
if (!sourceId2Node.hasOwnProperty(dataviewSourceId)) {
missingDataviewsSourceIds.push(new AnalysisError('Node with `source.id="' + dataviewSourceId +'"`' +
' not found in analyses for dataview "' + dataviewName + '"'));
}
});
return missingDataviewsSourceIds;
}
function AnalysisError(message) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.type = 'analysis';
this.message = message;
}
require('util').inherits(AnalysisError, Error);

View File

@@ -33,7 +33,7 @@ MapConfigOverviewsAdapter.prototype.getMapConfig = function(user, requestMapConf
step(
function collectFiltersData() {
var filters, unfiltered_query;
if ( layer.options.source && analysesResults ) {
if ( layer.options.source && analysesResults && !layer.options.sql_wrap) {
var sourceId = layer.options.source.id;
var node = _.find(analysesResults, function(a){ return a.rootNode.params.id === sourceId; });
if ( node ) {

View File

@@ -3,10 +3,22 @@
var dot = require('dot');
dot.templateSettings.strip = false;
var queue = require('queue-async');
var SubstitutionTokens = require('../../../utils/substitution-tokens');
var PSQL = require('cartodb-psql');
/**
* cartodb-psql creates `global.Promise` as an empty constructor.
* However, `turbo-carto` relies on a polyfil that fails to create the polyfil
* as it finds `global.Promise` but it doesn't find `Promise.resolve`.
*/
global.Promise = global.Promise || function() {};
global.Promise.resolve = global.Promise.resolve || function() {};
var turboCarto = require('turbo-carto');
function TurboCartoAdapter(turboCartoParser) {
this.turboCartoParser = turboCartoParser;
var SubstitutionTokens = require('../../../utils/substitution-tokens');
var PostgresDatasource = require('../../../backends/turbo-carto-postgres-datasource');
var MapConfig = require('windshaft').model.MapConfig;
function TurboCartoAdapter() {
}
module.exports = TurboCartoAdapter;
@@ -22,38 +34,116 @@ TurboCartoAdapter.prototype.getMapConfig = function (user, requestMapConfig, par
var parseCartoQueue = queue(layers.length);
layers.forEach(function(layer) {
parseCartoQueue.defer(self._parseCartoCss.bind(self), user, layer);
layers.forEach(function(layer, index) {
var layerId = MapConfig.getLayerId(requestMapConfig, index);
parseCartoQueue.defer(self._parseCartoCss.bind(self), user, params, layer, index, layerId);
});
parseCartoQueue.awaitAll(function (err, layers) {
parseCartoQueue.awaitAll(function (err, results) {
if (err) {
return callback(err);
}
requestMapConfig.layers = layers;
var errors = results.reduce(function(errors, result) {
if (result.error) {
errors.push(result.error);
}
return errors;
}, []);
if (errors.length > 0) {
return callback(errors);
}
requestMapConfig.layers = results.map(function(result) { return result.layer; });
context.turboCarto = {
layers: results.map(function(result) {
return result.meta;
})
};
return callback(null, requestMapConfig);
});
};
var bboxTemplate = dot.template('(select ST_SetSRID(st_extent(the_geom_webmercator), 3857) from ({{=it._sql}}) __c)');
var zoomTemplate = dot.template([
'GREATEST(',
'ceil(log(40075017000 / 256 / GREATEST(',
' st_xmax({{=it._bbox}}) - st_xmin({{=it._bbox}}),',
' st_ymax({{=it._bbox}}) - st_ymin({{=it._bbox}})',
'))/log(2)),',
'0',
')'
var tokensQueryTpl = dot.template([
'WITH input_query AS (',
' {{=it._sql}}',
'),',
'bbox_query AS (',
' SELECT ST_SetSRID(ST_Extent(the_geom_webmercator), 3857) as bbox from input_query',
'),',
'zoom_query as (',
' SELECT GREATEST(',
' ceil(log(40075017000 / 256 / GREATEST(ST_XMax(bbox) - ST_XMin(bbox), ST_YMax(bbox) - ST_YMin(bbox)))/log(2)),',
' 0) as zoom',
' FROM bbox_query',
'),',
'pixel_size_query as (',
' SELECT 40075017 * cos(radians(ST_Y(ST_Transform(ST_Centroid(bbox), 4326)))) / 2 ^ ((zoom) + 8) as pixel_size',
' FROM bbox_query, zoom_query',
'),',
'scale_denominator_query as (',
' SELECT (pixel_size / 0.00028)::numeric as scale_denominator',
' FROM pixel_size_query',
')',
'select ST_AsText(bbox) bbox, pixel_size, scale_denominator, zoom',
'from bbox_query, pixel_size_query, scale_denominator_query, zoom_query'
].join('\n'));
var pixelSizeTemplate = dot.template('40075017 * cos(ST_Y(ST_Centroid({{=it._bbox}}))) / 2 ^ (({{=it._zoom}}) + 8)');
var scaleDenominatorTemplate = dot.template('({{=it._pixelSize}} / 0.00028)::numeric');
TurboCartoAdapter.prototype._parseCartoCss = function (username, layer, callback) {
TurboCartoAdapter.prototype._parseCartoCss = function (username, params, layer, layerIndex, layerId, callback) {
if (!shouldParseLayerCartocss(layer)) {
return callback(null, layer);
return callback(null, { layer: layer });
}
var pg = new PSQL(dbParamsFromReqParams(params));
function processCallback(err, cartocss, meta) {
// Only return turbo-carto errors
if (err && err.name === 'TurboCartoError') {
var error = new Error(err.message);
error.http_status = 400;
error.type = 'layer';
error.subtype = 'turbo-carto';
error.layer = {
id: layerId,
index: layerIndex,
type: layer.type,
context: err.context
};
return callback(null, { error: error });
}
// Try to continue in the rest of the cases
if (cartocss) {
layer.options.cartocss = cartocss;
}
return callback(null, { layer: layer, meta: meta });
}
var layerSql = layer.options.sql;
var layerRawSql = layer.options.sql_raw;
if (SubstitutionTokens.hasTokens(layerSql) && layerRawSql) {
var self = this;
var tokensQuery = tokensQueryTpl({_sql: layerRawSql});
return pg.query(tokensQuery, function(err, resultSet) {
if (err) {
return processCallback(err);
}
resultSet = resultSet || {};
var rows = resultSet.rows || [];
var result = rows[0] || {};
var tokens = {
bbox: 'ST_SetSRID(ST_GeomFromText(\'' + result.bbox + '\'), 3857)',
scale_denominator: result.scale_denominator,
pixel_width: result.pixel_size,
pixel_height: result.pixel_size
};
var sql = SubstitutionTokens.replace(layerSql, tokens);
self.process(pg, layer.options.cartocss, sql, processCallback);
}, true); // use read-only transaction
}
var tokens = {
@@ -63,40 +153,35 @@ TurboCartoAdapter.prototype._parseCartoCss = function (username, layer, callback
pixel_height: '156412'
};
var layerSql = layer.options.sql;
var layerRawSql = layer.options.sql_raw;
if (SubstitutionTokens.hasTokens(layerSql) && layerRawSql) {
var bbox = bboxTemplate({ _sql: layerRawSql });
var zoom = zoomTemplate({ _bbox: bbox });
var pixelSize = pixelSizeTemplate({ _bbox: bbox, _zoom: zoom });
var scaleDenominator = scaleDenominatorTemplate({ _pixelSize: pixelSize });
tokens = {
bbox: bbox,
scale_denominator: scaleDenominator,
pixel_width: pixelSize,
pixel_height: pixelSize
};
}
var sql = SubstitutionTokens.replace(layerSql, tokens);
this.process(pg, layer.options.cartocss, sql, processCallback);
};
this.turboCartoParser.process(username, layer.options.cartocss, sql, function (err, cartocss) {
// Only return turbo-carto errors
if (err && err.name === 'TurboCartoError') {
err = new Error('turbo-carto: ' + err.message);
err.http_status = 400;
return callback(err);
}
// Try to continue in the rest of the cases
if (cartocss) {
layer.options.cartocss = cartocss;
}
return callback(null, layer);
});
TurboCartoAdapter.prototype.process = function (psql, cartocss, sql, callback) {
var datasource = new PostgresDatasource(psql, sql);
turboCarto(cartocss, datasource, callback);
};
function shouldParseLayerCartocss(layer) {
return layer && layer.options && layer.options.cartocss && layer.options.sql;
}
function dbParamsFromReqParams(params) {
var dbParams = {};
if ( params.dbuser ) {
dbParams.user = params.dbuser;
}
if ( params.dbpassword ) {
dbParams.pass = params.dbpassword;
}
if ( params.dbhost ) {
dbParams.host = params.dbhost;
}
if ( params.dbport ) {
dbParams.port = params.dbport;
}
if ( params.dbname ) {
dbParams.dbname = params.dbname;
}
return dbParams;
}

View File

@@ -95,6 +95,7 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
function prepareAdapterMapConfig(err, requestMapConfig) {
assert.ifError(err);
context.analysisConfiguration = {
user: self.owner,
db: {
host: rendererParams.dbhost,
port: rendererParams.dbport,
@@ -119,6 +120,7 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
self.mapConfig = (mapConfig === null) ? null : new MapConfig(mapConfig, context.datasource);
self.analysesResults = context.analysesResults || [];
self.rendererParams = rendererParams;
self.context = context;
self.context.limits = renderLimits || {};
return callback(self.err, self.mapConfig, self.rendererParams, self.context);
}

View File

@@ -0,0 +1,119 @@
var dot = require('dot');
dot.templateSettings.strip = false;
function ResourceLocator(environment) {
this.environment = environment;
this.resourcesUrlTemplates = null;
if (this.environment.resources_url_templates) {
var templates = environment.resources_url_templates;
if (templates.http) {
this.resourcesUrlTemplates = this.resourcesUrlTemplates || {};
this.resourcesUrlTemplates.http = dot.template(templates.http + '/{{=it.resource}}');
}
if (templates.https) {
this.resourcesUrlTemplates = this.resourcesUrlTemplates || {};
this.resourcesUrlTemplates.https = dot.template(templates.https + '/{{=it.resource}}');
}
}
}
module.exports = ResourceLocator;
ResourceLocator.prototype.getUrls = function(username, resource) {
if (this.resourcesUrlTemplates) {
return this.getUrlsFromTemplate(username, resource);
}
var cdnDomain = getCdnDomain(this.environment.serverMetadata, resource);
if (cdnDomain) {
return {
http: 'http://' + cdnDomain.http + '/' + username + '/api/v1/map/' + resource,
https: 'https://' + cdnDomain.https + '/' + username + '/api/v1/map/' + resource
};
} else {
var port = this.environment.port;
return {
http: 'http://' + username + '.' + 'localhost.lan:' + port + '/api/v1/map/' + resource
};
}
};
ResourceLocator.prototype.getUrlsFromTemplate = function(username, resource) {
var urls = {};
var cdnDomain = getCdnDomain(this.environment.serverMetadata, resource) || {};
if (this.resourcesUrlTemplates.http) {
urls.http = this.resourcesUrlTemplates.http({
cdn_url: cdnDomain.http,
user: username,
port: this.environment.port,
resource: resource
});
}
if (this.resourcesUrlTemplates.https) {
urls.https = this.resourcesUrlTemplates.https({
cdn_url: cdnDomain.https,
user: username,
port: this.environment.port,
resource: resource
});
}
return urls;
};
function getCdnDomain(serverMetadata, resource) {
if (serverMetadata && serverMetadata.cdn_url) {
var cdnUrl = serverMetadata.cdn_url;
var http = cdnUrl.http;
var https = cdnUrl.https;
if (cdnUrl.templates) {
var templates = cdnUrl.templates;
var httpUrlTemplate = templates.http.url;
var httpsUrlTemplate = templates.https.url;
http = httpUrlTemplate
.replace(/^(http[s]*:\/\/)/, '')
.replace('{s}', subdomain(templates.http.subdomains, resource));
https = httpsUrlTemplate
.replace(/^(http[s]*:\/\/)/, '')
.replace('{s}', subdomain(templates.https.subdomains, resource));
}
return {
http: http,
https: https,
};
}
return null;
}
// ref https://jsperf.com/js-crc32
function crcTable() {
var c;
var table = [];
for (var n = 0; n < 256; n++) {
c = n;
for (var k = 0; k < 8; k++) {
c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
}
table[n] = c;
}
return table;
}
var CRC_TABLE = crcTable();
function crc32(str) {
var crc = 0 ^ (-1);
for (var i = 0; i < str.length; i++) {
crc = (crc >>> 8) ^ CRC_TABLE[(crc ^ str.charCodeAt(i)) & 0xFF];
}
return (crc ^ (-1)) >>> 0;
}
function subdomain(subdomains, resource) {
var index = crc32(resource) % subdomains.length;
return subdomains[index];
}
module.exports.subdomain = subdomain;

View File

@@ -33,8 +33,6 @@ var AnalysisBackend = require('./backends/analysis');
var timeoutErrorTilePath = __dirname + '/../../assets/render-timeout-fallback.png';
var timeoutErrorTile = require('fs').readFileSync(timeoutErrorTilePath, {encoding: null});
var TurboCartoParser = require('./utils/style/turbo-carto-parser');
var SqlWrapMapConfigAdapter = require('./models/mapconfig/adapter/sql-wrap-mapconfig-adapter');
var MapConfigNamedLayersAdapter = require('./models/mapconfig/adapter/mapconfig-named-layers-adapter');
var AnalysisMapConfigAdapter = require('./models/mapconfig/adapter/analysis-mapconfig-adapter');
@@ -149,20 +147,19 @@ module.exports = function(serverOptions) {
var tileBackend = new windshaft.backend.Tile(rendererCache);
var mapValidatorBackend = new windshaft.backend.MapValidator(tileBackend, attributesBackend);
var mapBackend = new windshaft.backend.Map(rendererCache, mapStore, mapValidatorBackend);
var analysisBackend = new AnalysisBackend(serverOptions.analysis);
var analysisBackend = new AnalysisBackend(metadataBackend, serverOptions.analysis);
var layergroupAffectedTablesCache = new LayergroupAffectedTablesCache();
app.layergroupAffectedTablesCache = layergroupAffectedTablesCache;
var turboCartoParser = new TurboCartoParser(pgQueryRunner);
var mapConfigAdapter = new MapConfigAdapter(
new MapConfigNamedLayersAdapter(templateMaps, pgConnection),
new SqlWrapMapConfigAdapter(),
new DataviewsWidgetsAdapter(),
new AnalysisMapConfigAdapter(analysisBackend),
new MapConfigOverviewsAdapter(overviewsMetadataApi, filterStatsApi),
new TurboCartoAdapter(turboCartoParser)
new TurboCartoAdapter()
);
var namedMapProviderCache = new NamedMapProviderCache(
@@ -226,6 +223,8 @@ module.exports = function(serverOptions) {
new controller.NamedMapsAdmin(authApi, pgConnection, templateMaps).register(app);
new controller.Analyses(authApi, pgConnection).register(app);
new controller.ServerInfo(versions).register(app);
/*******************************************************************************************************************

View File

@@ -36,7 +36,11 @@ var analysisConfig = _.defaults(global.environment.analysis || {}, {
inlineExecution: false,
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
}
},
logger: {
filename: undefined
},
limits: {}
});
module.exports = {
@@ -66,6 +70,7 @@ module.exports = {
},
datasource: global.environment.postgres,
cachedir: global.environment.millstone.cache_basedir,
use_workers: rendererConfig.mapnik.useCartocssWorkers || false,
mapnik_version: global.environment.mapnik_version,
mapnik_tile_format: global.environment.mapnik_tile_format || 'png',
default_layergroup_ttl: global.environment.mapConfigTTL || 7200
@@ -95,7 +100,11 @@ module.exports = {
inlineExecution: analysisConfig.batch.inlineExecution,
endpoint: analysisConfig.batch.endpoint,
hostHeaderTemplate: analysisConfig.batch.hostHeaderTemplate
}
},
logger: {
filename: analysisConfig.logger.filename
},
limits: analysisConfig.limits
},
// Do not send unwatch on release. See http://github.com/CartoDB/Windshaft-cartodb/issues/161
redis: _.extend(global.environment.redis, {unwatchOnRelease: false}),

View File

@@ -2,7 +2,7 @@ var _ = require('underscore');
var TableNameParser = require('./table_name_parser');
var BBoxFilter = require('../models/filter/bbox');
var CamshaftFilter = require('../models/filter/camshaft');
var AnalysisFilter = require('../models/filter/analysis');
// Minimim number of filtered rows to use overviews
var FILTER_MIN_ROWS = 65536;
@@ -11,8 +11,8 @@ var FILTER_MAX_FRACTION = 0.2;
function apply_filters_to_query(query, filters, bbox_filter) {
if ( filters && !_.isEmpty(filters)) {
var camshaftFilter = new CamshaftFilter(filters);
query = camshaftFilter.sql(query);
var analysisFilter = new AnalysisFilter(filters);
query = analysisFilter.sql(query);
}
if ( bbox_filter ) {
var bboxFilter = new BBoxFilter(bbox_filter.options, bbox_filter.params);

View File

@@ -1,15 +0,0 @@
'use strict';
var turboCarto = require('turbo-carto');
var PostgresDatasource = require('./postgres-datasource');
function TurboCartoParser (pgQueryRunner) {
this.pgQueryRunner = pgQueryRunner;
}
module.exports = TurboCartoParser;
TurboCartoParser.prototype.process = function (username, cartocss, sql, callback) {
var datasource = new PostgresDatasource(this.pgQueryRunner, username, sql);
turboCarto(cartocss, datasource, callback);
};

4049
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "windshaft-cartodb",
"version": "2.47.0",
"version": "3.4.0",
"description": "A map tile server for CartoDB",
"keywords": [
"cartodb"
@@ -20,33 +20,34 @@
],
"dependencies": {
"body-parser": "~1.14.0",
"camshaft": "0.14.0",
"cartodb-psql": "~0.6.1",
"cartodb-query-tables": "~0.1.0",
"cartodb-redis": "~0.13.0",
"camshaft": "0.51.0",
"cartodb-psql": "~0.7.1",
"cartodb-query-tables": "0.2.0",
"cartodb-redis": "0.13.2",
"debug": "~2.2.0",
"dot": "~1.0.2",
"express": "~4.13.3",
"fastly-purge": "~1.0.1",
"log4js": "https://github.com/CartoDB/log4js-node/tarball/cdb",
"log4js": "cartodb/log4js-node#cdb",
"lru-cache": "2.6.5",
"lzma": "~1.3.7",
"lzma": "~2.3.2",
"node-statsd": "~0.0.7",
"queue-async": "~1.0.7",
"redis-mpool": "~0.4.0",
"request": "~2.62.0",
"redis-mpool": "0.4.1",
"request": "~2.79.0",
"step": "~0.0.6",
"step-profiler": "~0.3.0",
"turbo-carto": "0.11.0",
"turbo-carto": "0.19.0",
"underscore": "~1.6.0",
"windshaft": "2.3.0"
"windshaft": "3.1.0",
"yargs": "~5.0.0"
},
"devDependencies": {
"istanbul": "~0.4.3",
"jshint": "~2.6.0",
"mocha": "~1.21.4",
"nock": "~2.11.0",
"redis": "~0.8.6",
"redis": "~0.12.1",
"semver": "~1.1.4",
"strftime": "~0.8.2"
},
@@ -55,7 +56,7 @@
"test": "make test-all"
},
"engines": {
"node": ">=0.8 <0.11",
"npm": ">=2.14.16"
"node": ">=6.9",
"yarn": "^0.21.3"
}
}

View File

@@ -4,4 +4,4 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
fi
npm install
yarn

View File

@@ -202,7 +202,7 @@ describe('analysis-layers', function() {
assert.equal(analyses.length, 1, 'Invalid number of analyses in metadata');
var nodes = analyses[0].nodes;
var nodesIds = Object.keys(nodes);
assert.deepEqual(nodesIds, ['2570e105-7b37-40d2-bdf4-1af889598745', 'HEAD']);
assert.deepEqual(nodesIds, ['HEAD', '2570e105-7b37-40d2-bdf4-1af889598745']);
nodesIds.forEach(function(nodeId) {
var node = nodes[nodeId];
assert.ok(node.hasOwnProperty('url'), 'Missing "url" attribute in node');

View File

@@ -20,6 +20,13 @@ describe('analysis-layers error cases', function() {
}
};
var AUTH_ERROR_RESPONSE = {
status: 403,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
};
it('should handle missing analysis nodes for layers', function(done) {
var mapConfig = createMapConfig(
[
@@ -64,4 +71,307 @@ describe('analysis-layers error cases', function() {
testClient.drain(done);
});
});
it('should handle missing analyses when layers point to nonexistent one', function(done) {
var mapConfig = createMapConfig(
[
{
"type": "http",
"options": {
"urlTemplate": "http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png",
"subdomains": "abcd"
}
},
{
"type": "cartodb",
"options": {
"source": {
"id": "ID-FOR-NONEXISTENT-ANALYSIS"
},
"cartocss": '#polygons { polygon-fill: red; }',
"cartocss_version": "2.3.0"
}
}
]
);
var testClient = new TestClient(mapConfig, 1234);
testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroupResult) {
assert.ok(!err, err);
assert.equal(layergroupResult.errors.length, 1);
assert.equal(
layergroupResult.errors[0],
'Missing analysis node.id="ID-FOR-NONEXISTENT-ANALYSIS" for layer=1'
);
testClient.drain(done);
});
});
it('should handle missing analyses when dataviews point to nonexistent one', function(done) {
var mapConfig = createMapConfig(
[
{
"type": "http",
"options": {
"urlTemplate": "http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png",
"subdomains": "abcd"
}
},
{
"type": "cartodb",
"options": {
"sql": "select * from populated_places_simple_reduced",
"cartocss": '#polygons { polygon-fill: red; }',
"cartocss_version": "2.3.0"
}
}
],
{
pop_max_histogram: {
source: {
id: 'ID-FOR-NONEXISTENT-ANALYSIS'
},
type: 'histogram',
options: {
column: 'pop_max'
}
}
}
);
var testClient = new TestClient(mapConfig, 1234);
testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroupResult) {
assert.ok(!err, err);
assert.equal(layergroupResult.errors.length, 1);
assert.equal(layergroupResult.errors[0], 'Node with `source.id="ID-FOR-NONEXISTENT-ANALYSIS"`' +
' not found in analyses for dataview "pop_max_histogram"');
testClient.drain(done);
});
});
it('camshaft: should return error missing analysis nodes for layers with some context', function(done) {
var mapConfig = createMapConfig(
[
{
"type": "cartodb",
"options": {
"source": {
"id": "HEAD"
},
"cartocss": '#polygons { polygon-fill: red; }',
"cartocss_version": "2.3.0"
}
}
],
{},
[
{
"id": "HEAD",
"type": "buffer",
"params": {
"source": {
"id": "HEAD",
"type": "source",
"params": {
"query": "select * from populated_places_simple_reduced"
}
},
"radius": 50000
}
}
]
);
var testClient = new TestClient(mapConfig, 11111);
testClient.getLayergroup(AUTH_ERROR_RESPONSE, function(err, layergroupResult) {
assert.ok(!err, err);
assert.equal(layergroupResult.errors.length, 1);
assert.equal(
layergroupResult.errors[0],
'Analysis requires authentication with API key: permission denied.'
);
assert.equal(layergroupResult.errors_with_context[0].type, 'analysis');
assert.equal(
layergroupResult.errors_with_context[0].message,
'Analysis requires authentication with API key: permission denied.'
);
assert.equal(layergroupResult.errors_with_context[0].analysis.id, 'HEAD');
assert.equal(layergroupResult.errors_with_context[0].analysis.type, 'buffer');
testClient.drain(done);
});
});
it('camshaft: should return error: Missing required param "radius"; with context', function(done) {
var mapConfig = createMapConfig(
[
{
"type": "cartodb",
"options": {
"source": {
"id": "HEAD"
},
"cartocss": '#polygons { polygon-fill: red; }',
"cartocss_version": "2.3.0"
}
}
],
{},
[
{
"id": "HEAD",
"type": "buffer",
"params": {
"source": {
"id": "HEAD2",
"type": "source",
"params": {
"query": "select * from populated_places_simple_reduced"
}
}
}
}
]
);
var testClient = new TestClient(mapConfig, 1234);
testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroupResult) {
assert.ok(!err, err);
assert.equal(layergroupResult.errors.length, 1);
assert.equal(
layergroupResult.errors[0],
'Missing required param "radius"'
);
assert.equal(layergroupResult.errors_with_context[0].type, 'analysis');
assert.equal(layergroupResult.errors_with_context[0].message, 'Missing required param "radius"');
assert.equal(layergroupResult.errors_with_context[0].analysis.id, 'HEAD');
assert.equal(layergroupResult.errors_with_context[0].analysis.type, 'buffer');
testClient.drain(done);
});
});
it('should return missing param error of outer node indicating the node_id and context', function(done) {
var mapConfig = createMapConfig([{
"type": "cartodb",
"options": {
"source": {
"id": "HEAD"
},
"cartocss": '#polygons { polygon-fill: red; }',
"cartocss_version": "2.3.0"
}
}], {}, [{
"id": "HEAD",
"type": "buffer",
"params": {
"source": {
"id": "HEAD2",
"type": "buffer",
"params": {
"source": {
"id": "HEAD3",
"type": "source",
"params": {
"query": "select * from populated_places_simple_reduced"
}
},
"radius": 10
}
}
}
// radius: 'missing'
}]);
var testClient = new TestClient(mapConfig, 1234);
testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroupResult) {
assert.ok(!err, err);
assert.equal(layergroupResult.errors.length, 1);
assert.equal(
layergroupResult.errors[0],
'Missing required param "radius"'
);
assert.equal(layergroupResult.errors_with_context[0].type, 'analysis');
assert.equal(layergroupResult.errors_with_context[0].message, 'Missing required param "radius"');
assert.equal(layergroupResult.errors_with_context[0].analysis.id, 'HEAD');
assert.equal(layergroupResult.errors_with_context[0].analysis.type, 'buffer');
assert.equal(layergroupResult.errors_with_context[0].analysis.node_id, 'HEAD');
testClient.drain(done);
});
});
it('should return invalid param type error of inner node indicating the node_id and context', function(done) {
var mapConfig = createMapConfig([{
"type": "cartodb",
"options": {
"source": {
"id": "HEAD"
},
"cartocss": '#polygons { polygon-fill: red; }',
"cartocss_version": "2.3.0"
}
}], {}, [{
"id": "HEAD",
"type": "buffer",
"params": {
"source": {
"id": "HEAD2",
"type": "buffer",
"params": {
"source": {
"id": "HEAD3",
"type": "source",
"params": {
"query": "select * from populated_places_simple_reduced"
}
},
"radius": 'invalid_radius'
}
},
"radius": 10
}
}]);
var testClient = new TestClient(mapConfig, 1234);
testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroupResult) {
assert.ok(!err, err);
assert.equal(layergroupResult.errors.length, 1);
assert.equal(
layergroupResult.errors[0],
'Invalid type for param "radius", expects "number" type, got `"invalid_radius"`'
);
assert.equal(layergroupResult.errors_with_context[0].type, 'analysis');
assert.equal(
layergroupResult.errors_with_context[0].message,
'Invalid type for param "radius", expects "number" type, got `"invalid_radius"`'
);
assert.equal(layergroupResult.errors_with_context[0].analysis.id, 'HEAD');
assert.equal(layergroupResult.errors_with_context[0].analysis.type, 'buffer');
assert.equal(layergroupResult.errors_with_context[0].analysis.node_id, 'HEAD2');
testClient.drain(done);
});
});
});

View File

@@ -141,7 +141,7 @@ describe('named-maps analysis', function() {
assert.equal(analyses.length, 1, 'Invalid number of analyses in metadata');
var nodes = analyses[0].nodes;
var nodesIds = Object.keys(nodes);
assert.deepEqual(nodesIds, ['2570e105-7b37-40d2-bdf4-1af889598745', 'HEAD']);
assert.deepEqual(nodesIds, ['HEAD', '2570e105-7b37-40d2-bdf4-1af889598745']);
nodesIds.forEach(function(nodeId) {
var node = nodes[nodeId];
assert.ok(node.hasOwnProperty('url'), 'Missing "url" attribute in node');

View File

@@ -0,0 +1,115 @@
require('../../support/test_helper');
var assert = require('../../support/assert');
var TestClient = require('../../support/test-client');
describe('analysis-layers regressions', function() {
it('should return a complete list of nodes from analysis', function(done) {
var mapConfig = {
"version": "1.5.0",
"layers": [
{
"type": "cartodb",
"options": {
"cartocss": TestClient.CARTOCSS.POINTS,
"cartocss_version": "2.1.1",
"interactivity": [],
"source": {
"id": "a4"
}
}
},
{
"type": "cartodb",
"options": {
"cartocss": TestClient.CARTOCSS.POINTS,
"cartocss_version": "2.1.0",
"interactivity": [],
"source": {
"id": "b1"
}
}
}
],
"dataviews": {
"74493a30-4679-4b72-a60c-b6f808b57c98": {
"type": "histogram",
"source": {
"id": "b0"
},
"options": {
"column": "customer_value",
"bins": 10
}
}
},
"analyses": [
{
"id": "a4",
"type": "point-in-polygon",
"params": {
"polygons_source": {
"id": "a3",
"type": "buffer",
"params": {
"source": {
"id": "a2",
"type": "centroid",
"params": {
"source": {
"id": "b1",
"type": "kmeans",
"params": {
"source": {
"id": "b0",
"type": "source",
"params": {
"query": "SELECT * FROM populated_places_simple_reduced"
}
},
"clusters": 5
}
},
"category_column": "cluster_no"
}
},
"radius": 200000
}
},
"points_source": {
"id": "customer_home_locations",
"type": "source",
"params": {
"query": "SELECT * FROM populated_places_simple_reduced"
}
}
}
}
]
};
var testClient = new TestClient(mapConfig, 1234);
testClient.getLayergroup(function(err, layergroupResult) {
assert.ok(!err, err);
assert.ok(layergroupResult);
assert.ok(layergroupResult.metadata);
var analyses = layergroupResult.metadata.analyses;
assert.ok(analyses);
assert.equal(analyses.length, 1);
var expectedIds = ['customer_home_locations', 'b0', 'b1', 'a2', 'a3', 'a4'];
expectedIds.forEach(function(expectedId) {
assert.ok(
analyses[0].nodes.hasOwnProperty(expectedId),
'Missing "' + expectedId + '" from node list.'
);
});
assert.equal(Object.keys(analyses[0].nodes).length, expectedIds.length, Object.keys(analyses[0].nodes));
testClient.drain(done);
});
});
});

View File

@@ -0,0 +1,148 @@
require('../../support/test_helper');
var assert = require('../../support/assert');
var TestClient = require('../../support/test-client');
describe('aggregations happy cases', function() {
afterEach(function(done) {
if (this.testClient) {
this.testClient.drain(done);
} else {
done();
}
});
function aggregationOperationMapConfig(operation, query, column, aggregationColumn) {
column = column || 'adm0name';
aggregationColumn = aggregationColumn || 'pop_max';
query = query || 'select * from populated_places_simple_reduced';
var mapConfig = {
version: '1.5.0',
layers: [
{
type: 'mapnik',
options: {
sql: query,
cartocss: '#layer0 { marker-fill: red; marker-width: 10; }',
cartocss_version: '2.0.1',
widgets: {}
}
}
]
};
mapConfig.layers[0].options.widgets[column] = {
type: 'aggregation',
options: {
column: column,
aggregation: operation,
aggregationColumn: aggregationColumn
}
};
return mapConfig;
}
var operations = ['count', 'sum', 'avg', 'max', 'min'];
operations.forEach(function(operation) {
it('should be able to use "' + operation + '" as aggregation operation', function(done) {
this.testClient = new TestClient(aggregationOperationMapConfig(operation));
this.testClient.getDataview('adm0name', { own_filter: 0 }, function (err, aggregation) {
assert.ok(!err, err);
assert.ok(aggregation);
assert.equal(aggregation.type, 'aggregation');
assert.equal(aggregation.aggregation, operation);
done();
});
});
});
var query = [
'select 1 as val, \'a\' as cat, ST_Transform(ST_SetSRID(ST_MakePoint(0,0),4326),3857) as the_geom_webmercator',
'select null, \'b\', ST_Transform(ST_SetSRID(ST_MakePoint(0,1),4326),3857)',
'select null, \'b\', ST_Transform(ST_SetSRID(ST_MakePoint(1,0),4326),3857)',
'select null, null, ST_Transform(ST_SetSRID(ST_MakePoint(1,1),4326),3857)'
].join(' UNION ALL ');
operations.forEach(function (operation) {
var not = operation === 'count' ? ' not ' : ' ';
var description = 'should' +
not +
'handle NULL values in category and aggregation columns using "' +
operation +
'" as aggregation operation';
it(description, function (done) {
this.testClient = new TestClient(aggregationOperationMapConfig(operation, query, 'cat', 'val'));
this.testClient.getDataview('cat', { own_filter: 0 }, function (err, aggregation) {
assert.ifError(err);
assert.ok(aggregation);
assert.equal(aggregation.type, 'aggregation');
assert.ok(aggregation.categories);
assert.equal(aggregation.categoriesCount, 3);
assert.equal(aggregation.count, 4);
assert.equal(aggregation.nulls, 1);
var hasNullCategory = false;
aggregation.categories.forEach(function (category) {
if (category.category === null) {
hasNullCategory = true;
}
});
if (operation === 'count') {
assert.ok(hasNullCategory, 'aggregation has not a category NULL');
} else {
assert.ok(!hasNullCategory, 'aggregation has category NULL');
}
done();
});
});
});
var operations_and_values = {'count': 9, 'sum': 45, 'avg': 5, 'max': 9, 'min': 1};
var query_other = [
'select generate_series(1,3) as val, \'other_a\' as cat, NULL as the_geom_webmercator',
'select generate_series(4,6) as val, \'other_b\' as cat, NULL as the_geom_webmercator',
'select generate_series(7,9) as val, \'other_c\' as cat, NULL as the_geom_webmercator',
'select generate_series(10,12) as val, \'category_1\' as cat, NULL as the_geom_webmercator',
'select generate_series(10,12) as val, \'category_2\' as cat, NULL as the_geom_webmercator',
'select generate_series(10,12) as val, \'category_3\' as cat, NULL as the_geom_webmercator',
'select generate_series(10,12) as val, \'category_4\' as cat, NULL as the_geom_webmercator',
'select generate_series(10,12) as val, \'category_5\' as cat, NULL as the_geom_webmercator'
].join(' UNION ALL ');
Object.keys(operations_and_values).forEach(function (operation) {
var description = 'should aggregate OTHER category using "' + operation + '"';
it(description, function (done) {
this.testClient = new TestClient(aggregationOperationMapConfig(operation, query_other, 'cat', 'val'));
this.testClient.getDataview('cat', { own_filter: 0 }, function (err, aggregation) {
assert.ifError(err);
assert.ok(aggregation);
assert.equal(aggregation.type, 'aggregation');
assert.ok(aggregation.categories);
assert.equal(aggregation.categoriesCount, 8);
assert.equal(aggregation.count, 24);
assert.equal(aggregation.nulls, 0);
var aggregated_categories = aggregation.categories.filter( function(category) {
return category.agg === true;
});
assert.equal(aggregated_categories.length, 1);
assert.equal(aggregated_categories[0].value, operations_and_values[operation]);
done();
});
});
});
});

View File

@@ -54,7 +54,7 @@ describe('histogram-dataview', function() {
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, errObj) {
assert.ok(!err, err);
assert.deepEqual(errObj, { errors: [ '"dataviews" must be a valid JSON object: "string" type found' ] });
assert.deepEqual(errObj.errors, [ '"dataviews" must be a valid JSON object: "string" type found' ]);
done();
});
@@ -66,7 +66,7 @@ describe('histogram-dataview', function() {
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, errObj) {
assert.ok(!err, err);
assert.deepEqual(errObj, { errors: [ '"dataviews" must be a valid JSON object: "array" type found' ] });
assert.deepEqual(errObj.errors, [ '"dataviews" must be a valid JSON object: "array" type found' ]);
done();
});

View File

@@ -77,4 +77,24 @@ describe('histogram-dataview', function() {
done();
});
});
it('should cast all overridable params to numbers', function(done) {
var params = {
bins: '256 AS other, (select 256 * 2) AS bins_number--',
start: 1e3,
end: 0,
response: TestClient.RESPONSE.ERROR
};
this.testClient = new TestClient(mapConfig, 1234);
this.testClient.getDataview('pop_max_histogram', params, function(err, res) {
assert.ok(!err, err);
assert.ok(res.errors);
assert.equal(res.errors.length, 1);
assert.ok(res.errors[0].match(/Invalid number format for parameter 'bins'/));
done();
});
});
});

View File

@@ -144,6 +144,22 @@ describe('dataviews using tables with overviews', function() {
aggregationColumn: 'name',
}
},
test_histogram: {
type: 'histogram',
source: {id: 'data-source'},
options: {
column: 'value',
bins: 2
}
},
test_histogram_date: {
type: 'histogram',
source: {id: 'data-source'},
options: {
column: 'updated_at',
bins: 2
}
},
test_avg: {
type: 'formula',
source: {id: 'data-source'},
@@ -265,8 +281,83 @@ describe('dataviews using tables with overviews', function() {
});
});
it("should expose a histogram", function (done) {
var testClient = new TestClient(overviewsMapConfig);
testClient.getDataview('test_histogram', function (err, histogram) {
if (err) {
return done(err);
}
assert.ok(histogram);
assert.equal(histogram.type, 'histogram');
assert.ok(Array.isArray(histogram.bins));
testClient.drain(done);
});
});
describe('filters', function() {
describe('histogram', function () {
it("should expose a filtered histogram", function (done) {
var params = {
filters: {
dataviews: { test_histogram: { min: 2 } }
}
};
var testClient = new TestClient(overviewsMapConfig);
testClient.getDataview('test_histogram', params, function (err, histogram) {
if (err) {
return done(err);
}
assert.ok(histogram);
assert.equal(histogram.type, 'histogram');
assert.ok(Array.isArray(histogram.bins));
assert.equal(histogram.bins.length, 4);
testClient.drain(done);
});
});
it("should expose a filtered histogram with no results", function (done) {
var params = {
filters: {
dataviews: { test_histogram: { max: -1 } }
}
};
var testClient = new TestClient(overviewsMapConfig);
testClient.getDataview('test_histogram', params, function (err, histogram) {
if (err) {
return done(err);
}
assert.ok(histogram);
assert.equal(histogram.type, 'histogram');
assert.ok(Array.isArray(histogram.bins));
assert.equal(histogram.bins.length, 0);
testClient.drain(done);
});
});
it("should expose a filtered date histogram with no results", function (done) {
// This most likely works because the overviews will pass
// the responsibility to the normal dataviews.
var params = {
filters: {
dataviews: { test_histogram_date: { max: -1 } }
}
};
var testClient = new TestClient(overviewsMapConfig);
testClient.getDataview('test_histogram_date', params, function (err, histogram) {
if (err) {
return done(err);
}
assert.ok(histogram);
assert.equal(histogram.type, 'histogram');
assert.ok(Array.isArray(histogram.bins));
assert.equal(histogram.bins.length, 0);
testClient.drain(done);
});
});
});
describe('category', function () {
var params = {

View File

@@ -0,0 +1,68 @@
var assert = require('../support/assert');
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
describe('error with context', function () {
var layerOK = {
options: {
sql: 'select cartodb_id, ST_Translate(the_geom_webmercator, 5e6, 0) as the_geom_webmercator ' +
'from test_table',
cartocss: '#layer { marker-fill:red; marker-width:32; marker-allow-overlap:true; }',
cartocss_version: '2.0.1',
interactivity: 'cartodb_id'
}
};
var layerKO = {
options: {
sql: 'select cartodb_id from test_table offset 3', // it doesn't return the_geom_webmercator so it must fail
cartocss: '#layer { marker-fill:blue; marker-allow-overlap:true; }',
cartocss_version: '2.0.2',
interactivity: 'cartodb_id'
}
};
var DB_ERROR_MESSAGE = 'Postgis Plugin: ERROR: column "the_geom_webmercator" does not exist';
var scenarios = [{
description: 'layergroup with 2 layers, second one has query error',
layergroup: {
version: '1.0.0',
layers: [layerOK, layerKO]
},
expectedFailingLayer: { id: 'layer1', index: 1, type: 'mapnik' }
}, {
description: 'layergroup with 2 layers, first one has query error',
layergroup: {
version: '1.0.0',
layers: [layerKO, layerOK]
},
expectedFailingLayer: { id: 'layer0', index: 0, type: 'mapnik' }
}];
scenarios.forEach(function (scenario) {
it(scenario.description, function (done) {
assert.response(server, {
url: '/api/v1/map',
method: 'POST',
headers: {
host: 'localhost',
'Content-Type': 'application/json'
},
data: JSON.stringify(scenario.layergroup)
}, {
status: 400
}, function (res) {
var parsedBody = JSON.parse(res.body);
assert.ok(Array.isArray(parsedBody.errors_with_context));
var err = parsedBody.errors_with_context[0];
assert.equal(err.type, 'layer');
assert.equal(err.subtype, 'query');
assert.ok(err.message.indexOf(DB_ERROR_MESSAGE) >= 0);
assert.deepEqual(err.layer, scenario.expectedFailingLayer);
done();
});
});
});
});

View File

@@ -106,7 +106,7 @@ describe('render limits', function() {
},
function(res) {
var parsed = JSON.parse(res.body);
assert.deepEqual(parsed, { errors: [ 'Render timed out' ] });
assert.deepEqual(parsed.errors, [ 'Render timed out' ]);
done();
}
);
@@ -171,7 +171,7 @@ describe('render limits', function() {
},
function(res) {
var parsed = JSON.parse(res.body);
assert.deepEqual(parsed, { errors: ['Render timed out'] });
assert.deepEqual(parsed.errors, ['Render timed out']);
done();
}
);

View File

@@ -5,6 +5,9 @@ var step = require('step');
var strftime = require('strftime');
var redis_stats_db = 5;
var mapnik = require('windshaft').mapnik;
var semver = require('semver');
var helper = require(__dirname + '/../support/test_helper');
var LayergroupToken = require('../support/layergroup-token');
@@ -574,7 +577,7 @@ describe(suiteName, function() {
if ( err ) {
return done(err);
}
// trip epoch
// strip epoch
expected_token = expected_token.split(':')[0];
keysToDelete['map_cfg|' + expected_token] = 0;
keysToDelete['user:localhost:mapviews:global'] = 5;
@@ -973,70 +976,72 @@ describe(suiteName, function() {
});
// See https://github.com/CartoDB/Windshaft-cartodb/issues/93
it("accepts unused directives", function(done) {
var layergroup = {
version: '1.0.0',
layers: [
{ options: {
sql: "select 'SRID=3857;POINT(0 0)'::geometry as the_geom_webmercator",
cartocss: '#layer { point-transform:"scale(20)"; }',
cartocss_version: '2.0.1'
} }
]
};
var expected_token; // = "e34dd7e235138a062f8ba7ad051aa3a7";
step(
function do_post()
{
var next = this;
assert.response(server, {
url: layergroup_url,
method: 'POST',
headers: {host: 'localhost', 'Content-Type': 'application/json' },
data: JSON.stringify(layergroup)
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
var parsedBody = JSON.parse(res.body);
if ( expected_token ) {
assert.equal(parsedBody.layergroupid, expected_token + ':' + expected_last_updated_epoch);
assert.equal(res.headers['x-layergroup-id'], parsedBody.layergroupid);
}
else {
var token_components = parsedBody.layergroupid.split(':');
expected_token = token_components[0];
expected_last_updated_epoch = token_components[1];
}
next(null, res);
});
},
function do_get_tile(err)
{
assert.ifError(err);
var next = this;
assert.response(server, {
url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png',
method: 'GET',
headers: {host: 'localhost' },
encoding: 'binary'
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageBufferIsSimilarToFile(res.body, windshaft_fixtures + '/test_default_mapnik_point.png',
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err/*, similarity*/) {
next(err);
if (semver.satisfies(mapnik.versions.mapnik, '2.3.x')) {
it("accepts unused directives", function(done) {
var layergroup = {
version: '1.0.0',
layers: [
{ options: {
sql: "select 'SRID=3857;POINT(0 0)'::geometry as the_geom_webmercator",
cartocss: '#layer { point-transform:"scale(20)"; }',
cartocss_version: '2.0.1'
} }
]
};
var expected_token; // = "e34dd7e235138a062f8ba7ad051aa3a7";
step(
function do_post()
{
var next = this;
assert.response(server, {
url: layergroup_url,
method: 'POST',
headers: {host: 'localhost', 'Content-Type': 'application/json' },
data: JSON.stringify(layergroup)
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
var parsedBody = JSON.parse(res.body);
if ( expected_token ) {
assert.equal(parsedBody.layergroupid, expected_token + ':' + expected_last_updated_epoch);
assert.equal(res.headers['x-layergroup-id'], parsedBody.layergroupid);
}
);
});
},
function finish(err) {
keysToDelete['user:localhost:mapviews:global'] = 5;
keysToDelete['map_cfg|' + expected_token] = 0;
done(err);
}
);
});
else {
var token_components = parsedBody.layergroupid.split(':');
expected_token = token_components[0];
expected_last_updated_epoch = token_components[1];
}
next(null, res);
});
},
function do_get_tile(err)
{
assert.ifError(err);
var next = this;
assert.response(server, {
url: layergroup_url + "/" + expected_token + ':cb0/0/0/0.png',
method: 'GET',
headers: {host: 'localhost' },
encoding: 'binary'
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageBufferIsSimilarToFile(res.body, windshaft_fixtures + '/test_default_mapnik_point.png',
IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err/*, similarity*/) {
next(err);
}
);
});
},
function finish(err) {
keysToDelete['user:localhost:mapviews:global'] = 5;
keysToDelete['map_cfg|' + expected_token] = 0;
done(err);
}
);
});
}
// See https://github.com/CartoDB/Windshaft-cartodb/issues/91
// and https://github.com/CartoDB/Windshaft-cartodb/issues/38
it("tiles for private tables can be fetched with api_key", function(done) {

View File

@@ -228,7 +228,9 @@ describe('tests from old api translated to multilayer', function() {
},
function(res) {
var parsed = JSON.parse(res.body);
assert.deepEqual(parsed, { errors: [ 'Unexpected token W' ] });
assert.ok(parsed.errors);
assert.equal(parsed.errors.length, 1);
assert.ok(parsed.errors[0].match(/^Unexpected token W/));
done();
}
@@ -334,9 +336,7 @@ describe('tests from old api translated to multilayer', function() {
assert.ok(!res.headers.hasOwnProperty('x-cache-channel'));
var parsed = JSON.parse(res.body);
assert.deepEqual(parsed, {
errors: ["fake error message"]
});
assert.deepEqual(parsed.errors, ["fake error message"]);
done();
}

View File

@@ -181,7 +181,7 @@ describe('named_layers', function() {
}
var parsedBody = JSON.parse(response.body);
assert.deepEqual(parsedBody, { errors: ["Template 'nonexistent' of user 'localhost' not found"] });
assert.deepEqual(parsedBody.errors, ["Template 'nonexistent' of user 'localhost' not found"]);
return null;
},
@@ -234,10 +234,7 @@ describe('named_layers', function() {
}
var parsedBody = JSON.parse(response.body);
assert.deepEqual(
parsedBody,
{ errors: [ "Unauthorized 'auth_valid_template' template instantiation" ] }
);
assert.deepEqual(parsedBody.errors, [ "Unauthorized 'auth_valid_template' template instantiation" ]);
return null;
},
@@ -347,7 +344,7 @@ describe('named_layers', function() {
}
var parsedBody = JSON.parse(response.body);
assert.deepEqual(parsedBody, { errors: [ 'Nested named layers are not allowed' ] });
assert.deepEqual(parsedBody.errors, ['Nested named layers are not allowed' ]);
return null;
},

View File

@@ -0,0 +1,210 @@
var step = require('step');
var test_helper = require('../support/test_helper');
var assert = require('../support/assert');
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/server');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var RedisPool = require('redis-mpool');
var TemplateMaps = require('../../lib/cartodb/backends/template_maps.js');
var mapnik = require('windshaft').mapnik;
var IMAGE_TOLERANCE = 20;
describe('layers visibility for previews', function() {
// configure redis pool instance to use in tests
var redisPool = new RedisPool(global.environment.redis);
var templateMaps = new TemplateMaps(redisPool, {
max_user_templates: global.environment.maxUserTemplates
});
var username = 'localhost';
function createLayer (color, layerId) {
var mod;
if (color === 'red') {
mod = 0;
} else if (color === 'orange') {
mod = 1;
} else if (color === 'blue') {
mod = 2;
} else {
mod = 0;
}
return {
type: 'mapnik',
id: layerId,
options: {
sql: 'select * from populated_places_simple_reduced where cartodb_id % 3 = ' + mod,
cartocss: '#layer { marker-fill: ' + color + '; }',
cartocss_version: '2.3.0'
}
};
}
function createTemplate(scenario) {
return {
version: '0.0.1',
name: scenario.name,
auth: {
method: 'open'
},
view: {
bounds: {
west: 0,
south: 0,
east: 45,
north: 45
},
zoom: 4,
center: {
lng: 40,
lat: 20
},
preview_layers: scenario.layerPerview
},
layergroup: {
layers: scenario.layers
}
};
}
afterEach(function (done) {
test_helper.deleteRedisKeys({
'user:localhost:mapviews:global': 5
}, done);
});
function previewFixture(version) {
return './test/fixtures/previews/populated_places_simple_reduced-' + version + '.png';
}
var threeLayerPointDistintColor = [
createLayer('red'),
createLayer('orange'),
createLayer('blue', 'layer2')
];
var scenarios = [{
name: 'preview_layers_red',
layerPerview: {
'0': true,
'1': false,
'layer2': false
},
layers: threeLayerPointDistintColor
}, {
name: 'preview_layers_orange',
layerPerview: {
'0': false,
'1': true,
'layer2': false
},
layers: threeLayerPointDistintColor
}, {
name: 'preview_layers_blue',
layerPerview: {
'0': false,
'1': false,
'layer2': true
},
layers: threeLayerPointDistintColor
}, {
name: 'preview_layers_red_orange',
layerPerview: {
'0': true,
'1': true,
'layer2': false
},
layers: threeLayerPointDistintColor
}, {
name: 'preview_layers_red_blue',
layerPerview: {
'0': true,
'1': false,
'layer2': true
},
layers: threeLayerPointDistintColor
}, {
name: 'preview_layers_orange_blue',
layerPerview: {
'0': false,
'1': true,
'layer2': true
},
layers: threeLayerPointDistintColor
}, {
name: 'preview_layers_red_orange_blue',
layerPerview: {
'0': true,
'1': true,
'layer2': true
},
layers: threeLayerPointDistintColor
}, {
name: 'preview_layers_all',
layerPerview: {},
layers: threeLayerPointDistintColor
}, {
name: 'preview_layers_undefined',
layerPerview: undefined,
layers: threeLayerPointDistintColor
}];
scenarios.forEach(function (scenario) {
it('should filter layers for template: ' + scenario.name, function (done) {
step(
function addTemplate () {
var next = this;
var template = createTemplate(scenario);
templateMaps.addTemplate(username, template, next);
},
function requestPreview (err) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/static/named/' + scenario.name + '/640/480.png',
method: 'GET',
headers: {
host: 'localhost'
},
encoding: 'binary'
}, {
status: 200,
headers: {
'content-type': 'image/png'
}
}, function (res, err) {
next(err, res);
});
},
function checkPreview (err, res) {
assert.ifError(err);
var next = this;
var img = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
var previewFixturePath = previewFixture(scenario.name);
assert.imageIsSimilarToFile(img, previewFixturePath, IMAGE_TOLERANCE, next);
},
function deleteTemplate(err) {
assert.ifError(err);
var next = this;
templateMaps.delTemplate(username, scenario.name, next);
},
function finish (err) {
done(err);
}
);
});
});
});

View File

@@ -169,8 +169,8 @@ describe('named maps authentication', function() {
getNamedTile(nonexistentName, 0, 0, 0, { status: 404 }, function(err, res) {
assert.ok(!err);
assert.deepEqual(
JSON.parse(res.body),
{ errors: ["Template '" + nonexistentName + "' of user '" + username + "' not found"] }
JSON.parse(res.body).errors,
["Template '" + nonexistentName + "' of user '" + username + "' not found"]
);
done();
});
@@ -179,7 +179,7 @@ describe('named maps authentication', function() {
it('should return 403 if not properly authorized', function(done) {
getNamedTile(tokenAuthTemplateName, 0, 0, 0, { status: 403 }, function(err, res) {
assert.ok(!err);
assert.deepEqual(JSON.parse(res.body), { errors: ['Unauthorized template instantiation'] });
assert.deepEqual(JSON.parse(res.body).errors, ['Unauthorized template instantiation']);
done();
});
});
@@ -238,8 +238,8 @@ describe('named maps authentication', function() {
getStaticMap(nonexistentName, { status: 404 }, function(err, res) {
assert.ok(!err);
assert.deepEqual(
JSON.parse(res.body),
{ errors: ["Template '" + nonexistentName + "' of user '" + username + "' not found"] }
JSON.parse(res.body).errors,
["Template '" + nonexistentName + "' of user '" + username + "' not found"]
);
done();
});
@@ -248,7 +248,7 @@ describe('named maps authentication', function() {
it('should return 403 if not properly authorized', function(done) {
getStaticMap(tokenAuthTemplateName, { status: 403 }, function(err, res) {
assert.ok(!err);
assert.deepEqual(JSON.parse(res.body), { errors: ['Unauthorized template instantiation'] });
assert.deepEqual(JSON.parse(res.body).errors, ['Unauthorized template instantiation']);
done();
});
});

View File

@@ -124,8 +124,8 @@ describe('named maps provider cache', function() {
getNamedTile({ statusCode: 404 }, function(err, res) {
assert.ok(!err);
assert.deepEqual(
JSON.parse(res.body),
{ errors: ["Template 'template_with_color' of user 'localhost' not found"] }
JSON.parse(res.body).errors,
["Template 'template_with_color' of user 'localhost' not found"]
);
// add template again so it's clean in afterEach

View File

@@ -21,7 +21,7 @@ describe('named maps static view', function() {
var IMAGE_TOLERANCE = 20;
function createTemplate(view) {
function createTemplate(view, layers) {
return {
version: '0.0.1',
name: templateName,
@@ -36,7 +36,7 @@ describe('named maps static view', function() {
},
view: view,
layergroup: {
layers: [
layers: layers || [
{
type: 'mapnik',
options: {
@@ -198,4 +198,43 @@ describe('named maps static view', function() {
});
});
it('should allow to select the layers to render', function (done) {
var view = {
bounds: {
west: 0,
south: 0,
east: 45,
north: 45
}
};
var layers = [
{
type: 'mapnik',
options: {
sql: 'select * from populated_places_simple_reduced',
cartocss: '#layer { marker-fill: <%= color %>; }',
cartocss_version: '2.3.0'
}
},
{
type: 'mapnik',
options: {
sql: 'select ST_Transform(ST_MakeEnvelope(-45, -45, 45, 45, 4326), 3857) the_geom_webmercator',
cartocss: '#layer { polygon-fill: <%= color %>; }',
cartocss_version: '2.3.0'
}
}
];
templateMaps.addTemplate(username, createTemplate(view, layers), function (err) {
if (err) {
return done(err);
}
getStaticMap({ layer: 0 }, function(err, img) {
assert.ok(!err);
assert.imageIsSimilarToFile(img, previewFixture('bounds'), IMAGE_TOLERANCE, done);
});
});
});
});

View File

@@ -231,7 +231,11 @@ describe('attributes', function() {
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
assert.equal(
res.body,
'/**/ typeof test === \'function\' && test({"errors":["Layer 0 has no exposed attributes"]});'
'/**/ typeof test === \'function\' && ' +
'test({"errors":["Layer 0 has no exposed attributes"],' +
'"errors_with_context":[{' +
'"type":"unknown","message":"Layer 0 has no exposed attributes"' +
'}]});'
);
return null;
},

View File

@@ -138,11 +138,9 @@ describe('blend http fallback', function() {
testClient.getTileLayer(mapConfig, tileRequest, expectedResponse, function(err, res) {
assert.ok(!err);
var parsedBody = JSON.parse(res.body);
assert.deepEqual(parsedBody, {
errors: [
"Unable to fetch http tile: http://127.0.0.1:8033/error404/1/0/0.png [404]"
]
});
assert.deepEqual(parsedBody.errors, [
"Unable to fetch http tile: http://127.0.0.1:8033/error404/1/0/0.png [404]"
]);
done();
});
});

View File

@@ -119,12 +119,11 @@ describe('external resources', function() {
var mapConfig = testClient.defaultTableMapConfig('test_table_3', style);
testClient.createLayergroup(mapConfig, { statusCode: 400 }, function(err, res) {
assert.deepEqual(JSON.parse(res.body), {
errors: ["Unable to download '" + url + "' for 'style0' (server returned 404)"]
});
assert.deepEqual(JSON.parse(res.body).errors, [
"Unable to download '" + url + "' for 'style0' (server returned 404)"]
);
done();
});
});
});

View File

@@ -31,7 +31,7 @@ describe('multilayer error cases', function() {
}, {}, function(res) {
assert.equal(res.statusCode, 400, res.body);
var parsedBody = JSON.parse(res.body);
assert.deepEqual(parsedBody, {"errors":["layergroup POST data must be of type application/json"]});
assert.deepEqual(parsedBody.errors, ["layergroup POST data must be of type application/json"]);
done();
});
});
@@ -44,7 +44,7 @@ describe('multilayer error cases', function() {
}, {}, function(res) {
assert.equal(res.statusCode, 400, res.body);
var parsedBody = JSON.parse(res.body);
assert.deepEqual(parsedBody, {"errors":["Missing layers array from layergroup config"]});
assert.deepEqual(parsedBody.errors, ["Missing layers array from layergroup config"]);
done();
});
});
@@ -58,7 +58,10 @@ describe('multilayer error cases', function() {
assert.equal(res.statusCode, 200);
assert.equal(
res.body,
'/**/ typeof test === \'function\' && test({"errors":["Missing layers array from layergroup config"]});'
'/**/ typeof test === \'function\' && ' +
'test({"errors":["Missing layers array from layergroup config"],' +
'"errors_with_context":[{"type":"unknown",' +
'"message":"Missing layers array from layergroup config"}]});'
);
done();
});
@@ -83,7 +86,7 @@ describe('multilayer error cases', function() {
}, {}, function(res) {
assert.equal(res.statusCode, 400, res.body);
var parsedBody = JSON.parse(res.body);
assert.deepEqual(parsedBody, {errors:["Missing cartocss_version for layer 0 options"]});
assert.deepEqual(parsedBody.errors, ["Missing cartocss_version for layer 0 options"]);
done();
});
});
@@ -355,7 +358,7 @@ describe('multilayer error cases', function() {
var mapConfig = testClient.singleLayerMapConfig('select * from test_table', null, null, 'name');
testClient.getGrid(mapConfig, 1, 13, 4011, 3088, defaultErrorExpectedResponse, function(err, res) {
assert.deepEqual(JSON.parse(res.body), { errors: ["Layer '1' not found in layergroup"] });
assert.deepEqual(JSON.parse(res.body).errors, ["Layer '1' not found in layergroup"]);
done();
});
});
@@ -383,7 +386,7 @@ describe('multilayer error cases', function() {
// FIXME: should be 404
assert.equal(res.statusCode, 400, res.statusCode + ':' + res.body);
var parsed = JSON.parse(res.body);
assert.deepEqual(parsed, {"errors": ["Invalid or nonexistent map configuration token 'deadbeef'"]});
assert.deepEqual(parsed.errors, ["Invalid or nonexistent map configuration token 'deadbeef'"]);
return null;
},
function finish(err) {
@@ -416,7 +419,9 @@ describe('multilayer error cases', function() {
},
function(res) {
var parsedBody = JSON.parse(res.body);
assert.deepEqual(parsedBody, { errors: ['SyntaxError: Unexpected token {'] });
assert.ok(parsedBody.errors);
assert.equal(parsedBody.errors.length, 1);
assert.ok(parsedBody.errors[0].match(/^SyntaxError: Unexpected token {/));
done();
}
);

View File

@@ -148,11 +148,10 @@ describe('raster', function() {
assert.ok(!err);
checkCORSHeaders(res);
var parsedBody = JSON.parse(res.body);
assert.deepEqual(parsedBody, { errors: [ 'Mapnik raster layers do not support interactivity' ] });
assert.deepEqual(parsedBody.errors, [ 'Mapnik raster layers do not support interactivity' ]);
done();
}
);
});
});

View File

@@ -29,7 +29,7 @@ describe('regressions', function() {
contentType: 'application/json; charset=utf-8'
};
requestTile('/0/0/0.png?testUnexpectedError=1', options, function(err, res) {
assert.deepEqual(JSON.parse(res.body), { "errors": ["test unexpected error"] });
assert.deepEqual(JSON.parse(res.body).errors, ["test unexpected error"]);
finish(done);
});
});

View File

@@ -129,7 +129,7 @@ describe('retina support', function() {
},
function(res, err) {
assert.ok(!err, 'Failed to request 0/0/0' + scaleFactor + '.png tile');
assert.deepEqual(JSON.parse(res.body), { errors: ["Tile with specified resolution not found"] } );
assert.deepEqual(JSON.parse(res.body).errors, ["Tile with specified resolution not found"]);
done();
}

View File

@@ -112,7 +112,7 @@ describe('server', function() {
}
};
testClient.getGrid(mapConfig, 0, 13, 4011, 3088, expectedResponse, function(err, res) {
assert.deepEqual(JSON.parse(res.body), {"errors":["Tileset has no interactivity"]});
assert.deepEqual(JSON.parse(res.body).errors, ["Tileset has no interactivity"]);
done();
});
});

View File

@@ -139,13 +139,15 @@ describe('server_gettile', function() {
13, 4011, 3088, imageCompareFn('test_table_13_4011_3088_styled_black.png', done));
});
// See http://github.com/CartoDB/Windshaft/issues/99
it("unused directives are tolerated", function(done){
var style = "#test_table{point-transform: 'scale(100)';}";
var sql = "SELECT 1 as cartodb_id, 'SRID=4326;POINT(0 0)'::geometry as the_geom";
testClient.getTile(testClient.singleLayerMapConfig(sql, style), 0, 0, 0,
imageCompareFn('test_default_mapnik_point.png', done));
});
if ( semver.satisfies(mapnik.versions.mapnik, '2.3.x') ) {
// See http://github.com/CartoDB/Windshaft/issues/99
it("unused directives are tolerated", function(done){
var style = "#test_table{point-transform: 'scale(100)';}";
var sql = "SELECT 1 as cartodb_id, 'SRID=4326;POINT(0 0)'::geometry as the_geom";
testClient.getTile(testClient.singleLayerMapConfig(sql, style), 0, 0, 0,
imageCompareFn('test_default_mapnik_point.png', done));
});
}
// See http://github.com/CartoDB/Windshaft/issues/100
var test_strictness = function(done) {
@@ -168,51 +170,53 @@ describe('server_gettile', function() {
// Strictness handling changed in 2.3.x, possibly a bug: see http://github.com/mapnik/mapnik/issues/2301
it.skip('[skipped due to http://github.com/mapnik/mapnik/issues/2301]' + test_strict_lbl, test_strictness);
}
else {
else if (!semver.satisfies(mapnik.versions.mapnik, '3.0.x')) {
it(test_strict_lbl, test_strictness);
}
it('high cpu regression with mapnik <2.3.x', function(done) {
var sql = [
"SELECT 'my polygon name here' AS name,",
"st_envelope(st_buffer(st_transform(",
"st_setsrid(st_makepoint(-26.6592894004,49.7990296995),4326),3857),10000000)) AS the_geom",
"FROM generate_series(-6,6) x",
"UNION ALL",
"SELECT 'my marker name here' AS name,",
" st_transform(st_setsrid(st_makepoint(49.6042060319,-49.0522997372),4326),3857) AS the_geom",
"FROM generate_series(-6,6) x"
].join(' ');
if ( semver.satisfies(mapnik.versions.mapnik, '2.3.x') ) {
var style = [
'#test_table {marker-fill:#ff7;',
' marker-max-error:0.447492761618;',
' marker-line-opacity:0.659371340628;',
' marker-allow-overlap:true;',
' polygon-fill:green;',
' marker-spacing:0.0;',
' marker-width:4.0;',
' marker-height:18.0;',
' marker-opacity:0.942312062822;',
' line-color:green;',
' line-gamma:0.945973211092;',
' line-cap:square;',
' polygon-opacity:0.12576055992;',
' marker-type:arrow;',
' polygon-gamma:0.46354913107;',
' line-dasharray:33,23;',
' line-join:bevel;',
' marker-placement:line;',
' line-width:1.0;',
' marker-line-color:#ff7;',
' line-opacity:0.39403752154;',
' marker-line-width:3.0;',
'}'
].join('');
it('high cpu regression with mapnik <2.3.x', function(done) {
var sql = [
"SELECT 'my polygon name here' AS name,",
"st_envelope(st_buffer(st_transform(",
"st_setsrid(st_makepoint(-26.6592894004,49.7990296995),4326),3857),10000000)) AS the_geom",
"FROM generate_series(-6,6) x",
"UNION ALL",
"SELECT 'my marker name here' AS name,",
" st_transform(st_setsrid(st_makepoint(49.6042060319,-49.0522997372),4326),3857) AS the_geom",
"FROM generate_series(-6,6) x"
].join(' ');
testClient.getTile(testClient.singleLayerMapConfig(sql, style), 13, 4011, 3088, done);
});
var style = [
'#test_table {marker-fill:#ff7;',
' marker-max-error:0.447492761618;',
' marker-line-opacity:0.659371340628;',
' marker-allow-overlap:true;',
' polygon-fill:green;',
' marker-spacing:0.0;',
' marker-width:4.0;',
' marker-height:18.0;',
' marker-opacity:0.942312062822;',
' line-color:green;',
' line-gamma:0.945973211092;',
' line-cap:square;',
' polygon-opacity:0.12576055992;',
' marker-type:arrow;',
' polygon-gamma:0.46354913107;',
' line-dasharray:33,23;',
' line-join:bevel;',
' marker-placement:line;',
' line-width:1.0;',
' marker-line-color:#ff7;',
' line-opacity:0.39403752154;',
' marker-line-width:3.0;',
'}'
].join('');
testClient.getTile(testClient.singleLayerMapConfig(sql, style), 13, 4011, 3088, done);
});
}
// https://github.com/CartoDB/Windshaft-cartodb/issues/316
it('should return errors with better formatting', function(done) {
var mapConfig = {

View File

@@ -370,7 +370,7 @@ describe('torque', function() {
{
var next = this;
assert.response(server, {
url: '/database/windshaft_test/layergroup?dbport=1234567',
url: '/database/windshaft_test/layergroup?dbport=54777',
method: 'POST',
headers: {'Content-Type': 'application/json' },
data: JSON.stringify(mapconfig)

View File

@@ -1927,9 +1927,8 @@ describe('template_api', function() {
if (err) {
return done(err);
}
assert.deepEqual(JSON.parse(res.body), {
errors: ["Invalid or nonexistent map configuration token '" + nonexistentToken + "'"]
});
assert.deepEqual(JSON.parse(res.body).errors,
["Invalid or nonexistent map configuration token '" + nonexistentToken + "'"]);
done();
};

View File

@@ -0,0 +1,190 @@
require('../../support/test_helper');
var assert = require('../../support/assert');
var TestClient = require('../../support/test-client');
function makeMapconfig(markerWidth, markerFill) {
return {
"version": "1.4.0",
"layers": [
{
"type": 'mapnik',
"options": {
"cartocss_version": '2.3.0',
"sql": 'SELECT * FROM populated_places_simple_reduced',
"cartocss": createCartocss(markerWidth, markerFill)
}
}
]
};
}
function createCartocss(markerWidth, markerFill) {
return [
"#populated_places_simple_reduced {",
" marker-fill-opacity: 0.9;",
" marker-line-color: #FFF;",
" marker-line-width: 1;",
" marker-line-opacity: 1;",
" marker-placement: point;",
" marker-type: ellipse;",
" marker-allow-overlap: true;",
" marker-width: " + (markerWidth || '10') + ";",
" marker-fill: " + (markerFill || 'red') + ";",
"}"
].join('\n');
}
var ERROR_RESPONSE = {
status: 400,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
};
describe('turbo-carto error cases', function() {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
}
});
it('should return invalid number of ramp error', function(done) {
this.testClient = new TestClient(makeMapconfig('ramp([pop_max], 8, 96, 3, (8,24,96,128))'));
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^Failed\sto\sprocess/), layergroup.errors[0]);
assert.ok(layergroup.errors[0].match(/invalid\sramp\slength/i), layergroup.errors[0]);
done();
});
});
it('should return invalid column from datasource', function(done) {
this.testClient = new TestClient(makeMapconfig(null, 'ramp([wadus_column], (red, green, blue))'));
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors[0].match(/wadus_column/));
done();
});
});
it('should return invalid method from datasource', function(done) {
this.testClient = new TestClient(makeMapconfig(null, 'ramp([wadus_column], (red, green, blue), wadusmethod)'));
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors[0].match(/invalid\smethod\s\"wadusmethod\"/i));
done();
});
});
it('should fail by falling back to normal carto parser', function(done) {
this.testClient = new TestClient(makeMapconfig('ramp([price], (8,24,96), (8,24,96));//(red, green, blue))'));
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(!layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/invalid\scode/i));
done();
});
});
it('turbo-carto: should return error invalid column from datasource with some context', function(done) {
this.testClient = new TestClient(makeMapconfig(null, 'ramp([wadus_column], (red, green, blue))'));
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors_with_context.length, 1);
assert.equal(layergroup.errors_with_context[0].type, 'layer');
assert.equal(layergroup.errors_with_context[0].subtype, 'turbo-carto');
assert.ok(layergroup.errors_with_context[0].message.match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors_with_context[0].message.match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors_with_context[0].message.match(/wadus_column/));
assert.equal(layergroup.errors_with_context[0].layer.id, 'layer0');
assert.equal(layergroup.errors_with_context[0].layer.index, 0);
assert.equal(layergroup.errors_with_context[0].layer.type, 'mapnik');
assert.equal(layergroup.errors_with_context[0].layer.context.selector, '#populated_places_simple_reduced');
assert.deepEqual(layergroup.errors_with_context[0].layer.context.source, {
start: {
line: 10,
column: 3
},
end: {
line: 10,
column: 56
}
});
done();
});
});
it('should return multiple errors', function(done) {
var multipleErrorsMapConfig = {
"version": "1.4.0",
"layers": [
{
"type": 'mapnik',
"options": {
"cartocss_version": '2.3.0',
"sql": 'SELECT * FROM populated_places_simple_reduced',
"cartocss": createCartocss(null, 'ramp([wadus_column], (red, green, blue))')
}
},
{
"type": 'mapnik',
"options": {
"cartocss_version": '2.3.0',
"sql": 'SELECT * FROM populated_places_simple_reduced',
"cartocss": createCartocss('ramp([invalid_column], (red, green, blue))')
}
}
]
};
this.testClient = new TestClient(multipleErrorsMapConfig);
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors_with_context.length, 2);
assert.equal(layergroup.errors_with_context[0].type, 'layer');
assert.equal(layergroup.errors_with_context[0].subtype, 'turbo-carto');
assert.ok(layergroup.errors_with_context[0].message.match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors_with_context[0].message.match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors_with_context[0].message.match(/wadus_column/));
assert.equal(layergroup.errors_with_context[0].layer.id, 'layer0');
assert.equal(layergroup.errors_with_context[1].type, 'layer');
assert.equal(layergroup.errors_with_context[1].subtype, 'turbo-carto');
assert.ok(layergroup.errors_with_context[1].message.match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors_with_context[1].message.match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors_with_context[1].message.match(/invalid_column/));
assert.equal(layergroup.errors_with_context[1].layer.id, 'layer1');
done();
});
});
});

View File

@@ -0,0 +1,252 @@
var assert = require('../../support/assert');
var step = require('step');
var LayergroupToken = require('../../support/layergroup-token');
var testHelper = require('../../support/test_helper');
var CartodbWindshaft = require('../../../lib/cartodb/server');
var serverOptions = require('../../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var mapnik = require('windshaft').mapnik;
var IMAGE_TOLERANCE_PER_MIL = 10;
describe('turbo-carto for named maps', function() {
var keysToDelete;
beforeEach(function() {
keysToDelete = {};
});
afterEach(function(done) {
testHelper.deleteRedisKeys(keysToDelete, done);
});
var templateId = 'turbo-carto-template-1';
function template(table) {
return {
version: '0.0.1',
name: templateId,
auth: { method: 'open' },
placeholders: {
color: {
type: "css_color",
default: "Reds"
}
},
layergroup: {
version: '1.0.0',
layers: [
{
options: {
sql: [
'SELECT ' + table + '.*, _prices.price FROM ' + table + ' JOIN (' +
' SELECT 1 AS cartodb_id, 10.00 AS price',
' UNION',
' SELECT 2, 10.50',
' UNION',
' SELECT 3, 11.00',
' UNION',
' SELECT 4, 12.00',
' UNION',
' SELECT 5, 21.00',
') _prices ON _prices.cartodb_id = ' + table + '.cartodb_id'
].join('\n'),
cartocss: [
'#layer {',
' marker-fill: ramp([price], colorbrewer(<%= color %>));',
' marker-allow-overlap:true;',
'}'
].join('\n'),
cartocss_version: '2.0.2'
}
}
]
}
};
}
var templateParamsReds = { color: 'Reds' };
var templateParamsBlues = { color: 'Blues' };
var scenarios = [
{
desc: 'with public tables',
table: 'test_table'
},
{
desc: 'with private tables',
table: 'test_table_private_1'
}
];
scenarios.forEach(function(scenario) {
it('should create a template with turbo-carto parsed properly: ' + scenario.desc, function (done) {
step(
function postTemplate() {
var next = this;
assert.response(server, {
url: '/api/v1/map/named?api_key=1234',
method: 'POST',
headers: { host: 'localhost', 'Content-Type': 'application/json' },
data: JSON.stringify(template(scenario.table))
}, {},
function (res, err) {
next(err, res);
});
},
function checkTemplate(err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.deepEqual(JSON.parse(res.body), {
template_id: templateId
});
return null;
},
function instantiateTemplateWithReds(err) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/named/' + templateId,
method: 'POST',
headers: {
host: 'localhost',
'Content-Type': 'application/json'
},
data: JSON.stringify(templateParamsReds)
}, {},
function(res, err) {
return next(err, res);
});
},
function checkInstanciationWithReds(err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
var parsedBody = JSON.parse(res.body);
keysToDelete['map_cfg|' + LayergroupToken.parse(parsedBody.layergroupid).token] = 0;
keysToDelete['user:localhost:mapviews:global'] = 5;
assert.ok(parsedBody.layergroupid);
assert.ok(parsedBody.last_updated);
return parsedBody.layergroupid;
},
function requestTileReds(err, layergroupId) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/' + layergroupId + '/0/0/0.png',
method: 'GET',
headers: { host: 'localhost' },
encoding: 'binary'
}, {},
function(res, err) {
next(err, res);
});
},
function checkTileReds(err, res) {
assert.ifError(err);
var next = this;
assert.equal(res.statusCode, 200);
assert.equal(res.headers['content-type'], 'image/png');
var fixturePath = './test/fixtures/turbo-carto-named-maps-reds.png';
var image = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
assert.imageIsSimilarToFile(image, fixturePath, IMAGE_TOLERANCE_PER_MIL, next);
},
function instantiateTemplateWithBlues(err) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/named/' + templateId,
method: 'POST',
headers: {
host: 'localhost',
'Content-Type': 'application/json'
},
data: JSON.stringify(templateParamsBlues)
}, {},
function(res, err) {
return next(err, res);
});
},
function checkInstanciationWithBlues(err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
var parsedBody = JSON.parse(res.body);
keysToDelete['map_cfg|' + LayergroupToken.parse(parsedBody.layergroupid).token] = 0;
keysToDelete['user:localhost:mapviews:global'] = 5;
assert.ok(parsedBody.layergroupid);
assert.ok(parsedBody.last_updated);
return parsedBody.layergroupid;
},
function requestTileBlues(err, layergroupId) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/' + layergroupId + '/0/0/0.png',
method: 'GET',
headers: { host: 'localhost' },
encoding: 'binary'
}, {},
function(res, err) {
next(err, res);
});
},
function checkTileBlues(err, res) {
assert.ifError(err);
var next = this;
assert.equal(res.statusCode, 200);
assert.equal(res.headers['content-type'], 'image/png');
var fixturePath = './test/fixtures/turbo-carto-named-maps-blues.png';
var image = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
assert.imageIsSimilarToFile(image, fixturePath, IMAGE_TOLERANCE_PER_MIL, next);
},
function deleteTemplate(err) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/named/' + templateId + '?api_key=1234',
method: 'DELETE',
headers: { host: 'localhost' }
}, {}, function (res, err) {
next(err, res);
});
},
function checkDeleteTemplate(err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 204);
assert.ok(!res.body);
return null;
},
function finish(err) {
done(err);
}
);
});
});
});

View File

@@ -0,0 +1,383 @@
require('../../support/test_helper');
var assert = require('../../support/assert');
var TestClient = require('../../support/test-client');
function makeMapconfig(sql, cartocss) {
return {
"version": "1.4.0",
"layers": [
{
"type": 'mapnik',
"options": {
"cartocss_version": '2.3.0',
"sql": sql,
"cartocss": cartocss
}
}
]
};
}
describe('turbo-carto regressions', function() {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
} else {
done();
}
});
it('should accept // comments', function(done) {
var cartocss = [
"/** simple visualization */",
"",
"Map {",
" buffer-size: 256;",
"}",
"",
"#county_points_with_population{",
" marker-fill-opacity: 0.1;",
" marker-line-color:#FFFFFF;//#CF1C90;",
" marker-line-width: 0;",
" marker-line-opacity: 0.3;",
" marker-placement: point;",
" marker-type: ellipse;",
" //marker-comp-op: overlay;",
" marker-width: [cartodb_id];",
" [zoom=5]{marker-width: [cartodb_id]*2;}",
" [zoom=6]{marker-width: [cartodb_id]*4;}",
" marker-fill: #000000;",
" marker-allow-overlap: true;",
" ",
"",
"}"
].join('\n');
this.testClient = new TestClient(makeMapconfig('SELECT * FROM populated_places_simple_reduced', cartocss));
this.testClient.getLayergroup(function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
done();
});
});
it('should fail for private tables', function(done) {
var cartocss = [
"#private_table {",
" marker-placement: point;",
" marker-allow-overlap: true;",
" marker-line-width: 0;",
" marker-fill-opacity: 1.0;",
" marker-width: ramp([cartodb_id], 10, 20);",
" marker-fill: red;",
"}"
].join('\n');
this.testClient = new TestClient(makeMapconfig('SELECT * FROM test_table_private_1', cartocss));
this.testClient.getLayergroup(TestClient.RESPONSE.ERROR, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(!layergroup.hasOwnProperty('layergroupid'));
assert.ok(layergroup.hasOwnProperty('errors'));
var turboCartoError = layergroup.errors_with_context[0];
assert.ok(turboCartoError);
assert.equal(turboCartoError.type, 'layer');
assert.ok(turboCartoError.message.match(/permission\sdenied\sfor\srelation\stest_table_private_1/));
done();
});
});
it('should work for private tables with api key', function(done) {
var cartocss = [
"#private_table {",
" marker-placement: point;",
" marker-allow-overlap: true;",
" marker-line-width: 0;",
" marker-fill-opacity: 1.0;",
" marker-width: ramp([cartodb_id], 10, 20);",
" marker-fill: red;",
"}"
].join('\n');
this.testClient = new TestClient(makeMapconfig('SELECT * FROM test_table_private_1', cartocss), 1234);
this.testClient.getLayergroup(function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
done();
});
});
it('should work with mapnik substitution tokens', function(done) {
var cartocss = [
"#layer {",
" line-width: 2;",
" line-color: #3B3B58;",
" line-opacity: 1;",
" polygon-opacity: 0.7;",
" polygon-fill: ramp([points_count], (#E5F5F9,#99D8C9,#2CA25F))",
"}"
].join('\n');
var sql = [
'WITH hgrid AS (',
' SELECT CDB_HexagonGrid(',
' ST_Expand(!bbox!, greatest(!pixel_width!,!pixel_height!) * 100),',
' greatest(!pixel_width!,!pixel_height!) * 100',
' ) as cell',
')',
'SELECT',
' hgrid.cell as the_geom_webmercator,',
' count(1) as points_count,',
' count(1)/power(100 * CDB_XYZ_Resolution(CDB_ZoomFromScale(!scale_denominator!)), 2) as points_density,',
' 1 as cartodb_id',
'FROM hgrid, (SELECT * FROM populated_places_simple_reduced) i',
'where ST_Intersects(i.the_geom_webmercator, hgrid.cell)',
'GROUP BY hgrid.cell'
].join('\n');
this.testClient = new TestClient(makeMapconfig(sql, cartocss));
this.testClient.getLayergroup(function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
done();
});
});
it('should work with mapnik substitution tokens and analyses', function(done) {
var cartocss = [
"#layer {",
" line-width: 2;",
" line-color: #3B3B58;",
" line-opacity: 1;",
" polygon-opacity: 0.7;",
" polygon-fill: ramp([points_count], (#E5F5F9,#99D8C9,#2CA25F))",
"}"
].join('\n');
var sqlWrap = [
'WITH hgrid AS (',
' SELECT CDB_HexagonGrid(',
' ST_Expand(!bbox!, greatest(!pixel_width!,!pixel_height!) * 100),',
' greatest(!pixel_width!,!pixel_height!) * 100',
' ) as cell',
')',
'SELECT',
' hgrid.cell as the_geom_webmercator,',
' count(1) as points_count,',
' count(1)/power(100 * CDB_XYZ_Resolution(CDB_ZoomFromScale(!scale_denominator!)), 2) as points_density,',
' 1 as cartodb_id',
'FROM hgrid, (<%= sql %>) i',
'where ST_Intersects(i.the_geom_webmercator, hgrid.cell)',
'GROUP BY hgrid.cell'
].join('\n');
var mapConfig = {
"version": "1.5.0",
"layers": [
{
"type": 'mapnik',
"options": {
"cartocss_version": '2.3.0',
"source": {
"id": "head"
},
sql_wrap: sqlWrap,
"cartocss": cartocss
}
}
],
"analyses": [
{
"id": "head",
"type": "source",
"params": {
"query": "SELECT * FROM populated_places_simple_reduced"
}
}
]
};
this.testClient = new TestClient(mapConfig, 1234);
this.testClient.getLayergroup(function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
done();
});
});
describe('empty datasource results', function() {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
} else {
done();
}
});
function emptyResultMapConfig(markerFillRule) {
var cartocss = [
"#county_points_with_population {",
" marker-placement: point;",
" marker-allow-overlap: true;",
" marker-fill-opacity: 1.0;",
" marker-fill: " + markerFillRule + ';',
" marker-line-width: 0;",
"}"
].join('\n');
return {
"version": "1.5.0",
"layers": [
{
"type": 'mapnik',
"options": {
"cartocss_version": '2.3.0',
"source": {
"id": "head"
},
"cartocss": cartocss
}
}
],
"analyses": [
{
"id": "head",
"type": "source",
"params": {
"query": "SELECT * FROM populated_places_simple_reduced limit 0"
}
}
]
};
}
var methods = ['quantiles', 'equal', 'jenks', 'headtails', 'category'];
methods.forEach(function(method) {
it('should work for "' + method+ '" method', function(done) {
var makerFillRule = 'ramp([pop_max], (#E5F5F9,#99D8C9,#2CA25F), ' + method + ')';
this.testClient = new TestClient(emptyResultMapConfig(makerFillRule), 1234);
this.testClient.getLayergroup(function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
done();
});
});
});
});
var scenarios = [
{
desc: 'numeric datasource',
cartocss: [
"#points {",
" marker-fill: ramp([scalerank], colorbrewer(Reds), category);",
"}"
].join('\n'),
expected: [
'#points {',
' marker-fill: #fee5d9;',
' [ scalerank = 6 ] {',
' marker-fill: #fcae91',
' }',
' [ scalerank = 8 ] {',
' marker-fill: #fb6a4a',
' }',
' [ scalerank = 4 ] {',
' marker-fill: #de2d26',
' }',
' [ scalerank = 10 ] {',
' marker-fill: #a50f15',
' }',
'}',
].join('\n')
},
{
desc: 'string datasource',
cartocss: [
"#points {",
" marker-fill: ramp([adm0name], colorbrewer(Reds), category);",
"}"
].join('\n'),
expected: [
'#points {',
' marker-fill: #fee5d9;',
' [ adm0name = "Russia" ] {',
' marker-fill: #fcae91',
' }',
' [ adm0name = "China" ] {',
' marker-fill: #fb6a4a',
' }',
' [ adm0name = "Brazil" ] {',
' marker-fill: #de2d26',
' }',
' [ adm0name = "Canada" ] {',
' marker-fill: #a50f15',
' }',
'}',
].join('\n')
},
{
desc: 'numeric manual',
cartocss: [
"#points {",
" marker-fill: ramp([scalerank], colorbrewer(Reds), (-1, 6, 8, 4, 10), category);",
"}"
].join('\n'),
expected: [
'#points {',
' marker-fill: #fee5d9;',
' [ scalerank = 6 ] {',
' marker-fill: #fcae91',
' }',
' [ scalerank = 8 ] {',
' marker-fill: #fb6a4a',
' }',
' [ scalerank = 4 ] {',
' marker-fill: #de2d26',
' }',
' [ scalerank = 10 ] {',
' marker-fill: #a50f15',
' }',
'}',
].join('\n')
}
];
scenarios.forEach(function(scenario) {
it('category ramps should use original type: ' + scenario.desc, function(done) {
var mapConfig = makeMapconfig('SELECT * FROM populated_places_simple_reduced', scenario.cartocss);
this.testClient = new TestClient(mapConfig);
this.testClient.getLayergroup(function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.deepEqual(layergroup.metadata.layers[0].meta.cartocss, scenario.expected);
done();
});
});
});
});

View File

@@ -1,109 +0,0 @@
require('../../support/test_helper');
var assert = require('../../support/assert');
var TestClient = require('../../support/test-client');
function makeMapconfig(markerWidth, markerFill) {
return {
"version": "1.4.0",
"layers": [
{
"type": 'mapnik',
"options": {
"cartocss_version": '2.3.0',
"sql": 'SELECT * FROM populated_places_simple_reduced',
"cartocss": createCartocss(markerWidth, markerFill)
}
}
]
};
}
function createCartocss(markerWidth, markerFill) {
return [
"#populated_places_simple_reduced {",
" marker-fill-opacity: 0.9;",
" marker-line-color: #FFF;",
" marker-line-width: 1;",
" marker-line-opacity: 1;",
" marker-placement: point;",
" marker-type: ellipse;",
" marker-allow-overlap: true;",
" marker-width: " + (markerWidth || '10') + ";",
" marker-fill: " + (markerFill || 'red') + ";",
"}"
].join('\n');
}
var ERROR_RESPONSE = {
status: 400,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
};
describe('turbo-carto error cases', function() {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
}
});
it('should return invalid number of ramp error', function(done) {
this.testClient = new TestClient(makeMapconfig('ramp([pop_max], (8,24,96), (8,24,96,128))'));
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^turbo-carto/));
assert.ok(layergroup.errors[0].match(/invalid\sramp\slength/i));
done();
});
});
it('should return invalid column from datasource', function(done) {
this.testClient = new TestClient(makeMapconfig(null, 'ramp([wadus_column], (red, green, blue))'));
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^turbo-carto/));
assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors[0].match(/wadus_column/));
done();
});
});
it('should return invalid method from datasource', function(done) {
this.testClient = new TestClient(makeMapconfig(null, 'ramp([wadus_column], (red, green, blue), wadusmethod)'));
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^turbo-carto/));
assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors[0].match(/invalid\smethod\s\"wadusmethod\"/i));
done();
});
});
it('should fail by falling back to normal carto parser', function(done) {
this.testClient = new TestClient(makeMapconfig('ramp([price], (8,24,96), (8,24,96));//(red, green, blue))'));
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(!layergroup.errors[0].match(/^turbo-carto/));
assert.ok(layergroup.errors[0].match(/invalid\scode/i));
done();
});
});
});

View File

@@ -1,236 +0,0 @@
var assert = require('../../support/assert');
var step = require('step');
var LayergroupToken = require('../../support/layergroup-token');
var testHelper = require('../../support/test_helper');
var CartodbWindshaft = require('../../../lib/cartodb/server');
var serverOptions = require('../../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
var mapnik = require('windshaft').mapnik;
var IMAGE_TOLERANCE_PER_MIL = 10;
describe('turbo-carto for named maps', function() {
var keysToDelete;
beforeEach(function() {
keysToDelete = {};
});
afterEach(function(done) {
testHelper.deleteRedisKeys(keysToDelete, done);
});
var templateId = 'turbo-carto-template-1';
var template = {
version: '0.0.1',
name: templateId,
auth: { method: 'open' },
placeholders: {
color: {
type: "css_color",
default: "Reds"
}
},
layergroup: {
version: '1.0.0',
layers: [{
options: {
sql: [
'SELECT test_table.*, _prices.price FROM test_table JOIN (' +
' SELECT 1 AS cartodb_id, 10.00 AS price',
' UNION',
' SELECT 2, 10.50',
' UNION',
' SELECT 3, 11.00',
' UNION',
' SELECT 4, 12.00',
' UNION',
' SELECT 5, 21.00',
') _prices ON _prices.cartodb_id = test_table.cartodb_id'
].join('\n'),
cartocss: [
'#layer {',
' marker-fill: ramp([price], colorbrewer(<%= color %>));',
' marker-allow-overlap:true;',
'}'
].join('\n'),
cartocss_version: '2.0.2'
}
}
]
}
};
var templateParamsReds = { color: 'Reds' };
var templateParamsBlues = { color: 'Blues' };
it('should create a template with turbo-carto parsed properly', function (done) {
step(
function postTemplate() {
var next = this;
assert.response(server, {
url: '/api/v1/map/named?api_key=1234',
method: 'POST',
headers: { host: 'localhost', 'Content-Type': 'application/json' },
data: JSON.stringify(template)
}, {},
function (res, err) {
next(err, res);
});
},
function checkTemplate(err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert.deepEqual(JSON.parse(res.body), {
template_id: templateId
});
return null;
},
function instantiateTemplateWithReds(err) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/named/' + templateId,
method: 'POST',
headers: {
host: 'localhost',
'Content-Type': 'application/json'
},
data: JSON.stringify(templateParamsReds)
}, {},
function(res, err) {
return next(err, res);
});
},
function checkInstanciationWithReds(err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
var parsedBody = JSON.parse(res.body);
keysToDelete['map_cfg|' + LayergroupToken.parse(parsedBody.layergroupid).token] = 0;
keysToDelete['user:localhost:mapviews:global'] = 5;
assert.ok(parsedBody.layergroupid);
assert.ok(parsedBody.last_updated);
return parsedBody.layergroupid;
},
function requestTileReds(err, layergroupId) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/' + layergroupId + '/0/0/0.png',
method: 'GET',
headers: { host: 'localhost' },
encoding: 'binary'
}, {},
function(res, err) {
next(err, res);
});
},
function checkTileReds(err, res) {
assert.ifError(err);
var next = this;
assert.equal(res.statusCode, 200);
assert.equal(res.headers['content-type'], 'image/png');
var fixturePath = './test/fixtures/turbo-carto-named-maps-reds.png';
var image = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
assert.imageIsSimilarToFile(image, fixturePath, IMAGE_TOLERANCE_PER_MIL, next);
},
function instantiateTemplateWithBlues(err) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/named/' + templateId,
method: 'POST',
headers: {
host: 'localhost',
'Content-Type': 'application/json'
},
data: JSON.stringify(templateParamsBlues)
}, {},
function(res, err) {
return next(err, res);
});
},
function checkInstanciationWithBlues(err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
var parsedBody = JSON.parse(res.body);
keysToDelete['map_cfg|' + LayergroupToken.parse(parsedBody.layergroupid).token] = 0;
keysToDelete['user:localhost:mapviews:global'] = 5;
assert.ok(parsedBody.layergroupid);
assert.ok(parsedBody.last_updated);
return parsedBody.layergroupid;
},
function requestTileBlues(err, layergroupId) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/' + layergroupId + '/0/0/0.png',
method: 'GET',
headers: { host: 'localhost' },
encoding: 'binary'
}, {},
function(res, err) {
next(err, res);
});
},
function checkTileBlues(err, res) {
assert.ifError(err);
var next = this;
assert.equal(res.statusCode, 200);
assert.equal(res.headers['content-type'], 'image/png');
var fixturePath = './test/fixtures/turbo-carto-named-maps-blues.png';
var image = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
assert.imageIsSimilarToFile(image, fixturePath, IMAGE_TOLERANCE_PER_MIL, next);
},
function deleteTemplate(err) {
assert.ifError(err);
var next = this;
assert.response(server, {
url: '/api/v1/map/named/' + templateId + '?api_key=1234',
method: 'DELETE',
headers: { host: 'localhost' }
}, {}, function (res, err) {
next(err, res);
});
},
function checkDeleteTemplate(err, res) {
assert.ifError(err);
assert.equal(res.statusCode, 204);
assert.ok(!res.body);
return null;
},
function finish(err) {
done(err);
}
);
});
});

View File

@@ -1,170 +0,0 @@
require('../../support/test_helper');
var assert = require('../../support/assert');
var TestClient = require('../../support/test-client');
function makeMapconfig(sql, cartocss) {
return {
"version": "1.4.0",
"layers": [
{
"type": 'mapnik',
"options": {
"cartocss_version": '2.3.0',
"sql": sql,
"cartocss": cartocss
}
}
]
};
}
describe('turbo-carto regressions', function() {
afterEach(function (done) {
if (this.testClient) {
this.testClient.drain(done);
}
});
it('should accept // comments', function(done) {
var cartocss = [
"/** simple visualization */",
"",
"Map {",
" buffer-size: 256;",
"}",
"",
"#county_points_with_population{",
" marker-fill-opacity: 0.1;",
" marker-line-color:#FFFFFF;//#CF1C90;",
" marker-line-width: 0;",
" marker-line-opacity: 0.3;",
" marker-placement: point;",
" marker-type: ellipse;",
" //marker-comp-op: overlay;",
" marker-width: [cartodb_id];",
" [zoom=5]{marker-width: [cartodb_id]*2;}",
" [zoom=6]{marker-width: [cartodb_id]*4;}",
" marker-fill: #000000;",
" marker-allow-overlap: true;",
" ",
"",
"}"
].join('\n');
this.testClient = new TestClient(makeMapconfig('SELECT * FROM populated_places_simple_reduced', cartocss));
this.testClient.getLayergroup(function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
done();
});
});
it('should work with mapnik substitution tokens', function(done) {
var cartocss = [
"#layer {",
" line-width: 2;",
" line-color: #3B3B58;",
" line-opacity: 1;",
" polygon-opacity: 0.7;",
" polygon-fill: ramp([points_count], (#E5F5F9,#99D8C9,#2CA25F))",
"}"
].join('\n');
var sql = [
'WITH hgrid AS (',
' SELECT CDB_HexagonGrid(',
' ST_Expand(!bbox!, greatest(!pixel_width!,!pixel_height!) * 100),',
' greatest(!pixel_width!,!pixel_height!) * 100',
' ) as cell',
')',
'SELECT',
' hgrid.cell as the_geom_webmercator,',
' count(1) as points_count,',
' count(1)/power(100 * CDB_XYZ_Resolution(CDB_ZoomFromScale(!scale_denominator!)), 2) as points_density,',
' 1 as cartodb_id',
'FROM hgrid, (SELECT * FROM populated_places_simple_reduced) i',
'where ST_Intersects(i.the_geom_webmercator, hgrid.cell)',
'GROUP BY hgrid.cell'
].join('\n');
this.testClient = new TestClient(makeMapconfig(sql, cartocss));
this.testClient.getLayergroup(function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
done();
});
});
it('should work with mapnik substitution tokens and analyses', function(done) {
var cartocss = [
"#layer {",
" line-width: 2;",
" line-color: #3B3B58;",
" line-opacity: 1;",
" polygon-opacity: 0.7;",
" polygon-fill: ramp([points_count], (#E5F5F9,#99D8C9,#2CA25F))",
"}"
].join('\n');
var sqlWrap = [
'WITH hgrid AS (',
' SELECT CDB_HexagonGrid(',
' ST_Expand(!bbox!, greatest(!pixel_width!,!pixel_height!) * 100),',
' greatest(!pixel_width!,!pixel_height!) * 100',
' ) as cell',
')',
'SELECT',
' hgrid.cell as the_geom_webmercator,',
' count(1) as points_count,',
' count(1)/power(100 * CDB_XYZ_Resolution(CDB_ZoomFromScale(!scale_denominator!)), 2) as points_density,',
' 1 as cartodb_id',
'FROM hgrid, (<%= sql %>) i',
'where ST_Intersects(i.the_geom_webmercator, hgrid.cell)',
'GROUP BY hgrid.cell'
].join('\n');
var mapConfig = {
"version": "1.5.0",
"layers": [
{
"type": 'mapnik',
"options": {
"cartocss_version": '2.3.0',
"source": {
"id": "head"
},
sql_wrap: sqlWrap,
"cartocss": cartocss
}
}
],
"analyses": [
{
"id": "head",
"type": "source",
"params": {
"query": "SELECT * FROM populated_places_simple_reduced"
}
}
]
};
this.testClient = new TestClient(mapConfig, 1234);
this.testClient.getLayergroup(function(err, layergroup) {
assert.ok(!err, err);
assert.ok(layergroup.hasOwnProperty('layergroupid'));
assert.ok(!layergroup.hasOwnProperty('errors'));
done();
});
});
});

View File

@@ -304,6 +304,37 @@ describe('widgets', function() {
});
});
it('can use a datetime filtered column with no results', function(done) {
this.testClient = new TestClient(histogramsMapConfig({
updated_at: {
type: 'histogram',
options: {
column: 'updated_at'
}
}
}));
var params = {
own_filter: 1,
filters: {
layers: [{
updated_at: {
// this will remove all results
max: -1
}
}]
}
};
this.testClient.getWidget('updated_at', params, function (err, res, histogram) {
assert.ok(!err, err);
assert.ok(histogram);
assert.equal(histogram.type, 'histogram');
assert.equal(histogram.bins.length, 0);
done();
});
});
it('can getTile with datetime filtered column', function(done) {
this.testClient = new TestClient(histogramsMapConfig({
updated_at: {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Some files were not shown because too many files have changed in this diff Show More