Exemple #1
0
        private static Microsoft.SqlServer.Types.SqlGeometry CreateGeometryPolygon(Esri.ArcGISRuntime.Geometry.Polygon polygon, int cs)
        {
            var b = new Microsoft.SqlServer.Types.SqlGeometryBuilder();

            b.SetSrid(cs);

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

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

            foreach (var outerRing in rings)
            {
                b.BeginGeometry(Microsoft.SqlServer.Types.OpenGisGeometryType.Polygon);
                CreateGeometryFigures(new Esri.ArcGISRuntime.Geometry.ReadOnlyPart[] { outerRing.Item1 }.Union(outerRing.Item2), b, true);
                b.EndGeometry();
            }

            if (rings.Count > 1)
            {
                b.EndGeometry();
            }
            return(b.ConstructedGeometry);
        }
Exemple #2
0
        private static Microsoft.SqlServer.Types.SqlGeometry CreateGeometryMultipoint(Esri.ArcGISRuntime.Geometry.Multipoint multipoint, int cs)
        {
            var b = new Microsoft.SqlServer.Types.SqlGeometryBuilder();

            b.SetSrid(cs);
            b.BeginGeometry(Microsoft.SqlServer.Types.OpenGisGeometryType.MultiPoint);

            foreach (var p in multipoint.Points)
            {
                b.BeginGeometry(Microsoft.SqlServer.Types.OpenGisGeometryType.Point);
                b.BeginFigure(p.X, p.Y, p.HasZ ? (double?)p.Z : null,
                              p.HasM ? (double?)p.M : null);
                b.EndFigure();
                b.EndGeometry();
            }
            b.EndGeometry();
            return(b.ConstructedGeometry);
        }
Exemple #3
0
        private static Microsoft.SqlServer.Types.SqlGeometry CreateGeometryLineString(Esri.ArcGISRuntime.Geometry.Polyline polyline, int cs)
        {
            var b = new Microsoft.SqlServer.Types.SqlGeometryBuilder();

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

            CreateGeometryFigures(polyline.Parts, b, false);

            b.EndGeometry();
            return(b.ConstructedGeometry);
        }
Exemple #4
0
        private static Microsoft.SqlServer.Types.SqlGeometry CreateGeometryPoint(Esri.ArcGISRuntime.Geometry.MapPoint p, int cs)
        {
            if (!p.HasZ && !p.HasM)
            {
                return(Microsoft.SqlServer.Types.SqlGeometry.Point(p.X, p.Y, cs));
            }

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

            b.SetSrid(cs);
            b.BeginGeometry(Microsoft.SqlServer.Types.OpenGisGeometryType.Point);
            b.BeginFigure(p.X, p.Y, p.HasZ ? (double?)p.Z : null,
                          p.HasM ? (double?)p.M : null);
            b.EndFigure();
            b.EndGeometry();
            return(b.ConstructedGeometry);
        }