{"action":"created","comment":{"url":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/comments/47097406","id":47097406,"diff_hunk":"@@ -0,0 +1,105 @@\n+var Crossfilter = require(\"crossfilter\");\n+\n+function Filter(){\n+  this.crossfilter = new Crossfilter();\n+  this.dimensions = {};\n+  this.tiles = {};\n+  this.report = {};\n+  this.expressions = {};\n+};\n+\n+Filter.prototype = {\n+  addTile: function(tilePoint, collection){\n+    var tilePointString = tilePoint.zoom + \":\" + tilePoint.x + \":\" + tilePoint.y;\n+    if (typeof this.tiles[tilePointString] != 'undefined') return this.getTile(tilePoint);\n+    this.crossfilter.add(collection.features.map(function(f){\n+      f.properties.tilePoint = tilePoint.zoom + \":\" + tilePoint.x + \":\" + tilePoint.y;\n+      return f;\n+    }));\n+    this.tiles[tilePointString] = true;\n+    return this.getTile(tilePoint);\n+  },\n+\n+  removeTile: function(tilePoint){\n+    var tilePointString = tilePoint.zoom + \":\" + tilePoint.x + \":\" + tilePoint.y;\n+    if(!this.dimensions.tiles){\n+      return;\n+    }\n+    this.dimensions.tiles.filter(tilePointString);\n+    this.crossfilter.remove();\n+    this.dimensions.tiles.filterAll();\n+    delete this.tiles[tilePointString];\n+  },\n+\n+  getTile: function(tilePoint){\n+    var tilePointString = tilePoint.zoom + \":\" + tilePoint.x + \":\" + tilePoint.y;\n+    if(!this.dimensions.tiles){\n+      this.dimensions.tiles = this.crossfilter.dimension(function(f){return f.properties.tilePoint});\n+    }\n+    var tile = {type: \"FeatureCollection\", features: null};\n+    this.dimensions.tiles.filter(tilePointString);\n+    tile.features = this.dimensions.tiles.top(Infinity);\n+    this.dimensions.tiles.filterAll();\n+    return tile;\n+  },\n+\n+  filterRange: function(column, range){\n+    if (!this.dimensions[column]){\n+      this.dimensions[column] = this.crossfilter.dimension(function(f){return f.properties[column]});\n+    }\n+    this.dimensions[column].filter(range);\n+\n+  },\n+\n+  filterAccept: function(column, terms){\n+    if (!this.dimensions[column]){\n+      this.dimensions[column] = this.crossfilter.dimension(function(f){return f.properties[column]});\n+    }\n+    if (!(terms instanceof Array)){\n+      terms = [terms];\n+    }\n+    this.dimensions[column].filter(function(f){\n+      if (terms.indexOf(f) > -1){\n+        return true;\n+      }\n+    });\n+\n+  },\n+\n+  filterReject: function(column, terms){\n+    if (!this.dimensions[column]){\n+      this.dimensions[column] = this.crossfilter.dimension(function(f){return f.properties[column]});\n+    }\n+    if (!terms.length){\n+      terms = [terms];\n+    }\n+    this.dimensions[column].filter(function(f){\n+      if (terms.indexOf(f) === -1){\n+        return true;\n+      }\n+    });\n+  },\n+\n+  clearFilters: function() {\n+    for (var column in this.dimensions){\n+      this.dimensions[column].filterAll();\n+    }\n+  },\n+\n+  clearFilter: function(column) {\n+    this.dimensions[column].filterAll();\n+  },\n+\n+  getValues: function(column) {\n+    return this.dimensions[column].top(Infinity);\n+  },\n+\n+  // setBoundingBox: function(north, east, south, west) {","path":"src/filter.js","position":97,"original_position":97,"commit_id":"e80c58531b64c28d461b7167640c03859621b64d","original_commit_id":"e80c58531b64c28d461b7167640c03859621b64d","user":{"login":"rochoa","id":45346,"avatar_url":"https://avatars.githubusercontent.com/u/45346?v=3","gravatar_id":"","url":"https://api.github.com/users/rochoa","html_url":"https://github.com/rochoa","followers_url":"https://api.github.com/users/rochoa/followers","following_url":"https://api.github.com/users/rochoa/following{/other_user}","gists_url":"https://api.github.com/users/rochoa/gists{/gist_id}","starred_url":"https://api.github.com/users/rochoa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rochoa/subscriptions","organizations_url":"https://api.github.com/users/rochoa/orgs","repos_url":"https://api.github.com/users/rochoa/repos","events_url":"https://api.github.com/users/rochoa/events{/privacy}","received_events_url":"https://api.github.com/users/rochoa/received_events","type":"User","site_admin":false},"body":"Remove it.","created_at":"2015-12-09T14:37:53Z","updated_at":"2015-12-09T14:37:53Z","html_url":"https://github.com/CartoDB/d3.cartodb/pull/42#discussion_r47097406","pull_request_url":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/42","_links":{"self":{"href":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/comments/47097406"},"html":{"href":"https://github.com/CartoDB/d3.cartodb/pull/42#discussion_r47097406"},"pull_request":{"href":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/42","id":52369188,"html_url":"https://github.com/CartoDB/d3.cartodb/pull/42","diff_url":"https://github.com/CartoDB/d3.cartodb/pull/42.diff","patch_url":"https://github.com/CartoDB/d3.cartodb/pull/42.patch","issue_url":"https://api.github.com/repos/CartoDB/d3.cartodb/issues/42","number":42,"state":"open","locked":false,"title":"Filters","user":{"login":"fdansv","id":3707222,"avatar_url":"https://avatars.githubusercontent.com/u/3707222?v=3","gravatar_id":"","url":"https://api.github.com/users/fdansv","html_url":"https://github.com/fdansv","followers_url":"https://api.github.com/users/fdansv/followers","following_url":"https://api.github.com/users/fdansv/following{/other_user}","gists_url":"https://api.github.com/users/fdansv/gists{/gist_id}","starred_url":"https://api.github.com/users/fdansv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fdansv/subscriptions","organizations_url":"https://api.github.com/users/fdansv/orgs","repos_url":"https://api.github.com/users/fdansv/repos","events_url":"https://api.github.com/users/fdansv/events{/privacy}","received_events_url":"https://api.github.com/users/fdansv/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-02T09:05:59Z","updated_at":"2015-12-09T14:37:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b37c2e137fcd7dd15553730797bccec569d75a7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/42/commits","review_comments_url":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/42/comments","review_comment_url":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CartoDB/d3.cartodb/issues/42/comments","statuses_url":"https://api.github.com/repos/CartoDB/d3.cartodb/statuses/e80c58531b64c28d461b7167640c03859621b64d","head":{"label":"CartoDB:crossfilter","ref":"crossfilter","sha":"e80c58531b64c28d461b7167640c03859621b64d","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":42856777,"name":"d3.cartodb","full_name":"CartoDB/d3.cartodb","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/d3.cartodb","description":"Client-side rendering of CartoDB visualisations with d3","fork":false,"url":"https://api.github.com/repos/CartoDB/d3.cartodb","forks_url":"https://api.github.com/repos/CartoDB/d3.cartodb/forks","keys_url":"https://api.github.com/repos/CartoDB/d3.cartodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/d3.cartodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/d3.cartodb/teams","hooks_url":"https://api.github.com/repos/CartoDB/d3.cartodb/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/d3.cartodb/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/d3.cartodb/events","assignees_url":"https://api.github.com/repos/CartoDB/d3.cartodb/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/d3.cartodb/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/d3.cartodb/tags","blobs_url":"https://api.github.com/repos/CartoDB/d3.cartodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/d3.cartodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/d3.cartodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/d3.cartodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/d3.cartodb/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/d3.cartodb/languages","stargazers_url":"https://api.github.com/repos/CartoDB/d3.cartodb/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/d3.cartodb/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/d3.cartodb/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/d3.cartodb/subscription","commits_url":"https://api.github.com/repos/CartoDB/d3.cartodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/d3.cartodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/d3.cartodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/d3.cartodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/d3.cartodb/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/d3.cartodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/d3.cartodb/merges","archive_url":"https://api.github.com/repos/CartoDB/d3.cartodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/d3.cartodb/downloads","issues_url":"https://api.github.com/repos/CartoDB/d3.cartodb/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/d3.cartodb/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/d3.cartodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/d3.cartodb/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/d3.cartodb/releases{/id}","created_at":"2015-09-21T09:29:06Z","updated_at":"2015-11-20T16:36:48Z","pushed_at":"2015-12-09T11:47:20Z","git_url":"git://github.com/CartoDB/d3.cartodb.git","ssh_url":"git@github.com:CartoDB/d3.cartodb.git","clone_url":"https://github.com/CartoDB/d3.cartodb.git","svn_url":"https://github.com/CartoDB/d3.cartodb","homepage":"","size":566,"stargazers_count":17,"watchers_count":17,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":17,"default_branch":"gh-pages"}},"base":{"label":"CartoDB:gh-pages","ref":"gh-pages","sha":"969ebcea6a0d990ff9f89139877f36de81d400d8","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":42856777,"name":"d3.cartodb","full_name":"CartoDB/d3.cartodb","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/d3.cartodb","description":"Client-side rendering of CartoDB visualisations with d3","fork":false,"url":"https://api.github.com/repos/CartoDB/d3.cartodb","forks_url":"https://api.github.com/repos/CartoDB/d3.cartodb/forks","keys_url":"https://api.github.com/repos/CartoDB/d3.cartodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/d3.cartodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/d3.cartodb/teams","hooks_url":"https://api.github.com/repos/CartoDB/d3.cartodb/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/d3.cartodb/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/d3.cartodb/events","assignees_url":"https://api.github.com/repos/CartoDB/d3.cartodb/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/d3.cartodb/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/d3.cartodb/tags","blobs_url":"https://api.github.com/repos/CartoDB/d3.cartodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/d3.cartodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/d3.cartodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/d3.cartodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/d3.cartodb/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/d3.cartodb/languages","stargazers_url":"https://api.github.com/repos/CartoDB/d3.cartodb/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/d3.cartodb/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/d3.cartodb/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/d3.cartodb/subscription","commits_url":"https://api.github.com/repos/CartoDB/d3.cartodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/d3.cartodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/d3.cartodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/d3.cartodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/d3.cartodb/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/d3.cartodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/d3.cartodb/merges","archive_url":"https://api.github.com/repos/CartoDB/d3.cartodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/d3.cartodb/downloads","issues_url":"https://api.github.com/repos/CartoDB/d3.cartodb/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/d3.cartodb/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/d3.cartodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/d3.cartodb/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/d3.cartodb/releases{/id}","created_at":"2015-09-21T09:29:06Z","updated_at":"2015-11-20T16:36:48Z","pushed_at":"2015-12-09T11:47:20Z","git_url":"git://github.com/CartoDB/d3.cartodb.git","ssh_url":"git@github.com:CartoDB/d3.cartodb.git","clone_url":"https://github.com/CartoDB/d3.cartodb.git","svn_url":"https://github.com/CartoDB/d3.cartodb","homepage":"","size":566,"stargazers_count":17,"watchers_count":17,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":17,"default_branch":"gh-pages"}},"_links":{"self":{"href":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/42"},"html":{"href":"https://github.com/CartoDB/d3.cartodb/pull/42"},"issue":{"href":"https://api.github.com/repos/CartoDB/d3.cartodb/issues/42"},"comments":{"href":"https://api.github.com/repos/CartoDB/d3.cartodb/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CartoDB/d3.cartodb/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/CartoDB/d3.cartodb/statuses/e80c58531b64c28d461b7167640c03859621b64d"}}}}