Example #1
0
 public LocalNativeFeatureReader(MgFeatureReader reader)
 {
     _reader              = reader;
     _mgReader            = new FixedWKTReader();
     _agfRw               = new MgAgfReaderWriter();
     _wktRw               = new MgWktReaderWriter();
     base.ClassDefinition = Utility.ConvertClassDefinition(reader.GetClassDefinition());
     base.FieldCount      = reader.GetPropertyCount();
 }
Example #2
0
 public LocalNativeFeatureReader(MgFeatureReader reader)
 {
     _reader = reader;
     _mgReader = new FixedWKTReader();
     _agfRw = new MgAgfReaderWriter();
     _wktRw = new MgWktReaderWriter();
     base.ClassDefinition = Utility.ConvertClassDefinition(reader.GetClassDefinition());
     base.FieldCount = reader.GetPropertyCount();
 }
Example #3
0
        private MgFeature CreateFeatureFromReader(MgFeatureReader reader)
        {
            var feature = new MgFeature();
            var hash = feature.Properties;
            for (int i = 0; i < reader.GetPropertyCount(); i++)
            {
                var pt = reader.GetPropertyType(i);
                //Skip un-presentable types
                if (pt == MgPropertyType.Null ||
                    pt == MgPropertyType.Raster ||
                    pt == MgPropertyType.Blob ||
                    pt == MgPropertyType.Feature ||
                    pt == MgPropertyType.Clob)
                    continue;

                string name = reader.GetPropertyName(i);

                if (reader.IsNull(i))
                {
                    hash[name] = null;
                }
                else
                {
                    switch (pt)
                    {
                        case MgPropertyType.Boolean:
                            hash[name] = reader.GetBoolean(i);
                            break;
                        case MgPropertyType.Byte:
                            hash[name] = reader.GetByte(i);
                            break;
                        case MgPropertyType.DateTime:
                            {
                                var dt = reader.GetDateTime(i);
                                hash[name] = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, 0);
                            }
                            break;
                        case MgPropertyType.Double:
                        case MgPropertyType.Decimal:
                            hash[name] = reader.GetDouble(i);
                            break;
                        case MgPropertyType.Int16:
                            hash[name] = reader.GetInt16(i);
                            break;
                        case MgPropertyType.Int32:
                            hash[name] = reader.GetInt32(i);
                            break;
                        case MgPropertyType.Int64:
                            hash[name] = reader.GetInt64(i);
                            break;
                        case MgPropertyType.Single:
                            hash[name] = reader.GetSingle(i);
                            break;
                        case MgPropertyType.String:
                            hash[name] = reader.GetString(i);
                            break;
                        case MgPropertyType.Geometry:
                            {
                                MgByteReader agf = reader.GetGeometry(i);
                                feature.Geometry = _agfRw.Read(agf);
                            }
                            break;
                    }
                }
            }
            return feature;
        }
        public LocalNativeFeature(MgFeatureReader reader, FixedWKTReader mgReader, MgAgfReaderWriter agfRw, MgWktReaderWriter wktRw)
            : base(Utility.ConvertClassDefinition(reader.GetClassDefinition()))
        {
            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:
                        ((FeatureValue)_values[name]).Value = GetFeatureArray(reader, name);
                        break;

                    case PropertyValueType.Geometry:
                        //TODO: See if SWIG issues come into play here
                        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;
                    }
                }
            }
        }
Example #5
0
 public LocalNativeFeature(MgFeatureReader reader, FixedWKTReader mgReader, MgAgfReaderWriter agfRw, MgWktReaderWriter wktRw)
     : base(Utility.ConvertClassDefinition(reader.GetClassDefinition()))
 {
     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:
                     ((FeatureValue)_values[name]).Value = GetFeatureArray(reader, name);
                     break;
                 case PropertyValueType.Geometry:
                     //TODO: See if SWIG issues come into play here
                     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;
             }
         }
     }
 }
Example #6
0
 //---------------------------------------------------------------------------------------
 //
 //        ���ܣ�GetPropertyType()������GetPropertyName()������ʹ��
 //
 //         ���ߣ�
 //
 //         ���ڣ� 2007.5.23
 //        
 //         �޸���ʷ����
 //        
 //---------------------------------------------------------------------------------------
 public void OutputReader(MgFeatureReader featureReader)
 {
     while (featureReader.ReadNext())
        {
            int propCount = featureReader.GetPropertyCount();
            for (int j = 0; j < propCount; j++)
            {
                string propertyName = featureReader.GetPropertyName(j);
                bool boolVal = featureReader.IsNull(propertyName);
                if (boolVal)
                {
                    continue;
                }
                //MgPropertyType propertyType = (MgPropertyType)featureReader.GetPropertyType(propertyName);
                int proType = featureReader.GetPropertyType(propertyName);
                GetPropertyValue(featureReader, proType, propertyName);
            }
        }
 }
Example #7
0
        private MgFeature CreateFeatureFromReader(MgFeatureReader reader)
        {
            var feature = new MgFeature();
            var hash    = feature.Properties;

            for (int i = 0; i < reader.GetPropertyCount(); i++)
            {
                var pt = reader.GetPropertyType(i);
                //Skip un-presentable types
                if (pt == MgPropertyType.Null ||
                    pt == MgPropertyType.Raster ||
                    pt == MgPropertyType.Blob ||
                    pt == MgPropertyType.Feature ||
                    pt == MgPropertyType.Clob)
                {
                    continue;
                }

                string name = reader.GetPropertyName(i);

                if (reader.IsNull(i))
                {
                    hash[name] = null;
                }
                else
                {
                    switch (pt)
                    {
                    case MgPropertyType.Boolean:
                        hash[name] = reader.GetBoolean(i);
                        break;

                    case MgPropertyType.Byte:
                        hash[name] = reader.GetByte(i);
                        break;

                    case MgPropertyType.DateTime:
                    {
                        var dt = reader.GetDateTime(i);
                        hash[name] = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, 0);
                    }
                    break;

                    case MgPropertyType.Double:
                    case MgPropertyType.Decimal:
                        hash[name] = reader.GetDouble(i);
                        break;

                    case MgPropertyType.Int16:
                        hash[name] = reader.GetInt16(i);
                        break;

                    case MgPropertyType.Int32:
                        hash[name] = reader.GetInt32(i);
                        break;

                    case MgPropertyType.Int64:
                        hash[name] = reader.GetInt64(i);
                        break;

                    case MgPropertyType.Single:
                        hash[name] = reader.GetSingle(i);
                        break;

                    case MgPropertyType.String:
                        hash[name] = reader.GetString(i);
                        break;

                    case MgPropertyType.Geometry:
                    {
                        MgByteReader agf = reader.GetGeometry(i);
                        feature.Geometry = _agfRw.Read(agf);
                    }
                    break;
                    }
                }
            }
            return(feature);
        }