ArcGISRuntime.Samples.Desktop.Pages.SnapToGeometryPage.ExecuteSnap C# (CSharp) Method

ExecuteSnap() private static method

スナップ処理を実行
private static ExecuteSnap ( MapPoint input, Esri snapToGeometry, SnapType type, double vertexSnapTolerance ) : SnapResult
input MapPoint
snapToGeometry Esri
type SnapType
vertexSnapTolerance double
return SnapResult
        private static SnapResult ExecuteSnap(MapPoint input, Esri.ArcGISRuntime.Geometry.Geometry snapToGeometry, SnapType type, double vertexSnapTolerance)
        {
            //スナップ対象として頂点を使用する場合
            if ((type & SnapType.Vertex) == SnapType.Vertex)
            {
                //もっとも近いスナップ対象のジオメトリの頂点(スナップ対象の頂点)を取得
                var vertexResult = GeometryEngine.NearestVertex(snapToGeometry, input);

                //スナップ対象の頂点までの距離がスナップ許容値内の場合は値を返す
                if (vertexResult.Distance <= vertexSnapTolerance)
                {
                    return new SnapResult()
                    {
                        Result = vertexResult,
                        Type = SnapType.Vertex
                    };
                }
            }

            //スナップ対象として線分を使用する場合
            if ((type & SnapType.Segment) == SnapType.Segment)
            {
                //内部交差を避けるためポリゴンの外周をポリラインに変換
                var outline = snapToGeometry;
                if (outline is Polygon)
                {
                    outline = new Polyline(((Polygon)outline).Parts, outline.SpatialReference);
                }

                //もっとも近いスナップ対象の線分上の位置を取得
                var segmentResult = GeometryEngine.NearestCoordinate(outline, input);

                //スナップ対象の線分上の位置までの距離がスナップ許容値内の場合は値を返す
                if (segmentResult.Distance <= vertexSnapTolerance)
                {
                    return new SnapResult()
                    {
                        Result = segmentResult,
                        Type = SnapType.Segment
                    };
                }

            }

            //検索結果までの距離がスナップ許容値外の場合は結果を返さない
            return null;
        }