{"action":"created","comment":{"url":"https://api.github.com/repos/graphhopper/graphhopper/pulls/comments/62975774","id":62975774,"diff_hunk":"@@ -0,0 +1,186 @@\n+package com.graphhopper.matrix;\n+\n+import com.graphhopper.GHResponse;\n+import com.graphhopper.GraphHopper;\n+import com.graphhopper.matrix.algorithm.MatrixAlgorithm;\n+import com.graphhopper.matrix.algorithm.MatrixAlgorithmFactory;\n+import com.graphhopper.matrix.algorithm.SimpleMatrixAlgorithmFactory;\n+import com.graphhopper.routing.AlgorithmOptions;\n+import com.graphhopper.routing.QueryGraph;\n+import com.graphhopper.routing.RoutingAlgorithmFactory;\n+import com.graphhopper.routing.ch.CHAlgoFactoryDecorator;\n+import com.graphhopper.routing.ch.PrepareContractionHierarchies;\n+import com.graphhopper.routing.util.FlagEncoder;\n+import com.graphhopper.routing.util.TraversalMode;\n+import com.graphhopper.routing.util.Weighting;\n+import com.graphhopper.storage.CHGraph;\n+import com.graphhopper.storage.Graph;\n+import com.graphhopper.storage.index.QueryResult;\n+import com.graphhopper.util.shapes.GHPoint;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+/**\n+ * Provides a Distance Matrix API\n+ *\n+ * @author Pascal Büttiker\n+ */\n+public class DistanceMatrixService {\n+\n+    private final GraphHopper hopper; // TODO after GraphHopper refactoring, this dependency should go away\n+    private final MatrixAlgorithmFactory matrixAlgorithmFactory;\n+\n+\n+    public DistanceMatrixService(GraphHopper hopper){\n+        this(hopper, new SimpleMatrixAlgorithmFactory());\n+    }\n+\n+    public DistanceMatrixService(GraphHopper hopper, MatrixAlgorithmFactory matrixAlgorithmFactory){\n+        this.hopper = hopper;\n+        this.matrixAlgorithmFactory = matrixAlgorithmFactory;\n+    }\n+\n+    /**\n+     * Calculates a distance matrix based on the given request.\n+     */\n+    public GHMatrixResponse calculateMatrix(GHMatrixRequest request){\n+\n+\n+        AlgorithmOptions.Builder algoOptsBuilder =  buildOptions(request, hopper);\n+\n+\n+        AlgorithmOptions tmpOptions = algoOptsBuilder.build();\n+\n+\n+        Graph routingGraph = hopper.getGraphHopperStorage();\n+        if(hopper.isCHEnabled()) {\n+            routingGraph = hopper.getGraphHopperStorage().getGraph(CHGraph.class, tmpOptions.getWeighting());\n+        }\n+\n+        QueryGraph queryGraph = new QueryGraph(routingGraph);\n+        Weighting weighting = hopper.createTurnWeighting(tmpOptions.getWeighting(), queryGraph, tmpOptions.getFlagEncoder());\n+        AlgorithmOptions algoOpts = algoOptsBuilder.weighting(weighting).build();\n+\n+        List<QueryResult> originQNodes = lookupNodes(request.getOrigins(), algoOpts.getFlagEncoder());\n+        List<QueryResult> destinationQNodes = lookupNodes(request.getDestinations(), algoOpts.getFlagEncoder());\n+\n+        List<QueryResult> merged = new ArrayList<>(originQNodes);\n+        merged.addAll(destinationQNodes);\n+\n+        queryGraph.lookup(merged);\n+\n+        List<Integer> originNodes =  mapToNodes(originQNodes);\n+        List<Integer> destinationNodes =  mapToNodes(destinationQNodes);\n+\n+        MatrixAlgorithm algorithm = matrixAlgorithmFactory.build(queryGraph, algoOpts);\n+        DistanceMatrix matrix = algorithm.calcMatrix(originNodes, destinationNodes); // TODO","path":"core/src/main/java/com/graphhopper/matrix/DistanceMatrixService.java","position":77,"original_position":77,"commit_id":"180c20ed357777240d0cc1ab0221952ca3d1d971","original_commit_id":"180c20ed357777240d0cc1ab0221952ca3d1d971","user":{"login":"IsNull","id":439313,"avatar_url":"https://avatars.githubusercontent.com/u/439313?v=3","gravatar_id":"","url":"https://api.github.com/users/IsNull","html_url":"https://github.com/IsNull","followers_url":"https://api.github.com/users/IsNull/followers","following_url":"https://api.github.com/users/IsNull/following{/other_user}","gists_url":"https://api.github.com/users/IsNull/gists{/gist_id}","starred_url":"https://api.github.com/users/IsNull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IsNull/subscriptions","organizations_url":"https://api.github.com/users/IsNull/orgs","repos_url":"https://api.github.com/users/IsNull/repos","events_url":"https://api.github.com/users/IsNull/events{/privacy}","received_events_url":"https://api.github.com/users/IsNull/received_events","type":"User","site_admin":false},"body":"Its no longer required, I will remove it.","created_at":"2016-05-12T07:34:11Z","updated_at":"2016-05-12T07:34:11Z","html_url":"https://github.com/graphhopper/graphhopper/pull/705#discussion_r62975774","pull_request_url":"https://api.github.com/repos/graphhopper/graphhopper/pulls/705","_links":{"self":{"href":"https://api.github.com/repos/graphhopper/graphhopper/pulls/comments/62975774"},"html":{"href":"https://github.com/graphhopper/graphhopper/pull/705#discussion_r62975774"},"pull_request":{"href":"https://api.github.com/repos/graphhopper/graphhopper/pulls/705"}}},"pull_request":{"url":"https://api.github.com/repos/graphhopper/graphhopper/pulls/705","id":67363585,"html_url":"https://github.com/graphhopper/graphhopper/pull/705","diff_url":"https://github.com/graphhopper/graphhopper/pull/705.diff","patch_url":"https://github.com/graphhopper/graphhopper/pull/705.patch","issue_url":"https://api.github.com/repos/graphhopper/graphhopper/issues/705","number":705,"state":"open","locked":false,"title":"Distance matrix support (WIP)","user":{"login":"IsNull","id":439313,"avatar_url":"https://avatars.githubusercontent.com/u/439313?v=3","gravatar_id":"","url":"https://api.github.com/users/IsNull","html_url":"https://github.com/IsNull","followers_url":"https://api.github.com/users/IsNull/followers","following_url":"https://api.github.com/users/IsNull/following{/other_user}","gists_url":"https://api.github.com/users/IsNull/gists{/gist_id}","starred_url":"https://api.github.com/users/IsNull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IsNull/subscriptions","organizations_url":"https://api.github.com/users/IsNull/orgs","repos_url":"https://api.github.com/users/IsNull/repos","events_url":"https://api.github.com/users/IsNull/events{/privacy}","received_events_url":"https://api.github.com/users/IsNull/received_events","type":"User","site_admin":false},"body":"This pull request implements a basic API for distance matrix queries as discussed in #131. As such, I want to review the proposed API before refining it and adding tests. \r\n\r\n**This is an very early draft, not meant to be merged yet.**\r\n\r\nPlease have a look and tell me if the proposed API goes into the right direction. I'd like to avoid putting too much work into something you don't consider for merge. You find the primary code under the package /matrix in the core project.\r\n\r\n**TODO**\r\n* Some refactoring of GraphHopper required. The current integration point `DistanceMatrixService` is ugly and contains some code duplications due to #450\r\n\r\n**Edit**\r\n* Added some unit tests\r\n","created_at":"2016-04-21T14:29:08Z","updated_at":"2016-05-12T07:34:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e05a5e88bd58fee40a489be2d79e1eed5f426e0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/graphhopper/graphhopper/pulls/705/commits","review_comments_url":"https://api.github.com/repos/graphhopper/graphhopper/pulls/705/comments","review_comment_url":"https://api.github.com/repos/graphhopper/graphhopper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/graphhopper/graphhopper/issues/705/comments","statuses_url":"https://api.github.com/repos/graphhopper/graphhopper/statuses/180c20ed357777240d0cc1ab0221952ca3d1d971","head":{"label":"ElderByte-:distance-matrix-support","ref":"distance-matrix-support","sha":"180c20ed357777240d0cc1ab0221952ca3d1d971","user":{"login":"ElderByte-","id":10884650,"avatar_url":"https://avatars.githubusercontent.com/u/10884650?v=3","gravatar_id":"","url":"https://api.github.com/users/ElderByte-","html_url":"https://github.com/ElderByte-","followers_url":"https://api.github.com/users/ElderByte-/followers","following_url":"https://api.github.com/users/ElderByte-/following{/other_user}","gists_url":"https://api.github.com/users/ElderByte-/gists{/gist_id}","starred_url":"https://api.github.com/users/ElderByte-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElderByte-/subscriptions","organizations_url":"https://api.github.com/users/ElderByte-/orgs","repos_url":"https://api.github.com/users/ElderByte-/repos","events_url":"https://api.github.com/users/ElderByte-/events{/privacy}","received_events_url":"https://api.github.com/users/ElderByte-/received_events","type":"Organization","site_admin":false},"repo":{"id":56580308,"name":"graphhopper","full_name":"ElderByte-/graphhopper","owner":{"login":"ElderByte-","id":10884650,"avatar_url":"https://avatars.githubusercontent.com/u/10884650?v=3","gravatar_id":"","url":"https://api.github.com/users/ElderByte-","html_url":"https://github.com/ElderByte-","followers_url":"https://api.github.com/users/ElderByte-/followers","following_url":"https://api.github.com/users/ElderByte-/following{/other_user}","gists_url":"https://api.github.com/users/ElderByte-/gists{/gist_id}","starred_url":"https://api.github.com/users/ElderByte-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElderByte-/subscriptions","organizations_url":"https://api.github.com/users/ElderByte-/orgs","repos_url":"https://api.github.com/users/ElderByte-/repos","events_url":"https://api.github.com/users/ElderByte-/events{/privacy}","received_events_url":"https://api.github.com/users/ElderByte-/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ElderByte-/graphhopper","description":"Open source routing library and server using OpenStreetMap :earth_africa: #route #planner","fork":true,"url":"https://api.github.com/repos/ElderByte-/graphhopper","forks_url":"https://api.github.com/repos/ElderByte-/graphhopper/forks","keys_url":"https://api.github.com/repos/ElderByte-/graphhopper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ElderByte-/graphhopper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ElderByte-/graphhopper/teams","hooks_url":"https://api.github.com/repos/ElderByte-/graphhopper/hooks","issue_events_url":"https://api.github.com/repos/ElderByte-/graphhopper/issues/events{/number}","events_url":"https://api.github.com/repos/ElderByte-/graphhopper/events","assignees_url":"https://api.github.com/repos/ElderByte-/graphhopper/assignees{/user}","branches_url":"https://api.github.com/repos/ElderByte-/graphhopper/branches{/branch}","tags_url":"https://api.github.com/repos/ElderByte-/graphhopper/tags","blobs_url":"https://api.github.com/repos/ElderByte-/graphhopper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ElderByte-/graphhopper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ElderByte-/graphhopper/git/refs{/sha}","trees_url":"https://api.github.com/repos/ElderByte-/graphhopper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ElderByte-/graphhopper/statuses/{sha}","languages_url":"https://api.github.com/repos/ElderByte-/graphhopper/languages","stargazers_url":"https://api.github.com/repos/ElderByte-/graphhopper/stargazers","contributors_url":"https://api.github.com/repos/ElderByte-/graphhopper/contributors","subscribers_url":"https://api.github.com/repos/ElderByte-/graphhopper/subscribers","subscription_url":"https://api.github.com/repos/ElderByte-/graphhopper/subscription","commits_url":"https://api.github.com/repos/ElderByte-/graphhopper/commits{/sha}","git_commits_url":"https://api.github.com/repos/ElderByte-/graphhopper/git/commits{/sha}","comments_url":"https://api.github.com/repos/ElderByte-/graphhopper/comments{/number}","issue_comment_url":"https://api.github.com/repos/ElderByte-/graphhopper/issues/comments{/number}","contents_url":"https://api.github.com/repos/ElderByte-/graphhopper/contents/{+path}","compare_url":"https://api.github.com/repos/ElderByte-/graphhopper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ElderByte-/graphhopper/merges","archive_url":"https://api.github.com/repos/ElderByte-/graphhopper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ElderByte-/graphhopper/downloads","issues_url":"https://api.github.com/repos/ElderByte-/graphhopper/issues{/number}","pulls_url":"https://api.github.com/repos/ElderByte-/graphhopper/pulls{/number}","milestones_url":"https://api.github.com/repos/ElderByte-/graphhopper/milestones{/number}","notifications_url":"https://api.github.com/repos/ElderByte-/graphhopper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ElderByte-/graphhopper/labels{/name}","releases_url":"https://api.github.com/repos/ElderByte-/graphhopper/releases{/id}","deployments_url":"https://api.github.com/repos/ElderByte-/graphhopper/deployments","created_at":"2016-04-19T08:45:33Z","updated_at":"2016-04-19T08:45:36Z","pushed_at":"2016-05-06T11:13:49Z","git_url":"git://github.com/ElderByte-/graphhopper.git","ssh_url":"git@github.com:ElderByte-/graphhopper.git","clone_url":"https://github.com/ElderByte-/graphhopper.git","svn_url":"https://github.com/ElderByte-/graphhopper","homepage":"https://graphhopper.com","size":36646,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"graphhopper:master","ref":"master","sha":"c54e570055598eea3e05a8799b349f813774cd3a","user":{"login":"graphhopper","id":2264498,"avatar_url":"https://avatars.githubusercontent.com/u/2264498?v=3","gravatar_id":"","url":"https://api.github.com/users/graphhopper","html_url":"https://github.com/graphhopper","followers_url":"https://api.github.com/users/graphhopper/followers","following_url":"https://api.github.com/users/graphhopper/following{/other_user}","gists_url":"https://api.github.com/users/graphhopper/gists{/gist_id}","starred_url":"https://api.github.com/users/graphhopper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graphhopper/subscriptions","organizations_url":"https://api.github.com/users/graphhopper/orgs","repos_url":"https://api.github.com/users/graphhopper/repos","events_url":"https://api.github.com/users/graphhopper/events{/privacy}","received_events_url":"https://api.github.com/users/graphhopper/received_events","type":"Organization","site_admin":false},"repo":{"id":3480666,"name":"graphhopper","full_name":"graphhopper/graphhopper","owner":{"login":"graphhopper","id":2264498,"avatar_url":"https://avatars.githubusercontent.com/u/2264498?v=3","gravatar_id":"","url":"https://api.github.com/users/graphhopper","html_url":"https://github.com/graphhopper","followers_url":"https://api.github.com/users/graphhopper/followers","following_url":"https://api.github.com/users/graphhopper/following{/other_user}","gists_url":"https://api.github.com/users/graphhopper/gists{/gist_id}","starred_url":"https://api.github.com/users/graphhopper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graphhopper/subscriptions","organizations_url":"https://api.github.com/users/graphhopper/orgs","repos_url":"https://api.github.com/users/graphhopper/repos","events_url":"https://api.github.com/users/graphhopper/events{/privacy}","received_events_url":"https://api.github.com/users/graphhopper/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/graphhopper/graphhopper","description":"Open source routing library and server using OpenStreetMap :earth_africa: #route #planner","fork":false,"url":"https://api.github.com/repos/graphhopper/graphhopper","forks_url":"https://api.github.com/repos/graphhopper/graphhopper/forks","keys_url":"https://api.github.com/repos/graphhopper/graphhopper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/graphhopper/graphhopper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/graphhopper/graphhopper/teams","hooks_url":"https://api.github.com/repos/graphhopper/graphhopper/hooks","issue_events_url":"https://api.github.com/repos/graphhopper/graphhopper/issues/events{/number}","events_url":"https://api.github.com/repos/graphhopper/graphhopper/events","assignees_url":"https://api.github.com/repos/graphhopper/graphhopper/assignees{/user}","branches_url":"https://api.github.com/repos/graphhopper/graphhopper/branches{/branch}","tags_url":"https://api.github.com/repos/graphhopper/graphhopper/tags","blobs_url":"https://api.github.com/repos/graphhopper/graphhopper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/graphhopper/graphhopper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/graphhopper/graphhopper/git/refs{/sha}","trees_url":"https://api.github.com/repos/graphhopper/graphhopper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/graphhopper/graphhopper/statuses/{sha}","languages_url":"https://api.github.com/repos/graphhopper/graphhopper/languages","stargazers_url":"https://api.github.com/repos/graphhopper/graphhopper/stargazers","contributors_url":"https://api.github.com/repos/graphhopper/graphhopper/contributors","subscribers_url":"https://api.github.com/repos/graphhopper/graphhopper/subscribers","subscription_url":"https://api.github.com/repos/graphhopper/graphhopper/subscription","commits_url":"https://api.github.com/repos/graphhopper/graphhopper/commits{/sha}","git_commits_url":"https://api.github.com/repos/graphhopper/graphhopper/git/commits{/sha}","comments_url":"https://api.github.com/repos/graphhopper/graphhopper/comments{/number}","issue_comment_url":"https://api.github.com/repos/graphhopper/graphhopper/issues/comments{/number}","contents_url":"https://api.github.com/repos/graphhopper/graphhopper/contents/{+path}","compare_url":"https://api.github.com/repos/graphhopper/graphhopper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/graphhopper/graphhopper/merges","archive_url":"https://api.github.com/repos/graphhopper/graphhopper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/graphhopper/graphhopper/downloads","issues_url":"https://api.github.com/repos/graphhopper/graphhopper/issues{/number}","pulls_url":"https://api.github.com/repos/graphhopper/graphhopper/pulls{/number}","milestones_url":"https://api.github.com/repos/graphhopper/graphhopper/milestones{/number}","notifications_url":"https://api.github.com/repos/graphhopper/graphhopper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/graphhopper/graphhopper/labels{/name}","releases_url":"https://api.github.com/repos/graphhopper/graphhopper/releases{/id}","deployments_url":"https://api.github.com/repos/graphhopper/graphhopper/deployments","created_at":"2012-02-18T19:57:38Z","updated_at":"2016-05-12T02:25:18Z","pushed_at":"2016-05-11T18:03:55Z","git_url":"git://github.com/graphhopper/graphhopper.git","ssh_url":"git@github.com:graphhopper/graphhopper.git","clone_url":"https://github.com/graphhopper/graphhopper.git","svn_url":"https://github.com/graphhopper/graphhopper","homepage":"https://graphhopper.com","size":96173,"stargazers_count":768,"watchers_count":768,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":359,"mirror_url":null,"open_issues_count":130,"forks":359,"open_issues":130,"watchers":768,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/graphhopper/graphhopper/pulls/705"},"html":{"href":"https://github.com/graphhopper/graphhopper/pull/705"},"issue":{"href":"https://api.github.com/repos/graphhopper/graphhopper/issues/705"},"comments":{"href":"https://api.github.com/repos/graphhopper/graphhopper/issues/705/comments"},"review_comments":{"href":"https://api.github.com/repos/graphhopper/graphhopper/pulls/705/comments"},"review_comment":{"href":"https://api.github.com/repos/graphhopper/graphhopper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/graphhopper/graphhopper/pulls/705/commits"},"statuses":{"href":"https://api.github.com/repos/graphhopper/graphhopper/statuses/180c20ed357777240d0cc1ab0221952ca3d1d971"}}}}