Пример #1
0
		public override IGeometry Read(Stream stream)
		{
			using (BinaryReader reader1 = new BinaryReader(stream))
			{
				int srid = -1;
				try
				{
					srid = reader1.ReadInt32();
				}
				catch
				{
				}
				if (srid == 0)
				{
					srid = -1;
				}

				ByteOrder byteOrder = (ByteOrder)stream.ReadByte();
				BinaryReader reader2;
				if (byteOrder == ByteOrder.BigEndian)
				{
					reader2 = new BEBinaryReader(stream);
				}
				else
				{
					reader2 = new BinaryReader(stream);
				}
				using (reader2)
				{
					IGeometry geometry = Read(reader2);
					geometry.SRID = srid;
					return geometry;
				}
			}
		}
 public override IGeometry Read(Stream stream)
 {
     BinaryReader reader = null;
     var byteOrder = (ByteOrder)stream.ReadByte();
     try
     {
         if (byteOrder == ByteOrder.BigEndian)
             reader = new BEBinaryReader(stream);
         else reader = new BinaryReader(stream);
         IGeometry geometry = Read(reader);
         int srid = -1;
         try
         {
             srid = reader.ReadInt32();
         }
         catch { }
         if (srid == 0)
             srid = -1;
         geometry.SRID = srid;
         return geometry;
     }
     finally
     {
         if (reader != null)
             reader.Close();
     }
 }
        public override IGeometry Read(Stream stream)
        {
            BinaryReader reader    = null;
            var          byteOrder = (ByteOrder)stream.ReadByte();

            try
            {
                if (byteOrder == ByteOrder.BigEndian)
                {
                    reader = new BEBinaryReader(stream);
                }
                else
                {
                    reader = new BinaryReader(stream);
                }
                IGeometry geometry = Read(reader);
                int       srid     = -1;
                try
                {
                    srid = reader.ReadInt32();
                }
                catch { }
                if (srid == 0)
                {
                    srid = -1;
                }
                geometry.SRID = srid;
                return(geometry);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Reads a <see cref="IGeometry"/> in binary WKB format from an <see cref="Stream"/>.
        /// </summary>
        /// <param name="stream">The stream to read from</param>
        /// <returns>The geometry read</returns>
        /// <exception cref="GeoAPI.IO.ParseException"> if the WKB data is ill-formed.</exception>
        public virtual IGeometry Read(Stream stream)
        {
            ByteOrder byteOrder = (ByteOrder)stream.ReadByte();
            BinaryReader reader;
            if (byteOrder == ByteOrder.LittleEndian)
            {
                reader = new BinaryReader(stream);
            }
            else if (byteOrder == ByteOrder.BigEndian)
            {
                reader = new BEBinaryReader(stream);
            }
            else if (_isStrict)
            {
                string s = String.Format("Unknown geometry byte order (not LittleEndian or BigEndian): {0}", byteOrder);
                throw new GeoAPI.IO.ParseException(s);
            }
            else
            {
                // if not strict and not LittleEndian or BigEndian, then we just use the default reader at the
                // start of the geometry (if a multi-geometry).  This  allows WBKReader to work
                // with Spatialite native BLOB WKB, as well as other WKB variants that might just
                // specify endian-ness at the start of the multigeometry.
                reader = new BinaryReader(stream);
            }

            using (reader)
            {
                IGeometry res = Read(reader);
                return res;
            }
        }