{"action":"created","comment":{"url":"https://api.github.com/repos/mapsme/omim/pulls/comments/91737066","pull_request_review_id":12248612,"id":91737066,"diff_hunk":"@@ -1,27 +1,73 @@\n #include \"traffic/traffic_info.hpp\"\n #include \"traffic/speed_groups.hpp\"\n \n+#include \"indexer/classificator_loader.hpp\"\n+\n+#include \"platform/platform.hpp\"\n+\n+#include \"base/assert.hpp\"\n+#include \"base/logging.hpp\"\n+\n #include \"pyhelpers/vector_uint8.hpp\"\n \n #include <boost/python.hpp>\n #include <boost/python/suite/indexing/map_indexing_suite.hpp>\n+#include <boost/python/suite/indexing/vector_indexing_suite.hpp>\n \n namespace\n {\n using namespace boost::python;\n \n-vector<uint8_t> Serialize(traffic::TrafficInfo::Coloring const & coloring)\n+struct SegmentSpeeds\n+{\n+  SegmentSpeeds() = default;\n+  SegmentSpeeds(double weightedSpeed, double weightedRefSpeed, double weight)\n+    : m_weightedSpeed(weightedSpeed), m_weightedRefSpeed(weightedRefSpeed), m_weight(weight)\n+  {\n+  }\n+\n+  double m_weightedSpeed = 0;\n+  double m_weightedRefSpeed = 0;\n+  double m_weight = 0;\n+};\n+\n+using SegmentMapping = map<traffic::TrafficInfo::RoadSegmentId, SegmentSpeeds>;\n+\n+string SegmentSpeedsRepr(SegmentSpeeds const & v)\n {\n-  vector<uint8_t> data;\n-  traffic::TrafficInfo::SerializeTrafficData(coloring, data);\n-  return data;\n+  stringstream ss;\n+  ss << \"SegmentSpeeds(\"\n+     << \" weighted_speed=\" << v.m_weightedSpeed << \" weighted_ref_speed=\" << v.m_weightedRefSpeed\n+     << \" weight=\" << v.m_weight << \" )\";\n+  return ss.str();\n }\n \n-traffic::TrafficInfo::Coloring Deserialize(vector<uint8_t> const & data)\n+traffic::TrafficInfo::Coloring TransformToSpeedGroups(SegmentMapping const & segmentMapping)\n {\n-  traffic::TrafficInfo::Coloring coloring;\n-  traffic::TrafficInfo::DeserializeTrafficData(data, coloring);\n-  return coloring;\n+  traffic::TrafficInfo::Coloring result;\n+  for (auto const & kv : segmentMapping)\n+  {\n+    double const ws = kv.second.m_weightedSpeed;\n+    double const wrs = kv.second.m_weightedRefSpeed;\n+    double const w = kv.second.m_weight;\n+    if (w == 0.0)\n+    {\n+      LOG(LWARNING, (\"A traffic segment has zero weight.\"));\n+      continue;\n+    }\n+    double const u = ws / w;\n+    double const v = wrs / w;\n+    if (u == 0.0 && v == 0.0)\n+    {\n+      result[kv.first] = traffic::SpeedGroup::TempBlock;","path":"traffic/pytraffic/bindings.cpp","position":70,"original_position":70,"commit_id":"f991004c0489b96330b80075f5cd6ff48a9c4551","original_commit_id":"f991004c0489b96330b80075f5cd6ff48a9c4551","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":"Again, use AlmostEqualEps for comparisions with zero.","created_at":"2016-12-09T15:34:43Z","updated_at":"2016-12-09T15:34:43Z","html_url":"https://github.com/mapsme/omim/pull/4942#discussion_r91737066","pull_request_url":"https://api.github.com/repos/mapsme/omim/pulls/4942","_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments/91737066"},"html":{"href":"https://github.com/mapsme/omim/pull/4942#discussion_r91737066"},"pull_request":{"href":"https://api.github.com/repos/mapsme/omim/pulls/4942"}}},"pull_request":{"url":"https://api.github.com/repos/mapsme/omim/pulls/4942","id":97323849,"html_url":"https://github.com/mapsme/omim/pull/4942","diff_url":"https://github.com/mapsme/omim/pull/4942.diff","patch_url":"https://github.com/mapsme/omim/pull/4942.patch","issue_url":"https://api.github.com/repos/mapsme/omim/issues/4942","number":4942,"state":"open","locked":false,"title":"[traffic] Added python bindings for traffic serialization.","user":{"login":"mpimenov","id":10366009,"avatar_url":"https://avatars.githubusercontent.com/u/10366009?v=3","gravatar_id":"","url":"https://api.github.com/users/mpimenov","html_url":"https://github.com/mpimenov","followers_url":"https://api.github.com/users/mpimenov/followers","following_url":"https://api.github.com/users/mpimenov/following{/other_user}","gists_url":"https://api.github.com/users/mpimenov/gists{/gist_id}","starred_url":"https://api.github.com/users/mpimenov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpimenov/subscriptions","organizations_url":"https://api.github.com/users/mpimenov/orgs","repos_url":"https://api.github.com/users/mpimenov/repos","events_url":"https://api.github.com/users/mpimenov/events{/privacy}","received_events_url":"https://api.github.com/users/mpimenov/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-09T15:04:06Z","updated_at":"2016-12-09T15:34:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7dd30c66724250d6fbcb099777c63038d42067e1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mapsme/omim/pulls/4942/commits","review_comments_url":"https://api.github.com/repos/mapsme/omim/pulls/4942/comments","review_comment_url":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapsme/omim/issues/4942/comments","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/f991004c0489b96330b80075f5cd6ff48a9c4551","head":{"label":"mpimenov:traffic-python-bindings","ref":"traffic-python-bindings","sha":"f991004c0489b96330b80075f5cd6ff48a9c4551","user":{"login":"mpimenov","id":10366009,"avatar_url":"https://avatars.githubusercontent.com/u/10366009?v=3","gravatar_id":"","url":"https://api.github.com/users/mpimenov","html_url":"https://github.com/mpimenov","followers_url":"https://api.github.com/users/mpimenov/followers","following_url":"https://api.github.com/users/mpimenov/following{/other_user}","gists_url":"https://api.github.com/users/mpimenov/gists{/gist_id}","starred_url":"https://api.github.com/users/mpimenov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpimenov/subscriptions","organizations_url":"https://api.github.com/users/mpimenov/orgs","repos_url":"https://api.github.com/users/mpimenov/repos","events_url":"https://api.github.com/users/mpimenov/events{/privacy}","received_events_url":"https://api.github.com/users/mpimenov/received_events","type":"User","site_admin":false},"repo":{"id":43427925,"name":"omim","full_name":"mpimenov/omim","owner":{"login":"mpimenov","id":10366009,"avatar_url":"https://avatars.githubusercontent.com/u/10366009?v=3","gravatar_id":"","url":"https://api.github.com/users/mpimenov","html_url":"https://github.com/mpimenov","followers_url":"https://api.github.com/users/mpimenov/followers","following_url":"https://api.github.com/users/mpimenov/following{/other_user}","gists_url":"https://api.github.com/users/mpimenov/gists{/gist_id}","starred_url":"https://api.github.com/users/mpimenov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpimenov/subscriptions","organizations_url":"https://api.github.com/users/mpimenov/orgs","repos_url":"https://api.github.com/users/mpimenov/repos","events_url":"https://api.github.com/users/mpimenov/events{/privacy}","received_events_url":"https://api.github.com/users/mpimenov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mpimenov/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":true,"url":"https://api.github.com/repos/mpimenov/omim","forks_url":"https://api.github.com/repos/mpimenov/omim/forks","keys_url":"https://api.github.com/repos/mpimenov/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mpimenov/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mpimenov/omim/teams","hooks_url":"https://api.github.com/repos/mpimenov/omim/hooks","issue_events_url":"https://api.github.com/repos/mpimenov/omim/issues/events{/number}","events_url":"https://api.github.com/repos/mpimenov/omim/events","assignees_url":"https://api.github.com/repos/mpimenov/omim/assignees{/user}","branches_url":"https://api.github.com/repos/mpimenov/omim/branches{/branch}","tags_url":"https://api.github.com/repos/mpimenov/omim/tags","blobs_url":"https://api.github.com/repos/mpimenov/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mpimenov/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mpimenov/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/mpimenov/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mpimenov/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/mpimenov/omim/languages","stargazers_url":"https://api.github.com/repos/mpimenov/omim/stargazers","contributors_url":"https://api.github.com/repos/mpimenov/omim/contributors","subscribers_url":"https://api.github.com/repos/mpimenov/omim/subscribers","subscription_url":"https://api.github.com/repos/mpimenov/omim/subscription","commits_url":"https://api.github.com/repos/mpimenov/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/mpimenov/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/mpimenov/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/mpimenov/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/mpimenov/omim/contents/{+path}","compare_url":"https://api.github.com/repos/mpimenov/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mpimenov/omim/merges","archive_url":"https://api.github.com/repos/mpimenov/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mpimenov/omim/downloads","issues_url":"https://api.github.com/repos/mpimenov/omim/issues{/number}","pulls_url":"https://api.github.com/repos/mpimenov/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/mpimenov/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/mpimenov/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mpimenov/omim/labels{/name}","releases_url":"https://api.github.com/repos/mpimenov/omim/releases{/id}","deployments_url":"https://api.github.com/repos/mpimenov/omim/deployments","created_at":"2015-09-30T10:55:18Z","updated_at":"2016-01-15T13:41:49Z","pushed_at":"2016-12-09T15:03:55Z","git_url":"git://github.com/mpimenov/omim.git","ssh_url":"git@github.com:mpimenov/omim.git","clone_url":"https://github.com/mpimenov/omim.git","svn_url":"https://github.com/mpimenov/omim","homepage":null,"size":2751699,"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":"2eef321bb242e07b73dc9b52a7c8c8e1249a0722","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-12-08T22:59:26Z","pushed_at":"2016-12-09T15:28:17Z","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":2937624,"stargazers_count":2061,"watchers_count":2061,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":409,"mirror_url":null,"open_issues_count":369,"forks":409,"open_issues":369,"watchers":2061,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/4942"},"html":{"href":"https://github.com/mapsme/omim/pull/4942"},"issue":{"href":"https://api.github.com/repos/mapsme/omim/issues/4942"},"comments":{"href":"https://api.github.com/repos/mapsme/omim/issues/4942/comments"},"review_comments":{"href":"https://api.github.com/repos/mapsme/omim/pulls/4942/comments"},"review_comment":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapsme/omim/pulls/4942/commits"},"statuses":{"href":"https://api.github.com/repos/mapsme/omim/statuses/f991004c0489b96330b80075f5cd6ff48a9c4551"}}}}
{"actor":{"display_login":"ygorshenin"}}