{"action":"created","comment":{"url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/comments/47988100","id":47988100,"diff_hunk":"@@ -0,0 +1,127 @@\n+package fr.free.nrw.commons.upload;\n+\n+import android.content.Context;\n+import android.database.Cursor;\n+import android.media.ExifInterface;\n+import android.net.Uri;\n+import android.provider.DocumentsContract;\n+import android.provider.MediaStore;\n+import android.util.Log;\n+\n+import java.io.IOException;\n+\n+\n+/**\n+ * Created by misao on 16-Dec-15.\n+ */\n+public class ImageProcessing {\n+\n+    private Uri uri;\n+    private Context context;\n+\n+    public ImageProcessing(Context context, Uri uri){\n+        this.context = context;\n+        this.uri = uri;\n+    }\n+\n+    //Gets file path of image from its Uri\n+    public String getFilePath(){\n+        String filePath =\"\";\n+        // Will return \"image:x*\"\n+        String wholeID = DocumentsContract.getDocumentId(uri);\n+\n+        // Split at colon, use second item in the array\n+        String id = wholeID.split(\":\")[1];\n+        String[] column = { MediaStore.Images.Media.DATA };\n+\n+        // where id is equal to\n+        String sel = MediaStore.Images.Media._ID + \"=?\";\n+        Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,\n+                column, sel, new String[]{id}, null);\n+\n+        int columnIndex = cursor.getColumnIndex(column[0]);\n+\n+        if (cursor.moveToFirst()) {\n+            filePath = cursor.getString(columnIndex);\n+        }\n+        cursor.close();\n+\n+        Log.d(\"Image\", \"File path: \" + filePath);\n+        return filePath;\n+    }\n+\n+    //Extract GPS coords of image\n+    public String getCoords(String filePath) {\n+\n+        ExifInterface exif;\n+        String latitude = \"\";\n+        String longitude = \"\";\n+        String latitude_ref = \"\";\n+        String longitude_ref = \"\";\n+        String decimalCoords = \"\";\n+\n+        try {\n+            exif = new ExifInterface(filePath);\n+            latitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);\n+            latitude_ref = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF);\n+            longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);\n+            longitude_ref = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF);\n+\n+            Log.d(\"Image\", \"Latitude: \" + latitude + \" \" + latitude_ref);\n+            Log.d(\"Image\", \"Longitude: \" + longitude + \" \" + longitude_ref);\n+\n+            decimalCoords = getDecimalCoords(latitude, latitude_ref, longitude, longitude_ref);\n+\n+        } catch (IOException e) {\n+            Log.w(\"Image\", e);\n+        }\n+        return decimalCoords;\n+    }\n+\n+    //Converts format of coords into decimal coords as required by API for next step\n+    private String getDecimalCoords(String latitude, String latitude_ref, String longitude, String longitude_ref) {\n+\n+        Float decLatitude, decLongitude;\n+\n+        if(latitude_ref.equals(\"N\")){\n+            decLatitude = convertToDegree(latitude);\n+        }\n+        else{\n+            decLatitude = 0 - convertToDegree(latitude);\n+        }\n+\n+        if(longitude_ref.equals(\"E\")){\n+            decLongitude = convertToDegree(longitude);\n+        }\n+        else{\n+            decLongitude = 0 - convertToDegree(longitude);\n+        }\n+\n+        return (String.valueOf(decLatitude) + \", \" + String.valueOf(decLongitude));\n+    }\n+\n+    private Float convertToDegree(String stringDMS){","path":"commons/src/main/java/fr/free/nrw/commons/upload/ImageProcessing.java","position":null,"original_position":103,"commit_id":"3ffcb8fd575d5ebbf2c2d73720a31f470484d940","original_commit_id":"7804546ae39cbca22d5e6382b7a22c980019eb22","user":{"login":"niedzielski","id":1071806,"avatar_url":"https://avatars.githubusercontent.com/u/1071806?v=3","gravatar_id":"","url":"https://api.github.com/users/niedzielski","html_url":"https://github.com/niedzielski","followers_url":"https://api.github.com/users/niedzielski/followers","following_url":"https://api.github.com/users/niedzielski/following{/other_user}","gists_url":"https://api.github.com/users/niedzielski/gists{/gist_id}","starred_url":"https://api.github.com/users/niedzielski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niedzielski/subscriptions","organizations_url":"https://api.github.com/users/niedzielski/orgs","repos_url":"https://api.github.com/users/niedzielski/repos","events_url":"https://api.github.com/users/niedzielski/events{/privacy}","received_events_url":"https://api.github.com/users/niedzielski/received_events","type":"User","site_admin":false},"body":"Isn't `Double.parseDouble(String)` a static function that returns a `double`? ","created_at":"2015-12-18T02:22:27Z","updated_at":"2015-12-18T02:22:27Z","html_url":"https://github.com/nicolas-raoul/apps-android-commons/pull/31#discussion_r47988100","pull_request_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/31","_links":{"self":{"href":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/comments/47988100"},"html":{"href":"https://github.com/nicolas-raoul/apps-android-commons/pull/31#discussion_r47988100"},"pull_request":{"href":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/31"}}},"pull_request":{"url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/31","id":54051877,"html_url":"https://github.com/nicolas-raoul/apps-android-commons/pull/31","diff_url":"https://github.com/nicolas-raoul/apps-android-commons/pull/31.diff","patch_url":"https://github.com/nicolas-raoul/apps-android-commons/pull/31.patch","issue_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/issues/31","number":31,"state":"open","locked":false,"title":"Extracts gps coords","user":{"login":"misaochan","id":3611199,"avatar_url":"https://avatars.githubusercontent.com/u/3611199?v=3","gravatar_id":"","url":"https://api.github.com/users/misaochan","html_url":"https://github.com/misaochan","followers_url":"https://api.github.com/users/misaochan/followers","following_url":"https://api.github.com/users/misaochan/following{/other_user}","gists_url":"https://api.github.com/users/misaochan/gists{/gist_id}","starred_url":"https://api.github.com/users/misaochan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/misaochan/subscriptions","organizations_url":"https://api.github.com/users/misaochan/orgs","repos_url":"https://api.github.com/users/misaochan/repos","events_url":"https://api.github.com/users/misaochan/events{/privacy}","received_events_url":"https://api.github.com/users/misaochan/received_events","type":"User","site_admin":false},"body":"Extracts gps coords and converts them to decimal degrees, ready for use in next step. @niedzielski , would appreciate feedback. :)","created_at":"2015-12-18T00:41:12Z","updated_at":"2015-12-18T02:22:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"26b7876051c7214c7076f1f3cb5e19a5ec107ea6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/31/commits","review_comments_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/31/comments","review_comment_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/issues/31/comments","statuses_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/statuses/3ffcb8fd575d5ebbf2c2d73720a31f470484d940","head":{"label":"misaochan:gps-coords","ref":"gps-coords","sha":"3ffcb8fd575d5ebbf2c2d73720a31f470484d940","user":{"login":"misaochan","id":3611199,"avatar_url":"https://avatars.githubusercontent.com/u/3611199?v=3","gravatar_id":"","url":"https://api.github.com/users/misaochan","html_url":"https://github.com/misaochan","followers_url":"https://api.github.com/users/misaochan/followers","following_url":"https://api.github.com/users/misaochan/following{/other_user}","gists_url":"https://api.github.com/users/misaochan/gists{/gist_id}","starred_url":"https://api.github.com/users/misaochan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/misaochan/subscriptions","organizations_url":"https://api.github.com/users/misaochan/orgs","repos_url":"https://api.github.com/users/misaochan/repos","events_url":"https://api.github.com/users/misaochan/events{/privacy}","received_events_url":"https://api.github.com/users/misaochan/received_events","type":"User","site_admin":false},"repo":{"id":43427766,"name":"apps-android-commons","full_name":"misaochan/apps-android-commons","owner":{"login":"misaochan","id":3611199,"avatar_url":"https://avatars.githubusercontent.com/u/3611199?v=3","gravatar_id":"","url":"https://api.github.com/users/misaochan","html_url":"https://github.com/misaochan","followers_url":"https://api.github.com/users/misaochan/followers","following_url":"https://api.github.com/users/misaochan/following{/other_user}","gists_url":"https://api.github.com/users/misaochan/gists{/gist_id}","starred_url":"https://api.github.com/users/misaochan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/misaochan/subscriptions","organizations_url":"https://api.github.com/users/misaochan/orgs","repos_url":"https://api.github.com/users/misaochan/repos","events_url":"https://api.github.com/users/misaochan/events{/privacy}","received_events_url":"https://api.github.com/users/misaochan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/misaochan/apps-android-commons","description":"Upload pictures from Android to Wikimedia Commons. Looking for volunteers! Come say hi at https://groups.google.com/d/forum/commons-app-android and install at https://play.google.com/store/apps/details?id=fr.free.nrw.commons","fork":true,"url":"https://api.github.com/repos/misaochan/apps-android-commons","forks_url":"https://api.github.com/repos/misaochan/apps-android-commons/forks","keys_url":"https://api.github.com/repos/misaochan/apps-android-commons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/misaochan/apps-android-commons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/misaochan/apps-android-commons/teams","hooks_url":"https://api.github.com/repos/misaochan/apps-android-commons/hooks","issue_events_url":"https://api.github.com/repos/misaochan/apps-android-commons/issues/events{/number}","events_url":"https://api.github.com/repos/misaochan/apps-android-commons/events","assignees_url":"https://api.github.com/repos/misaochan/apps-android-commons/assignees{/user}","branches_url":"https://api.github.com/repos/misaochan/apps-android-commons/branches{/branch}","tags_url":"https://api.github.com/repos/misaochan/apps-android-commons/tags","blobs_url":"https://api.github.com/repos/misaochan/apps-android-commons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/misaochan/apps-android-commons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/misaochan/apps-android-commons/git/refs{/sha}","trees_url":"https://api.github.com/repos/misaochan/apps-android-commons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/misaochan/apps-android-commons/statuses/{sha}","languages_url":"https://api.github.com/repos/misaochan/apps-android-commons/languages","stargazers_url":"https://api.github.com/repos/misaochan/apps-android-commons/stargazers","contributors_url":"https://api.github.com/repos/misaochan/apps-android-commons/contributors","subscribers_url":"https://api.github.com/repos/misaochan/apps-android-commons/subscribers","subscription_url":"https://api.github.com/repos/misaochan/apps-android-commons/subscription","commits_url":"https://api.github.com/repos/misaochan/apps-android-commons/commits{/sha}","git_commits_url":"https://api.github.com/repos/misaochan/apps-android-commons/git/commits{/sha}","comments_url":"https://api.github.com/repos/misaochan/apps-android-commons/comments{/number}","issue_comment_url":"https://api.github.com/repos/misaochan/apps-android-commons/issues/comments{/number}","contents_url":"https://api.github.com/repos/misaochan/apps-android-commons/contents/{+path}","compare_url":"https://api.github.com/repos/misaochan/apps-android-commons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/misaochan/apps-android-commons/merges","archive_url":"https://api.github.com/repos/misaochan/apps-android-commons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/misaochan/apps-android-commons/downloads","issues_url":"https://api.github.com/repos/misaochan/apps-android-commons/issues{/number}","pulls_url":"https://api.github.com/repos/misaochan/apps-android-commons/pulls{/number}","milestones_url":"https://api.github.com/repos/misaochan/apps-android-commons/milestones{/number}","notifications_url":"https://api.github.com/repos/misaochan/apps-android-commons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/misaochan/apps-android-commons/labels{/name}","releases_url":"https://api.github.com/repos/misaochan/apps-android-commons/releases{/id}","created_at":"2015-09-30T10:51:23Z","updated_at":"2015-12-14T16:50:35Z","pushed_at":"2015-12-18T02:21:13Z","git_url":"git://github.com/misaochan/apps-android-commons.git","ssh_url":"git@github.com:misaochan/apps-android-commons.git","clone_url":"https://github.com/misaochan/apps-android-commons.git","svn_url":"https://github.com/misaochan/apps-android-commons","homepage":"","size":24947,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":4,"default_branch":"master"}},"base":{"label":"nicolas-raoul:master","ref":"master","sha":"a845aa0da17404c21ea72b60b288445d7baec0fe","user":{"login":"nicolas-raoul","id":99590,"avatar_url":"https://avatars.githubusercontent.com/u/99590?v=3","gravatar_id":"","url":"https://api.github.com/users/nicolas-raoul","html_url":"https://github.com/nicolas-raoul","followers_url":"https://api.github.com/users/nicolas-raoul/followers","following_url":"https://api.github.com/users/nicolas-raoul/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-raoul/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-raoul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-raoul/subscriptions","organizations_url":"https://api.github.com/users/nicolas-raoul/orgs","repos_url":"https://api.github.com/users/nicolas-raoul/repos","events_url":"https://api.github.com/users/nicolas-raoul/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-raoul/received_events","type":"User","site_admin":false},"repo":{"id":42032884,"name":"apps-android-commons","full_name":"nicolas-raoul/apps-android-commons","owner":{"login":"nicolas-raoul","id":99590,"avatar_url":"https://avatars.githubusercontent.com/u/99590?v=3","gravatar_id":"","url":"https://api.github.com/users/nicolas-raoul","html_url":"https://github.com/nicolas-raoul","followers_url":"https://api.github.com/users/nicolas-raoul/followers","following_url":"https://api.github.com/users/nicolas-raoul/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-raoul/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-raoul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-raoul/subscriptions","organizations_url":"https://api.github.com/users/nicolas-raoul/orgs","repos_url":"https://api.github.com/users/nicolas-raoul/repos","events_url":"https://api.github.com/users/nicolas-raoul/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-raoul/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nicolas-raoul/apps-android-commons","description":"Upload pictures from Android to Wikimedia Commons. Looking for volunteers! Come say hi at https://groups.google.com/d/forum/commons-app-android and install at https://play.google.com/store/apps/details?id=fr.free.nrw.commons","fork":true,"url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons","forks_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/forks","keys_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/teams","hooks_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/hooks","issue_events_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/issues/events{/number}","events_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/events","assignees_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/assignees{/user}","branches_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/branches{/branch}","tags_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/tags","blobs_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/git/refs{/sha}","trees_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/statuses/{sha}","languages_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/languages","stargazers_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/stargazers","contributors_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/contributors","subscribers_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/subscribers","subscription_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/subscription","commits_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/commits{/sha}","git_commits_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/git/commits{/sha}","comments_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/comments{/number}","issue_comment_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/issues/comments{/number}","contents_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/contents/{+path}","compare_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/merges","archive_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/downloads","issues_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/issues{/number}","pulls_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls{/number}","milestones_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/milestones{/number}","notifications_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/labels{/name}","releases_url":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/releases{/id}","created_at":"2015-09-07T05:23:27Z","updated_at":"2015-11-21T12:09:14Z","pushed_at":"2015-12-18T02:21:13Z","git_url":"git://github.com/nicolas-raoul/apps-android-commons.git","ssh_url":"git@github.com:nicolas-raoul/apps-android-commons.git","clone_url":"https://github.com/nicolas-raoul/apps-android-commons.git","svn_url":"https://github.com/nicolas-raoul/apps-android-commons","homepage":"","size":24943,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":16,"forks":3,"open_issues":16,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/31"},"html":{"href":"https://github.com/nicolas-raoul/apps-android-commons/pull/31"},"issue":{"href":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/issues/31"},"comments":{"href":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/issues/31/comments"},"review_comments":{"href":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/31/comments"},"review_comment":{"href":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/pulls/31/commits"},"statuses":{"href":"https://api.github.com/repos/nicolas-raoul/apps-android-commons/statuses/3ffcb8fd575d5ebbf2c2d73720a31f470484d940"}}}}