public static String GetFeaturePropertyValue(MgReader featureReader, String propName) { String value = string.Empty; int propertyType = featureReader.GetPropertyType(propName); switch (propertyType) { case MgPropertyType.Boolean: value = featureReader.GetBoolean(propName).ToString(); break; case MgPropertyType.Byte: value = featureReader.GetByte(propName).ToString(); break; case MgPropertyType.Single: value = featureReader.GetSingle(propName).ToString(); break; case MgPropertyType.Double: value = featureReader.GetDouble(propName).ToString(); break; case MgPropertyType.Int16: value = featureReader.GetInt16(propName).ToString(); break; case MgPropertyType.Int32: value = featureReader.GetInt32(propName).ToString(); break; case MgPropertyType.Int64: value = featureReader.GetInt64(propName).ToString(); break; case MgPropertyType.String: value = featureReader.GetString(propName); break; case MgPropertyType.DateTime: case MgPropertyType.Null: case MgPropertyType.Blob: case MgPropertyType.Clob: case MgPropertyType.Feature: case MgPropertyType.Geometry: case MgPropertyType.Raster: value = Strings.StrUnsupportedDataType; //NOXLATE break; } return(value); }
public static String GetFeaturePropertyValue(MgReader featureReader, String propName) { String value = ""; int propertyType = featureReader.GetPropertyType(propName); switch (propertyType) { case MgPropertyType.Boolean: value = featureReader.GetBoolean(propName).ToString(); break; case MgPropertyType.Byte: value = featureReader.GetByte(propName).ToString(); break; case MgPropertyType.Single: value = featureReader.GetSingle(propName).ToString(); break; case MgPropertyType.Double: value = featureReader.GetDouble(propName).ToString(); break; case MgPropertyType.Int16: value = featureReader.GetInt16(propName).ToString(); break; case MgPropertyType.Int32: value = featureReader.GetInt32(propName).ToString(); break; case MgPropertyType.Int64: value = featureReader.GetInt64(propName).ToString(); break; case MgPropertyType.String: value = featureReader.GetString(propName); break; case MgPropertyType.DateTime: case MgPropertyType.Null: case MgPropertyType.Blob: case MgPropertyType.Clob: case MgPropertyType.Feature: case MgPropertyType.Geometry: case MgPropertyType.Raster: value = "[unsupported data type]"; break; } return value; }
public LocalNativeRecord(MgReader reader, FixedWKTReader mgReader, MgAgfReaderWriter agfRw, MgWktReaderWriter wktRw) { for (int i = 0; i < reader.GetPropertyCount(); i++) { string name = reader.GetPropertyName(i); _ordinalMap[i] = name; var pt = (PropertyValueType)reader.GetPropertyType(name); switch (pt) { case PropertyValueType.Blob: _values[name] = new BlobValue(); break; case PropertyValueType.Boolean: _values[name] = new BooleanValue(); break; case PropertyValueType.Byte: _values[name] = new ByteValue(); break; case PropertyValueType.Clob: _values[name] = new ClobValue(); break; case PropertyValueType.DateTime: _values[name] = new DateTimeValue(); break; case PropertyValueType.Double: _values[name] = new DoubleValue(); break; case PropertyValueType.Feature: _values[name] = new FeatureValue(); break; case PropertyValueType.Geometry: _values[name] = new GeometryValue(); break; case PropertyValueType.Int16: _values[name] = new Int16Value(); break; case PropertyValueType.Int32: _values[name] = new Int32Value(); break; case PropertyValueType.Int64: _values[name] = new Int64Value(); break; case PropertyValueType.Raster: _values[name] = new RasterValue(); break; case PropertyValueType.Single: _values[name] = new SingleValue(); break; case PropertyValueType.String: _values[name] = new StringValue(); break; } } for (int i = 0; i < reader.GetPropertyCount(); i++) { string name = _ordinalMap[i]; GetByteReaderMethod getblob = () => { return reader.GetBLOB(name); }; GetByteReaderMethod getclob = () => { return reader.GetCLOB(name); }; GetByteReaderMethod getgeom = () => { return reader.GetGeometry(name); }; if (!reader.IsNull(name)) { var pt = (PropertyValueType)reader.GetPropertyType(name); switch (pt) { case PropertyValueType.Blob: ((BlobValue)_values[name]).Value = Utility.StreamAsArray(new MgReadOnlyStream(getblob)); break; case PropertyValueType.Boolean: ((BooleanValue)_values[name]).Value = reader.GetBoolean(name); break; case PropertyValueType.Byte: ((ByteValue)_values[name]).Value = reader.GetByte(name); break; case PropertyValueType.Clob: byte[] b = Utility.StreamAsArray(new MgReadOnlyStream(getclob)); ((ClobValue)_values[name]).Value = Encoding.UTF8.GetChars(b); break; case PropertyValueType.DateTime: ((DateTimeValue)_values[name]).Value = Utility.ConvertMgDateTime(reader.GetDateTime(name)); break; case PropertyValueType.Double: ((DoubleValue)_values[name]).Value = reader.GetDouble(name); break; //case PropertyValueType.Feature: case PropertyValueType.Geometry: try { //TODO: See if SWIG issues come into play here var geom = agfRw.Read(reader.GetGeometry(name)); var wkt = wktRw.Write(geom); ((GeometryValue)_values[name]).Value = mgReader.Read(wkt); } catch //Invalid geometry fail! { ((GeometryValue)_values[name]).SetNull(); } break; case PropertyValueType.Int16: ((Int16Value)_values[name]).Value = reader.GetInt16(name); break; case PropertyValueType.Int32: ((Int32Value)_values[name]).Value = reader.GetInt32(name); break; case PropertyValueType.Int64: ((Int64Value)_values[name]).Value = reader.GetInt64(name); break; case PropertyValueType.Single: ((SingleValue)_values[name]).Value = reader.GetSingle(name); break; case PropertyValueType.String: ((StringValue)_values[name]).Value = reader.GetString(name); break; } } } }
protected override void OnLoad(EventArgs e) { for (int i = 0; i < _reader.GetPropertyCount(); i++) { string name = _reader.GetPropertyName(i); grdResults.Columns.Add(name, name); } int count = 0; try { this.Cursor = Cursors.WaitCursor; while (_reader.ReadNext()) { count++; object[] values = new object[_reader.GetPropertyCount()]; for (int i = 0; i < _reader.GetPropertyCount(); i++) { if (_reader.IsNull(i)) { values[i] = null; } else { int pt = _reader.GetPropertyType(i); switch (pt) { case MgPropertyType.Blob: values[i] = "BLOB VALUE"; break; case MgPropertyType.Boolean: values[i] = _reader.GetBoolean(i); break; case MgPropertyType.Byte: values[i] = _reader.GetByte(i); break; case MgPropertyType.Clob: values[i] = "CLOB VALUE"; break; case MgPropertyType.DateTime: var mdt = _reader.GetDateTime(i); values[i] = mdt.ToString(); break; case MgPropertyType.Decimal: case MgPropertyType.Double: values[i] = _reader.GetDouble(i); break; case MgPropertyType.Feature: values[i] = "NESTED FEATURE READER"; break; case MgPropertyType.Geometry: MgByteReader agf = _reader.GetGeometry(i); MgGeometry geom = _agfRW.Read(agf); values[i] = _wktRW.Write(geom); break; case MgPropertyType.Int16: values[i] = _reader.GetInt16(i); break; case MgPropertyType.Int32: values[i] = _reader.GetInt32(i); break; case MgPropertyType.Int64: values[i] = _reader.GetInt64(i); break; case MgPropertyType.Raster: values[i] = "RASTER IMAGE"; break; case MgPropertyType.Single: values[i] = _reader.GetSingle(i); break; case MgPropertyType.String: values[i] = _reader.GetString(i); break; } } } grdResults.Rows.Add(values); } } finally { this.Cursor = Cursors.Default; _reader.Close(); toolStripStatusLabel1.Text = count + " features returned"; } }
public LocalNativeRecord(MgReader reader, FixedWKTReader mgReader, MgAgfReaderWriter agfRw, MgWktReaderWriter wktRw) { for (int i = 0; i < reader.GetPropertyCount(); i++) { string name = reader.GetPropertyName(i); _ordinalMap[i] = name; var pt = (PropertyValueType)reader.GetPropertyType(name); switch (pt) { case PropertyValueType.Blob: _values[name] = new BlobValue(); break; case PropertyValueType.Boolean: _values[name] = new BooleanValue(); break; case PropertyValueType.Byte: _values[name] = new ByteValue(); break; case PropertyValueType.Clob: _values[name] = new ClobValue(); break; case PropertyValueType.DateTime: _values[name] = new DateTimeValue(); break; case PropertyValueType.Double: _values[name] = new DoubleValue(); break; case PropertyValueType.Feature: _values[name] = new FeatureValue(); break; case PropertyValueType.Geometry: _values[name] = new GeometryValue(); break; case PropertyValueType.Int16: _values[name] = new Int16Value(); break; case PropertyValueType.Int32: _values[name] = new Int32Value(); break; case PropertyValueType.Int64: _values[name] = new Int64Value(); break; case PropertyValueType.Raster: _values[name] = new RasterValue(); break; case PropertyValueType.Single: _values[name] = new SingleValue(); break; case PropertyValueType.String: _values[name] = new StringValue(); break; } } for (int i = 0; i < reader.GetPropertyCount(); i++) { string name = _ordinalMap[i]; GetByteReaderMethod getblob = () => { return reader.GetBLOB(name); }; GetByteReaderMethod getclob = () => { return reader.GetCLOB(name); }; GetByteReaderMethod getgeom = () => { return reader.GetGeometry(name); }; if (!reader.IsNull(name)) { var pt = (PropertyValueType)reader.GetPropertyType(name); switch (pt) { case PropertyValueType.Blob: ((BlobValue)_values[name]).Value = Utility.StreamAsArray(new MgReadOnlyStream(getblob)); break; case PropertyValueType.Boolean: ((BooleanValue)_values[name]).Value = reader.GetBoolean(name); break; case PropertyValueType.Byte: ((ByteValue)_values[name]).Value = reader.GetByte(name); break; case PropertyValueType.Clob: byte [] b = Utility.StreamAsArray(new MgReadOnlyStream(getclob)); ((ClobValue)_values[name]).Value = Encoding.UTF8.GetChars(b); break; case PropertyValueType.DateTime: ((DateTimeValue)_values[name]).Value = Utility.ConvertMgDateTime(reader.GetDateTime(name)); break; case PropertyValueType.Double: ((DoubleValue)_values[name]).Value = reader.GetDouble(name); break; //case PropertyValueType.Feature: case PropertyValueType.Geometry: try { //TODO: See if SWIG issues come into play here var geom = agfRw.Read(reader.GetGeometry(name)); var wkt = wktRw.Write(geom); ((GeometryValue)_values[name]).Value = mgReader.Read(wkt); } catch //Invalid geometry fail! { ((GeometryValue)_values[name]).SetNull(); } break; case PropertyValueType.Int16: ((Int16Value)_values[name]).Value = reader.GetInt16(name); break; case PropertyValueType.Int32: ((Int32Value)_values[name]).Value = reader.GetInt32(name); break; case PropertyValueType.Int64: ((Int64Value)_values[name]).Value = reader.GetInt64(name); break; case PropertyValueType.Single: ((SingleValue)_values[name]).Value = reader.GetSingle(name); break; case PropertyValueType.String: ((StringValue)_values[name]).Value = reader.GetString(name); break; } } } }
public object GetFeaturePropertyValue(MgReader reader, string propertyName, bool toString) { object val = null; int propertyType = reader.GetPropertyType(propertyName); if (reader.IsNull(propertyName)) { switch (propertyType) { case 9: val = string.Empty; break; case 3: if (toString) { val = string.Empty; } else { val = new DateTime(); } break; } } else { switch (propertyType) { case 1: val = reader.GetBoolean(propertyName); goto Label_01BE; case 2: val = reader.GetByte(propertyName); goto Label_01BE; case 3: { MgDateTime dt = reader.GetDateTime(propertyName); if (!toString) { val = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second); } else { string strDt = string.Empty; if (dt != null) { strDt = string.Format("{0}/{1}/{2}", dt.Day, dt.Month, dt.Year); } val = strDt; } goto Label_01BE; } case 4: val = Math.Round((double)reader.GetSingle(propertyName), 2); goto Label_01BE; case 5: val = Math.Round(reader.GetDouble(propertyName), 2); goto Label_01BE; case 6: val = reader.GetInt16(propertyName); goto Label_01BE; case 7: val = reader.GetInt32(propertyName); goto Label_01BE; case 8: val = reader.GetInt64(propertyName); goto Label_01BE; case 9: val = reader.GetString(propertyName); goto Label_01BE; } } Label_01BE: if (toString && (val == null)) { val = string.Empty; } return val; }