{"action":"created","comment":{"url":"https://api.github.com/repos/boostorg/geometry/pulls/comments/23810304","id":23810304,"diff_hunk":"@@ -54,128 +57,210 @@ namespace detail { namespace is_simple\n {\n \n \n-template <typename Linestring, bool CheckSelfIntersections = true>\n-struct is_simple_linestring\n+template <typename Turn>\n+inline bool check_segment_indices(Turn const& turn,\n+                                  signed_index_type last_index)\n {\n-    static inline bool apply(Linestring const& linestring)\n+    return\n+        (turn.operations[0].seg_id.segment_index == 0\n+         && turn.operations[1].seg_id.segment_index == last_index)\n+        ||\n+        (turn.operations[0].seg_id.segment_index == 0\n+         && turn.operations[1].seg_id.segment_index == last_index);\n+}\n+\n+\n+template <typename Geometry, typename Tag = typename tag<Geometry>::type>\n+class is_acceptable_turn\n+    : not_implemented<Geometry>\n+{};\n+\n+template <typename Linestring>\n+class is_acceptable_turn<Linestring, linestring_tag>\n+{\n+public:\n+    is_acceptable_turn(Linestring const& linestring)\n+        : m_linestring(linestring)\n+        , m_is_closed(geometry::equals(range::front(linestring),\n+                                       range::back(linestring)))\n+    {}\n+\n+    template <typename Turn>\n+    inline bool apply(Turn const& turn) const\n     {\n-        return !detail::is_valid::has_duplicates\n-                    <\n-                        Linestring, closed\n-                    >::apply(linestring)\n-            && !detail::is_valid::has_spikes\n-                    <\n-                        Linestring, closed\n-                    >::apply(linestring)\n-            && !(CheckSelfIntersections && geometry::intersects(linestring));\n+        BOOST_ASSERT(boost::size(m_linestring) > 1);\n+        return m_is_closed\n+            && turn.method == overlay::method_none\n+            && check_segment_indices(turn, boost::size(m_linestring) - 2)\n+            && geometry::equals(range::front(m_linestring), turn.point);\n     }\n-};\n-\n \n+private:\n+    Linestring const& m_linestring;\n+    bool const m_is_closed;\n+};\n \n template <typename MultiLinestring>\n-class is_simple_multilinestring\n+class is_acceptable_turn<MultiLinestring, multi_linestring_tag>\n {\n private:\n-    class is_acceptable_turn\n+    typedef typename boost::range_value<MultiLinestring>::type linestring_type;\n+    typedef is_acceptable_turn<linestring_type> base_type;\n+\n+    template <typename Point, typename Linestring>\n+    static inline bool is_boundary_point_of(Point const& point,\n+                                            Linestring const& linestring)\n     {\n-    private:\n-        template <typename Point, typename Linestring>\n-        static inline bool is_boundary_point_of(Point const& point,\n-                                                Linestring const& linestring)\n-        {\n-            BOOST_ASSERT( boost::size(linestring) > 1 );\n-            return\n-                !geometry::equals(range::front(linestring),\n-                                  range::back(linestring))\n-                &&\n-                ( geometry::equals(point, range::front(linestring))\n-                  || geometry::equals(point, range::back(linestring)) );\n-        }\n+        BOOST_ASSERT(boost::size(linestring) > 1);\n+        return\n+            ! geometry::equals(range::front(linestring),\n+                               range::back(linestring))\n+            &&\n+            (geometry::equals(point, range::front(linestring))\n+             || geometry::equals(point, range::back(linestring)));\n+    }\n \n-        template <typename Point, typename Linestring>\n-        static inline bool is_closing_point_of(Point const& point,\n-                                               Linestring const& linestring)\n-        {\n-            BOOST_ASSERT( boost::size(linestring) > 1 );\n-            return\n-                geometry::equals(range::front(linestring),\n-                                 range::back(linestring))\n-                &&\n-                geometry::equals(range::front(linestring), point)\n-                ;\n-        }\n+    template <typename Turn, typename Linestring>\n+    static inline bool is_closing_point_of(Turn const& turn,\n+                                           Linestring const& linestring)\n+    {\n+        BOOST_ASSERT(boost::size(linestring) > 1);\n+        return\n+            turn.method == overlay::method_none\n+            &&\n+            check_segment_indices(turn, boost::size(linestring) - 2)\n+            &&\n+            geometry::equals(range::front(linestring), range::back(linestring))\n+            &&\n+            geometry::equals(range::front(linestring), turn.point)\n+            ;\n+    }","path":"include/boost/geometry/algorithms/detail/is_simple/linear.hpp","position":149,"original_position":149,"commit_id":"7d581f649bcfd35dff0a480155968eff490ab364","original_commit_id":"7d581f649bcfd35dff0a480155968eff490ab364","user":{"login":"awulkiew","id":1226951,"avatar_url":"https://avatars.githubusercontent.com/u/1226951?v=3","gravatar_id":"","url":"https://api.github.com/users/awulkiew","html_url":"https://github.com/awulkiew","followers_url":"https://api.github.com/users/awulkiew/followers","following_url":"https://api.github.com/users/awulkiew/following{/other_user}","gists_url":"https://api.github.com/users/awulkiew/gists{/gist_id}","starred_url":"https://api.github.com/users/awulkiew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awulkiew/subscriptions","organizations_url":"https://api.github.com/users/awulkiew/orgs","repos_url":"https://api.github.com/users/awulkiew/repos","events_url":"https://api.github.com/users/awulkiew/events{/privacy}","received_events_url":"https://api.github.com/users/awulkiew/received_events","type":"User","site_admin":false},"body":"Ratios not necessarily must be compatible with points. Remember the fix I made some time ago in cart_intersect?","created_at":"2015-01-29T22:48:58Z","updated_at":"2015-01-29T22:48:58Z","html_url":"https://github.com/boostorg/geometry/pull/204#discussion_r23810304","pull_request_url":"https://api.github.com/repos/boostorg/geometry/pulls/204","_links":{"self":{"href":"https://api.github.com/repos/boostorg/geometry/pulls/comments/23810304"},"html":{"href":"https://github.com/boostorg/geometry/pull/204#discussion_r23810304"},"pull_request":{"href":"https://api.github.com/repos/boostorg/geometry/pulls/204"}}},"pull_request":{"url":"https://api.github.com/repos/boostorg/geometry/pulls/204","id":28318481,"html_url":"https://github.com/boostorg/geometry/pull/204","diff_url":"https://github.com/boostorg/geometry/pull/204.diff","patch_url":"https://github.com/boostorg/geometry/pull/204.patch","issue_url":"https://api.github.com/repos/boostorg/geometry/issues/204","number":204,"state":"open","locked":false,"title":"Fix/is simple wrong turns detection","user":{"login":"mkaravel","id":6397014,"avatar_url":"https://avatars.githubusercontent.com/u/6397014?v=3","gravatar_id":"","url":"https://api.github.com/users/mkaravel","html_url":"https://github.com/mkaravel","followers_url":"https://api.github.com/users/mkaravel/followers","following_url":"https://api.github.com/users/mkaravel/following{/other_user}","gists_url":"https://api.github.com/users/mkaravel/gists{/gist_id}","starred_url":"https://api.github.com/users/mkaravel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkaravel/subscriptions","organizations_url":"https://api.github.com/users/mkaravel/orgs","repos_url":"https://api.github.com/users/mkaravel/repos","events_url":"https://api.github.com/users/mkaravel/events{/privacy}","received_events_url":"https://api.github.com/users/mkaravel/received_events","type":"User","site_admin":false},"body":"This PR essentially deals with two issues:\r\n* Optimizing the `bg::is_simple` computation for multilinestrings. In the older implementation self turns were computed for each linestring in the multilinestring individually, and then again if needed at the multilinestring level. In the new implementation the self turns of the linestrings are not computed, while the self turns of the entire multilinestring are used to determine/decide simplicity.\r\n* The change in the above item conveniently deals with and fixes a bug in `bg::intersects`: `bg::intersects` cannot identify an open linestring whose one endpoint is the same as an interior point as self-intersecting (for example: `LINESTRING(4 1,10 8,4 6,4 1,10 5,10 3)`). This immediately fixes a bug in `is_simple`, which, previously to this PR, erroneously considers linestrings, like the ones described just above, as simple.","created_at":"2015-01-29T21:56:06Z","updated_at":"2015-01-29T22:48:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a9e7e6b0c2abdfba8f1b59b14f2d0b58df7e7091","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/boostorg/geometry/pulls/204/commits","review_comments_url":"https://api.github.com/repos/boostorg/geometry/pulls/204/comments","review_comment_url":"https://api.github.com/repos/boostorg/geometry/pulls/comments/{number}","comments_url":"https://api.github.com/repos/boostorg/geometry/issues/204/comments","statuses_url":"https://api.github.com/repos/boostorg/geometry/statuses/7d581f649bcfd35dff0a480155968eff490ab364","head":{"label":"mkaravel:fix/is_simple_wrong_turns_detection","ref":"fix/is_simple_wrong_turns_detection","sha":"7d581f649bcfd35dff0a480155968eff490ab364","user":{"login":"mkaravel","id":6397014,"avatar_url":"https://avatars.githubusercontent.com/u/6397014?v=3","gravatar_id":"","url":"https://api.github.com/users/mkaravel","html_url":"https://github.com/mkaravel","followers_url":"https://api.github.com/users/mkaravel/followers","following_url":"https://api.github.com/users/mkaravel/following{/other_user}","gists_url":"https://api.github.com/users/mkaravel/gists{/gist_id}","starred_url":"https://api.github.com/users/mkaravel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkaravel/subscriptions","organizations_url":"https://api.github.com/users/mkaravel/orgs","repos_url":"https://api.github.com/users/mkaravel/repos","events_url":"https://api.github.com/users/mkaravel/events{/privacy}","received_events_url":"https://api.github.com/users/mkaravel/received_events","type":"User","site_admin":false},"repo":{"id":15894753,"name":"geometry","full_name":"mkaravel/geometry","owner":{"login":"mkaravel","id":6397014,"avatar_url":"https://avatars.githubusercontent.com/u/6397014?v=3","gravatar_id":"","url":"https://api.github.com/users/mkaravel","html_url":"https://github.com/mkaravel","followers_url":"https://api.github.com/users/mkaravel/followers","following_url":"https://api.github.com/users/mkaravel/following{/other_user}","gists_url":"https://api.github.com/users/mkaravel/gists{/gist_id}","starred_url":"https://api.github.com/users/mkaravel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkaravel/subscriptions","organizations_url":"https://api.github.com/users/mkaravel/orgs","repos_url":"https://api.github.com/users/mkaravel/repos","events_url":"https://api.github.com/users/mkaravel/events{/privacy}","received_events_url":"https://api.github.com/users/mkaravel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mkaravel/geometry","description":"Boost.org geometry module","fork":true,"url":"https://api.github.com/repos/mkaravel/geometry","forks_url":"https://api.github.com/repos/mkaravel/geometry/forks","keys_url":"https://api.github.com/repos/mkaravel/geometry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mkaravel/geometry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mkaravel/geometry/teams","hooks_url":"https://api.github.com/repos/mkaravel/geometry/hooks","issue_events_url":"https://api.github.com/repos/mkaravel/geometry/issues/events{/number}","events_url":"https://api.github.com/repos/mkaravel/geometry/events","assignees_url":"https://api.github.com/repos/mkaravel/geometry/assignees{/user}","branches_url":"https://api.github.com/repos/mkaravel/geometry/branches{/branch}","tags_url":"https://api.github.com/repos/mkaravel/geometry/tags","blobs_url":"https://api.github.com/repos/mkaravel/geometry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mkaravel/geometry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mkaravel/geometry/git/refs{/sha}","trees_url":"https://api.github.com/repos/mkaravel/geometry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mkaravel/geometry/statuses/{sha}","languages_url":"https://api.github.com/repos/mkaravel/geometry/languages","stargazers_url":"https://api.github.com/repos/mkaravel/geometry/stargazers","contributors_url":"https://api.github.com/repos/mkaravel/geometry/contributors","subscribers_url":"https://api.github.com/repos/mkaravel/geometry/subscribers","subscription_url":"https://api.github.com/repos/mkaravel/geometry/subscription","commits_url":"https://api.github.com/repos/mkaravel/geometry/commits{/sha}","git_commits_url":"https://api.github.com/repos/mkaravel/geometry/git/commits{/sha}","comments_url":"https://api.github.com/repos/mkaravel/geometry/comments{/number}","issue_comment_url":"https://api.github.com/repos/mkaravel/geometry/issues/comments/{number}","contents_url":"https://api.github.com/repos/mkaravel/geometry/contents/{+path}","compare_url":"https://api.github.com/repos/mkaravel/geometry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mkaravel/geometry/merges","archive_url":"https://api.github.com/repos/mkaravel/geometry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mkaravel/geometry/downloads","issues_url":"https://api.github.com/repos/mkaravel/geometry/issues{/number}","pulls_url":"https://api.github.com/repos/mkaravel/geometry/pulls{/number}","milestones_url":"https://api.github.com/repos/mkaravel/geometry/milestones{/number}","notifications_url":"https://api.github.com/repos/mkaravel/geometry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mkaravel/geometry/labels{/name}","releases_url":"https://api.github.com/repos/mkaravel/geometry/releases{/id}","created_at":"2014-01-14T07:16:18Z","updated_at":"2014-10-22T07:10:01Z","pushed_at":"2015-01-29T21:47:55Z","git_url":"git://github.com/mkaravel/geometry.git","ssh_url":"git@github.com:mkaravel/geometry.git","clone_url":"https://github.com/mkaravel/geometry.git","svn_url":"https://github.com/mkaravel/geometry","homepage":"http://boost.org/libs/geometry","size":35026,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"boostorg:develop","ref":"develop","sha":"75b95b1b9102d5324f2396db7d01367d00537f91","user":{"login":"boostorg","id":3170529,"avatar_url":"https://avatars.githubusercontent.com/u/3170529?v=3","gravatar_id":"","url":"https://api.github.com/users/boostorg","html_url":"https://github.com/boostorg","followers_url":"https://api.github.com/users/boostorg/followers","following_url":"https://api.github.com/users/boostorg/following{/other_user}","gists_url":"https://api.github.com/users/boostorg/gists{/gist_id}","starred_url":"https://api.github.com/users/boostorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boostorg/subscriptions","organizations_url":"https://api.github.com/users/boostorg/orgs","repos_url":"https://api.github.com/users/boostorg/repos","events_url":"https://api.github.com/users/boostorg/events{/privacy}","received_events_url":"https://api.github.com/users/boostorg/received_events","type":"Organization","site_admin":false},"repo":{"id":7590021,"name":"geometry","full_name":"boostorg/geometry","owner":{"login":"boostorg","id":3170529,"avatar_url":"https://avatars.githubusercontent.com/u/3170529?v=3","gravatar_id":"","url":"https://api.github.com/users/boostorg","html_url":"https://github.com/boostorg","followers_url":"https://api.github.com/users/boostorg/followers","following_url":"https://api.github.com/users/boostorg/following{/other_user}","gists_url":"https://api.github.com/users/boostorg/gists{/gist_id}","starred_url":"https://api.github.com/users/boostorg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boostorg/subscriptions","organizations_url":"https://api.github.com/users/boostorg/orgs","repos_url":"https://api.github.com/users/boostorg/repos","events_url":"https://api.github.com/users/boostorg/events{/privacy}","received_events_url":"https://api.github.com/users/boostorg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/boostorg/geometry","description":"Boost.org geometry module","fork":false,"url":"https://api.github.com/repos/boostorg/geometry","forks_url":"https://api.github.com/repos/boostorg/geometry/forks","keys_url":"https://api.github.com/repos/boostorg/geometry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/boostorg/geometry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/boostorg/geometry/teams","hooks_url":"https://api.github.com/repos/boostorg/geometry/hooks","issue_events_url":"https://api.github.com/repos/boostorg/geometry/issues/events{/number}","events_url":"https://api.github.com/repos/boostorg/geometry/events","assignees_url":"https://api.github.com/repos/boostorg/geometry/assignees{/user}","branches_url":"https://api.github.com/repos/boostorg/geometry/branches{/branch}","tags_url":"https://api.github.com/repos/boostorg/geometry/tags","blobs_url":"https://api.github.com/repos/boostorg/geometry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/boostorg/geometry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/boostorg/geometry/git/refs{/sha}","trees_url":"https://api.github.com/repos/boostorg/geometry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/boostorg/geometry/statuses/{sha}","languages_url":"https://api.github.com/repos/boostorg/geometry/languages","stargazers_url":"https://api.github.com/repos/boostorg/geometry/stargazers","contributors_url":"https://api.github.com/repos/boostorg/geometry/contributors","subscribers_url":"https://api.github.com/repos/boostorg/geometry/subscribers","subscription_url":"https://api.github.com/repos/boostorg/geometry/subscription","commits_url":"https://api.github.com/repos/boostorg/geometry/commits{/sha}","git_commits_url":"https://api.github.com/repos/boostorg/geometry/git/commits{/sha}","comments_url":"https://api.github.com/repos/boostorg/geometry/comments{/number}","issue_comment_url":"https://api.github.com/repos/boostorg/geometry/issues/comments/{number}","contents_url":"https://api.github.com/repos/boostorg/geometry/contents/{+path}","compare_url":"https://api.github.com/repos/boostorg/geometry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/boostorg/geometry/merges","archive_url":"https://api.github.com/repos/boostorg/geometry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/boostorg/geometry/downloads","issues_url":"https://api.github.com/repos/boostorg/geometry/issues{/number}","pulls_url":"https://api.github.com/repos/boostorg/geometry/pulls{/number}","milestones_url":"https://api.github.com/repos/boostorg/geometry/milestones{/number}","notifications_url":"https://api.github.com/repos/boostorg/geometry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/boostorg/geometry/labels{/name}","releases_url":"https://api.github.com/repos/boostorg/geometry/releases{/id}","created_at":"2013-01-13T15:59:29Z","updated_at":"2014-12-22T17:37:49Z","pushed_at":"2015-01-29T21:23:10Z","git_url":"git://github.com/boostorg/geometry.git","ssh_url":"git@github.com:boostorg/geometry.git","clone_url":"https://github.com/boostorg/geometry.git","svn_url":"https://github.com/boostorg/geometry","homepage":"http://boost.org/libs/geometry","size":45374,"stargazers_count":40,"watchers_count":40,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"open_issues_count":4,"forks":25,"open_issues":4,"watchers":40,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/boostorg/geometry/pulls/204"},"html":{"href":"https://github.com/boostorg/geometry/pull/204"},"issue":{"href":"https://api.github.com/repos/boostorg/geometry/issues/204"},"comments":{"href":"https://api.github.com/repos/boostorg/geometry/issues/204/comments"},"review_comments":{"href":"https://api.github.com/repos/boostorg/geometry/pulls/204/comments"},"review_comment":{"href":"https://api.github.com/repos/boostorg/geometry/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/boostorg/geometry/pulls/204/commits"},"statuses":{"href":"https://api.github.com/repos/boostorg/geometry/statuses/7d581f649bcfd35dff0a480155968eff490ab364"}}}}