示例#1
0
        public static System.Data.Entity.Spatial.DbGeometry Reverse(
            this System.Data.Entity.Spatial.DbGeometry linestring)
        {
            var fromWkb = SqlGeometry.STGeomFromWKB(new SqlBytes(linestring.AsBinary()), 0);

            // Create a new Geometry Builder
            var gb = new SqlGeometryBuilder();

            // Set the Spatial Reference ID equal to the supplied linestring
            gb.SetSrid((int)(fromWkb.STSrid));
            // Start the linestring
            gb.BeginGeometry(OpenGisGeometryType.LineString);
            // Add the first point using BeginFigure()
            gb.BeginFigure((double)fromWkb.STEndPoint().STX, (double)fromWkb.STEndPoint().STY);
            // Loop through remaining points in reverse order
            for (var x = (int)fromWkb.STNumPoints() - 1; x > 0; --x)
            {
                gb.AddLine((double)fromWkb.STPointN(x).STX, (double)fromWkb.STPointN(x).STY);
            }
            // End the figure
            gb.EndFigure();
            // End the geometry
            gb.EndGeometry();
            // Return that as a SqlGeometry instance
            return(System.Data.Entity.Spatial.DbGeometry.FromBinary(gb.ConstructedGeometry.STAsBinary().Buffer));
        }
        public static System.Data.Entity.Spatial.DbGeometry Buffer(System.Data.Entity.Spatial.DbGeometry location,
                                                                   double distance)
        {
            var sqlGeometry = SqlGeometry.STGeomFromWKB(new SqlBytes(location.AsBinary()), 0).STBuffer(distance);

            return(System.Data.Entity.Spatial.DbGeometry.FromBinary(sqlGeometry.STAsBinary().Buffer));
        }
示例#3
0
 public static SqlGeometry ToSqlGeometry(this System.Data.Entity.Spatial.DbGeometry dbGeometry)
 {
     return(SqlGeometry.STGeomFromWKB(new SqlBytes(dbGeometry.AsBinary()), 0));
 }