Beispiel #1
0
        static GISAttribute ReadAttribute(DataTable table, int RowIndex)
        {
            GISAttribute attribute = new GISAttribute();
            DataRow      row       = table.Rows[RowIndex]; //该函数读取给定序号的rowindex的一行数据

            for (int i = 0; i < table.Columns.Count; i++)
            {
                attribute.AddValue(row[i]);
            }
            return(attribute);
        }
Beispiel #2
0
        public GISAttribute attributepart;                            //空间与属性信息

        public GISFeature(GISSpatial spatial, GISAttribute attribute) //构造函数传入空间与属性信息
        {
            spatialpart   = spatial;
            attributepart = attribute;
        }
Beispiel #3
0
        //读取一个gisfeature的所有属性值,放在gisfile中 此函数需要事先知道字段结构,根据字段类型选取适当的读取函数
        static GISAttribute ReadAttributes(List <GISField> fs, BinaryReader br)
        {
            GISAttribute attribute = new GISAttribute();

            for (int i = 0; i < fs.Count; i++)
            {
                Type type = fs[i].datatype;
                if (type.ToString() == "System.Boolean")
                {
                    attribute.AddValue(br.ReadBoolean());
                }
                else if (type.ToString() == "System.Boolean")
                {
                    attribute.AddValue(br.ReadBoolean());
                }
                else if (type.ToString() == "System.Byte")
                {
                    attribute.AddValue(br.ReadByte());
                }
                else if (type.ToString() == "System.Char")
                {
                    attribute.AddValue(br.ReadChar());
                }
                else if (type.ToString() == "System.Decimal")
                {
                    attribute.AddValue(br.ReadDecimal());
                }
                else if (type.ToString() == "System.Double")
                {
                    attribute.AddValue(br.ReadDouble());
                }
                else if (type.ToString() == "System.Single")
                {
                    attribute.AddValue(br.ReadSingle());
                }
                else if (type.ToString() == "System.Int32")
                {
                    attribute.AddValue(br.ReadInt32());
                }
                else if (type.ToString() == "System.Int64")
                {
                    attribute.AddValue(br.ReadInt64());
                }
                else if (type.ToString() == "System.UInt16")
                {
                    attribute.AddValue(br.ReadUInt16());
                }
                else if (type.ToString() == "System.UInt32")
                {
                    attribute.AddValue(br.ReadUInt32());
                }
                else if (type.ToString() == "System.UInt64")
                {
                    attribute.AddValue(br.ReadUInt64());
                }
                else if (type.ToString() == "System.Boolean")
                {
                    attribute.AddValue(br.ReadBoolean());
                }
                else if (type.ToString() == "System.String")
                {
                    attribute.AddValue(GISTools.ReadString(br));
                }
            }
            return(attribute);
        }
Beispiel #4
0
 static void WriteAttributes(GISAttribute attribute, BinaryWriter bw)
 {
     for (int i = 0; i < attribute.ValueCount(); i++)
     {
         Type type = attribute.GetValue(i).GetType();
         if (type.ToString() == "System.Boolean")
         {
             bw.Write((bool)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.Byte")
         {
             bw.Write((byte)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.Char")
         {
             bw.Write((char)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.Decimal")
         {
             bw.Write((decimal)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.Double")
         {
             bw.Write((double)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.Single")
         {
             bw.Write((float)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.Int32")
         {
             bw.Write((int)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.Int64")
         {
             bw.Write((long)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.UInt16")
         {
             bw.Write((ushort)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.UInt32")
         {
             bw.Write((uint)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.UInt64")
         {
             bw.Write((ulong)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.SByte")
         {
             bw.Write((sbyte)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.Int16")
         {
             bw.Write((short)attribute.GetValue(i));
         }
         else if (type.ToString() == "System.String")
         {
             GISTools.WriteString((string)attribute.GetValue(i), bw);
         }
     }
 }