Example #1
0
        private static RasterPropertyDefinition ConvertRasterProperty(MgRasterPropertyDefinition mgRaster)
        {
            var rp = new RasterPropertyDefinition(mgRaster.Name, mgRaster.Description);

            rp.DefaultImageXSize = mgRaster.DefaultImageXSize;
            rp.DefaultImageYSize = mgRaster.DefaultImageYSize;
            rp.IsNullable        = mgRaster.Nullable;
            rp.IsReadOnly        = mgRaster.ReadOnly;
#if LOCAL_API
            rp.SpatialContextAssociation = mgRaster.SpatialContextAssociation;
#endif
            return(rp);
        }
Example #2
0
        public static ClassDefinition ConvertClassDefinition(MgClassDefinition mgClass)
        {
            var cls = new ClassDefinition(mgClass.Name, mgClass.Description);
            //foreach (var prop in mgClass.GetProperties())
            var props  = mgClass.GetProperties();
            int pcount = props.GetCount();

            for (int i = 0; i < pcount; i++)
            {
                var prop = props.GetItem(i);
                switch (prop.PropertyType)
                {
                case MgFeaturePropertyType.DataProperty:
                    MgDataPropertyDefinition mgData = (MgDataPropertyDefinition)prop;
                    var dp = ConvertDataProperty(mgData);

                    //API Bug? passing object reference gives incorrect result for identity
                    //properties
                    bool identity = (mgClass.GetIdentityProperties().Contains(prop.Name));
                    cls.AddProperty(dp, identity);
                    break;

                case MgFeaturePropertyType.GeometricProperty:
                    MgGeometricPropertyDefinition mgGeom = (MgGeometricPropertyDefinition)prop;
                    var geom = ConvertGeometricProperty(mgGeom);

                    cls.AddProperty(geom);
                    break;

                case MgFeaturePropertyType.RasterProperty:
                    MgRasterPropertyDefinition mgRaster = (MgRasterPropertyDefinition)prop;
                    var raster = ConvertRasterProperty(mgRaster);

                    cls.AddProperty(raster);
                    break;

                case MgFeaturePropertyType.ObjectProperty:
                    break;

                case MgFeaturePropertyType.AssociationProperty:
                    break;
                }
            }

            cls.DefaultGeometryPropertyName = mgClass.DefaultGeometryPropertyName;

            return(cls);
        }
Example #3
0
        public void Execute(IPlatformFactory factory, ITestLogger logger)
        {
            MgRasterPropertyDefinition rpd = new MgRasterPropertyDefinition("rasterPropDef");

            rpd.ReadOnly = true;
            Assert.IsTrue(rpd.ReadOnly);

            rpd.Nullable = true;
            Assert.IsTrue(rpd.Nullable);

            rpd.DefaultImageXSize = 600;
            Assert.AreEqual(600, rpd.DefaultImageXSize);

            rpd.DefaultImageYSize = 600;
            Assert.AreEqual(600, rpd.DefaultImageYSize);

            Assert.AreEqual("rasterPropDef", rpd.Name);
        }
Example #4
0
        internal static MgFeatureSchema ConvertSchema(FeatureSchema source)
        {
            MgFeatureSchema             fs      = new MgFeatureSchema(source.Name, source.Description);
            MgClassDefinitionCollection classes = fs.GetClasses();

            foreach (ClassDefinition cls in source.Classes)
            {
                MgClassDefinition clsDef = new MgClassDefinition();
                clsDef.SetName(cls.Name);
                clsDef.SetDescription(cls.Description);
                clsDef.SetDefaultGeometryPropertyName(cls.DefaultGeometryPropertyName);
                var clsProps = clsDef.GetProperties();
                var idProps  = clsDef.GetIdentityProperties();

                foreach (PropertyDefinition prop in cls.Properties)
                {
                    switch (prop.Type)
                    {
                    case PropertyDefinitionType.Data:
                    {
                        var dp    = new MgDataPropertyDefinition(prop.Name);
                        var srcDp = (DataPropertyDefinition)prop;
                        dp.SetAutoGeneration(srcDp.IsAutoGenerated);
                        dp.SetDataType((int)srcDp.DataType);
                        if (srcDp.DefaultValue != null)
                        {
                            dp.SetDefaultValue(srcDp.DefaultValue);
                        }
                        if (srcDp.Description != null)
                        {
                            dp.SetDescription(srcDp.Description);
                        }
                        dp.SetLength(srcDp.Length);
                        dp.SetNullable(srcDp.IsNullable);
                        dp.SetPrecision(srcDp.Precision);
                        dp.SetReadOnly(srcDp.IsReadOnly);
                        dp.SetScale(srcDp.Scale);

                        clsProps.Add(dp);

                        if (cls.IdentityProperties.Contains(srcDp))
                        {
                            idProps.Add(dp);
                        }
                    }
                    break;

                    case PropertyDefinitionType.Geometry:
                    {
                        var gp    = new MgGeometricPropertyDefinition(prop.Name);
                        var srcGp = (GeometricPropertyDefinition)prop;
                        if (srcGp.Description != null)
                        {
                            gp.SetDescription(srcGp.Description);
                        }
                        gp.SetGeometryTypes((int)srcGp.GeometricTypes);
                        gp.SetHasElevation(srcGp.HasElevation);
                        gp.SetHasMeasure(srcGp.HasMeasure);
                        gp.SetReadOnly(srcGp.IsReadOnly);
                        if (srcGp.SpatialContextAssociation != null)
                        {
                            gp.SetSpatialContextAssociation(srcGp.SpatialContextAssociation);
                        }

                        clsProps.Add(gp);
                    }
                    break;

                    case PropertyDefinitionType.Raster:
                    {
                        var rp    = new MgRasterPropertyDefinition(prop.Name);
                        var srcRp = (RasterPropertyDefinition)prop;
                        rp.SetDefaultImageXSize(srcRp.DefaultImageYSize);
                        rp.SetDefaultImageYSize(srcRp.DefaultImageYSize);
                        if (srcRp.Description != null)
                        {
                            rp.SetDescription(srcRp.Description);
                        }
                        rp.SetNullable(srcRp.IsNullable);
                        rp.SetReadOnly(srcRp.IsReadOnly);
                        if (srcRp.SpatialContextAssociation != null)
                        {
                            rp.SetSpatialContextAssociation(srcRp.SpatialContextAssociation);
                        }

                        clsProps.Add(rp);
                    }
                    break;

                    default:
                        throw new NotSupportedException();
                    }
                }

                classes.Add(clsDef);
            }

            return(fs);
        }
Example #5
0
 private static RasterPropertyDefinition ConvertRasterProperty(MgRasterPropertyDefinition mgRaster)
 {
     var rp = new RasterPropertyDefinition(mgRaster.Name, mgRaster.Description);
     rp.DefaultImageXSize = mgRaster.DefaultImageXSize;
     rp.DefaultImageYSize = mgRaster.DefaultImageYSize;
     rp.IsNullable = mgRaster.Nullable;
     rp.IsReadOnly = mgRaster.ReadOnly;
     #if LOCAL_API
     rp.SpatialContextAssociation = mgRaster.SpatialContextAssociation;
     #endif
     return rp;
 }
Example #6
0
        public void RasterPropertyDefinition()
        {
            MgRasterPropertyDefinition rpd = new MgRasterPropertyDefinition("rasterPropDef");

            rpd.ReadOnly = true;
            Assert.IsTrue(rpd.ReadOnly);

            rpd.Nullable = true;
            Assert.IsTrue(rpd.Nullable);

            rpd.DefaultImageXSize = 600;
            Assert.AreEqual(600, rpd.DefaultImageXSize);

            rpd.DefaultImageYSize = 600;
            Assert.AreEqual(600, rpd.DefaultImageYSize);

            Assert.AreEqual("rasterPropDef", rpd.Name);
        }