Ejemplo n.º 1
0
        public static bool TestHelper(string wkt)
        {
            PrecisionModel pm = new PrecisionModel(1, 0, 0);
            GeometryFactory fact = new GeometryFactory(pm, 0);

            //read wkt
            Geometry a = new GeometryWKTReader(fact).Create(wkt);

            //write wkb
            FileStream fs = new FileStream("TestFile.wkb", FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);
            GeometryWKBWriter bWriter = new GeometryWKBWriter(bw, fact);
            bWriter.Write(a, WKBByteOrder.Ndr);
            bw.Close();
            fs.Close();

            //read wkb
            fs = new FileStream("TestFile.wkb", FileMode.Open);
            byte[] bytes = new byte[fs.Length];
            for(int i = 0; i < fs.Length; i++)
            {
                bytes[i] = (byte)fs.ReadByte();
            }
            GeometryWKBReader bReader = new GeometryWKBReader(fact);
            Geometry geom = bReader.Create(bytes);
            fs.Close();

            //write to wkt & compare with original text.
            bool results = ( Compare.WktStrings(wkt,a.toText()));
            return results;
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Creates a new geometry object from a BinaryReader that contains well-known binary.
		/// </summary>
		/// <param name="bReader">The BinaryReader that contains well-known binary.</param>
		/// <returns>A new geometry object.</returns>
		public Geometry CreateFromWKB(BinaryReader bReader)
		{
			if (bReader == null)
			{
				throw new ArgumentNullException("bReader");
			}
			GeometryWKBReader wkbReader = new GeometryWKBReader(this);
			return wkbReader.Create(bReader);
		}