• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WkbByteOrder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WkbByteOrder的典型用法代码示例。如果您正苦于以下问题:C# WkbByteOrder类的具体用法?C# WkbByteOrder怎么用?C# WkbByteOrder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WkbByteOrder类属于命名空间,在下文中一共展示了WkbByteOrder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Write

		/// <summary>
		/// Writes a geometry to a byte array using the specified encoding.
		/// </summary>
		/// <param name="g">The geometry to write</param>
		/// <param name="wkbByteOrder">Byte order</param>
		/// <returns>WKB representation of the geometry</returns>
		public static byte[] Write(IGeometry geometry, WkbByteOrder wkbByteOrder)
		{
			byte[] result = null;
			switch (wkbByteOrder)
			{
				case WkbByteOrder.Ndr:
					result = new WKBWriter(ByteOrder.LittleEndian).Write(geometry);
					break;
				case WkbByteOrder.Xdr:
					result = new WKBWriter(ByteOrder.BigEndian).Write(geometry);
					break;
			}
			return result;
			
//			MemoryStream ms = new MemoryStream();
//			BinaryWriter bw = new BinaryWriter(ms);
//
//			//Write the byteorder format.
//			bw.Write((byte)wkbByteOrder);
//
//			//Write the type of this geometry
//			WriteType(g, bw, wkbByteOrder);
//
//			//Write the geometry
//			WriteGeometry(g, bw, wkbByteOrder);
//
//			return ms.ToArray();
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:GeometryToWKB.cs


示例2: Write

        /// <summary>
        /// Writes a geometry to a byte array using the specified encoding.
        /// </summary>
        /// <param name="g">The geometry to write</param>
        /// <param name="wkbByteOrder">Byte order</param>
        /// <returns>WKB representation of the geometry</returns>
        public static byte[] Write(IGeometry g, WkbByteOrder wkbByteOrder)
        {
            ByteOrder order;
            switch (wkbByteOrder)
            {
                case WkbByteOrder.Xdr:
                    order = ByteOrder.BigEndian;
                    break;
                case WkbByteOrder.Ndr:
                    order = ByteOrder.LittleEndian;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("wkbByteOrder");
            }

            WKBWriter wkb = new WKBWriter(order);
            return wkb.Write(g);

            /*
            MemoryStream ms = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(ms);

            //Write the byteorder format.
            bw.Write((byte) wkbByteOrder);

            //Write the type of this geometry
            WriteType(g, bw, wkbByteOrder);

            //Write the geometry
            WriteGeometry(g, bw, wkbByteOrder);

            return ms.ToArray();
            */
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:40,代码来源:GeometryToWKB.cs


示例3: ToBinaryAndBack

 private Geometry ToBinaryAndBack(Geometry gIn, WkbByteOrder byteOrder)
 {
     MemoryStream stream = new MemoryStream();
     BinaryWriter writer = new BinaryWriter(stream);
     writer.Write(GeometryToWKB.Write(gIn, byteOrder));
     BinaryReader reader = new BinaryReader(stream);
     stream.Position = 0;
     Geometry gOut = GeometryFromWKB.Parse(reader);
     return gOut;
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:10,代码来源:WKBTests.cs


示例4: WriteDouble

 /// <summary>
 /// Writes a double to the stream
 /// </summary>
 /// <param name="value">Value to write</param>
 /// <param name="writer">Binary Writer</param>
 /// <param name="byteOrder">byteorder</param>
 private static void WriteDouble(double value, BinaryWriter writer, WkbByteOrder byteOrder)
 {
     if (byteOrder == WkbByteOrder.Xdr)
     {
         byte[] bytes = BitConverter.GetBytes(value);
         Array.Reverse(bytes);
         writer.Write(BitConverter.ToDouble(bytes, 0));
     }
     else
         writer.Write(value);
 }
开发者ID:BrunoCaimar,项目名称:Drikka,代码行数:17,代码来源:WkbWriter.cs


示例5: ReadDouble

        /// <summary>
        /// Read double value from reader
        /// </summary>
        /// <param name="reader">Stream Reader</param>
        /// <param name="byteOrder">Byte order</param>
        /// <returns>Double value</returns>
        private static double ReadDouble(BinaryReader reader, WkbByteOrder byteOrder)
        {
            if (byteOrder == WkbByteOrder.Xdr)
            {
                byte[] bytes = BitConverter.GetBytes(reader.ReadDouble());
                Array.Reverse(bytes);
                return BitConverter.ToDouble(bytes, 0);
            }

            if (byteOrder == WkbByteOrder.Ndr)
            {
                return reader.ReadDouble();
            }

            throw new ArgumentException("Byte order not recognized");
        }
开发者ID:BrunoCaimar,项目名称:Drikka,代码行数:22,代码来源:WkbReader.cs


示例6: Write

        //private const byte WKBByteOrder = 0;
        /// <summary>
        ///     Writes a geometry to a byte array using the specified encoding.
        /// </summary>
        /// <param name="g">The geometry to write</param>
        /// <param name="wkbByteOrder">Byte order</param>
        /// <returns>WKB representation of the geometry</returns>
        public static byte[] Write(Geometry g, WkbByteOrder wkbByteOrder = WkbByteOrder.Ndr)
        {
            var ms = new MemoryStream();
            var bw = new BinaryWriter(ms);

            //Write the byteorder format.
            bw.Write((byte) wkbByteOrder);

            //Write the type of this geometry
            WriteType(g, bw, wkbByteOrder);

            //Write the geometry
            WriteGeometry(g, bw, wkbByteOrder);

            return ms.ToArray();
        }
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:23,代码来源:GeometryToWKB.cs


示例7: WriteGeometry

 /// <summary>
 /// Write the geometry
 /// </summary>
 /// <param name="geometry">Geometry</param>
 /// <param name="writer">BinaryWriter</param>
 /// <param name="byteOrder">Byte order</param>
 private static void WriteGeometry(IGeometry geometry, BinaryWriter writer, WkbByteOrder byteOrder)
 {
     if (geometry is IMapPoint)
     {
         WriteUInt32((uint) WkbGeometryTypes.WkbPoint, writer, byteOrder);
         WriteMapPoint(geometry as IMapPoint, writer, byteOrder);
     }
     else if(geometry is ILinearRing)
     {
         WriteUInt32((uint)WkbGeometryTypes.WkbLineString, writer, byteOrder);
         WriteLineString(geometry as ILineString, writer, byteOrder);
     }
     else if(geometry is IPolygon)
     {
         WriteUInt32((uint)WkbGeometryTypes.WkbPolygon, writer, byteOrder);
         WritePolygon(geometry as IPolygon, writer, byteOrder);
     }
     else
     {
         throw new ArgumentOutOfRangeException("geometry", "Geometry not supported.");
     }
 }
开发者ID:BrunoCaimar,项目名称:Drikka,代码行数:28,代码来源:WkbWriter.cs


示例8: CreateWKBMultiPolygon

        private static GraphicsPath CreateWKBMultiPolygon(BinaryReader reader, WkbByteOrder byteOrder, Func<System.Windows.Point, System.Windows.Point> geoToPixel)
        {
            GraphicsPath gp = new GraphicsPath();

            // Get the number of Polygons.
            int numPolygons = (int)ReadUInt32(reader, byteOrder);

            // Loop on the number of polygons.
            for (int i = 0; i < numPolygons; i++)
            {
                // read polygon header
                reader.ReadByte();
                ReadUInt32(reader, byteOrder);

                // TODO: Validate type

                // Create the next polygon and add it to the array.
                gp.AddPath(CreateWKBPolygon(reader, byteOrder, geoToPixel), false);
            }

            //Create and return the MultiPolygon.
            return gp;
        }
开发者ID:Cyarix,项目名称:SpatialTutorial,代码行数:23,代码来源:WkbTools.cs


示例9: WriteGeometry

 /// <summary>
 /// Writes the geometry to the binary writer.
 /// </summary>
 /// <param name="geometry">The geometry to be written.</param>
 /// <param name="bWriter"></param>
 /// <param name="byteorder">Byte order</param>
 private static void WriteGeometry(IGeometry geometry, BinaryWriter bWriter, WkbByteOrder byteorder)
 {
     switch (geometry.OgcGeometryType)
     {
             //Write the point.
         case OgcGeometryType.Point:
             WritePoint((IPoint) geometry, bWriter, byteorder);
             break;
         case OgcGeometryType.LineString:
             var ls = (ILineString) geometry;
             WriteLineString(ls, bWriter, byteorder);
             break;
         case OgcGeometryType.Polygon:
             WritePolygon((IPolygon) geometry, bWriter, byteorder);
             break;
             //Write the Multipoint.
         case OgcGeometryType.MultiPoint:
             WriteMultiPoint((IMultiPoint) geometry, bWriter, byteorder);
             break;
             //Write the Multilinestring.
         case OgcGeometryType.MultiLineString:
             WriteMultiLineString((IMultiLineString) geometry, bWriter, byteorder);
             break;
             //Write the Multipolygon.
         case OgcGeometryType.MultiPolygon:
             WriteMultiPolygon((IMultiPolygon) geometry, bWriter, byteorder);
             break;
             //Write the Geometrycollection.
         case OgcGeometryType.GeometryCollection:
             WriteGeometryCollection((IGeometryCollection) geometry, bWriter, byteorder);
             break;
             //If the type is not of the above 7 throw an exception.
         default:
             throw new ArgumentException("Invalid Geometry Type");
     }
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:42,代码来源:GeometryToWKB.cs


示例10: WriteGeometryCollection

        /// <summary>
        /// Writes a geometrycollection.
        /// </summary>
        /// <param name="gc">The geometrycollection to be written.</param>
        /// <param name="bWriter">Stream to write to.</param>
        /// <param name="byteorder">Byte order</param>
        private static void WriteGeometryCollection(IGeometryCollection gc, BinaryWriter bWriter, WkbByteOrder byteorder)
        {
            //Get the number of geometries in this geometrycollection.
            var num = gc.NumGeometries;

            //Write the number of geometries.
            WriteUInt32((uint) num, bWriter, byteorder);

            //Loop on the number of geometries.
            //NOTE: by contract, the first item returned 
            //      from GetEnumerator (i.e. using foreach) is the IGeometryCollection itself!
            for (var i = 0; i < num; i++)
            {
                IGeometry geom = gc.GetGeometryN(i);
                //Write the byte-order format of the following geometry.
                bWriter.Write((byte) byteorder);
                //Write the type of each geometry.                
                WriteType(geom, bWriter, byteorder);
                //Write each geometry.
                WriteGeometry(geom, bWriter, byteorder);
            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:28,代码来源:GeometryToWKB.cs


示例11: WriteMultiPolygon

        /// <summary>
        /// Writes a multipolygon.
        /// </summary>
        /// <param name="mp">The mulitpolygon to be written.</param>
        /// <param name="bWriter">Stream to write to.</param>
        /// <param name="byteorder">Byte order</param>
        private static void WriteMultiPolygon(IMultiPolygon mp, BinaryWriter bWriter, WkbByteOrder byteorder)
        {
            //Write the number of polygons.
            int num = mp.NumGeometries;
            WriteUInt32((uint) num, bWriter, byteorder);

            //Loop on the number of polygons.
            //NOTE: by contract, the first item returned 
            //      from GetEnumerator (i.e. using foreach) is the IMultiPolygon itself!
            for (int i = 0; i < num; i++)
            {
                IPolygon poly = (IPolygon) mp.GetGeometryN(i);
                //Write polygon header
                bWriter.Write((byte) byteorder);
                WriteUInt32((uint) WKBGeometryType.wkbPolygon, bWriter, byteorder);
                //Write each polygon.
                WritePolygon(poly, bWriter, byteorder);
            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:25,代码来源:GeometryToWKB.cs


示例12: WriteMultiLineString

        /// <summary>
        /// Writes a multilinestring.
        /// </summary>
        /// <param name="mls">The multilinestring to be written.</param>
        /// <param name="bWriter">Stream to write to.</param>
        /// <param name="byteorder">Byte order</param>
        private static void WriteMultiLineString(IMultiLineString mls, BinaryWriter bWriter, WkbByteOrder byteorder)
        {
            //Write the number of linestrings.
            int num = mls.NumGeometries;
            WriteUInt32((uint) num, bWriter, byteorder);

            //Loop on the number of linestrings. 
            //NOTE: by contract, the first item returned 
            //      from GetEnumerator (i.e. using foreach) is the IMultiLineString itself!
            for (int i = 0; i < num; i++)
            {
                ILineString ls = (ILineString) mls.GetGeometryN(i);
                //Write LineString Header
                bWriter.Write((byte)byteorder);
                WriteUInt32((uint)WKBGeometryType.wkbLineString, bWriter, byteorder);
                //Write each linestring.
                WriteLineString(ls, bWriter, byteorder);
            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:25,代码来源:GeometryToWKB.cs


示例13: CreateWKBGeometryCollection

        private static Geometry CreateWKBGeometryCollection(BinaryReader reader, WkbByteOrder byteOrder)
        {
            // The next byte in the array tells the number of geometries in this collection.
            int numGeometries = (int) ReadUInt32(reader, byteOrder);

            // Create a new array for the geometries.
            GeometryCollection geometries = new GeometryCollection();

            // Loop on the number of geometries.
            for (int i = 0; i < numGeometries; i++)
            {
                // Call the main create function with the next geometry.
                geometries.Collection.Add(Parse(reader));
            }

            // Create and return the next geometry.
            return geometries;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:18,代码来源:GeometryFromWKB.cs


示例14: CreateWKBMultiLineString

        private static MultiLineString CreateWKBMultiLineString(BinaryReader reader, WkbByteOrder byteOrder)
        {
            // Get the number of linestrings in this multilinestring.
            int numLineStrings = (int) ReadUInt32(reader, byteOrder);

            // Create a new array for the linestrings .
            MultiLineString mline = new MultiLineString();

            // Loop on the number of linestrings.
            for (int i = 0; i < numLineStrings; i++)
            {
                // Read linestring header
                reader.ReadByte();
                ReadUInt32(reader, byteOrder);

                // Create the next linestring and add it to the array.
                mline.LineStrings.Add(CreateWKBLineString(reader, byteOrder));
            }

            // Create and return the MultiLineString.
            return mline;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:22,代码来源:GeometryFromWKB.cs


示例15: CreateWKBPolygon

        private static Polygon CreateWKBPolygon(BinaryReader reader, WkbByteOrder byteOrder)
        {
            // Get the Number of rings in this Polygon.
            int numRings = (int) ReadUInt32(reader, byteOrder);

            Debug.Assert(numRings >= 1, "Number of rings in polygon must be 1 or more.");

            Polygon shell = new Polygon(CreateWKBLinearRing(reader, byteOrder));

            // Create a new array of linearrings for the interior rings.
            for (int i = 0; i < (numRings - 1); i++)
                shell.InteriorRings.Add(CreateWKBLinearRing(reader, byteOrder));

            // Create and return the Poylgon.
            return shell;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:16,代码来源:GeometryFromWKB.cs


示例16: CreateWKBLineString

        private static LineString CreateWKBLineString(BinaryReader reader, WkbByteOrder byteOrder)
        {
            LineString l = new LineString();
            //l.Vertices.AddRange(ReadCoordinates(reader, byteOrder));
            Point[] arrPoint = ReadCoordinates(reader, byteOrder);
            for (int i = 0; i < arrPoint.Length; i++)
                l.Vertices.Add(arrPoint[i]);

            return l;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:10,代码来源:GeometryFromWKB.cs


示例17: CreateWKBPoint

 private static Point CreateWKBPoint(BinaryReader reader, WkbByteOrder byteOrder)
 {
     // Create and return the point.
     return new Point(ReadDouble(reader, byteOrder), ReadDouble(reader, byteOrder));
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:5,代码来源:GeometryFromWKB.cs


示例18: WriteType

 /// <summary>
 /// Writes the type number for this geometry.
 /// </summary>
 /// <param name="geometry">The geometry to determine the type of.</param>
 /// <param name="bWriter">Binary Writer</param>
 /// <param name="byteorder">Byte order</param>
 private static void WriteType(IGeometry geometry, BinaryWriter bWriter, WkbByteOrder byteorder)
 {
     //Determine the type of the geometry.
     switch (geometry.OgcGeometryType)
     {
             //Points are type 1.
         case OgcGeometryType.Point:
             WriteUInt32((uint) WKBGeometryType.wkbPoint, bWriter, byteorder);
             break;
             //Linestrings are type 2.
         case OgcGeometryType.LineString:
             WriteUInt32((uint) WKBGeometryType.wkbLineString, bWriter, byteorder);
             break;
             //Polygons are type 3.
         case OgcGeometryType.Polygon:
             WriteUInt32((uint) WKBGeometryType.wkbPolygon, bWriter, byteorder);
             break;
             //Mulitpoints are type 4.
         case OgcGeometryType.MultiPoint:
             WriteUInt32((uint) WKBGeometryType.wkbMultiPoint, bWriter, byteorder);
             break;
             //Multilinestrings are type 5.
         case OgcGeometryType.MultiLineString:
             WriteUInt32((uint) WKBGeometryType.wkbMultiLineString, bWriter, byteorder);
             break;
             //Multipolygons are type 6.
         case OgcGeometryType.MultiPolygon:
             WriteUInt32((uint) WKBGeometryType.wkbMultiPolygon, bWriter, byteorder);
             break;
             //Geometrycollections are type 7.
         case OgcGeometryType.GeometryCollection:
             WriteUInt32((uint) WKBGeometryType.wkbGeometryCollection, bWriter, byteorder);
             break;
             //If the type is not of the above 7 throw an exception.
         default:
             throw new ArgumentException("Invalid Geometry Type");
     }
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:44,代码来源:GeometryToWKB.cs


示例19: CreateWKBLinearRing

        private static LinearRing CreateWKBLinearRing(BinaryReader reader, WkbByteOrder byteOrder)
        {
            //l.Vertices.AddRange(ReadCoordinates(reader, byteOrder));
            Point[] arrPoint = ReadCoordinates(reader, byteOrder);
            Coordinate clasurePoint = null;

            //if polygon isn't closed, add the first point to the end (this shouldn't occur for correct WKB data)
            if (arrPoint[0].X != arrPoint[arrPoint.Length - 1].X ||
                arrPoint[0].Y != arrPoint[arrPoint.Length - 1].Y)
            {
                clasurePoint = new Coordinate(arrPoint[0].X, arrPoint[0].Y);
            }

            Coordinate[] arrCoordinate;

            if (clasurePoint == null)
            {
                arrCoordinate = new Coordinate[arrPoint.Length];
            }
            else
            {
                arrCoordinate = new Coordinate[arrPoint.Length+1];
            }

            for (int i = 0; i < arrPoint.Length; i++)
                arrCoordinate[i] = new Coordinate(arrPoint[i].X, arrPoint[i].Y);

            if (clasurePoint != null)
                arrCoordinate[arrCoordinate.Length - 1] = clasurePoint;

            LinearRing l = new LinearRing(arrCoordinate);

            return l;
        }
开发者ID:sridhar19091986,项目名称:sharpmapx,代码行数:34,代码来源:GeometryFromWKB.cs


示例20: CreateWKBLineString

        private static LineString CreateWKBLineString(BinaryReader reader, WkbByteOrder byteOrder)
        {
            //l.Vertices.AddRange(ReadCoordinates(reader, byteOrder));
            Point[] arrPoint = ReadCoordinates(reader, byteOrder);
            var arrCoordinate = new Coordinate[arrPoint.Length];

            for (int i = 0; i < arrPoint.Length; i++)
                arrCoordinate[i] = new Coordinate(arrPoint[i].X, arrPoint[i].Y);

            LineString l = new LineString(arrCoordinate);
            return l;
        }
开发者ID:sridhar19091986,项目名称:sharpmapx,代码行数:12,代码来源:GeometryFromWKB.cs



注:本文中的WkbByteOrder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WndEventArgs类代码示例发布时间:2022-05-24
下一篇:
C# WizardRunKind类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap