private static Microsoft.SqlServer.Types.SqlGeography CreateGeographyPolygon(Esri.ArcGISRuntime.Geometry.Polygon polygon, int cs)
        {
            var b = new Microsoft.SqlServer.Types.SqlGeographyBuilder();

            b.SetSrid(cs);

            var rings = Utilities.SplitMultiPolygon(polygon).ToList();

            if (rings.Count > 1)
            {
                b.BeginGeography(Microsoft.SqlServer.Types.OpenGisGeographyType.MultiPolygon);
            }

            foreach (var outerRing in rings)
            {
                b.BeginGeography(Microsoft.SqlServer.Types.OpenGisGeographyType.Polygon);
                CreateGeographyFigures(new Esri.ArcGISRuntime.Geometry.ReadOnlyPart[] { outerRing.Item1 }.Union(outerRing.Item2), b, true);
                b.EndGeography();
            }

            if (rings.Count > 1)
            {
                b.EndGeography();
            }
            return(b.ConstructedGeography);
        }
        private static Microsoft.SqlServer.Types.SqlGeography CreateGeographyLineString(Esri.ArcGISRuntime.Geometry.Polyline polyline, int cs)
        {
            var b = new Microsoft.SqlServer.Types.SqlGeographyBuilder();

            b.SetSrid(cs);
            b.BeginGeography(
                polyline.Parts.Count <= 1 ?
                Microsoft.SqlServer.Types.OpenGisGeographyType.LineString :
                Microsoft.SqlServer.Types.OpenGisGeographyType.MultiLineString);

            CreateGeographyFigures(polyline.Parts, b, false);

            b.EndGeography();
            return(b.ConstructedGeography);
        }
        private static Microsoft.SqlServer.Types.SqlGeography CreateGeographyPoint(Esri.ArcGISRuntime.Geometry.MapPoint p, int cs)
        {
            if (!p.HasZ && !p.HasM)
            {
                return(Microsoft.SqlServer.Types.SqlGeography.Point(p.Y, p.X, cs));
            }

            var b = new Microsoft.SqlServer.Types.SqlGeographyBuilder();

            b.SetSrid(cs);
            b.BeginGeography(Microsoft.SqlServer.Types.OpenGisGeographyType.Point);
            b.BeginFigure(p.Y, p.X, p.HasZ ? (double?)p.Z : null,
                          p.HasM ? (double?)p.M : null);
            b.EndFigure();
            b.EndGeography();
            return(b.ConstructedGeography);
        }
        private static Microsoft.SqlServer.Types.SqlGeography CreateGeographyMultipoint(Esri.ArcGISRuntime.Geometry.Multipoint multipoint, int cs)
        {
            var b = new Microsoft.SqlServer.Types.SqlGeographyBuilder();

            b.SetSrid(cs);
            b.BeginGeography(Microsoft.SqlServer.Types.OpenGisGeographyType.MultiPoint);

            foreach (var p in multipoint.Points)
            {
                b.BeginGeography(Microsoft.SqlServer.Types.OpenGisGeographyType.Point);
                b.BeginFigure(p.Y, p.X,
                              p.HasZ ? (double?)p.Z : null,
                              p.HasM ? (double?)p.M : null);
                b.EndFigure();
                b.EndGeography();
            }
            b.EndGeography();
            return(b.ConstructedGeography);
        }