{"action":"created","comment":{"url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/comments/65583636","id":65583636,"diff_hunk":"@@ -31,12 +31,33 @@ L.DistanceMarkers = L.LayerGroup.extend({\n \t\tvar cssClass = options.cssClass || 'dist-marker';\n \n \t\tvar zoomLayers = {};\n-\t\tvar length = L.GeometryUtil.length(line);\n+\t\t// Get line coords as an array\n+        \t  if (typeof line.getLatLngs == 'function') {\n+                \tvar coords = line.getLatLngs();\n+        \t }\n+            \t// Get accumulated line lengths as well as overall length\n+            \tvar accumulated = L.GeometryUtil.accumulatedLengths(line);\n+            \tvar length = accumulated.length > 0 ? accumulated[accumulated.length - 1] : 0;\n+            \t// Position in accumulated line length array\n+            \tvar j = 0;\n+            \t// Number of distance markers to be added\n \t\tvar count = Math.floor(length / offset);\n \n \t\tfor (var i = 1; i <= count; ++i) {\n \t\t\tvar distance = offset * i;\n-\t\t\tvar position = L.GeometryUtil.interpolateOnLine(map, line, distance / length);\n+\t\t\t// Find the first accumulated distance that is greater\n+        \t\t// than the distance of this marker\n+                \twhile (j < length - 1 && accumulated[j] < distance) {","path":"leaflet-distance-marker.js","position":22,"original_position":22,"commit_id":"5fbb81126bd0d37739da2106c958630715d4ef77","original_commit_id":"9fdc62dbc6525557e4fc69bcad135fc3930743aa","user":{"login":"adoroszlai","id":6454655,"avatar_url":"https://avatars.githubusercontent.com/u/6454655?v=3","gravatar_id":"","url":"https://api.github.com/users/adoroszlai","html_url":"https://github.com/adoroszlai","followers_url":"https://api.github.com/users/adoroszlai/followers","following_url":"https://api.github.com/users/adoroszlai/following{/other_user}","gists_url":"https://api.github.com/users/adoroszlai/gists{/gist_id}","starred_url":"https://api.github.com/users/adoroszlai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adoroszlai/subscriptions","organizations_url":"https://api.github.com/users/adoroszlai/orgs","repos_url":"https://api.github.com/users/adoroszlai/repos","events_url":"https://api.github.com/users/adoroszlai/events{/privacy}","received_events_url":"https://api.github.com/users/adoroszlai/received_events","type":"User","site_admin":false},"body":"`length` is the length of the polyline here, not the size of the `accumulated` array.  This could lead to out of bounds problem.  I think it should be `j < accumulated.length - 1` instead.","created_at":"2016-06-02T17:32:56Z","updated_at":"2016-06-02T17:32:56Z","html_url":"https://github.com/adoroszlai/leaflet-distance-markers/pull/4#discussion_r65583636","pull_request_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/comments/65583636"},"html":{"href":"https://github.com/adoroszlai/leaflet-distance-markers/pull/4#discussion_r65583636"},"pull_request":{"href":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/4","id":72339741,"html_url":"https://github.com/adoroszlai/leaflet-distance-markers/pull/4","diff_url":"https://github.com/adoroszlai/leaflet-distance-markers/pull/4.diff","patch_url":"https://github.com/adoroszlai/leaflet-distance-markers/pull/4.patch","issue_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/issues/4","number":4,"state":"open","locked":false,"title":"Performance enhancement","user":{"login":"PhilWhitehurst","id":14213601,"avatar_url":"https://avatars.githubusercontent.com/u/14213601?v=3","gravatar_id":"","url":"https://api.github.com/users/PhilWhitehurst","html_url":"https://github.com/PhilWhitehurst","followers_url":"https://api.github.com/users/PhilWhitehurst/followers","following_url":"https://api.github.com/users/PhilWhitehurst/following{/other_user}","gists_url":"https://api.github.com/users/PhilWhitehurst/gists{/gist_id}","starred_url":"https://api.github.com/users/PhilWhitehurst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PhilWhitehurst/subscriptions","organizations_url":"https://api.github.com/users/PhilWhitehurst/orgs","repos_url":"https://api.github.com/users/PhilWhitehurst/repos","events_url":"https://api.github.com/users/PhilWhitehurst/events{/privacy}","received_events_url":"https://api.github.com/users/PhilWhitehurst/received_events","type":"User","site_admin":false},"body":"Hi,\r\n\r\nI've now done my performance enhancements to the distance marker code.  It is orders of magnitude faster when dealing with many points.  Even 10,000 or more points is fast. I've updated the license as well to include my name in there.\r\n\r\nRegards\r\n\r\nPhil","created_at":"2016-06-02T12:46:05Z","updated_at":"2016-06-02T17:32:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70abd5bad0cbd0f2431718b19ac64b351ff49a31","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/4/commits","review_comments_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/4/comments","review_comment_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/issues/4/comments","statuses_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/statuses/5fbb81126bd0d37739da2106c958630715d4ef77","head":{"label":"PhilWhitehurst:master","ref":"master","sha":"5fbb81126bd0d37739da2106c958630715d4ef77","user":{"login":"PhilWhitehurst","id":14213601,"avatar_url":"https://avatars.githubusercontent.com/u/14213601?v=3","gravatar_id":"","url":"https://api.github.com/users/PhilWhitehurst","html_url":"https://github.com/PhilWhitehurst","followers_url":"https://api.github.com/users/PhilWhitehurst/followers","following_url":"https://api.github.com/users/PhilWhitehurst/following{/other_user}","gists_url":"https://api.github.com/users/PhilWhitehurst/gists{/gist_id}","starred_url":"https://api.github.com/users/PhilWhitehurst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PhilWhitehurst/subscriptions","organizations_url":"https://api.github.com/users/PhilWhitehurst/orgs","repos_url":"https://api.github.com/users/PhilWhitehurst/repos","events_url":"https://api.github.com/users/PhilWhitehurst/events{/privacy}","received_events_url":"https://api.github.com/users/PhilWhitehurst/received_events","type":"User","site_admin":false},"repo":{"id":60262786,"name":"leaflet-distance-markers","full_name":"PhilWhitehurst/leaflet-distance-markers","owner":{"login":"PhilWhitehurst","id":14213601,"avatar_url":"https://avatars.githubusercontent.com/u/14213601?v=3","gravatar_id":"","url":"https://api.github.com/users/PhilWhitehurst","html_url":"https://github.com/PhilWhitehurst","followers_url":"https://api.github.com/users/PhilWhitehurst/followers","following_url":"https://api.github.com/users/PhilWhitehurst/following{/other_user}","gists_url":"https://api.github.com/users/PhilWhitehurst/gists{/gist_id}","starred_url":"https://api.github.com/users/PhilWhitehurst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PhilWhitehurst/subscriptions","organizations_url":"https://api.github.com/users/PhilWhitehurst/orgs","repos_url":"https://api.github.com/users/PhilWhitehurst/repos","events_url":"https://api.github.com/users/PhilWhitehurst/events{/privacy}","received_events_url":"https://api.github.com/users/PhilWhitehurst/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PhilWhitehurst/leaflet-distance-markers","description":"Leaflet plugin for displaying equidistant markers along a route","fork":true,"url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers","forks_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/forks","keys_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/teams","hooks_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/hooks","issue_events_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/issues/events{/number}","events_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/events","assignees_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/assignees{/user}","branches_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/branches{/branch}","tags_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/tags","blobs_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/git/refs{/sha}","trees_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/statuses/{sha}","languages_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/languages","stargazers_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/stargazers","contributors_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/contributors","subscribers_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/subscribers","subscription_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/subscription","commits_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/commits{/sha}","git_commits_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/git/commits{/sha}","comments_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/comments{/number}","issue_comment_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/issues/comments{/number}","contents_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/contents/{+path}","compare_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/merges","archive_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/downloads","issues_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/issues{/number}","pulls_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/pulls{/number}","milestones_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/milestones{/number}","notifications_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/labels{/name}","releases_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/releases{/id}","deployments_url":"https://api.github.com/repos/PhilWhitehurst/leaflet-distance-markers/deployments","created_at":"2016-06-02T12:37:49Z","updated_at":"2016-06-02T12:37:51Z","pushed_at":"2016-06-02T14:16:23Z","git_url":"git://github.com/PhilWhitehurst/leaflet-distance-markers.git","ssh_url":"git@github.com:PhilWhitehurst/leaflet-distance-markers.git","clone_url":"https://github.com/PhilWhitehurst/leaflet-distance-markers.git","svn_url":"https://github.com/PhilWhitehurst/leaflet-distance-markers","homepage":"","size":17,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"adoroszlai:master","ref":"master","sha":"4a0b2bac4448ac89a6458e2e1f4d40cc77f5e8b4","user":{"login":"adoroszlai","id":6454655,"avatar_url":"https://avatars.githubusercontent.com/u/6454655?v=3","gravatar_id":"","url":"https://api.github.com/users/adoroszlai","html_url":"https://github.com/adoroszlai","followers_url":"https://api.github.com/users/adoroszlai/followers","following_url":"https://api.github.com/users/adoroszlai/following{/other_user}","gists_url":"https://api.github.com/users/adoroszlai/gists{/gist_id}","starred_url":"https://api.github.com/users/adoroszlai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adoroszlai/subscriptions","organizations_url":"https://api.github.com/users/adoroszlai/orgs","repos_url":"https://api.github.com/users/adoroszlai/repos","events_url":"https://api.github.com/users/adoroszlai/events{/privacy}","received_events_url":"https://api.github.com/users/adoroszlai/received_events","type":"User","site_admin":false},"repo":{"id":16471742,"name":"leaflet-distance-markers","full_name":"adoroszlai/leaflet-distance-markers","owner":{"login":"adoroszlai","id":6454655,"avatar_url":"https://avatars.githubusercontent.com/u/6454655?v=3","gravatar_id":"","url":"https://api.github.com/users/adoroszlai","html_url":"https://github.com/adoroszlai","followers_url":"https://api.github.com/users/adoroszlai/followers","following_url":"https://api.github.com/users/adoroszlai/following{/other_user}","gists_url":"https://api.github.com/users/adoroszlai/gists{/gist_id}","starred_url":"https://api.github.com/users/adoroszlai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adoroszlai/subscriptions","organizations_url":"https://api.github.com/users/adoroszlai/orgs","repos_url":"https://api.github.com/users/adoroszlai/repos","events_url":"https://api.github.com/users/adoroszlai/events{/privacy}","received_events_url":"https://api.github.com/users/adoroszlai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adoroszlai/leaflet-distance-markers","description":"Leaflet plugin for displaying equidistant markers along a route","fork":false,"url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers","forks_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/forks","keys_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/teams","hooks_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/hooks","issue_events_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/issues/events{/number}","events_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/events","assignees_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/assignees{/user}","branches_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/branches{/branch}","tags_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/tags","blobs_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/git/refs{/sha}","trees_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/statuses/{sha}","languages_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/languages","stargazers_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/stargazers","contributors_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/contributors","subscribers_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/subscribers","subscription_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/subscription","commits_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/commits{/sha}","git_commits_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/git/commits{/sha}","comments_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/comments{/number}","issue_comment_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/issues/comments{/number}","contents_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/contents/{+path}","compare_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/merges","archive_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/downloads","issues_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/issues{/number}","pulls_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls{/number}","milestones_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/milestones{/number}","notifications_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/labels{/name}","releases_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/releases{/id}","deployments_url":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/deployments","created_at":"2014-02-03T06:41:17Z","updated_at":"2016-05-13T05:53:40Z","pushed_at":"2016-06-02T14:16:23Z","git_url":"git://github.com/adoroszlai/leaflet-distance-markers.git","ssh_url":"git@github.com:adoroszlai/leaflet-distance-markers.git","clone_url":"https://github.com/adoroszlai/leaflet-distance-markers.git","svn_url":"https://github.com/adoroszlai/leaflet-distance-markers","homepage":"","size":13,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/4"},"html":{"href":"https://github.com/adoroszlai/leaflet-distance-markers/pull/4"},"issue":{"href":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/issues/4"},"comments":{"href":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/adoroszlai/leaflet-distance-markers/statuses/5fbb81126bd0d37739da2106c958630715d4ef77"}}}}
{"actor":{"display_login":"adoroszlai"}}