{"action":"created","comment":{"url":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/comments/24327431","id":24327431,"diff_hunk":"@@ -0,0 +1,326 @@\n+package com.google.maps.android.kml;\n+\n+import com.google.android.gms.maps.model.LatLng;\n+import com.google.android.gms.maps.model.LatLngBounds;\n+\n+import org.xmlpull.v1.XmlPullParser;\n+import org.xmlpull.v1.XmlPullParserException;\n+\n+import java.io.IOException;\n+import java.util.ArrayList;\n+import java.util.HashMap;\n+\n+import static org.xmlpull.v1.XmlPullParser.END_TAG;\n+import static org.xmlpull.v1.XmlPullParser.START_TAG;\n+\n+/**\n+ * Parses the feature of a given KML file into a KmlPlacemark or KmlGroundOverlay object\n+ */\n+/* package */ class KmlFeatureParser {\n+\n+    private final static String GEOMETRY_REGEX = \"Point|LineString|Polygon|MultiGeometry\";\n+\n+    private final static int LONGITUDE_INDEX = 0;\n+\n+    private final static int LATITUDE_INDEX = 1;\n+\n+    private final static String PROPERTY_REGEX = \"name|description|visibility\";\n+\n+    private final static String BOUNDARY_REGEX = \"outerBoundaryIs|innerBoundaryIs\";\n+\n+    private final static String EXTENDED_DATA = \"ExtendedData\";\n+\n+    private final static String STYLE_URL_TAG = \"styleUrl\";\n+\n+    private final static String STYLE_TAG = \"Style\";\n+\n+    private final static String COMPASS_REGEX = \"north|south|east|west\";\n+\n+    /**\n+     * Creates a new Placemark object (created if a Placemark start tag is read by the\n+     * XmlPullParser and if a Geometry tag is contained within the Placemark tag)\n+     * and assigns specific elements read from the parser to the Placemark.\n+     */\n+    /* package */\n+    static KmlPlacemark createPlacemark(XmlPullParser parser)\n+            throws IOException, XmlPullParserException {\n+        String styleId = null;\n+        KmlStyle inlineStyle = null;\n+        HashMap<String, String> properties = new HashMap<String, String>();\n+        KmlGeometry geometry = null;\n+        int eventType = parser.getEventType();\n+        while (!(eventType == END_TAG && parser.getName().equals(\"Placemark\"))) {\n+            if (eventType == START_TAG) {\n+                if (parser.getName().equals(STYLE_URL_TAG)) {\n+                    styleId = parser.nextText();\n+                } else if (parser.getName().matches(GEOMETRY_REGEX)) {\n+                    geometry = createGeometry(parser, parser.getName());\n+                } else if (parser.getName().matches(PROPERTY_REGEX)) {\n+                    properties.put(parser.getName(), parser.nextText());\n+                } else if (parser.getName().equals(EXTENDED_DATA)) {\n+                    properties.putAll(setExtendedDataProperties(parser));\n+                } else if (parser.getName().equals(STYLE_TAG)) {\n+                    inlineStyle = KmlStyleParser.createStyle(parser);\n+                }\n+            }\n+            eventType = parser.next();\n+        }\n+        // If there is no geometry associated with the Placemark then we do not add it\n+        if (geometry != null) {\n+            return new KmlPlacemark(geometry, styleId, inlineStyle, properties);\n+        }\n+        return null;\n+    }\n+\n+    /**\n+     * Creates a new GroundOverlay object (created if a GroundOverlay tag is read by the\n+     * XmlPullParser) and assigns specific elements read from the parser to the GroundOverlay\n+     */\n+    /* package */\n+    static KmlGroundOverlay createGroundOverlay(XmlPullParser parser)\n+            throws IOException, XmlPullParserException {\n+        float drawOrder = 0.0f;\n+        float rotation = 0.0f;\n+        int visibility = 1;\n+        String imageUrl = null;\n+        LatLngBounds latLonBox;\n+        HashMap<String, String> properties = new HashMap<String, String>();\n+        HashMap<String, Double> compassPoints = new HashMap<String, Double>();\n+\n+        int eventType = parser.getEventType();\n+        while (!(eventType == END_TAG && parser.getName().equals(\"GroundOverlay\"))) {\n+            if (eventType == START_TAG) {\n+                if (parser.getName().equals(\"Icon\")) {\n+                    imageUrl = getImageUrl(parser);\n+                } else if (parser.getName().equals(\"drawOrder\")) {\n+                    drawOrder = Float.parseFloat(parser.nextText());\n+                } else if (parser.getName().equals(\"visibility\")) {\n+                    visibility = Integer.parseInt(parser.nextText());\n+                } else if (parser.getName().equals(\"ExtendedData\")) {\n+                    properties.putAll(setExtendedDataProperties(parser));\n+                } else if (parser.getName().equals(\"rotation\")) {\n+                    rotation = getRotation(parser);\n+                } else if (parser.getName().matches(PROPERTY_REGEX) || parser.getName().equals(\"color\")) {\n+                    properties.put(parser.getName(), parser.nextText());\n+                } else if (parser.getName().matches(COMPASS_REGEX)) {\n+                    compassPoints.put(parser.getName(), Double.parseDouble(parser.nextText()));\n+                }\n+            }\n+            eventType = parser.next();\n+        }\n+        latLonBox = createLatLngBounds(compassPoints.get(\"north\"), compassPoints.get(\"south\"),\n+                compassPoints.get(\"east\"), compassPoints.get(\"west\"));\n+        return new KmlGroundOverlay(imageUrl, latLonBox, drawOrder, visibility, properties,\n+                rotation);\n+    }\n+\n+    private static float getRotation(XmlPullParser parser)\n+            throws IOException, XmlPullParserException {\n+        float rotation;\n+        float parsedRotation = Float.parseFloat(parser.nextText());\n+        if (parsedRotation > 0.0 && parsedRotation <= 180.0) {","path":"library/src/com/google/maps/android/kml/KmlFeatureParser.java","position":121,"original_position":121,"commit_id":"d84b68c4add9f4c0f931e4d6675eabff0bbeaa64","original_commit_id":"d84b68c4add9f4c0f931e4d6675eabff0bbeaa64","user":{"login":"amorris13","id":4523811,"avatar_url":"https://avatars.githubusercontent.com/u/4523811?v=3","gravatar_id":"","url":"https://api.github.com/users/amorris13","html_url":"https://github.com/amorris13","followers_url":"https://api.github.com/users/amorris13/followers","following_url":"https://api.github.com/users/amorris13/following{/other_user}","gists_url":"https://api.github.com/users/amorris13/gists{/gist_id}","starred_url":"https://api.github.com/users/amorris13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amorris13/subscriptions","organizations_url":"https://api.github.com/users/amorris13/orgs","repos_url":"https://api.github.com/users/amorris13/repos","events_url":"https://api.github.com/users/amorris13/events{/privacy}","received_events_url":"https://api.github.com/users/amorris13/received_events","type":"User","site_admin":false},"body":"I think this is wrong - let's chat in person","created_at":"2015-02-09T13:31:10Z","updated_at":"2015-02-09T13:31:10Z","html_url":"https://github.com/juliawong/android-maps-utils/pull/3#discussion_r24327431","pull_request_url":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/comments/24327431"},"html":{"href":"https://github.com/juliawong/android-maps-utils/pull/3#discussion_r24327431"},"pull_request":{"href":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/3","id":28341968,"html_url":"https://github.com/juliawong/android-maps-utils/pull/3","diff_url":"https://github.com/juliawong/android-maps-utils/pull/3.diff","patch_url":"https://github.com/juliawong/android-maps-utils/pull/3.patch","issue_url":"https://api.github.com/repos/juliawong/android-maps-utils/issues/3","number":3,"state":"closed","locked":false,"title":"KML Code Review","user":{"login":"lchans","id":5670255,"avatar_url":"https://avatars.githubusercontent.com/u/5670255?v=3","gravatar_id":"","url":"https://api.github.com/users/lchans","html_url":"https://github.com/lchans","followers_url":"https://api.github.com/users/lchans/followers","following_url":"https://api.github.com/users/lchans/following{/other_user}","gists_url":"https://api.github.com/users/lchans/gists{/gist_id}","starred_url":"https://api.github.com/users/lchans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lchans/subscriptions","organizations_url":"https://api.github.com/users/lchans/orgs","repos_url":"https://api.github.com/users/lchans/repos","events_url":"https://api.github.com/users/lchans/events{/privacy}","received_events_url":"https://api.github.com/users/lchans/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-30T07:01:19Z","updated_at":"2015-02-09T13:31:10Z","closed_at":"2015-02-09T00:44:26Z","merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/3/commits","review_comments_url":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/3/comments","review_comment_url":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/comments/{number}","comments_url":"https://api.github.com/repos/juliawong/android-maps-utils/issues/3/comments","statuses_url":"https://api.github.com/repos/juliawong/android-maps-utils/statuses/d84b68c4add9f4c0f931e4d6675eabff0bbeaa64","head":{"label":"juliawong:new","ref":"new","sha":"d84b68c4add9f4c0f931e4d6675eabff0bbeaa64","user":{"login":"juliawong","id":1804284,"avatar_url":"https://avatars.githubusercontent.com/u/1804284?v=3","gravatar_id":"","url":"https://api.github.com/users/juliawong","html_url":"https://github.com/juliawong","followers_url":"https://api.github.com/users/juliawong/followers","following_url":"https://api.github.com/users/juliawong/following{/other_user}","gists_url":"https://api.github.com/users/juliawong/gists{/gist_id}","starred_url":"https://api.github.com/users/juliawong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliawong/subscriptions","organizations_url":"https://api.github.com/users/juliawong/orgs","repos_url":"https://api.github.com/users/juliawong/repos","events_url":"https://api.github.com/users/juliawong/events{/privacy}","received_events_url":"https://api.github.com/users/juliawong/received_events","type":"User","site_admin":false},"repo":{"id":27356280,"name":"android-maps-utils","full_name":"juliawong/android-maps-utils","owner":{"login":"juliawong","id":1804284,"avatar_url":"https://avatars.githubusercontent.com/u/1804284?v=3","gravatar_id":"","url":"https://api.github.com/users/juliawong","html_url":"https://github.com/juliawong","followers_url":"https://api.github.com/users/juliawong/followers","following_url":"https://api.github.com/users/juliawong/following{/other_user}","gists_url":"https://api.github.com/users/juliawong/gists{/gist_id}","starred_url":"https://api.github.com/users/juliawong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliawong/subscriptions","organizations_url":"https://api.github.com/users/juliawong/orgs","repos_url":"https://api.github.com/users/juliawong/repos","events_url":"https://api.github.com/users/juliawong/events{/privacy}","received_events_url":"https://api.github.com/users/juliawong/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/juliawong/android-maps-utils","description":"Handy extensions to the Google Maps Android API.","fork":true,"url":"https://api.github.com/repos/juliawong/android-maps-utils","forks_url":"https://api.github.com/repos/juliawong/android-maps-utils/forks","keys_url":"https://api.github.com/repos/juliawong/android-maps-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juliawong/android-maps-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juliawong/android-maps-utils/teams","hooks_url":"https://api.github.com/repos/juliawong/android-maps-utils/hooks","issue_events_url":"https://api.github.com/repos/juliawong/android-maps-utils/issues/events{/number}","events_url":"https://api.github.com/repos/juliawong/android-maps-utils/events","assignees_url":"https://api.github.com/repos/juliawong/android-maps-utils/assignees{/user}","branches_url":"https://api.github.com/repos/juliawong/android-maps-utils/branches{/branch}","tags_url":"https://api.github.com/repos/juliawong/android-maps-utils/tags","blobs_url":"https://api.github.com/repos/juliawong/android-maps-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juliawong/android-maps-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juliawong/android-maps-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/juliawong/android-maps-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juliawong/android-maps-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/juliawong/android-maps-utils/languages","stargazers_url":"https://api.github.com/repos/juliawong/android-maps-utils/stargazers","contributors_url":"https://api.github.com/repos/juliawong/android-maps-utils/contributors","subscribers_url":"https://api.github.com/repos/juliawong/android-maps-utils/subscribers","subscription_url":"https://api.github.com/repos/juliawong/android-maps-utils/subscription","commits_url":"https://api.github.com/repos/juliawong/android-maps-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/juliawong/android-maps-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/juliawong/android-maps-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/juliawong/android-maps-utils/issues/comments/{number}","contents_url":"https://api.github.com/repos/juliawong/android-maps-utils/contents/{+path}","compare_url":"https://api.github.com/repos/juliawong/android-maps-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juliawong/android-maps-utils/merges","archive_url":"https://api.github.com/repos/juliawong/android-maps-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juliawong/android-maps-utils/downloads","issues_url":"https://api.github.com/repos/juliawong/android-maps-utils/issues{/number}","pulls_url":"https://api.github.com/repos/juliawong/android-maps-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/juliawong/android-maps-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/juliawong/android-maps-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juliawong/android-maps-utils/labels{/name}","releases_url":"https://api.github.com/repos/juliawong/android-maps-utils/releases{/id}","created_at":"2014-12-01T00:55:10Z","updated_at":"2015-02-09T06:18:33Z","pushed_at":"2015-02-09T06:18:32Z","git_url":"git://github.com/juliawong/android-maps-utils.git","ssh_url":"git@github.com:juliawong/android-maps-utils.git","clone_url":"https://github.com/juliawong/android-maps-utils.git","svn_url":"https://github.com/juliawong/android-maps-utils","homepage":"http://googlemaps.github.io/android-maps-utils/","size":4905,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"new"}},"base":{"label":"juliawong:master","ref":"master","sha":"f59b401807225d0e6b969aa96dfe85023a8c9bad","user":{"login":"juliawong","id":1804284,"avatar_url":"https://avatars.githubusercontent.com/u/1804284?v=3","gravatar_id":"","url":"https://api.github.com/users/juliawong","html_url":"https://github.com/juliawong","followers_url":"https://api.github.com/users/juliawong/followers","following_url":"https://api.github.com/users/juliawong/following{/other_user}","gists_url":"https://api.github.com/users/juliawong/gists{/gist_id}","starred_url":"https://api.github.com/users/juliawong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliawong/subscriptions","organizations_url":"https://api.github.com/users/juliawong/orgs","repos_url":"https://api.github.com/users/juliawong/repos","events_url":"https://api.github.com/users/juliawong/events{/privacy}","received_events_url":"https://api.github.com/users/juliawong/received_events","type":"User","site_admin":false},"repo":{"id":27356280,"name":"android-maps-utils","full_name":"juliawong/android-maps-utils","owner":{"login":"juliawong","id":1804284,"avatar_url":"https://avatars.githubusercontent.com/u/1804284?v=3","gravatar_id":"","url":"https://api.github.com/users/juliawong","html_url":"https://github.com/juliawong","followers_url":"https://api.github.com/users/juliawong/followers","following_url":"https://api.github.com/users/juliawong/following{/other_user}","gists_url":"https://api.github.com/users/juliawong/gists{/gist_id}","starred_url":"https://api.github.com/users/juliawong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliawong/subscriptions","organizations_url":"https://api.github.com/users/juliawong/orgs","repos_url":"https://api.github.com/users/juliawong/repos","events_url":"https://api.github.com/users/juliawong/events{/privacy}","received_events_url":"https://api.github.com/users/juliawong/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/juliawong/android-maps-utils","description":"Handy extensions to the Google Maps Android API.","fork":true,"url":"https://api.github.com/repos/juliawong/android-maps-utils","forks_url":"https://api.github.com/repos/juliawong/android-maps-utils/forks","keys_url":"https://api.github.com/repos/juliawong/android-maps-utils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juliawong/android-maps-utils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juliawong/android-maps-utils/teams","hooks_url":"https://api.github.com/repos/juliawong/android-maps-utils/hooks","issue_events_url":"https://api.github.com/repos/juliawong/android-maps-utils/issues/events{/number}","events_url":"https://api.github.com/repos/juliawong/android-maps-utils/events","assignees_url":"https://api.github.com/repos/juliawong/android-maps-utils/assignees{/user}","branches_url":"https://api.github.com/repos/juliawong/android-maps-utils/branches{/branch}","tags_url":"https://api.github.com/repos/juliawong/android-maps-utils/tags","blobs_url":"https://api.github.com/repos/juliawong/android-maps-utils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juliawong/android-maps-utils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juliawong/android-maps-utils/git/refs{/sha}","trees_url":"https://api.github.com/repos/juliawong/android-maps-utils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juliawong/android-maps-utils/statuses/{sha}","languages_url":"https://api.github.com/repos/juliawong/android-maps-utils/languages","stargazers_url":"https://api.github.com/repos/juliawong/android-maps-utils/stargazers","contributors_url":"https://api.github.com/repos/juliawong/android-maps-utils/contributors","subscribers_url":"https://api.github.com/repos/juliawong/android-maps-utils/subscribers","subscription_url":"https://api.github.com/repos/juliawong/android-maps-utils/subscription","commits_url":"https://api.github.com/repos/juliawong/android-maps-utils/commits{/sha}","git_commits_url":"https://api.github.com/repos/juliawong/android-maps-utils/git/commits{/sha}","comments_url":"https://api.github.com/repos/juliawong/android-maps-utils/comments{/number}","issue_comment_url":"https://api.github.com/repos/juliawong/android-maps-utils/issues/comments/{number}","contents_url":"https://api.github.com/repos/juliawong/android-maps-utils/contents/{+path}","compare_url":"https://api.github.com/repos/juliawong/android-maps-utils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juliawong/android-maps-utils/merges","archive_url":"https://api.github.com/repos/juliawong/android-maps-utils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juliawong/android-maps-utils/downloads","issues_url":"https://api.github.com/repos/juliawong/android-maps-utils/issues{/number}","pulls_url":"https://api.github.com/repos/juliawong/android-maps-utils/pulls{/number}","milestones_url":"https://api.github.com/repos/juliawong/android-maps-utils/milestones{/number}","notifications_url":"https://api.github.com/repos/juliawong/android-maps-utils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juliawong/android-maps-utils/labels{/name}","releases_url":"https://api.github.com/repos/juliawong/android-maps-utils/releases{/id}","created_at":"2014-12-01T00:55:10Z","updated_at":"2015-02-09T06:18:33Z","pushed_at":"2015-02-09T06:18:32Z","git_url":"git://github.com/juliawong/android-maps-utils.git","ssh_url":"git@github.com:juliawong/android-maps-utils.git","clone_url":"https://github.com/juliawong/android-maps-utils.git","svn_url":"https://github.com/juliawong/android-maps-utils","homepage":"http://googlemaps.github.io/android-maps-utils/","size":4905,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"new"}},"_links":{"self":{"href":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/3"},"html":{"href":"https://github.com/juliawong/android-maps-utils/pull/3"},"issue":{"href":"https://api.github.com/repos/juliawong/android-maps-utils/issues/3"},"comments":{"href":"https://api.github.com/repos/juliawong/android-maps-utils/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/juliawong/android-maps-utils/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/juliawong/android-maps-utils/statuses/d84b68c4add9f4c0f931e4d6675eabff0bbeaa64"}}}}