{"action":"created","comment":{"url":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/comments/47139202","id":47139202,"diff_hunk":"@@ -0,0 +1,160 @@\n+# -*- coding: utf-8 -*-\n+from __future__ import print_function\n+from __future__ import unicode_literals\n+from __future__ import division\n+\n+from math import floor\n+\n+from django.db import connection\n+\n+from treemap.models import MapFeature\n+\n+GRID_PIXELS = 2\n+MAX_ZOOM = 14\n+MIN_ZOOM = 0\n+\n+# When viewing a zoomed-out tree map, multiple plots in a local area are\n+# rendered on top of one another. We set MapFeature.hide_at_zoom so the tiler\n+# can render just one plot in such cases, speeding up tile creation for maps\n+# with many plots.\n+#\n+# At each zoom level Z we find groups of plots located in the same cell of\n+# a 2-pixel grid, and set hide_at_zoom = Z for all but one plot in each group.","path":"opentreemap/treemap/lib/hide_at_zoom.py","position":22,"original_position":22,"commit_id":"c66dcb35c71a28d931c6874fc68854fbadb9532c","original_commit_id":"c66dcb35c71a28d931c6874fc68854fbadb9532c","user":{"login":"RickMohr","id":2162993,"avatar_url":"https://avatars.githubusercontent.com/u/2162993?v=3","gravatar_id":"","url":"https://api.github.com/users/RickMohr","html_url":"https://github.com/RickMohr","followers_url":"https://api.github.com/users/RickMohr/followers","following_url":"https://api.github.com/users/RickMohr/following{/other_user}","gists_url":"https://api.github.com/users/RickMohr/gists{/gist_id}","starred_url":"https://api.github.com/users/RickMohr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RickMohr/subscriptions","organizations_url":"https://api.github.com/users/RickMohr/orgs","repos_url":"https://api.github.com/users/RickMohr/repos","events_url":"https://api.github.com/users/RickMohr/events{/privacy}","received_events_url":"https://api.github.com/users/RickMohr/received_events","type":"User","site_admin":false},"body":"Good point. I tried a bunch of sizes. The bigger the grid the better the speedup, but with larger grids the map starts to look funny. 2 pixels was the sweet spot.","created_at":"2015-12-09T19:29:23Z","updated_at":"2015-12-09T19:29:23Z","html_url":"https://github.com/OpenTreeMap/otm-core/pull/2375#discussion_r47139202","pull_request_url":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/2375","_links":{"self":{"href":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/comments/47139202"},"html":{"href":"https://github.com/OpenTreeMap/otm-core/pull/2375#discussion_r47139202"},"pull_request":{"href":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/2375"}}},"pull_request":{"url":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/2375","id":52901046,"html_url":"https://github.com/OpenTreeMap/otm-core/pull/2375","diff_url":"https://github.com/OpenTreeMap/otm-core/pull/2375.diff","patch_url":"https://github.com/OpenTreeMap/otm-core/pull/2375.patch","issue_url":"https://api.github.com/repos/OpenTreeMap/otm-core/issues/2375","number":2375,"state":"open","locked":false,"title":"Support for tiler to render fewer plots on large maps","user":{"login":"RickMohr","id":2162993,"avatar_url":"https://avatars.githubusercontent.com/u/2162993?v=3","gravatar_id":"","url":"https://api.github.com/users/RickMohr","html_url":"https://github.com/RickMohr","followers_url":"https://api.github.com/users/RickMohr/followers","following_url":"https://api.github.com/users/RickMohr/following{/other_user}","gists_url":"https://api.github.com/users/RickMohr/gists{/gist_id}","starred_url":"https://api.github.com/users/RickMohr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RickMohr/subscriptions","organizations_url":"https://api.github.com/users/RickMohr/orgs","repos_url":"https://api.github.com/users/RickMohr/repos","events_url":"https://api.github.com/users/RickMohr/events{/privacy}","received_events_url":"https://api.github.com/users/RickMohr/received_events","type":"User","site_admin":false},"body":"When viewing a zoomed-out tree map, multiple plots in a local area are rendered on top of one another. We set `MapFeature.hide_at_zoom` so the tiler can render just one plot in such cases, speeding up tile creation for maps with many plots.\r\n\r\nThe plan is to recompute `hide_at_zoom` nightly. After a large tree import, tiling could be somewhat slower until the next day.\r\n\r\nTo test:\r\n\r\n1. Run migrations\r\n2. Run management command to set `hide_at_zoom` for all plots in a large instance, e.g. `manage.py recompute_hide_at_zoom latreemap`. (It takes several minutes to complete.)\r\n3. Load the tree map (with dev tools open to disable cacheing) and click around\r\n4. To compare performance, do an advanced search of \"Last Updated\" from 5 years ago to now. (When a filter is passed to the tiler the optimizations aren't used.)\r\n\r\nRequires OpenTreeMap/otm-tiler#93\r\nConnects #2374 ","created_at":"2015-12-07T21:08:55Z","updated_at":"2015-12-09T19:29:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f37ed5a7dc91fbe99845e980941147b9adf64061","assignee":{"login":"jwalgran","id":17363,"avatar_url":"https://avatars.githubusercontent.com/u/17363?v=3","gravatar_id":"","url":"https://api.github.com/users/jwalgran","html_url":"https://github.com/jwalgran","followers_url":"https://api.github.com/users/jwalgran/followers","following_url":"https://api.github.com/users/jwalgran/following{/other_user}","gists_url":"https://api.github.com/users/jwalgran/gists{/gist_id}","starred_url":"https://api.github.com/users/jwalgran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwalgran/subscriptions","organizations_url":"https://api.github.com/users/jwalgran/orgs","repos_url":"https://api.github.com/users/jwalgran/repos","events_url":"https://api.github.com/users/jwalgran/events{/privacy}","received_events_url":"https://api.github.com/users/jwalgran/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/2375/commits","review_comments_url":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/2375/comments","review_comment_url":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenTreeMap/otm-core/issues/2375/comments","statuses_url":"https://api.github.com/repos/OpenTreeMap/otm-core/statuses/c66dcb35c71a28d931c6874fc68854fbadb9532c","head":{"label":"RickMohr:hide-at-zoom","ref":"hide-at-zoom","sha":"c66dcb35c71a28d931c6874fc68854fbadb9532c","user":{"login":"RickMohr","id":2162993,"avatar_url":"https://avatars.githubusercontent.com/u/2162993?v=3","gravatar_id":"","url":"https://api.github.com/users/RickMohr","html_url":"https://github.com/RickMohr","followers_url":"https://api.github.com/users/RickMohr/followers","following_url":"https://api.github.com/users/RickMohr/following{/other_user}","gists_url":"https://api.github.com/users/RickMohr/gists{/gist_id}","starred_url":"https://api.github.com/users/RickMohr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RickMohr/subscriptions","organizations_url":"https://api.github.com/users/RickMohr/orgs","repos_url":"https://api.github.com/users/RickMohr/repos","events_url":"https://api.github.com/users/RickMohr/events{/privacy}","received_events_url":"https://api.github.com/users/RickMohr/received_events","type":"User","site_admin":false},"repo":{"id":11528430,"name":"otm-core","full_name":"RickMohr/otm-core","owner":{"login":"RickMohr","id":2162993,"avatar_url":"https://avatars.githubusercontent.com/u/2162993?v=3","gravatar_id":"","url":"https://api.github.com/users/RickMohr","html_url":"https://github.com/RickMohr","followers_url":"https://api.github.com/users/RickMohr/followers","following_url":"https://api.github.com/users/RickMohr/following{/other_user}","gists_url":"https://api.github.com/users/RickMohr/gists{/gist_id}","starred_url":"https://api.github.com/users/RickMohr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RickMohr/subscriptions","organizations_url":"https://api.github.com/users/RickMohr/orgs","repos_url":"https://api.github.com/users/RickMohr/repos","events_url":"https://api.github.com/users/RickMohr/events{/privacy}","received_events_url":"https://api.github.com/users/RickMohr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RickMohr/otm-core","description":"","fork":true,"url":"https://api.github.com/repos/RickMohr/otm-core","forks_url":"https://api.github.com/repos/RickMohr/otm-core/forks","keys_url":"https://api.github.com/repos/RickMohr/otm-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RickMohr/otm-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RickMohr/otm-core/teams","hooks_url":"https://api.github.com/repos/RickMohr/otm-core/hooks","issue_events_url":"https://api.github.com/repos/RickMohr/otm-core/issues/events{/number}","events_url":"https://api.github.com/repos/RickMohr/otm-core/events","assignees_url":"https://api.github.com/repos/RickMohr/otm-core/assignees{/user}","branches_url":"https://api.github.com/repos/RickMohr/otm-core/branches{/branch}","tags_url":"https://api.github.com/repos/RickMohr/otm-core/tags","blobs_url":"https://api.github.com/repos/RickMohr/otm-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RickMohr/otm-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RickMohr/otm-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/RickMohr/otm-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RickMohr/otm-core/statuses/{sha}","languages_url":"https://api.github.com/repos/RickMohr/otm-core/languages","stargazers_url":"https://api.github.com/repos/RickMohr/otm-core/stargazers","contributors_url":"https://api.github.com/repos/RickMohr/otm-core/contributors","subscribers_url":"https://api.github.com/repos/RickMohr/otm-core/subscribers","subscription_url":"https://api.github.com/repos/RickMohr/otm-core/subscription","commits_url":"https://api.github.com/repos/RickMohr/otm-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/RickMohr/otm-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/RickMohr/otm-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/RickMohr/otm-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/RickMohr/otm-core/contents/{+path}","compare_url":"https://api.github.com/repos/RickMohr/otm-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RickMohr/otm-core/merges","archive_url":"https://api.github.com/repos/RickMohr/otm-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RickMohr/otm-core/downloads","issues_url":"https://api.github.com/repos/RickMohr/otm-core/issues{/number}","pulls_url":"https://api.github.com/repos/RickMohr/otm-core/pulls{/number}","milestones_url":"https://api.github.com/repos/RickMohr/otm-core/milestones{/number}","notifications_url":"https://api.github.com/repos/RickMohr/otm-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RickMohr/otm-core/labels{/name}","releases_url":"https://api.github.com/repos/RickMohr/otm-core/releases{/id}","created_at":"2013-07-19T13:31:15Z","updated_at":"2015-05-29T21:30:41Z","pushed_at":"2015-12-09T18:55:14Z","git_url":"git://github.com/RickMohr/otm-core.git","ssh_url":"git@github.com:RickMohr/otm-core.git","clone_url":"https://github.com/RickMohr/otm-core.git","svn_url":"https://github.com/RickMohr/otm-core","homepage":null,"size":12502,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"OpenTreeMap:master","ref":"master","sha":"86ff071b52b31a243434183eb8189e20964fa19b","user":{"login":"OpenTreeMap","id":1125635,"avatar_url":"https://avatars.githubusercontent.com/u/1125635?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenTreeMap","html_url":"https://github.com/OpenTreeMap","followers_url":"https://api.github.com/users/OpenTreeMap/followers","following_url":"https://api.github.com/users/OpenTreeMap/following{/other_user}","gists_url":"https://api.github.com/users/OpenTreeMap/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenTreeMap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenTreeMap/subscriptions","organizations_url":"https://api.github.com/users/OpenTreeMap/orgs","repos_url":"https://api.github.com/users/OpenTreeMap/repos","events_url":"https://api.github.com/users/OpenTreeMap/events{/privacy}","received_events_url":"https://api.github.com/users/OpenTreeMap/received_events","type":"Organization","site_admin":false},"repo":{"id":8292625,"name":"otm-core","full_name":"OpenTreeMap/otm-core","owner":{"login":"OpenTreeMap","id":1125635,"avatar_url":"https://avatars.githubusercontent.com/u/1125635?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenTreeMap","html_url":"https://github.com/OpenTreeMap","followers_url":"https://api.github.com/users/OpenTreeMap/followers","following_url":"https://api.github.com/users/OpenTreeMap/following{/other_user}","gists_url":"https://api.github.com/users/OpenTreeMap/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenTreeMap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenTreeMap/subscriptions","organizations_url":"https://api.github.com/users/OpenTreeMap/orgs","repos_url":"https://api.github.com/users/OpenTreeMap/repos","events_url":"https://api.github.com/users/OpenTreeMap/events{/privacy}","received_events_url":"https://api.github.com/users/OpenTreeMap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenTreeMap/otm-core","description":"OpenTreeMap is a collaborative platform for crowdsourced tree inventory, ecosystem services calculations, urban forestry analysis, and community engagement.","fork":false,"url":"https://api.github.com/repos/OpenTreeMap/otm-core","forks_url":"https://api.github.com/repos/OpenTreeMap/otm-core/forks","keys_url":"https://api.github.com/repos/OpenTreeMap/otm-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenTreeMap/otm-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenTreeMap/otm-core/teams","hooks_url":"https://api.github.com/repos/OpenTreeMap/otm-core/hooks","issue_events_url":"https://api.github.com/repos/OpenTreeMap/otm-core/issues/events{/number}","events_url":"https://api.github.com/repos/OpenTreeMap/otm-core/events","assignees_url":"https://api.github.com/repos/OpenTreeMap/otm-core/assignees{/user}","branches_url":"https://api.github.com/repos/OpenTreeMap/otm-core/branches{/branch}","tags_url":"https://api.github.com/repos/OpenTreeMap/otm-core/tags","blobs_url":"https://api.github.com/repos/OpenTreeMap/otm-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenTreeMap/otm-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenTreeMap/otm-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenTreeMap/otm-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenTreeMap/otm-core/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenTreeMap/otm-core/languages","stargazers_url":"https://api.github.com/repos/OpenTreeMap/otm-core/stargazers","contributors_url":"https://api.github.com/repos/OpenTreeMap/otm-core/contributors","subscribers_url":"https://api.github.com/repos/OpenTreeMap/otm-core/subscribers","subscription_url":"https://api.github.com/repos/OpenTreeMap/otm-core/subscription","commits_url":"https://api.github.com/repos/OpenTreeMap/otm-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenTreeMap/otm-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenTreeMap/otm-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenTreeMap/otm-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenTreeMap/otm-core/contents/{+path}","compare_url":"https://api.github.com/repos/OpenTreeMap/otm-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenTreeMap/otm-core/merges","archive_url":"https://api.github.com/repos/OpenTreeMap/otm-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenTreeMap/otm-core/downloads","issues_url":"https://api.github.com/repos/OpenTreeMap/otm-core/issues{/number}","pulls_url":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenTreeMap/otm-core/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenTreeMap/otm-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenTreeMap/otm-core/labels{/name}","releases_url":"https://api.github.com/repos/OpenTreeMap/otm-core/releases{/id}","created_at":"2013-02-19T15:11:04Z","updated_at":"2015-10-28T03:48:08Z","pushed_at":"2015-12-09T18:55:05Z","git_url":"git://github.com/OpenTreeMap/otm-core.git","ssh_url":"git@github.com:OpenTreeMap/otm-core.git","clone_url":"https://github.com/OpenTreeMap/otm-core.git","svn_url":"https://github.com/OpenTreeMap/otm-core","homepage":"www.opentreemap.org","size":12821,"stargazers_count":63,"watchers_count":63,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":43,"mirror_url":null,"open_issues_count":331,"forks":43,"open_issues":331,"watchers":63,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/2375"},"html":{"href":"https://github.com/OpenTreeMap/otm-core/pull/2375"},"issue":{"href":"https://api.github.com/repos/OpenTreeMap/otm-core/issues/2375"},"comments":{"href":"https://api.github.com/repos/OpenTreeMap/otm-core/issues/2375/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/2375/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenTreeMap/otm-core/pulls/2375/commits"},"statuses":{"href":"https://api.github.com/repos/OpenTreeMap/otm-core/statuses/c66dcb35c71a28d931c6874fc68854fbadb9532c"}}}}