{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/mapbox-gl/issues/26","repository_url":"https://api.github.com/repos/mapbox/mapbox-gl","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl/issues/26/comments","events_url":"https://api.github.com/repos/mapbox/mapbox-gl/issues/26/events","html_url":"https://github.com/mapbox/mapbox-gl/issues/26","id":177194594,"number":26,"title":"Adding custom cluster aggregation support","user":{"login":"redbmk","id":83964,"avatar_url":"https://avatars.githubusercontent.com/u/83964?v=3","gravatar_id":"","url":"https://api.github.com/users/redbmk","html_url":"https://github.com/redbmk","followers_url":"https://api.github.com/users/redbmk/followers","following_url":"https://api.github.com/users/redbmk/following{/other_user}","gists_url":"https://api.github.com/users/redbmk/gists{/gist_id}","starred_url":"https://api.github.com/users/redbmk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redbmk/subscriptions","organizations_url":"https://api.github.com/users/redbmk/orgs","repos_url":"https://api.github.com/users/redbmk/repos","events_url":"https://api.github.com/users/redbmk/events{/privacy}","received_events_url":"https://api.github.com/users/redbmk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-15T14:36:26Z","updated_at":"2016-09-15T18:04:29Z","closed_at":null,"body":"I've been working on getting support for custom aggregations within clusters. There's been some discussion at mapbox/mapboxgl-js#2412 about adding support for cluster properties.\r\n\r\nI'm not sure the best way to go about getting a change implemented, but I'm willing to work on the code, and I have a rough draft I'd like to get reviewed. Could somebody please walk me through the process of getting the code reviewed and merged? It involves changes to at least three projects - [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js), [mapbox-gl-style-spec](https://github.com/mapbox/mapbox-gl-style-spec), and [supercluster](https://github.com/mapbox/supercluster).\r\n\r\nI still need to write tests and make changes to the spec. Also I figure it will need to be tested and code reviewed for style, browser support, error checking, safety/security, speed, etc. Regardless, here's what I have so far:\r\n\r\n* [supercluster changes](https://github.com/mapbox/supercluster/compare/master...redbmk:4d54aeb)\r\n* [mapbox-gl-js changes](https://github.com/mapbox/mapbox-gl-js/compare/master...redbmk:0a33ec7)\r\n\r\nThen in your mapbox style you could provide an option like this:\r\n\r\n```\r\nclusterAggregates: {\r\n  property1: 'sum',\r\n  property2: 'min',\r\n  property3: 'min',\r\n  property4: 'max'\r\n}\r\n```\r\n\r\nI'm also not sure how much error/type checking should be involved (Also is it better to discuss this here or in the mapbox-gl-js issue referenced above?). Would we expect users to have proper numbers in all the properties for all the points they want aggregated, or should we do things like `Number(num) || 0)` when summing and something like `Math.max(Number(num1) || -Infinity, Number(num2) || -Infinity)`? The code as it is now just assumes you're providing legit numbers. Technically the `sum` option would concatenate strings."},"comment":{"url":"https://api.github.com/repos/mapbox/mapbox-gl/issues/comments/247404448","html_url":"https://github.com/mapbox/mapbox-gl/issues/26#issuecomment-247404448","issue_url":"https://api.github.com/repos/mapbox/mapbox-gl/issues/26","id":247404448,"user":{"login":"lucaswoj","id":281306,"avatar_url":"https://avatars.githubusercontent.com/u/281306?v=3","gravatar_id":"","url":"https://api.github.com/users/lucaswoj","html_url":"https://github.com/lucaswoj","followers_url":"https://api.github.com/users/lucaswoj/followers","following_url":"https://api.github.com/users/lucaswoj/following{/other_user}","gists_url":"https://api.github.com/users/lucaswoj/gists{/gist_id}","starred_url":"https://api.github.com/users/lucaswoj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucaswoj/subscriptions","organizations_url":"https://api.github.com/users/lucaswoj/orgs","repos_url":"https://api.github.com/users/lucaswoj/repos","events_url":"https://api.github.com/users/lucaswoj/events{/privacy}","received_events_url":"https://api.github.com/users/lucaswoj/received_events","type":"User","site_admin":false},"created_at":"2016-09-15T18:04:29Z","updated_at":"2016-09-15T18:04:29Z","body":"Thanks @redbmk! Does that syntax support calculating both the `sum` and the `min` of a particular key? What do you think about something like this?\r\n\r\n```js\r\nclusterAggregates: {\r\n  priceSum: ['sum', 'price'],\r\n  priceMin: ['min', 'price'],\r\n  sizeMax: ['max', 'size']\r\n}\r\n```"}}
{"actor":{"display_login":"lucaswoj"}}