{"action":"created","comment":{"url":"https://api.github.com/repos/mapsme/omim/pulls/comments/63370958","id":63370958,"diff_hunk":"@@ -0,0 +1,187 @@\n+#include \"routing/bicycle_directions.hpp\"\n+#include \"routing/car_model.hpp\"\n+#include \"routing/router_delegate.hpp\"\n+#include \"routing/routing_result_graph.hpp\"\n+#include \"routing/turns_generator.hpp\"\n+\n+#include \"indexer/ftypes_matcher.hpp\"\n+#include \"indexer/index.hpp\"\n+#include \"indexer/scales.hpp\"\n+\n+#include \"geometry/point2d.hpp\"\n+\n+namespace\n+{\n+using namespace routing;\n+using namespace routing::turns;\n+\n+class AStarRoutingResult : public IRoutingResult\n+{\n+public:\n+  AStarRoutingResult(IRoadGraph::TEdgeVector const & routeEdges,\n+                     AdjacentEdgesMap const & adjacentEdges,\n+                     TUnpackedPathSegments const & pathSegments)\n+    : m_routeEdges(routeEdges)\n+    , m_adjacentEdges(adjacentEdges)\n+    , m_pathSegments(pathSegments)\n+    , m_routeLength(0)\n+  {\n+    for (auto const & edge : routeEdges)\n+    {\n+      m_routeLength += MercatorBounds::DistanceOnEarth(edge.GetStartJunction().GetPoint(),\n+                                                       edge.GetEndJunction().GetPoint());\n+    }\n+  }\n+\n+  // turns::IRoutingResult overrides:\n+  virtual TUnpackedPathSegments const & GetSegments() const override { return m_pathSegments; }\n+\n+  virtual void GetPossibleTurns(TNodeId node, m2::PointD const & ingoingPoint,\n+                                m2::PointD const & junctionPoint, size_t & ingoingCount,\n+                                TTurnCandidates & outgoingTurns) const override\n+  {\n+    ingoingCount = 0;\n+    outgoingTurns.clear();\n+\n+    if (node >= m_routeEdges.size())\n+    {\n+      ASSERT(false, (m_routeEdges.size()));\n+      return;\n+    }\n+\n+    auto adjacentEdges = m_adjacentEdges.find(node);\n+    if (adjacentEdges == m_adjacentEdges.cend())\n+    {\n+      ASSERT(false, ());\n+      return;\n+    }\n+\n+    ingoingCount = adjacentEdges->second.m_ingoingTurnsCount;\n+    outgoingTurns = adjacentEdges->second.m_outgoingTurns;\n+  }\n+\n+  virtual double GetPathLength() const override { return m_routeLength; }\n+\n+  virtual m2::PointD const & GetStartPoint() const override\n+  {\n+    CHECK(!m_routeEdges.empty(), ());\n+    return m_routeEdges.front().GetStartJunction().GetPoint();\n+  }\n+\n+  virtual m2::PointD const & GetEndPoint() const override\n+  {\n+    CHECK(!m_routeEdges.empty(), ());\n+    return m_routeEdges.back().GetEndJunction().GetPoint();\n+  }\n+\n+private:\n+  IRoadGraph::TEdgeVector const & m_routeEdges;\n+  AdjacentEdgesMap const & m_adjacentEdges;\n+  TUnpackedPathSegments const & m_pathSegments;\n+  double m_routeLength;\n+};\n+\n+ftypes::HighwayClass GetHighwayClass(FeatureID const & featureId, Index const & index)\n+{\n+  ftypes::HighwayClass highWayClass = ftypes::HighwayClass::Undefined;\n+  MwmSet::MwmId const & mwmId = featureId.m_mwmId;\n+  uint32_t const featureIndex = featureId.m_index;\n+\n+  FeatureType ft;\n+  Index::FeaturesLoaderGuard loader(index, mwmId);\n+  loader.GetFeatureByIndex(featureIndex, ft);\n+  highWayClass = ftypes::GetHighwayClass(ft);\n+  ASSERT_NOT_EQUAL(highWayClass, ftypes::HighwayClass::Error, ());\n+  ASSERT_NOT_EQUAL(highWayClass, ftypes::HighwayClass::Undefined, ());\n+  return highWayClass;\n+}\n+}  // namespace\n+\n+namespace routing\n+{\n+BicycleDirectionsEngine::BicycleDirectionsEngine(Index const & index) : m_index(index) {}\n+\n+void BicycleDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junction> const & path,\n+                                       Route::TTimes & times, Route::TTurns & turns,\n+                                       vector<m2::PointD> & routeGeometry,\n+                                       my::Cancellable const & cancellable)\n+{\n+  size_t const pathSize = path.size();\n+  CHECK_NOT_EQUAL(pathSize, 0, ());\n+\n+  times.clear();\n+  turns.clear();\n+  routeGeometry.clear();\n+  m_adjacentEdges.clear();\n+  m_pathSegments.clear();\n+\n+  auto emptyPathWorkaround = [&]()\n+  {\n+    turns.emplace_back(pathSize - 1, turns::TurnDirection::ReachedYourDestination);\n+    this->m_adjacentEdges[0] = AdjacentEdges(1);  // There's one ingoing edge to the finish.\n+  };\n+\n+  if (pathSize <= 1)\n+  {\n+    ASSERT(false, (pathSize));","path":"routing/bicycle_directions.cpp","position":105,"original_position":126,"commit_id":"5d794a0391a69992c812c8578157744d7aa9cebd","original_commit_id":"9baaad5dc2dcca77a0d680f95489faf3c593eab7","user":{"login":"ygorshenin","id":454567,"avatar_url":"https://avatars.githubusercontent.com/u/454567?v=3","gravatar_id":"","url":"https://api.github.com/users/ygorshenin","html_url":"https://github.com/ygorshenin","followers_url":"https://api.github.com/users/ygorshenin/followers","following_url":"https://api.github.com/users/ygorshenin/following{/other_user}","gists_url":"https://api.github.com/users/ygorshenin/gists{/gist_id}","starred_url":"https://api.github.com/users/ygorshenin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ygorshenin/subscriptions","organizations_url":"https://api.github.com/users/ygorshenin/orgs","repos_url":"https://api.github.com/users/ygorshenin/repos","events_url":"https://api.github.com/users/ygorshenin/events{/privacy}","received_events_url":"https://api.github.com/users/ygorshenin/received_events","type":"User","site_admin":false},"body":"This is a kernel code, that may be run from unit tests, without any UI. And our algorithms should not depend on the UI checks. Please, clean up this code.","created_at":"2016-05-16T15:21:01Z","updated_at":"2016-05-16T15:21:01Z","html_url":"https://github.com/mapsme/omim/pull/3025#discussion_r63370958","pull_request_url":"https://api.github.com/repos/mapsme/omim/pulls/3025","_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments/63370958"},"html":{"href":"https://github.com/mapsme/omim/pull/3025#discussion_r63370958"},"pull_request":{"href":"https://api.github.com/repos/mapsme/omim/pulls/3025"}}},"pull_request":{"url":"https://api.github.com/repos/mapsme/omim/pulls/3025","id":68035975,"html_url":"https://github.com/mapsme/omim/pull/3025","diff_url":"https://github.com/mapsme/omim/pull/3025.diff","patch_url":"https://github.com/mapsme/omim/pull/3025.patch","issue_url":"https://api.github.com/repos/mapsme/omim/issues/3025","number":3025,"state":"open","locked":false,"title":"Bicycle turn generation.","user":{"login":"bykoianko","id":1768114,"avatar_url":"https://avatars.githubusercontent.com/u/1768114?v=3","gravatar_id":"","url":"https://api.github.com/users/bykoianko","html_url":"https://github.com/bykoianko","followers_url":"https://api.github.com/users/bykoianko/followers","following_url":"https://api.github.com/users/bykoianko/following{/other_user}","gists_url":"https://api.github.com/users/bykoianko/gists{/gist_id}","starred_url":"https://api.github.com/users/bykoianko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bykoianko/subscriptions","organizations_url":"https://api.github.com/users/bykoianko/orgs","repos_url":"https://api.github.com/users/bykoianko/repos","events_url":"https://api.github.com/users/bykoianko/events{/privacy}","received_events_url":"https://api.github.com/users/bykoianko/received_events","type":"User","site_admin":false},"body":"Генерация тернов для велороутинга. \r\nPR реализует простую идею: использовать генератор тернов от car-routing-га для вело-роутинга. \r\n+ написана тестовая инфраструктура для тестов вело маршрутов и написано пару routing_integration_test: на прокладку вело маршрута и на маневры в вело маршруте. Их кол-во будет увеличиваться.\r\n\r\n@ygorshenin @mpimenov  по возможности посмотрите.","created_at":"2016-04-27T11:14:36Z","updated_at":"2016-05-16T15:21:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed54f9ecc985b673e4325c04ea83fb3153dfb9b2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mapsme/omim/pulls/3025/commits","review_comments_url":"https://api.github.com/repos/mapsme/omim/pulls/3025/comments","review_comment_url":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapsme/omim/issues/3025/comments","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/5d794a0391a69992c812c8578157744d7aa9cebd","head":{"label":"bykoianko:master-bicycle-directions-first-appr2","ref":"master-bicycle-directions-first-appr2","sha":"5d794a0391a69992c812c8578157744d7aa9cebd","user":{"login":"bykoianko","id":1768114,"avatar_url":"https://avatars.githubusercontent.com/u/1768114?v=3","gravatar_id":"","url":"https://api.github.com/users/bykoianko","html_url":"https://github.com/bykoianko","followers_url":"https://api.github.com/users/bykoianko/followers","following_url":"https://api.github.com/users/bykoianko/following{/other_user}","gists_url":"https://api.github.com/users/bykoianko/gists{/gist_id}","starred_url":"https://api.github.com/users/bykoianko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bykoianko/subscriptions","organizations_url":"https://api.github.com/users/bykoianko/orgs","repos_url":"https://api.github.com/users/bykoianko/repos","events_url":"https://api.github.com/users/bykoianko/events{/privacy}","received_events_url":"https://api.github.com/users/bykoianko/received_events","type":"User","site_admin":false},"repo":{"id":43428862,"name":"omim","full_name":"bykoianko/omim","owner":{"login":"bykoianko","id":1768114,"avatar_url":"https://avatars.githubusercontent.com/u/1768114?v=3","gravatar_id":"","url":"https://api.github.com/users/bykoianko","html_url":"https://github.com/bykoianko","followers_url":"https://api.github.com/users/bykoianko/followers","following_url":"https://api.github.com/users/bykoianko/following{/other_user}","gists_url":"https://api.github.com/users/bykoianko/gists{/gist_id}","starred_url":"https://api.github.com/users/bykoianko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bykoianko/subscriptions","organizations_url":"https://api.github.com/users/bykoianko/orgs","repos_url":"https://api.github.com/users/bykoianko/repos","events_url":"https://api.github.com/users/bykoianko/events{/privacy}","received_events_url":"https://api.github.com/users/bykoianko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bykoianko/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":true,"url":"https://api.github.com/repos/bykoianko/omim","forks_url":"https://api.github.com/repos/bykoianko/omim/forks","keys_url":"https://api.github.com/repos/bykoianko/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bykoianko/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bykoianko/omim/teams","hooks_url":"https://api.github.com/repos/bykoianko/omim/hooks","issue_events_url":"https://api.github.com/repos/bykoianko/omim/issues/events{/number}","events_url":"https://api.github.com/repos/bykoianko/omim/events","assignees_url":"https://api.github.com/repos/bykoianko/omim/assignees{/user}","branches_url":"https://api.github.com/repos/bykoianko/omim/branches{/branch}","tags_url":"https://api.github.com/repos/bykoianko/omim/tags","blobs_url":"https://api.github.com/repos/bykoianko/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bykoianko/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bykoianko/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/bykoianko/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bykoianko/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/bykoianko/omim/languages","stargazers_url":"https://api.github.com/repos/bykoianko/omim/stargazers","contributors_url":"https://api.github.com/repos/bykoianko/omim/contributors","subscribers_url":"https://api.github.com/repos/bykoianko/omim/subscribers","subscription_url":"https://api.github.com/repos/bykoianko/omim/subscription","commits_url":"https://api.github.com/repos/bykoianko/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/bykoianko/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/bykoianko/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/bykoianko/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/bykoianko/omim/contents/{+path}","compare_url":"https://api.github.com/repos/bykoianko/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bykoianko/omim/merges","archive_url":"https://api.github.com/repos/bykoianko/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bykoianko/omim/downloads","issues_url":"https://api.github.com/repos/bykoianko/omim/issues{/number}","pulls_url":"https://api.github.com/repos/bykoianko/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/bykoianko/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/bykoianko/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bykoianko/omim/labels{/name}","releases_url":"https://api.github.com/repos/bykoianko/omim/releases{/id}","deployments_url":"https://api.github.com/repos/bykoianko/omim/deployments","created_at":"2015-09-30T11:21:20Z","updated_at":"2016-03-24T12:55:17Z","pushed_at":"2016-05-16T13:59:00Z","git_url":"git://github.com/bykoianko/omim.git","ssh_url":"git@github.com:bykoianko/omim.git","clone_url":"https://github.com/bykoianko/omim.git","svn_url":"https://github.com/bykoianko/omim","homepage":null,"size":2367392,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"mapsme:master","ref":"master","sha":"91090294b0208bf3e887a9de20edbae2c14e9e2a","user":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"repo":{"id":42798033,"name":"omim","full_name":"mapsme/omim","owner":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapsme/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":false,"url":"https://api.github.com/repos/mapsme/omim","forks_url":"https://api.github.com/repos/mapsme/omim/forks","keys_url":"https://api.github.com/repos/mapsme/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapsme/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapsme/omim/teams","hooks_url":"https://api.github.com/repos/mapsme/omim/hooks","issue_events_url":"https://api.github.com/repos/mapsme/omim/issues/events{/number}","events_url":"https://api.github.com/repos/mapsme/omim/events","assignees_url":"https://api.github.com/repos/mapsme/omim/assignees{/user}","branches_url":"https://api.github.com/repos/mapsme/omim/branches{/branch}","tags_url":"https://api.github.com/repos/mapsme/omim/tags","blobs_url":"https://api.github.com/repos/mapsme/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapsme/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapsme/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapsme/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/mapsme/omim/languages","stargazers_url":"https://api.github.com/repos/mapsme/omim/stargazers","contributors_url":"https://api.github.com/repos/mapsme/omim/contributors","subscribers_url":"https://api.github.com/repos/mapsme/omim/subscribers","subscription_url":"https://api.github.com/repos/mapsme/omim/subscription","commits_url":"https://api.github.com/repos/mapsme/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapsme/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapsme/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapsme/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapsme/omim/contents/{+path}","compare_url":"https://api.github.com/repos/mapsme/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapsme/omim/merges","archive_url":"https://api.github.com/repos/mapsme/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapsme/omim/downloads","issues_url":"https://api.github.com/repos/mapsme/omim/issues{/number}","pulls_url":"https://api.github.com/repos/mapsme/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/mapsme/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/mapsme/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapsme/omim/labels{/name}","releases_url":"https://api.github.com/repos/mapsme/omim/releases{/id}","deployments_url":"https://api.github.com/repos/mapsme/omim/deployments","created_at":"2015-09-20T02:57:13Z","updated_at":"2016-05-15T22:02:35Z","pushed_at":"2016-05-16T13:59:01Z","git_url":"git://github.com/mapsme/omim.git","ssh_url":"git@github.com:mapsme/omim.git","clone_url":"https://github.com/mapsme/omim.git","svn_url":"https://github.com/mapsme/omim","homepage":null,"size":2442356,"stargazers_count":1771,"watchers_count":1771,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":272,"mirror_url":null,"open_issues_count":156,"forks":272,"open_issues":156,"watchers":1771,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/3025"},"html":{"href":"https://github.com/mapsme/omim/pull/3025"},"issue":{"href":"https://api.github.com/repos/mapsme/omim/issues/3025"},"comments":{"href":"https://api.github.com/repos/mapsme/omim/issues/3025/comments"},"review_comments":{"href":"https://api.github.com/repos/mapsme/omim/pulls/3025/comments"},"review_comment":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapsme/omim/pulls/3025/commits"},"statuses":{"href":"https://api.github.com/repos/mapsme/omim/statuses/5d794a0391a69992c812c8578157744d7aa9cebd"}}}}