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);
        }
 private static void CreateGeographyFigures(IEnumerable <Esri.ArcGISRuntime.Geometry.ReadOnlyPart> parts,
                                            Microsoft.SqlServer.Types.SqlGeographyBuilder b, bool close)
 {
     foreach (var part in parts)
     {
         if (part.Count == 0)
         {
             continue;
         }
         var p = part.Points[0];
         b.BeginFigure(p.Y, p.X, p.HasZ ? (double?)p.Z : null, p.HasM ? (double?)p.M : null);
         for (int i = 1; i < part.Count; i++)
         {
             p = part.Points[i];
             b.AddLine(p.Y, p.X, p.HasZ ? (double?)p.Z : null, p.HasM ? (double?)p.M : null);
         }
         if (close)
         {
             p = part.Points[0];
             b.AddLine(p.X, p.Y, p.HasZ ? (double?)p.Z : null, p.HasM ? (double?)p.M : null);
         }
         b.EndFigure();
     }
 }