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); }
//读取一个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); }