The GIS Professional Group

ジオメトリの作成

ArcGIS Runtime でポリゴンを作成する場合、最後の頂点として最初の頂点を再び追加する必要はない。https://developers.arcgis.com/net/spatial-and-data-analysis/geometry/

            // ポイント追加によるポリゴン作成
            List<MapPoint> polygonPoints = new List<MapPoint>
            {
                // 星型
                new MapPoint(100,30, SpatialReferences.Wgs84),
                new MapPoint(150,30, SpatialReferences.Wgs84),
                new MapPoint(110,10, SpatialReferences.Wgs84),
                new MapPoint(125,50, SpatialReferences.Wgs84),
                new MapPoint(140,10, SpatialReferences.Wgs84)
            };

            // ポリゴンの作成
            Esri.ArcGISRuntime.Geometry.Polygon polygon = new Esri.ArcGISRuntime.Geometry.Polygon(polygonPoints);

            //Simplify
            Esri.ArcGISRuntime.Geometry.GeometryEngine.Simplify(polygon);
             // マルチパート ポリゴンの作成(頂点の追加)
            List<MapPoint> polygonPart1 = new List<MapPoint>
            {
                new MapPoint(100, 30, SpatialReferences.Wgs84),
                new MapPoint(120, 30, SpatialReferences.Wgs84),
                new MapPoint(110, 10, SpatialReferences.Wgs84)
            };

            List<MapPoint> polygonPart2 = new List<MapPoint>
            {
                new MapPoint(100, 20, SpatialReferences.Wgs84),
                new MapPoint(110, 40, SpatialReferences.Wgs84),
                new MapPoint(120, 20, SpatialReferences.Wgs84)
            };

            // 2つのパートを追加
            PolygonBuilder polygonBuilder = new PolygonBuilder(SpatialReferences.Wgs84);
            polygonBuilder.AddPart(polygonPart1);
            polygonBuilder.AddPart(polygonPart2);

            // ポリゴンの作成
            Esri.ArcGISRuntime.Geometry.Polygon polygon = polygonBuilder.ToGeometry();

            //Simplify
            Esri.ArcGISRuntime.Geometry.GeometryEngine.Simplify(polygon);
            // マルチパート ポリゴンの作成(セグメントから作成する方法)
                     
             // 頂点の作成
            MapPoint p1 = new MapPoint(100, 30, SpatialReferences.Wgs84);
            MapPoint p2 = new MapPoint(120, 30, SpatialReferences.Wgs84);
            MapPoint p3 = new MapPoint(110, 10, SpatialReferences.Wgs84);

            MapPoint p4 = new MapPoint(100, 20, SpatialReferences.Wgs84);
            MapPoint p5 = new MapPoint(110, 40, SpatialReferences.Wgs84);
            MapPoint p6 = new MapPoint(120, 20, SpatialReferences.Wgs84);


            //1つ目のパート
            List<Esri.ArcGISRuntime.Geometry.LineSegment> polygonPart1 = new List<Esri.ArcGISRuntime.Geometry.LineSegment>
            {
                new Esri.ArcGISRuntime.Geometry.LineSegment(p1,p2),
                new Esri.ArcGISRuntime.Geometry.LineSegment(p2,p3),
                new Esri.ArcGISRuntime.Geometry.LineSegment(p3,p1)
            };

            //2つ目のパート
            List<Esri.ArcGISRuntime.Geometry.LineSegment> polygonPart2 = new List<Esri.ArcGISRuntime.Geometry.LineSegment>
            {
                new Esri.ArcGISRuntime.Geometry.LineSegment(p4,p5),
                new Esri.ArcGISRuntime.Geometry.LineSegment(p5,p6),
                new Esri.ArcGISRuntime.Geometry.LineSegment(p6,p4)
            };

            // 2つのパートを追加
            PolygonBuilder polygonBuilder = new PolygonBuilder(SpatialReferences.Wgs84);
            polygonBuilder.AddPart(polygonPart1);
            polygonBuilder.AddPart(polygonPart2);

            // ポリゴンの作成
            Esri.ArcGISRuntime.Geometry.Polygon polygon = polygonBuilder.ToGeometry();

            //Simplify
            Esri.ArcGISRuntime.Geometry.GeometryEngine.Simplify(polygon);
            //ベジェ曲線セグメント
            //始点・コントロールポイント1、コントロールポイント2、終点、空間参照
            List<Esri.ArcGISRuntime.Geometry.CubicBezierSegment> polygonPart1 = new List<Esri.ArcGISRuntime.Geometry.CubicBezierSegment>
            {
                new CubicBezierSegment(p1, c1, c2, p2, SpatialReferences.Wgs84),
                new CubicBezierSegment(p1, c1, c2, p2, SpatialReferences.Wgs84),
                new CubicBezierSegment(p1, c1, c2, p2, SpatialReferences.Wgs84)
            };
  • B!