{"action":"created","comment":{"url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/comments/41100470","id":41100470,"diff_hunk":"@@ -0,0 +1,113 @@\n+package main.java.ru.fizteh.fivt.students.ypechatnov;\n+\n+/**\n+ * Created by ura on 27.09.15.\n+ */\n+\n+\n+import java.io.*;\n+import java.net.*;\n+import javax.xml.parsers.*;\n+import org.apache.commons.io.IOUtils;\n+import org.xml.sax.InputSource;\n+import org.w3c.dom.*;\n+import org.xml.sax.SAXException;\n+import twitter4j.JSONObject;\n+\n+\n+public class YandexPlaces {\n+\n+    private boolean connectionError;\n+    private boolean ioError;\n+    private boolean strangeError;\n+    private Document doc;\n+\n+\n+    public boolean isSmthFailed() {\n+        return connectionError || ioError || strangeError;\n+    }\n+\n+    public double[] calcCoord() {\n+        String p = doc.getElementsByTagName(\"pos\").item(0).getTextContent();\n+        double[] coord = {Double.parseDouble(p.split(\" \")[0]), Double.parseDouble(p.split(\" \")[1])};\n+        return coord;\n+    }\n+    public Double calcRadiusKm() {\n+        // https://ru.wikipedia.org/wiki/%D0%9E%D1%80%D1%82%D0%BE%D0%B4%D1%80%D0%BE%D0%BC%D0%B8%D1%8F\n+        String b1, b2;\n+        b1 = doc.getElementsByTagName(\"lowerCorner\").item(0).getTextContent();\n+        b2 = doc.getElementsByTagName(\"upperCorner\").item(0).getTextContent();\n+        Double a1, a2, p1, p2, d;\n+        final Double r = new Double(6300), k = new Double(180) / Math.PI;\n+        p1 = Double.parseDouble(b1.split(\" \")[0]) / k;\n+        a1 = Double.parseDouble(b1.split(\" \")[1]) / k;\n+        p2 = Double.parseDouble(b2.split(\" \")[0]) / k;\n+        a2 = Double.parseDouble(b2.split(\" \")[1]) / k;\n+        d = Math.acos(Math.sin(p1) * Math.sin(p2)\n+                + StrictMath.cos(p1) * Math.cos(p2) * Math.cos(a2 - a1));\n+        return d * r / new Double(2.0);\n+    }\n+\n+    public double[][] calcBounds() {\n+        String b1, b2;\n+        b1 = doc.getElementsByTagName(\"lowerCorner\").item(0).getTextContent();\n+        b2 = doc.getElementsByTagName(\"upperCorner\").item(0).getTextContent();\n+        double[][] bnds =  {{Double.parseDouble(b1.split(\" \")[1]), Double.parseDouble(b1.split(\" \")[0])},\n+                {Double.parseDouble(b2.split(\" \")[1]), Double.parseDouble(b2.split(\" \")[0])}};\n+        return bnds;\n+    }\n+\n+    YandexPlaces(String place) {\n+        connectionError = false;\n+        ioError = false;\n+        strangeError = false;\n+\n+        if (place.equals(\"nearby\")) {\n+            place = findSelf();\n+        }\n+        if (place == null) {t\n+            connectionError = true;\n+            return;\n+        }\n+\n+        StringBuilder result = new StringBuilder();\n+        try {\n+            URL url = new URL(\"https://geocode-maps.yandex.ru/1.x/?&geocode=\" + place + \"&results=1\");\n+            System.err.println(\"Query to YandexMaps: \" + url.toString());\n+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();\n+            conn.setRequestMethod(\"GET\");\n+            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));\n+            String line;\n+            while ((line = rd.readLine()) != null) {\n+                result.append(line + \"\\n\");\n+            }\n+            rd.close();\n+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\n+            DocumentBuilder builder = factory.newDocumentBuilder();\n+            doc = builder.parse(new InputSource(new StringReader(result.toString())));\n+        } catch (MalformedURLException e) {\n+            connectionError = true;\n+\n+        } catch (ProtocolException e) {\n+            connectionError = true;\n+        } catch (IOException e) {\n+            ioError = true;\n+        } catch (ParserConfigurationException e) {\n+            strangeError = true;\n+        } catch (SAXException e) {\n+            strangeError = true;\n+        }\n+    }\n+\n+    // not a Yandex, but.....\n+    private static String findSelf() {\n+        JSONObject jsonObject;\n+        String url = \"http://ipinfo.io/json\";\n+        try {\n+            return new JSONObject(IOUtils.toString(new URL(url))).getString(\"city\");\n+        } catch (Exception e) {","path":"ypechatnov/src/main/java/ru/fizteh/fivt/students/ypechatnov/YandexPlaces.java","position":108,"original_position":108,"commit_id":"70d7a4ae28ded4a0d7dfb6f59f326f76358a3706","original_commit_id":"70d7a4ae28ded4a0d7dfb6f59f326f76358a3706","user":{"login":"zakharovas","id":14183139,"avatar_url":"https://avatars.githubusercontent.com/u/14183139?v=3","gravatar_id":"","url":"https://api.github.com/users/zakharovas","html_url":"https://github.com/zakharovas","followers_url":"https://api.github.com/users/zakharovas/followers","following_url":"https://api.github.com/users/zakharovas/following{/other_user}","gists_url":"https://api.github.com/users/zakharovas/gists{/gist_id}","starred_url":"https://api.github.com/users/zakharovas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zakharovas/subscriptions","organizations_url":"https://api.github.com/users/zakharovas/orgs","repos_url":"https://api.github.com/users/zakharovas/repos","events_url":"https://api.github.com/users/zakharovas/events{/privacy}","received_events_url":"https://api.github.com/users/zakharovas/received_events","type":"User","site_admin":false},"body":"Exception лучше пробросить наверх. Ну и обработать там в main'е.","created_at":"2015-10-04T18:16:59Z","updated_at":"2015-10-04T18:16:59Z","html_url":"https://github.com/akormushin/fizteh-java-2015/pull/57#discussion_r41100470","pull_request_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/57","_links":{"self":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/comments/41100470"},"html":{"href":"https://github.com/akormushin/fizteh-java-2015/pull/57#discussion_r41100470"},"pull_request":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/57"}}},"pull_request":{"url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/57","id":46127793,"html_url":"https://github.com/akormushin/fizteh-java-2015/pull/57","diff_url":"https://github.com/akormushin/fizteh-java-2015/pull/57.diff","patch_url":"https://github.com/akormushin/fizteh-java-2015/pull/57.patch","issue_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/57","number":57,"state":"open","locked":false,"title":"Печатнов Юрий, 495. TwitterStream. Somehow working sketch.","user":{"login":"yuri-pechatnov","id":1867157,"avatar_url":"https://avatars.githubusercontent.com/u/1867157?v=3","gravatar_id":"","url":"https://api.github.com/users/yuri-pechatnov","html_url":"https://github.com/yuri-pechatnov","followers_url":"https://api.github.com/users/yuri-pechatnov/followers","following_url":"https://api.github.com/users/yuri-pechatnov/following{/other_user}","gists_url":"https://api.github.com/users/yuri-pechatnov/gists{/gist_id}","starred_url":"https://api.github.com/users/yuri-pechatnov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuri-pechatnov/subscriptions","organizations_url":"https://api.github.com/users/yuri-pechatnov/orgs","repos_url":"https://api.github.com/users/yuri-pechatnov/repos","events_url":"https://api.github.com/users/yuri-pechatnov/events{/privacy}","received_events_url":"https://api.github.com/users/yuri-pechatnov/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-28T07:42:24Z","updated_at":"2015-10-04T18:16:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e8964ce1c7032f087d9d521b8982eca88dcd4723","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/57/commits","review_comments_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/57/comments","review_comment_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/57/comments","statuses_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/statuses/70d7a4ae28ded4a0d7dfb6f59f326f76358a3706","head":{"label":"yuri-pechatnov:master","ref":"master","sha":"70d7a4ae28ded4a0d7dfb6f59f326f76358a3706","user":{"login":"yuri-pechatnov","id":1867157,"avatar_url":"https://avatars.githubusercontent.com/u/1867157?v=3","gravatar_id":"","url":"https://api.github.com/users/yuri-pechatnov","html_url":"https://github.com/yuri-pechatnov","followers_url":"https://api.github.com/users/yuri-pechatnov/followers","following_url":"https://api.github.com/users/yuri-pechatnov/following{/other_user}","gists_url":"https://api.github.com/users/yuri-pechatnov/gists{/gist_id}","starred_url":"https://api.github.com/users/yuri-pechatnov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuri-pechatnov/subscriptions","organizations_url":"https://api.github.com/users/yuri-pechatnov/orgs","repos_url":"https://api.github.com/users/yuri-pechatnov/repos","events_url":"https://api.github.com/users/yuri-pechatnov/events{/privacy}","received_events_url":"https://api.github.com/users/yuri-pechatnov/received_events","type":"User","site_admin":false},"repo":{"id":42513913,"name":"fizteh-java-2015","full_name":"yuri-pechatnov/fizteh-java-2015","owner":{"login":"yuri-pechatnov","id":1867157,"avatar_url":"https://avatars.githubusercontent.com/u/1867157?v=3","gravatar_id":"","url":"https://api.github.com/users/yuri-pechatnov","html_url":"https://github.com/yuri-pechatnov","followers_url":"https://api.github.com/users/yuri-pechatnov/followers","following_url":"https://api.github.com/users/yuri-pechatnov/following{/other_user}","gists_url":"https://api.github.com/users/yuri-pechatnov/gists{/gist_id}","starred_url":"https://api.github.com/users/yuri-pechatnov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuri-pechatnov/subscriptions","organizations_url":"https://api.github.com/users/yuri-pechatnov/orgs","repos_url":"https://api.github.com/users/yuri-pechatnov/repos","events_url":"https://api.github.com/users/yuri-pechatnov/events{/privacy}","received_events_url":"https://api.github.com/users/yuri-pechatnov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yuri-pechatnov/fizteh-java-2015","description":"","fork":true,"url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015","forks_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/forks","keys_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/teams","hooks_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/hooks","issue_events_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/issues/events{/number}","events_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/events","assignees_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/assignees{/user}","branches_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/branches{/branch}","tags_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/tags","blobs_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/git/refs{/sha}","trees_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/statuses/{sha}","languages_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/languages","stargazers_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/stargazers","contributors_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/contributors","subscribers_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/subscribers","subscription_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/subscription","commits_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/commits{/sha}","git_commits_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/git/commits{/sha}","comments_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/comments{/number}","issue_comment_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/issues/comments{/number}","contents_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/contents/{+path}","compare_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/merges","archive_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/downloads","issues_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/issues{/number}","pulls_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/pulls{/number}","milestones_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/milestones{/number}","notifications_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/labels{/name}","releases_url":"https://api.github.com/repos/yuri-pechatnov/fizteh-java-2015/releases{/id}","created_at":"2015-09-15T11:09:47Z","updated_at":"2015-09-15T11:09:48Z","pushed_at":"2015-09-27T19:08:15Z","git_url":"git://github.com/yuri-pechatnov/fizteh-java-2015.git","ssh_url":"git@github.com:yuri-pechatnov/fizteh-java-2015.git","clone_url":"https://github.com/yuri-pechatnov/fizteh-java-2015.git","svn_url":"https://github.com/yuri-pechatnov/fizteh-java-2015","homepage":null,"size":228,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"akormushin:master","ref":"master","sha":"9220bc40f3d4aba8e97f1e3230b8c9896f63e28c","user":{"login":"akormushin","id":1074038,"avatar_url":"https://avatars.githubusercontent.com/u/1074038?v=3","gravatar_id":"","url":"https://api.github.com/users/akormushin","html_url":"https://github.com/akormushin","followers_url":"https://api.github.com/users/akormushin/followers","following_url":"https://api.github.com/users/akormushin/following{/other_user}","gists_url":"https://api.github.com/users/akormushin/gists{/gist_id}","starred_url":"https://api.github.com/users/akormushin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akormushin/subscriptions","organizations_url":"https://api.github.com/users/akormushin/orgs","repos_url":"https://api.github.com/users/akormushin/repos","events_url":"https://api.github.com/users/akormushin/events{/privacy}","received_events_url":"https://api.github.com/users/akormushin/received_events","type":"User","site_admin":false},"repo":{"id":42108549,"name":"fizteh-java-2015","full_name":"akormushin/fizteh-java-2015","owner":{"login":"akormushin","id":1074038,"avatar_url":"https://avatars.githubusercontent.com/u/1074038?v=3","gravatar_id":"","url":"https://api.github.com/users/akormushin","html_url":"https://github.com/akormushin","followers_url":"https://api.github.com/users/akormushin/followers","following_url":"https://api.github.com/users/akormushin/following{/other_user}","gists_url":"https://api.github.com/users/akormushin/gists{/gist_id}","starred_url":"https://api.github.com/users/akormushin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akormushin/subscriptions","organizations_url":"https://api.github.com/users/akormushin/orgs","repos_url":"https://api.github.com/users/akormushin/repos","events_url":"https://api.github.com/users/akormushin/events{/privacy}","received_events_url":"https://api.github.com/users/akormushin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/akormushin/fizteh-java-2015","description":"","fork":false,"url":"https://api.github.com/repos/akormushin/fizteh-java-2015","forks_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/forks","keys_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/teams","hooks_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/hooks","issue_events_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/events{/number}","events_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/events","assignees_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/assignees{/user}","branches_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/branches{/branch}","tags_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/tags","blobs_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/git/refs{/sha}","trees_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/statuses/{sha}","languages_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/languages","stargazers_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/stargazers","contributors_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/contributors","subscribers_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/subscribers","subscription_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/subscription","commits_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/commits{/sha}","git_commits_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/git/commits{/sha}","comments_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/comments{/number}","issue_comment_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/comments{/number}","contents_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/contents/{+path}","compare_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/merges","archive_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/downloads","issues_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues{/number}","pulls_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls{/number}","milestones_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/milestones{/number}","notifications_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/labels{/name}","releases_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/releases{/id}","created_at":"2015-09-08T11:37:54Z","updated_at":"2015-09-14T13:54:17Z","pushed_at":"2015-10-04T18:14:52Z","git_url":"git://github.com/akormushin/fizteh-java-2015.git","ssh_url":"git@github.com:akormushin/fizteh-java-2015.git","clone_url":"https://github.com/akormushin/fizteh-java-2015.git","svn_url":"https://github.com/akormushin/fizteh-java-2015","homepage":null,"size":3853,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":24,"forks":39,"open_issues":24,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/57"},"html":{"href":"https://github.com/akormushin/fizteh-java-2015/pull/57"},"issue":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/57"},"comments":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/57/comments"},"review_comments":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/57/comments"},"review_comment":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/57/commits"},"statuses":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/statuses/70d7a4ae28ded4a0d7dfb6f59f326f76358a3706"}}}}