{"action":"created","comment":{"url":"https://api.github.com/repos/STEMLab/geotools/pulls/comments/48592539","id":48592539,"diff_hunk":"@@ -0,0 +1,257 @@\n+/*\r\n+ *    GeoTools - The Open Source Java GIS Toolkit\r\n+ *    http://geotools.org\r\n+ *\r\n+ *    (C) 2015, Spatio-temporal Databases Laboratory (STEMLab)\r\n+ *\r\n+ *    This library is free software; you can redistribute it and/or\r\n+ *    modify it under the terms of the GNU Lesser General Public\r\n+ *    License as published by the Free Software Foundation;\r\n+ *    version 2.1 of the License.\r\n+ *\r\n+ *    This library is distributed in the hope that it will be useful,\r\n+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r\n+ *    Lesser General Public License for more details.\r\n+ */\r\n+package org.geotools.geometry.iso.sfcgal.util;\r\n+\r\n+import org.geotools.geometry.iso.root.GeometryImpl;\r\n+import org.geotools.geometry.iso.sfcgal.relate.IntersectionMatrix3D;\r\n+import org.geotools.geometry.iso.sfcgal.relate.RelateOp3D;\r\n+import org.geotools.geometry.iso.sfcgal.wrapper.SFAlgorithm;\r\n+import org.geotools.geometry.iso.sfcgal.wrapper.SFGeometry;\r\n+import org.opengis.geometry.Geometry;\r\n+import org.opengis.geometry.TransfiniteSet;\r\n+\r\n+/**\r\n+ * @author Donguk Seo\r\n+ *\r\n+ */\r\n+public class Geometry3DOperation {\r\n+\r\n+        /**\r\n+         * Computes the distance between two geometries using distance3D operation of SFCGAL\r\n+         * @param gA\r\n+         * @param gB\r\n+         * @return distance between two geometry objects\r\n+         */\r\n+        public static double distance(Geometry gA, Geometry gB) {\r\n+                SFGeometry geometryA = SFCGALConvertor.geometryToSFCGALGeometry(gA);\r\n+                SFGeometry geometryB = SFCGALConvertor.geometryToSFCGALGeometry(gB);\r\n+\r\n+                return SFAlgorithm.distance3D(geometryA, geometryB);\r\n+        }\r\n+\r\n+        /**\r\n+         * @param geom\r\n+         * @return ConvexHull of geometry\r\n+         */\r\n+        public static Geometry getConvexHull(GeometryImpl geom) {\r\n+                SFGeometry g = SFCGALConvertor.geometryToSFCGALGeometry((Geometry) geom);\r\n+                SFGeometry convex = SFAlgorithm.convexHull3D(g);\r\n+\r\n+                return SFCGALConvertor.geometryFromSFCGALGeometry(convex);\r\n+        }\r\n+\r\n+        public static boolean relate(GeometryImpl gA, GeometryImpl gB,\r\n+                        String intersectionPatternMatrix) {\r\n+                return false;\r\n+        }\r\n+\r\n+        /**\r\n+         * @param gA\r\n+         * @param gB\r\n+         * @return TRUE, if the gA is equal to gB\r\n+         */\r\n+        public static boolean equals(GeometryImpl gA, GeometryImpl gB) {\r\n+                SFGeometry geometryA = SFCGALConvertor.geometryToSFCGALGeometry(gA);\r\n+                SFGeometry geometryB = SFCGALConvertor.geometryToSFCGALGeometry(gB);\r\n+\r\n+                return geometryA.equals(geometryB);\r\n+        }\r\n+\r\n+        /**\r\n+         * @param gA\r\n+         * @param gB\r\n+         * @return TRUE, if the gA is disjoint with gB\r\n+         */\r\n+        public static boolean disjoint(GeometryImpl gA, GeometryImpl gB) {\r\n+                SFGeometry geometryA = SFCGALConvertor.geometryToSFCGALGeometry(gA);\r\n+                SFGeometry geometryB = SFCGALConvertor.geometryToSFCGALGeometry(gB);\r\n+\r\n+                return !SFAlgorithm.intersects3D(geometryA, geometryB);\r\n+        }\r\n+\r\n+        \r\n+        /**\r\n+         * @param gA\r\n+         * @param gB\r\n+         * @return TRUE, if the gA is intersect with gB\r\n+         */\r\n+        public static boolean intersects(GeometryImpl gA, GeometryImpl gB) {\r\n+                SFGeometry geometryA = SFCGALConvertor.geometryToSFCGALGeometry(gA);\r\n+                SFGeometry geometryB = SFCGALConvertor.geometryToSFCGALGeometry(gB);\r\n+\r\n+                return SFAlgorithm.intersects3D(geometryA, geometryB);\r\n+        }\r\n+\r\n+        /**\r\n+         * @param gA\r\n+         * @param gB\r\n+         * @return TRUE, if the gA touches gB.\r\n+         */\r\n+        public static boolean touches(GeometryImpl gA, GeometryImpl gB) {\r\n+                IntersectionMatrix3D tIM = null;\r\n+                try {\r\n+                        tIM = RelateOp3D.relate(gA, gB);\r\n+                } catch (Exception e) {\r\n+                        e.printStackTrace();\r\n+                }\r\n+\r\n+                boolean rValue = false;\r\n+                if (tIM.matches(\"FT**\") || tIM.matches(\"F*T*\") || tIM.matches(\"F**T\")) {\r\n+                        rValue = true;\r\n+                }\r\n+\r\n+                return rValue;\r\n+        }\r\n+\r\n+        /**\r\n+         * @param gA\r\n+         * @param gB\r\n+         * @return TRUE, if the gA is spatially contain gB.\r\n+         */\r\n+        public static boolean contains(GeometryImpl gA, GeometryImpl gB) {\r\n+                SFGeometry geometryA = SFCGALConvertor.geometryToSFCGALGeometry(gA);\r\n+                SFGeometry geometryB = SFCGALConvertor.geometryToSFCGALGeometry(gB);\r\n+\r\n+                return !geometryA.equals(geometryB) && !touches(gA, gB)\r\n+                                && SFAlgorithm.covers3D(geometryA, geometryB);\r\n+        }\r\n+\r\n+        /**\r\n+         * @param gA\r\n+         * @param gB\r\n+         * @return TRUE, if the gA is spatially within gB.\r\n+         */\r\n+        public static boolean within(GeometryImpl gA, GeometryImpl gB) {\r\n+                return contains(gB, gA);\r\n+        }\r\n+\r\n+        /**\r\n+         * @param gA\r\n+         * @param gB\r\n+         * @return TRUE, if the gA overlaps with gB.\r\n+         */\r\n+        public static boolean overlaps(GeometryImpl gA, GeometryImpl gB) {\r\n+                SFGeometry geometryA = SFCGALConvertor.geometryToSFCGALGeometry(gA);\r\n+                SFGeometry geometryB = SFCGALConvertor.geometryToSFCGALGeometry(gB);\r\n+                SFGeometry intersection = SFAlgorithm.intersection3D(geometryA, geometryB);\r\n+                boolean rValue = false;\r\n+\r\n+                if (equals(gA, gB))\r\n+                        return rValue;\r\n+                if (!intersection.isEmpty() && !contains(gA, gB) && !contains(gB, gA)\r","path":"modules/unsupported/geometry/src/main/java/org/geotools/geometry/iso/sfcgal/util/Geometry3DOperation.java","position":155,"original_position":155,"commit_id":"0326a53976aa4c2f1cd6e257a26a2e00bf42224a","original_commit_id":"0326a53976aa4c2f1cd6e257a26a2e00bf42224a","user":{"login":"Joon-Seok","id":15980136,"avatar_url":"https://avatars.githubusercontent.com/u/15980136?v=3","gravatar_id":"","url":"https://api.github.com/users/Joon-Seok","html_url":"https://github.com/Joon-Seok","followers_url":"https://api.github.com/users/Joon-Seok/followers","following_url":"https://api.github.com/users/Joon-Seok/following{/other_user}","gists_url":"https://api.github.com/users/Joon-Seok/gists{/gist_id}","starred_url":"https://api.github.com/users/Joon-Seok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Joon-Seok/subscriptions","organizations_url":"https://api.github.com/users/Joon-Seok/orgs","repos_url":"https://api.github.com/users/Joon-Seok/repos","events_url":"https://api.github.com/users/Joon-Seok/events{/privacy}","received_events_url":"https://api.github.com/users/Joon-Seok/received_events","type":"User","site_admin":false},"body":"These function calls are inefficient. You need to avoid duplication of operations.","created_at":"2015-12-30T08:53:00Z","updated_at":"2015-12-30T08:53:00Z","html_url":"https://github.com/STEMLab/geotools/pull/1#discussion_r48592539","pull_request_url":"https://api.github.com/repos/STEMLab/geotools/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/STEMLab/geotools/pulls/comments/48592539"},"html":{"href":"https://github.com/STEMLab/geotools/pull/1#discussion_r48592539"},"pull_request":{"href":"https://api.github.com/repos/STEMLab/geotools/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/STEMLab/geotools/pulls/1","id":54708773,"html_url":"https://github.com/STEMLab/geotools/pull/1","diff_url":"https://github.com/STEMLab/geotools/pull/1.diff","patch_url":"https://github.com/STEMLab/geotools/pull/1.patch","issue_url":"https://api.github.com/repos/STEMLab/geotools/issues/1","number":1,"state":"open","locked":false,"title":"SFCGAL Wrapper pull request test","user":{"login":"STEM-DongukSeo","id":13566842,"avatar_url":"https://avatars.githubusercontent.com/u/13566842?v=3","gravatar_id":"","url":"https://api.github.com/users/STEM-DongukSeo","html_url":"https://github.com/STEM-DongukSeo","followers_url":"https://api.github.com/users/STEM-DongukSeo/followers","following_url":"https://api.github.com/users/STEM-DongukSeo/following{/other_user}","gists_url":"https://api.github.com/users/STEM-DongukSeo/gists{/gist_id}","starred_url":"https://api.github.com/users/STEM-DongukSeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/STEM-DongukSeo/subscriptions","organizations_url":"https://api.github.com/users/STEM-DongukSeo/orgs","repos_url":"https://api.github.com/users/STEM-DongukSeo/repos","events_url":"https://api.github.com/users/STEM-DongukSeo/events{/privacy}","received_events_url":"https://api.github.com/users/STEM-DongukSeo/received_events","type":"User","site_admin":false},"body":"SFCGAL Wrapper pull request test","created_at":"2015-12-29T08:03:57Z","updated_at":"2015-12-30T08:53:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"135ff20143a995633c470b67c3ae9c0ef72b5977","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/STEMLab/geotools/pulls/1/commits","review_comments_url":"https://api.github.com/repos/STEMLab/geotools/pulls/1/comments","review_comment_url":"https://api.github.com/repos/STEMLab/geotools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/STEMLab/geotools/issues/1/comments","statuses_url":"https://api.github.com/repos/STEMLab/geotools/statuses/0326a53976aa4c2f1cd6e257a26a2e00bf42224a","head":{"label":"STEMLab:wrapper_test","ref":"wrapper_test","sha":"0326a53976aa4c2f1cd6e257a26a2e00bf42224a","user":{"login":"STEMLab","id":15979942,"avatar_url":"https://avatars.githubusercontent.com/u/15979942?v=3","gravatar_id":"","url":"https://api.github.com/users/STEMLab","html_url":"https://github.com/STEMLab","followers_url":"https://api.github.com/users/STEMLab/followers","following_url":"https://api.github.com/users/STEMLab/following{/other_user}","gists_url":"https://api.github.com/users/STEMLab/gists{/gist_id}","starred_url":"https://api.github.com/users/STEMLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/STEMLab/subscriptions","organizations_url":"https://api.github.com/users/STEMLab/orgs","repos_url":"https://api.github.com/users/STEMLab/repos","events_url":"https://api.github.com/users/STEMLab/events{/privacy}","received_events_url":"https://api.github.com/users/STEMLab/received_events","type":"Organization","site_admin":false},"repo":{"id":42836774,"name":"geotools","full_name":"STEMLab/geotools","owner":{"login":"STEMLab","id":15979942,"avatar_url":"https://avatars.githubusercontent.com/u/15979942?v=3","gravatar_id":"","url":"https://api.github.com/users/STEMLab","html_url":"https://github.com/STEMLab","followers_url":"https://api.github.com/users/STEMLab/followers","following_url":"https://api.github.com/users/STEMLab/following{/other_user}","gists_url":"https://api.github.com/users/STEMLab/gists{/gist_id}","starred_url":"https://api.github.com/users/STEMLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/STEMLab/subscriptions","organizations_url":"https://api.github.com/users/STEMLab/orgs","repos_url":"https://api.github.com/users/STEMLab/repos","events_url":"https://api.github.com/users/STEMLab/events{/privacy}","received_events_url":"https://api.github.com/users/STEMLab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/STEMLab/geotools","description":"Official GeoTools repository","fork":true,"url":"https://api.github.com/repos/STEMLab/geotools","forks_url":"https://api.github.com/repos/STEMLab/geotools/forks","keys_url":"https://api.github.com/repos/STEMLab/geotools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/STEMLab/geotools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/STEMLab/geotools/teams","hooks_url":"https://api.github.com/repos/STEMLab/geotools/hooks","issue_events_url":"https://api.github.com/repos/STEMLab/geotools/issues/events{/number}","events_url":"https://api.github.com/repos/STEMLab/geotools/events","assignees_url":"https://api.github.com/repos/STEMLab/geotools/assignees{/user}","branches_url":"https://api.github.com/repos/STEMLab/geotools/branches{/branch}","tags_url":"https://api.github.com/repos/STEMLab/geotools/tags","blobs_url":"https://api.github.com/repos/STEMLab/geotools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/STEMLab/geotools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/STEMLab/geotools/git/refs{/sha}","trees_url":"https://api.github.com/repos/STEMLab/geotools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/STEMLab/geotools/statuses/{sha}","languages_url":"https://api.github.com/repos/STEMLab/geotools/languages","stargazers_url":"https://api.github.com/repos/STEMLab/geotools/stargazers","contributors_url":"https://api.github.com/repos/STEMLab/geotools/contributors","subscribers_url":"https://api.github.com/repos/STEMLab/geotools/subscribers","subscription_url":"https://api.github.com/repos/STEMLab/geotools/subscription","commits_url":"https://api.github.com/repos/STEMLab/geotools/commits{/sha}","git_commits_url":"https://api.github.com/repos/STEMLab/geotools/git/commits{/sha}","comments_url":"https://api.github.com/repos/STEMLab/geotools/comments{/number}","issue_comment_url":"https://api.github.com/repos/STEMLab/geotools/issues/comments{/number}","contents_url":"https://api.github.com/repos/STEMLab/geotools/contents/{+path}","compare_url":"https://api.github.com/repos/STEMLab/geotools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/STEMLab/geotools/merges","archive_url":"https://api.github.com/repos/STEMLab/geotools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/STEMLab/geotools/downloads","issues_url":"https://api.github.com/repos/STEMLab/geotools/issues{/number}","pulls_url":"https://api.github.com/repos/STEMLab/geotools/pulls{/number}","milestones_url":"https://api.github.com/repos/STEMLab/geotools/milestones{/number}","notifications_url":"https://api.github.com/repos/STEMLab/geotools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/STEMLab/geotools/labels{/name}","releases_url":"https://api.github.com/repos/STEMLab/geotools/releases{/id}","created_at":"2015-09-21T01:18:29Z","updated_at":"2015-12-17T11:55:50Z","pushed_at":"2015-12-29T08:03:57Z","git_url":"git://github.com/STEMLab/geotools.git","ssh_url":"git@github.com:STEMLab/geotools.git","clone_url":"https://github.com/STEMLab/geotools.git","svn_url":"https://github.com/STEMLab/geotools","homepage":"http://geotools.org","size":114592,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"STEMLab:master","ref":"master","sha":"7a879d1927454e635a1c8b3b25857da8db12ed7a","user":{"login":"STEMLab","id":15979942,"avatar_url":"https://avatars.githubusercontent.com/u/15979942?v=3","gravatar_id":"","url":"https://api.github.com/users/STEMLab","html_url":"https://github.com/STEMLab","followers_url":"https://api.github.com/users/STEMLab/followers","following_url":"https://api.github.com/users/STEMLab/following{/other_user}","gists_url":"https://api.github.com/users/STEMLab/gists{/gist_id}","starred_url":"https://api.github.com/users/STEMLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/STEMLab/subscriptions","organizations_url":"https://api.github.com/users/STEMLab/orgs","repos_url":"https://api.github.com/users/STEMLab/repos","events_url":"https://api.github.com/users/STEMLab/events{/privacy}","received_events_url":"https://api.github.com/users/STEMLab/received_events","type":"Organization","site_admin":false},"repo":{"id":42836774,"name":"geotools","full_name":"STEMLab/geotools","owner":{"login":"STEMLab","id":15979942,"avatar_url":"https://avatars.githubusercontent.com/u/15979942?v=3","gravatar_id":"","url":"https://api.github.com/users/STEMLab","html_url":"https://github.com/STEMLab","followers_url":"https://api.github.com/users/STEMLab/followers","following_url":"https://api.github.com/users/STEMLab/following{/other_user}","gists_url":"https://api.github.com/users/STEMLab/gists{/gist_id}","starred_url":"https://api.github.com/users/STEMLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/STEMLab/subscriptions","organizations_url":"https://api.github.com/users/STEMLab/orgs","repos_url":"https://api.github.com/users/STEMLab/repos","events_url":"https://api.github.com/users/STEMLab/events{/privacy}","received_events_url":"https://api.github.com/users/STEMLab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/STEMLab/geotools","description":"Official GeoTools repository","fork":true,"url":"https://api.github.com/repos/STEMLab/geotools","forks_url":"https://api.github.com/repos/STEMLab/geotools/forks","keys_url":"https://api.github.com/repos/STEMLab/geotools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/STEMLab/geotools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/STEMLab/geotools/teams","hooks_url":"https://api.github.com/repos/STEMLab/geotools/hooks","issue_events_url":"https://api.github.com/repos/STEMLab/geotools/issues/events{/number}","events_url":"https://api.github.com/repos/STEMLab/geotools/events","assignees_url":"https://api.github.com/repos/STEMLab/geotools/assignees{/user}","branches_url":"https://api.github.com/repos/STEMLab/geotools/branches{/branch}","tags_url":"https://api.github.com/repos/STEMLab/geotools/tags","blobs_url":"https://api.github.com/repos/STEMLab/geotools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/STEMLab/geotools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/STEMLab/geotools/git/refs{/sha}","trees_url":"https://api.github.com/repos/STEMLab/geotools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/STEMLab/geotools/statuses/{sha}","languages_url":"https://api.github.com/repos/STEMLab/geotools/languages","stargazers_url":"https://api.github.com/repos/STEMLab/geotools/stargazers","contributors_url":"https://api.github.com/repos/STEMLab/geotools/contributors","subscribers_url":"https://api.github.com/repos/STEMLab/geotools/subscribers","subscription_url":"https://api.github.com/repos/STEMLab/geotools/subscription","commits_url":"https://api.github.com/repos/STEMLab/geotools/commits{/sha}","git_commits_url":"https://api.github.com/repos/STEMLab/geotools/git/commits{/sha}","comments_url":"https://api.github.com/repos/STEMLab/geotools/comments{/number}","issue_comment_url":"https://api.github.com/repos/STEMLab/geotools/issues/comments{/number}","contents_url":"https://api.github.com/repos/STEMLab/geotools/contents/{+path}","compare_url":"https://api.github.com/repos/STEMLab/geotools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/STEMLab/geotools/merges","archive_url":"https://api.github.com/repos/STEMLab/geotools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/STEMLab/geotools/downloads","issues_url":"https://api.github.com/repos/STEMLab/geotools/issues{/number}","pulls_url":"https://api.github.com/repos/STEMLab/geotools/pulls{/number}","milestones_url":"https://api.github.com/repos/STEMLab/geotools/milestones{/number}","notifications_url":"https://api.github.com/repos/STEMLab/geotools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/STEMLab/geotools/labels{/name}","releases_url":"https://api.github.com/repos/STEMLab/geotools/releases{/id}","created_at":"2015-09-21T01:18:29Z","updated_at":"2015-12-17T11:55:50Z","pushed_at":"2015-12-29T08:03:57Z","git_url":"git://github.com/STEMLab/geotools.git","ssh_url":"git@github.com:STEMLab/geotools.git","clone_url":"https://github.com/STEMLab/geotools.git","svn_url":"https://github.com/STEMLab/geotools","homepage":"http://geotools.org","size":114592,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/STEMLab/geotools/pulls/1"},"html":{"href":"https://github.com/STEMLab/geotools/pull/1"},"issue":{"href":"https://api.github.com/repos/STEMLab/geotools/issues/1"},"comments":{"href":"https://api.github.com/repos/STEMLab/geotools/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/STEMLab/geotools/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/STEMLab/geotools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/STEMLab/geotools/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/STEMLab/geotools/statuses/0326a53976aa4c2f1cd6e257a26a2e00bf42224a"}}}}