{"id":2360,"date":"2016-05-23T13:53:10","date_gmt":"2016-05-23T13:53:10","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=2360"},"modified":"2017-01-26T21:59:56","modified_gmt":"2017-01-26T12:59:56","slug":"convex-hull-%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%ea%b5%ac%ed%98%84","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=2360","title":{"rendered":"Convex-Hull \uc54c\uace0\ub9ac\uc998 \uad6c\ud604"},"content":{"rendered":"<p><P>Convex Hull\uc740 \ubcfc\ub85d\ud55c \uaecd\ub370\uae30\ub85c.. \ubb34\uc218\ud788 \ub9ce\uc740 \ud3ec\uc778\ud2b8\ub97c \uac10\uc2f8\ub294 \ubcfc\ub85d\ud55c \uc601\uc5ed\uc73c\ub85c \uc815\uc758\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc785\ub825 \ub370\uc774\ud130\uc778 \ud3ec\uc778\ud2b8\ub294 SHP \ud30c\uc77c\ub85c\ubd80\ud130 \uc81c\uacf5\ubc1b\uc544, \uc774\ub97c \ub4c0\ub77c\ub9f5\uc5d0\uc11c \uadf8 \uacb0\uacfc\ub97c \ud45c\uc2dc\ud558\ub3c4\ub85d \ud558\uc600\uc2b5\ub2c8\ub2e4. \uc544\ub798\ub294 \uadf8 \uacb0\uacfc \ud654\uba74\uc785\ub2c8\ub2e4.<\/P><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/1\/1257429672.png\" \/><\/p>\n<p>\ubb34\uc218\ud788 \ub9ce\uc740 \uc791\uc740 \ud3ec\uc778\ud2b8\ub97c \uac10\uc2f8\ub294 Convex Hull\uc774 \ubc18\ud22c\uba85\ud55c \ube68\uac04\uc0c9 \ud3f4\ub9ac\uace4\uc73c\ub85c \ud45c\uc2dc\ub418\uc5b4\uc838 \uc788\uc2b5\ub2c8\ub2e4. \uc774\ub7ec\ud55c Convex-Hull\uc5d0 \ub300\ud55c \uad6c\ud604\uc5d0 \ub300\ud574 C# \ud074\ub798\uc2a4\ub85c \uc815\uc758\ud588\uc73c\uba70 \uc544\ub798\uc640 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre>\r\nusing System;\r\nusing System.Collections.Generic;\r\n\r\nnamespace tstConvexHull\r\n{\r\n    public class ConvexHull\r\n    {\r\n        public class Point : IComparer<Point>\r\n        {\r\n            public double x;\r\n            public double y;\r\n\r\n            public Point()\r\n            {\r\n                x = 0.0;\r\n                y = 0.0;\r\n            }\r\n\r\n            public Point(double x, double y)\r\n            {\r\n                this.x = x;\r\n                this.y = y;\r\n            }\r\n\r\n            public int Compare(Point p1, Point p2)\r\n            {\r\n                if (p1.x == p2.x)\r\n                {\r\n                    return p1.y > p2.y ? 1 : p1.y < p2.y ? -1 : 0;\r\n                }\r\n                else\r\n                {\r\n                    return p1.x > p2.x ? 1 : p1.x < p2.x ? -1 : 0;\r\n                }\r\n            }\r\n        }\r\n\r\n        public static double Cross(Point O, Point A, Point B)\r\n        {\r\n            return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);\r\n        }\r\n\r\n        public static Point[] Get(Point[] P)\r\n        {\r\n            if (P.Length > 1)\r\n            {\r\n                int n = P.Length, k = 0;\r\n                Point[] H = new Point[2 * n];\r\n\r\n                Array.Sort(P, new Point());\r\n\r\n                for (int i = 0; i < n; ++i)\r\n                {\r\n                    while (k >= 2 && Cross(H[k - 2], H[k - 1], P[i]) <= 0)\r\n                        k--;\r\n                    H[k++] = P[i];\r\n                }\r\n\r\n                for (int i = n - 2, t = k + 1; i >= 0; i--)\r\n                {\r\n                    while (k >= t && Cross(H[k - 2], H[k - 1], P[i]) <= 0)\r\n                        k--;\r\n                    H[k++] = P[i];\r\n                }\r\n\r\n                if (k > 1)\r\n                {\r\n                    Point[] NewH = new Point[k - 1];\r\n                    Array.Copy(H, NewH, k - 1);\r\n                    H = NewH;\r\n                }\r\n                return H;\r\n            }\r\n            else if (P.Length <= 1)\r\n            {\r\n                return P;\r\n            }\r\n            else\r\n            {\r\n                return null;\r\n            }\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<p>\uc2e4\uc81c \uc704\uc758 Convex-Hull \ud074\ub798\uc2a4\uc5d0 \ub300\ud55c \uc0ac\uc6a9\uc740 \uc544\ub798 \ucf54\ub4dc\uc640 \uac19\uc740\ub370\uc694. DuraMap-Xr\uc5d0\uc11c SHP \ud30c\uc77c\ub85c\ubd80\ud130 \uc810 \ub370\uc774\ud130\ub97c \uc77d\uc5b4 \uc785\ub825 \ub370\uc774\ud130\ub97c \uad6c\uc131\ud558\uc5ec Convex-Hull\uc744 \uc2e4\ud589\ud558\uace0 \uadf8 \uacb0\uacfc\ub85c \ubc18\ud22c\uba85 \ube68\uac04\uc0c9 \ud3f4\ub9ac\uace4\uc744 \ucd94\uac00\ud558\ub294 \ucf54\ub4dc \ubaa8\ub450\ub97c \ub098\ud0c0\ub0b4\uace0 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre>\r\nXrMapLib.ShapeMapLayer lyr = axXr.Layers.GetLayerAsShapeMap(\"lyr\");\r\nXrMapLib.ShapeTable tbl = lyr.ShapeTable;\r\nint cntRows = tbl.RowCount;\r\n\r\nConvexHull.Point[] pts = new ConvexHull.Point[cntRows];\r\n\r\nfor(int i=0; i<cntRows; i++)\r\n{\r\n    XrMapLib.ShapeRow row = tbl.GetRow(i);\r\n    if (row.Load())\r\n    {\r\n        pts[i] = new ConvexHull.Point(row.Centroid.X, row.Centroid.Y);\r\n        row.Unload();\r\n    }\r\n}\r\n\r\npts = ConvexHull.Get(pts);\r\n\r\naxXr.Layers.AddGraphicLayer(\"gl\", \"\");\r\naxXr.WaitForAllConnections();\r\n\r\nXrMapLib.IPolygonGraphicElement gr = new XrMapLib.PolygonGraphicElement();\r\n\r\nXrMapLib.CoordListCollection clc = new XrMapLib.CoordListCollection();\r\nXrMapLib.CoordList cl = new XrMapLib.CoordList();\r\n\r\nfor(int i=0; i< pts.Length; i++)\r\n{\r\n    cl.Add(pts[i].x, pts[i].y);\r\n}\r\n\r\nclc.Add(cl);\r\n\r\ngr.SetPolygonList(clc);\r\n\r\ngr.FillSymbol.Color = RGB(0, 0, 255);\r\ngr.FillSymbol.Alpha = 110;\r\ngr.LineSymbol.Alpha = 0;\r\n\r\nXrMapLib.IGraphicLayer gl = axXr.Layers.GetLayerAsGraphic(\"gl\");\r\n\r\ngl.AddElement(3, gr as XrMapLib.GraphicElement);\r\n\r\naxXr.Update();\r\n<\/pre>\n<p><P>\ucf54\ub4dc\ub97c \uc0b4\uc9dd \uc124\uba85\ud558\uba74, 1~15\ubc88 \ucf54\ub4dc\ub294 SHP \ud30c\uc77c\ub85c\ubd80\ud130 \ud3ec\uc778\ud2b8 \ub370\uc774\ud130\ub97c \uc77d\uc5b4\uc640 Convex-Hull \uc54c\uace0\ub9ac\uc998\uc5d0 \uc785\ub825\ud560 \ub370\uc774\ud130\ub97c \uc900\ube44\ud558\ub294 \uac83\uc774\uace0, 17\ubc88 \ucf54\ub4dc\uac00 \ubc14\ub85c Convex-Hull\uc758 \uc2e4\ud589\uc774\uba70 19\ubc88 \ucf54\ub4dc\ubd80\ud130\ub294 Convex-Hull\uc758 \uacb0\uacfc\ub97c \uadf8\ub798\ud53d \uac1d\uccb4\ub85c \uac00\uc2dc\ud654\uc2dc\ucf1c\uc8fc\ub294 \ucf54\ub4dc\ub4e4\uc785\ub2c8\ub2e4.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Convex Hull\uc740 \ubcfc\ub85d\ud55c \uaecd\ub370\uae30\ub85c.. \ubb34\uc218\ud788 \ub9ce\uc740 \ud3ec\uc778\ud2b8\ub97c \uac10\uc2f8\ub294 \ubcfc\ub85d\ud55c \uc601\uc5ed\uc73c\ub85c \uc815\uc758\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc785\ub825 \ub370\uc774\ud130\uc778 \ud3ec\uc778\ud2b8\ub294 SHP \ud30c\uc77c\ub85c\ubd80\ud130 \uc81c\uacf5\ubc1b\uc544, \uc774\ub97c \ub4c0\ub77c\ub9f5\uc5d0\uc11c \uadf8 \uacb0\uacfc\ub97c \ud45c\uc2dc\ud558\ub3c4\ub85d \ud558\uc600\uc2b5\ub2c8\ub2e4. \uc544\ub798\ub294 \uadf8 \uacb0\uacfc \ud654\uba74\uc785\ub2c8\ub2e4. \ubb34\uc218\ud788 \ub9ce\uc740 \uc791\uc740 \ud3ec\uc778\ud2b8\ub97c \uac10\uc2f8\ub294 Convex Hull\uc774 \ubc18\ud22c\uba85\ud55c \ube68\uac04\uc0c9 \ud3f4\ub9ac\uace4\uc73c\ub85c \ud45c\uc2dc\ub418\uc5b4\uc838 \uc788\uc2b5\ub2c8\ub2e4. \uc774\ub7ec\ud55c Convex-Hull\uc5d0 \ub300\ud55c \uad6c\ud604\uc5d0 \ub300\ud574 C# \ud074\ub798\uc2a4\ub85c \uc815\uc758\ud588\uc73c\uba70 \uc544\ub798\uc640 \uac19\uc2b5\ub2c8\ub2e4. using System; using System.Collections.Generic; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=2360\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Convex-Hull \uc54c\uace0\ub9ac\uc998 \uad6c\ud604&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-2360","post","type-post","status-publish","format-standard","hentry","category-algorithms"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2360"}],"version-history":[{"count":1,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2360\/revisions"}],"predecessor-version":[{"id":2674,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2360\/revisions\/2674"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2360"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}