{"action":"created","comment":{"url":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/comments/107588773","pull_request_review_id":28568856,"id":107588773,"diff_hunk":"@@ -1,24 +1,145 @@\n ﻿using System;\n using System.Collections.Generic;\n-\n+using System.Threading.Tasks;\n+using System.Diagnostics;\n+using Plugin.Geolocator;\n+using Plugin.Geolocator.Abstractions;\n using Xamarin.Forms;\n+using StudentDriver.Services;\n+using StudentDriver.Models;\n \n namespace StudentDriver\n {\n \tpublic partial class DrivePage : ContentPage\n \t{\n-\t\tprivate bool drivingButtonPressed = false;\n-\t\tpublic DrivePage ()\n+\t\tprivate bool isStudentDriving = false;\n+\t\t//speed and distance in miles (imperial)\n+\t\tprivate double currentAverageSpeed = 0.0;\n+\t\tprivate TimeSpan currentTime;\n+\t\tprivate List<DrivePoint> positions = new List<DrivePoint>();\n+\t\tprivate IGeolocator locator;\n+\n+\t\tprotected override void OnAppearing()\n \t\t{\n-\t\t\tInitializeComponent ();\n-\t\t\tNavigationPage.SetHasNavigationBar (this, false);\n-\t\t\tdrivingButton.Clicked += async (object sender, EventArgs e) => {\n-\t\t\t\tdrivingButton.BackgroundColor = drivingButtonPressed ? AppColors.Third : AppColors.Fourth;\n-\t\t\t\tdrivingButtonPressed = !drivingButtonPressed;\n-\t\t\t\tdrivingButton.Text = drivingButtonPressed ? \"Stop\" : \"Start\";\n+\t\t\tbase.OnAppearing();\n+\n+\t\t\ttry\n+\t\t\t{\n+\t\t\t\tlocator = CrossGeolocator.Current;\n+\t\t\t\tlocator.DesiredAccuracy = 5;\n+\t\t\t\tlocator.PositionChanged += (object s, PositionEventArgs eventArg) =>\n+\t\t\t\t{\n+\t\t\t\t\tvar currentPosition = eventArg.Position;\n+\t\t\t\t\tif (positions.Count < 100) // every 100 points, we will add to the database.\n+\t\t\t\t\t{\n+\t\t\t\t\t\tvar drivePoint = new DrivePoint();\n+\t\t\t\t\t\tdrivePoint.Latitude = currentPosition.Latitude;\n+\t\t\t\t\t\tdrivePoint.Longitude = currentPosition.Longitude;\n+\t\t\t\t\t\tdrivePoint.PointDateTime = currentPosition.Timestamp.DateTime;\n+\t\t\t\t\t\tdrivePoint.Speed = (float)currentPosition.Speed;\n+\t\t\t\t\t\tpositions.Add(drivePoint);\n+\t\t\t\t\t\tcurrentAverageSpeed = currentAverageSpeed == 0.0 ? ConvertSpeeds(eventArg.Position.Speed) : (0.95 * currentAverageSpeed) + (0.05 * ConvertSpeeds(eventArg.Position.Speed));\n+\t\t\t\t\t}\n+\t\t\t\t\telse\n+\t\t\t\t\t{\n+\t\t\t\t\t\tTask.Factory.StartNew(async () =>\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tvar database = SQLiteDatabase.GetInstance();\n+\t\t\t\t\t\t\tawait database.AddDrivePoints(positions);\n+\t\t\t\t\t\t\tpositions.Clear();\n+\t\t\t\t\t\t});\n+\t\t\t\t\t}\n+\t\t\t\t\tavgSpeedLabel.Text = string.Format(\"{0} MPH\", currentAverageSpeed.ToString(\"F1\"));","path":"StudentDriver/StudentDriver/DrivePage.xaml.cs","position":61,"original_position":61,"commit_id":"cee1b1e72357ed2d01f650cdaee283496459fd29","original_commit_id":"cee1b1e72357ed2d01f650cdaee283496459fd29","user":{"login":"sorianog","id":13261711,"avatar_url":"https://avatars3.githubusercontent.com/u/13261711?v=3","gravatar_id":"","url":"https://api.github.com/users/sorianog","html_url":"https://github.com/sorianog","followers_url":"https://api.github.com/users/sorianog/followers","following_url":"https://api.github.com/users/sorianog/following{/other_user}","gists_url":"https://api.github.com/users/sorianog/gists{/gist_id}","starred_url":"https://api.github.com/users/sorianog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sorianog/subscriptions","organizations_url":"https://api.github.com/users/sorianog/orgs","repos_url":"https://api.github.com/users/sorianog/repos","events_url":"https://api.github.com/users/sorianog/events{/privacy}","received_events_url":"https://api.github.com/users/sorianog/received_events","type":"User","site_admin":false},"body":"@zawadzkip @DylanWalseth Offhand, do any of you know a .js lib for processing GPS points to calculate speed (that accounts for factors such as elevations, etc. iirc we also discussed about this and our experience with the GPS lab in SE2800/Software Processes in Sophomore Year)? I remember past discussions that it would make sense for the backend/server to handle all the legwork for mathematical calculations so that the mobile app is fast/responsive for the end-user. ","created_at":"2017-03-23T05:03:21Z","updated_at":"2017-03-23T05:03:45Z","html_url":"https://github.com/msoeSE/TheHopefuls/pull/105#discussion_r107588773","pull_request_url":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/105","_links":{"self":{"href":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/comments/107588773"},"html":{"href":"https://github.com/msoeSE/TheHopefuls/pull/105#discussion_r107588773"},"pull_request":{"href":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/105"}}},"pull_request":{"url":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/105","id":112035091,"html_url":"https://github.com/msoeSE/TheHopefuls/pull/105","diff_url":"https://github.com/msoeSE/TheHopefuls/pull/105.diff","patch_url":"https://github.com/msoeSE/TheHopefuls/pull/105.patch","issue_url":"https://api.github.com/repos/msoeSE/TheHopefuls/issues/105","number":105,"state":"open","locked":false,"title":"94m gps tracking","user":{"login":"zawadzkip","id":7703723,"avatar_url":"https://avatars0.githubusercontent.com/u/7703723?v=3","gravatar_id":"","url":"https://api.github.com/users/zawadzkip","html_url":"https://github.com/zawadzkip","followers_url":"https://api.github.com/users/zawadzkip/followers","following_url":"https://api.github.com/users/zawadzkip/following{/other_user}","gists_url":"https://api.github.com/users/zawadzkip/gists{/gist_id}","starred_url":"https://api.github.com/users/zawadzkip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zawadzkip/subscriptions","organizations_url":"https://api.github.com/users/zawadzkip/orgs","repos_url":"https://api.github.com/users/zawadzkip/repos","events_url":"https://api.github.com/users/zawadzkip/events{/privacy}","received_events_url":"https://api.github.com/users/zawadzkip/received_events","type":"User","site_admin":false},"body":"NOTE: There is no current webservice calls as Hardip is refactoring the class, will add a new issue for it and take care of it once his PR is made.","created_at":"2017-03-22T15:17:40Z","updated_at":"2017-03-23T05:03:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f91e51b6120f4bbacd37183728a6f7afcbdc515c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/105/commits","review_comments_url":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/105/comments","review_comment_url":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/comments{/number}","comments_url":"https://api.github.com/repos/msoeSE/TheHopefuls/issues/105/comments","statuses_url":"https://api.github.com/repos/msoeSE/TheHopefuls/statuses/cee1b1e72357ed2d01f650cdaee283496459fd29","head":{"label":"msoeSE:94m-gps-tracking","ref":"94m-gps-tracking","sha":"cee1b1e72357ed2d01f650cdaee283496459fd29","user":{"login":"msoeSE","id":10049389,"avatar_url":"https://avatars2.githubusercontent.com/u/10049389?v=3","gravatar_id":"","url":"https://api.github.com/users/msoeSE","html_url":"https://github.com/msoeSE","followers_url":"https://api.github.com/users/msoeSE/followers","following_url":"https://api.github.com/users/msoeSE/following{/other_user}","gists_url":"https://api.github.com/users/msoeSE/gists{/gist_id}","starred_url":"https://api.github.com/users/msoeSE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msoeSE/subscriptions","organizations_url":"https://api.github.com/users/msoeSE/orgs","repos_url":"https://api.github.com/users/msoeSE/repos","events_url":"https://api.github.com/users/msoeSE/events{/privacy}","received_events_url":"https://api.github.com/users/msoeSE/received_events","type":"Organization","site_admin":false},"repo":{"id":68405559,"name":"TheHopefuls","full_name":"msoeSE/TheHopefuls","owner":{"login":"msoeSE","id":10049389,"avatar_url":"https://avatars2.githubusercontent.com/u/10049389?v=3","gravatar_id":"","url":"https://api.github.com/users/msoeSE","html_url":"https://github.com/msoeSE","followers_url":"https://api.github.com/users/msoeSE/followers","following_url":"https://api.github.com/users/msoeSE/following{/other_user}","gists_url":"https://api.github.com/users/msoeSE/gists{/gist_id}","starred_url":"https://api.github.com/users/msoeSE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msoeSE/subscriptions","organizations_url":"https://api.github.com/users/msoeSE/orgs","repos_url":"https://api.github.com/users/msoeSE/repos","events_url":"https://api.github.com/users/msoeSE/events{/privacy}","received_events_url":"https://api.github.com/users/msoeSE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/msoeSE/TheHopefuls","description":"16-17 Senior Design - The Hopefuls","fork":false,"url":"https://api.github.com/repos/msoeSE/TheHopefuls","forks_url":"https://api.github.com/repos/msoeSE/TheHopefuls/forks","keys_url":"https://api.github.com/repos/msoeSE/TheHopefuls/keys{/key_id}","collaborators_url":"https://api.github.com/repos/msoeSE/TheHopefuls/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/msoeSE/TheHopefuls/teams","hooks_url":"https://api.github.com/repos/msoeSE/TheHopefuls/hooks","issue_events_url":"https://api.github.com/repos/msoeSE/TheHopefuls/issues/events{/number}","events_url":"https://api.github.com/repos/msoeSE/TheHopefuls/events","assignees_url":"https://api.github.com/repos/msoeSE/TheHopefuls/assignees{/user}","branches_url":"https://api.github.com/repos/msoeSE/TheHopefuls/branches{/branch}","tags_url":"https://api.github.com/repos/msoeSE/TheHopefuls/tags","blobs_url":"https://api.github.com/repos/msoeSE/TheHopefuls/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/msoeSE/TheHopefuls/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/msoeSE/TheHopefuls/git/refs{/sha}","trees_url":"https://api.github.com/repos/msoeSE/TheHopefuls/git/trees{/sha}","statuses_url":"https://api.github.com/repos/msoeSE/TheHopefuls/statuses/{sha}","languages_url":"https://api.github.com/repos/msoeSE/TheHopefuls/languages","stargazers_url":"https://api.github.com/repos/msoeSE/TheHopefuls/stargazers","contributors_url":"https://api.github.com/repos/msoeSE/TheHopefuls/contributors","subscribers_url":"https://api.github.com/repos/msoeSE/TheHopefuls/subscribers","subscription_url":"https://api.github.com/repos/msoeSE/TheHopefuls/subscription","commits_url":"https://api.github.com/repos/msoeSE/TheHopefuls/commits{/sha}","git_commits_url":"https://api.github.com/repos/msoeSE/TheHopefuls/git/commits{/sha}","comments_url":"https://api.github.com/repos/msoeSE/TheHopefuls/comments{/number}","issue_comment_url":"https://api.github.com/repos/msoeSE/TheHopefuls/issues/comments{/number}","contents_url":"https://api.github.com/repos/msoeSE/TheHopefuls/contents/{+path}","compare_url":"https://api.github.com/repos/msoeSE/TheHopefuls/compare/{base}...{head}","merges_url":"https://api.github.com/repos/msoeSE/TheHopefuls/merges","archive_url":"https://api.github.com/repos/msoeSE/TheHopefuls/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/msoeSE/TheHopefuls/downloads","issues_url":"https://api.github.com/repos/msoeSE/TheHopefuls/issues{/number}","pulls_url":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls{/number}","milestones_url":"https://api.github.com/repos/msoeSE/TheHopefuls/milestones{/number}","notifications_url":"https://api.github.com/repos/msoeSE/TheHopefuls/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/msoeSE/TheHopefuls/labels{/name}","releases_url":"https://api.github.com/repos/msoeSE/TheHopefuls/releases{/id}","deployments_url":"https://api.github.com/repos/msoeSE/TheHopefuls/deployments","created_at":"2016-09-16T18:35:23Z","updated_at":"2017-02-02T07:20:53Z","pushed_at":"2017-03-22T16:54:21Z","git_url":"git://github.com/msoeSE/TheHopefuls.git","ssh_url":"git@github.com:msoeSE/TheHopefuls.git","clone_url":"https://github.com/msoeSE/TheHopefuls.git","svn_url":"https://github.com/msoeSE/TheHopefuls","homepage":null,"size":4195,"stargazers_count":4,"watchers_count":4,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":25,"forks":0,"open_issues":25,"watchers":4,"default_branch":"master"}},"base":{"label":"msoeSE:mobile-dev","ref":"mobile-dev","sha":"496e94889c9f25fcfc3daee814d1da8b22fe56f7","user":{"login":"msoeSE","id":10049389,"avatar_url":"https://avatars2.githubusercontent.com/u/10049389?v=3","gravatar_id":"","url":"https://api.github.com/users/msoeSE","html_url":"https://github.com/msoeSE","followers_url":"https://api.github.com/users/msoeSE/followers","following_url":"https://api.github.com/users/msoeSE/following{/other_user}","gists_url":"https://api.github.com/users/msoeSE/gists{/gist_id}","starred_url":"https://api.github.com/users/msoeSE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msoeSE/subscriptions","organizations_url":"https://api.github.com/users/msoeSE/orgs","repos_url":"https://api.github.com/users/msoeSE/repos","events_url":"https://api.github.com/users/msoeSE/events{/privacy}","received_events_url":"https://api.github.com/users/msoeSE/received_events","type":"Organization","site_admin":false},"repo":{"id":68405559,"name":"TheHopefuls","full_name":"msoeSE/TheHopefuls","owner":{"login":"msoeSE","id":10049389,"avatar_url":"https://avatars2.githubusercontent.com/u/10049389?v=3","gravatar_id":"","url":"https://api.github.com/users/msoeSE","html_url":"https://github.com/msoeSE","followers_url":"https://api.github.com/users/msoeSE/followers","following_url":"https://api.github.com/users/msoeSE/following{/other_user}","gists_url":"https://api.github.com/users/msoeSE/gists{/gist_id}","starred_url":"https://api.github.com/users/msoeSE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msoeSE/subscriptions","organizations_url":"https://api.github.com/users/msoeSE/orgs","repos_url":"https://api.github.com/users/msoeSE/repos","events_url":"https://api.github.com/users/msoeSE/events{/privacy}","received_events_url":"https://api.github.com/users/msoeSE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/msoeSE/TheHopefuls","description":"16-17 Senior Design - The Hopefuls","fork":false,"url":"https://api.github.com/repos/msoeSE/TheHopefuls","forks_url":"https://api.github.com/repos/msoeSE/TheHopefuls/forks","keys_url":"https://api.github.com/repos/msoeSE/TheHopefuls/keys{/key_id}","collaborators_url":"https://api.github.com/repos/msoeSE/TheHopefuls/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/msoeSE/TheHopefuls/teams","hooks_url":"https://api.github.com/repos/msoeSE/TheHopefuls/hooks","issue_events_url":"https://api.github.com/repos/msoeSE/TheHopefuls/issues/events{/number}","events_url":"https://api.github.com/repos/msoeSE/TheHopefuls/events","assignees_url":"https://api.github.com/repos/msoeSE/TheHopefuls/assignees{/user}","branches_url":"https://api.github.com/repos/msoeSE/TheHopefuls/branches{/branch}","tags_url":"https://api.github.com/repos/msoeSE/TheHopefuls/tags","blobs_url":"https://api.github.com/repos/msoeSE/TheHopefuls/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/msoeSE/TheHopefuls/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/msoeSE/TheHopefuls/git/refs{/sha}","trees_url":"https://api.github.com/repos/msoeSE/TheHopefuls/git/trees{/sha}","statuses_url":"https://api.github.com/repos/msoeSE/TheHopefuls/statuses/{sha}","languages_url":"https://api.github.com/repos/msoeSE/TheHopefuls/languages","stargazers_url":"https://api.github.com/repos/msoeSE/TheHopefuls/stargazers","contributors_url":"https://api.github.com/repos/msoeSE/TheHopefuls/contributors","subscribers_url":"https://api.github.com/repos/msoeSE/TheHopefuls/subscribers","subscription_url":"https://api.github.com/repos/msoeSE/TheHopefuls/subscription","commits_url":"https://api.github.com/repos/msoeSE/TheHopefuls/commits{/sha}","git_commits_url":"https://api.github.com/repos/msoeSE/TheHopefuls/git/commits{/sha}","comments_url":"https://api.github.com/repos/msoeSE/TheHopefuls/comments{/number}","issue_comment_url":"https://api.github.com/repos/msoeSE/TheHopefuls/issues/comments{/number}","contents_url":"https://api.github.com/repos/msoeSE/TheHopefuls/contents/{+path}","compare_url":"https://api.github.com/repos/msoeSE/TheHopefuls/compare/{base}...{head}","merges_url":"https://api.github.com/repos/msoeSE/TheHopefuls/merges","archive_url":"https://api.github.com/repos/msoeSE/TheHopefuls/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/msoeSE/TheHopefuls/downloads","issues_url":"https://api.github.com/repos/msoeSE/TheHopefuls/issues{/number}","pulls_url":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls{/number}","milestones_url":"https://api.github.com/repos/msoeSE/TheHopefuls/milestones{/number}","notifications_url":"https://api.github.com/repos/msoeSE/TheHopefuls/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/msoeSE/TheHopefuls/labels{/name}","releases_url":"https://api.github.com/repos/msoeSE/TheHopefuls/releases{/id}","deployments_url":"https://api.github.com/repos/msoeSE/TheHopefuls/deployments","created_at":"2016-09-16T18:35:23Z","updated_at":"2017-02-02T07:20:53Z","pushed_at":"2017-03-22T16:54:21Z","git_url":"git://github.com/msoeSE/TheHopefuls.git","ssh_url":"git@github.com:msoeSE/TheHopefuls.git","clone_url":"https://github.com/msoeSE/TheHopefuls.git","svn_url":"https://github.com/msoeSE/TheHopefuls","homepage":null,"size":4195,"stargazers_count":4,"watchers_count":4,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":25,"forks":0,"open_issues":25,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/105"},"html":{"href":"https://github.com/msoeSE/TheHopefuls/pull/105"},"issue":{"href":"https://api.github.com/repos/msoeSE/TheHopefuls/issues/105"},"comments":{"href":"https://api.github.com/repos/msoeSE/TheHopefuls/issues/105/comments"},"review_comments":{"href":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/105/comments"},"review_comment":{"href":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/msoeSE/TheHopefuls/pulls/105/commits"},"statuses":{"href":"https://api.github.com/repos/msoeSE/TheHopefuls/statuses/cee1b1e72357ed2d01f650cdaee283496459fd29"}}}}
{"actor":{"display_login":"sorianog"}}