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); }
private void WriteRasterProperty(RasterPropertyDefinition raster) { Console.WriteLine("\tDescription: {0}", raster.Description); Console.WriteLine("\tNullable: {0}\n\tRead-Only: {1}", raster.Nullable, raster.ReadOnly); Console.WriteLine("\tSpatial Context Association: {0}", raster.SpatialContextAssociation); Console.WriteLine("\tDefault Image Size (X): {0}\n\tDefault Image Size (Y): {1}", raster.DefaultImageXSize, raster.DefaultImageYSize); if (raster.DefaultDataModel != null) { Console.WriteLine("\tRaster Data Model:"); Console.WriteLine("\t\tBits per-pixel: {0}", raster.DefaultDataModel.BitsPerPixel); Console.WriteLine("\t\tDefault Tile Size (X): {0}\n\t\tDefault Tile Size (Y): {1}", raster.DefaultDataModel.TileSizeX, raster.DefaultDataModel.TileSizeY); Console.WriteLine("\t\tData Model Type: {0}", raster.DefaultDataModel.DataModelType); Console.WriteLine("\t\tData Type: {0}", raster.DefaultDataModel.DataType); Console.WriteLine("\t\tOrganization: {0}", raster.DefaultDataModel.Organization); } }
/// <summary> /// Clones a given property definition /// </summary> /// <param name="pd"></param> /// <returns></returns> public static PropertyDefinition CloneProperty(PropertyDefinition pd) { PropertyDefinition propDef = null; switch (pd.PropertyType) { case PropertyType.PropertyType_DataProperty: { DataPropertyDefinition srcData = pd as DataPropertyDefinition; DataPropertyDefinition dataDef = new DataPropertyDefinition(srcData.Name, srcData.Description); dataDef.DataType = srcData.DataType; dataDef.DefaultValue = srcData.DefaultValue; dataDef.IsAutoGenerated = srcData.IsAutoGenerated; dataDef.IsSystem = srcData.IsSystem; dataDef.Length = srcData.Length; dataDef.Nullable = srcData.Nullable; dataDef.Precision = srcData.Precision; dataDef.ReadOnly = srcData.ReadOnly; //Copy constraints if (srcData.ValueConstraint != null) { if (srcData.ValueConstraint.ConstraintType == PropertyValueConstraintType.PropertyValueConstraintType_Range) { PropertyValueConstraintRange range = (PropertyValueConstraintRange)srcData.ValueConstraint; PropertyValueConstraintRange constraint = new PropertyValueConstraintRange(range.MinValue, range.MaxValue); constraint.MaxInclusive = range.MaxInclusive; constraint.MinInclusive = range.MinInclusive; dataDef.ValueConstraint = constraint; } else if (srcData.ValueConstraint.ConstraintType == PropertyValueConstraintType.PropertyValueConstraintType_List) { PropertyValueConstraintList list = (PropertyValueConstraintList)srcData.ValueConstraint; PropertyValueConstraintList constraint = new PropertyValueConstraintList(); foreach (DataValue dval in list.ConstraintList) { constraint.ConstraintList.Add(dval); } dataDef.ValueConstraint = constraint; } } CopyPropertyAttributes(srcData, dataDef); propDef = dataDef; } break; case PropertyType.PropertyType_GeometricProperty: { GeometricPropertyDefinition srcData = pd as GeometricPropertyDefinition; GeometricPropertyDefinition geomDef = new GeometricPropertyDefinition(srcData.Name, srcData.Description); geomDef.GeometryTypes = srcData.GeometryTypes; geomDef.HasElevation = srcData.HasElevation; geomDef.HasMeasure = srcData.HasMeasure; geomDef.IsSystem = srcData.IsSystem; geomDef.ReadOnly = srcData.ReadOnly; geomDef.SpatialContextAssociation = srcData.SpatialContextAssociation; CopyPropertyAttributes(srcData, geomDef); propDef = geomDef; } break; case PropertyType.PropertyType_RasterProperty: { RasterPropertyDefinition srcData = pd as RasterPropertyDefinition; RasterPropertyDefinition rastDef = new RasterPropertyDefinition(srcData.Name, srcData.Description); if (srcData.DefaultDataModel != null) { rastDef.DefaultDataModel = new OSGeo.FDO.Raster.RasterDataModel(); rastDef.DefaultDataModel.BitsPerPixel = srcData.DefaultDataModel.BitsPerPixel; rastDef.DefaultDataModel.DataModelType = srcData.DefaultDataModel.DataModelType; rastDef.DefaultDataModel.DataType = srcData.DefaultDataModel.DataType; rastDef.DefaultDataModel.Organization = srcData.DefaultDataModel.Organization; rastDef.DefaultDataModel.TileSizeX = srcData.DefaultDataModel.TileSizeX; rastDef.DefaultDataModel.TileSizeY = srcData.DefaultDataModel.TileSizeY; } rastDef.DefaultImageXSize = srcData.DefaultImageXSize; rastDef.DefaultImageYSize = srcData.DefaultImageYSize; rastDef.IsSystem = srcData.IsSystem; rastDef.Nullable = srcData.Nullable; rastDef.ReadOnly = srcData.ReadOnly; rastDef.SpatialContextAssociation = srcData.SpatialContextAssociation; CopyPropertyAttributes(srcData, rastDef); propDef = rastDef; } break; case PropertyType.PropertyType_AssociationProperty: throw new UnsupportedException(Res.GetString("ERR_UNSUPPORTED_CLONE_ASSOCIATION")); case PropertyType.PropertyType_ObjectProperty: throw new UnsupportedException(Res.GetString("ERR_UNSUPPORTED_CLONE_OBJECT")); } return propDef; }
/// <summary> /// Clones a given property definition /// </summary> /// <param name="pd"></param> /// <returns></returns> public static PropertyDefinition CloneProperty(PropertyDefinition pd) { PropertyDefinition propDef = null; switch (pd.PropertyType) { case PropertyType.PropertyType_DataProperty: { DataPropertyDefinition srcData = pd as DataPropertyDefinition; DataPropertyDefinition dataDef = new DataPropertyDefinition(srcData.Name, srcData.Description); dataDef.DataType = srcData.DataType; dataDef.DefaultValue = srcData.DefaultValue; dataDef.IsAutoGenerated = srcData.IsAutoGenerated; dataDef.IsSystem = srcData.IsSystem; dataDef.Length = srcData.Length; dataDef.Nullable = srcData.Nullable; dataDef.Precision = srcData.Precision; dataDef.ReadOnly = srcData.ReadOnly; //Copy constraints if (srcData.ValueConstraint != null) { if (srcData.ValueConstraint.ConstraintType == PropertyValueConstraintType.PropertyValueConstraintType_Range) { PropertyValueConstraintRange range = (PropertyValueConstraintRange)srcData.ValueConstraint; PropertyValueConstraintRange constraint = new PropertyValueConstraintRange(range.MinValue, range.MaxValue); constraint.MaxInclusive = range.MaxInclusive; constraint.MinInclusive = range.MinInclusive; dataDef.ValueConstraint = constraint; } else if (srcData.ValueConstraint.ConstraintType == PropertyValueConstraintType.PropertyValueConstraintType_List) { PropertyValueConstraintList list = (PropertyValueConstraintList)srcData.ValueConstraint; PropertyValueConstraintList constraint = new PropertyValueConstraintList(); foreach (DataValue dval in list.ConstraintList) { constraint.ConstraintList.Add(dval); } dataDef.ValueConstraint = constraint; } } CopyPropertyAttributes(srcData, dataDef); propDef = dataDef; } break; case PropertyType.PropertyType_GeometricProperty: { GeometricPropertyDefinition srcData = pd as GeometricPropertyDefinition; GeometricPropertyDefinition geomDef = new GeometricPropertyDefinition(srcData.Name, srcData.Description); geomDef.GeometryTypes = srcData.GeometryTypes; geomDef.HasElevation = srcData.HasElevation; geomDef.HasMeasure = srcData.HasMeasure; geomDef.IsSystem = srcData.IsSystem; geomDef.ReadOnly = srcData.ReadOnly; geomDef.SpatialContextAssociation = srcData.SpatialContextAssociation; CopyPropertyAttributes(srcData, geomDef); propDef = geomDef; } break; case PropertyType.PropertyType_RasterProperty: { RasterPropertyDefinition srcData = pd as RasterPropertyDefinition; RasterPropertyDefinition rastDef = new RasterPropertyDefinition(srcData.Name, srcData.Description); if (srcData.DefaultDataModel != null) { rastDef.DefaultDataModel = new OSGeo.FDO.Raster.RasterDataModel(); rastDef.DefaultDataModel.BitsPerPixel = srcData.DefaultDataModel.BitsPerPixel; rastDef.DefaultDataModel.DataModelType = srcData.DefaultDataModel.DataModelType; rastDef.DefaultDataModel.DataType = srcData.DefaultDataModel.DataType; rastDef.DefaultDataModel.Organization = srcData.DefaultDataModel.Organization; rastDef.DefaultDataModel.TileSizeX = srcData.DefaultDataModel.TileSizeX; rastDef.DefaultDataModel.TileSizeY = srcData.DefaultDataModel.TileSizeY; } rastDef.DefaultImageXSize = srcData.DefaultImageXSize; rastDef.DefaultImageYSize = srcData.DefaultImageYSize; rastDef.IsSystem = srcData.IsSystem; rastDef.Nullable = srcData.Nullable; rastDef.ReadOnly = srcData.ReadOnly; rastDef.SpatialContextAssociation = srcData.SpatialContextAssociation; CopyPropertyAttributes(srcData, rastDef); propDef = rastDef; } break; case PropertyType.PropertyType_AssociationProperty: throw new UnsupportedException(Res.GetString("ERR_UNSUPPORTED_CLONE_ASSOCIATION")); case PropertyType.PropertyType_ObjectProperty: throw new UnsupportedException(Res.GetString("ERR_UNSUPPORTED_CLONE_OBJECT")); } return(propDef); }
void CreatePropertyNodes(ClassDefinition classDef, TreeNode classNode) { //Pre-sort SortedList <string, PropertyDefinition> sorted = new SortedList <string, PropertyDefinition>(); foreach (PropertyDefinition propDef in classDef.Properties) { sorted.Add(propDef.Name, propDef); } foreach (PropertyDefinition propDef in sorted.Values) { TreeNode propertyNode = new TreeNode(); propertyNode.Name = propertyNode.Text = propDef.Name; switch (propDef.PropertyType) { case PropertyType.PropertyType_DataProperty: { DataPropertyDefinition dataDef = propDef as DataPropertyDefinition; propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_DATA_PROPERTY; if (classDef.IdentityProperties.Contains(dataDef)) { propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_ID_PROPERTY; } propertyNode.ToolTipText = string.Format("Data Type: {0}\nLength: {1}\nAuto-Generated: {2}\nRead-Only: {3}\nNullable: {4}", dataDef.DataType, dataDef.Length, dataDef.IsAutoGenerated, dataDef.ReadOnly, dataDef.Nullable); } break; case PropertyType.PropertyType_GeometricProperty: { GeometricPropertyDefinition geomDef = propDef as GeometricPropertyDefinition; propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_GEOM_PROPERTY; propertyNode.ToolTipText = string.Format("Has Elevation: {0}\nHas Measure: {1}\nRead-Only: {2}\nGeometry Types: {3}\nSpatial Context: {4}", geomDef.HasElevation, geomDef.HasMeasure, geomDef.ReadOnly, GeomTypesAsString(geomDef.GeometryTypes), geomDef.SpatialContextAssociation); } break; case PropertyType.PropertyType_RasterProperty: { RasterPropertyDefinition rastDef = propDef as RasterPropertyDefinition; propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_RASTER_PROPERTY; propertyNode.ToolTipText = "Raster Property"; } break; case PropertyType.PropertyType_ObjectProperty: { ObjectPropertyDefinition objDef = propDef as ObjectPropertyDefinition; propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_OBJECT_PROPERTY; propertyNode.ToolTipText = "Object Property"; } break; case PropertyType.PropertyType_AssociationProperty: { AssociationPropertyDefinition assocDef = propDef as AssociationPropertyDefinition; propertyNode.ImageKey = propertyNode.SelectedImageKey = IMG_ASSOC_PROPERTY; propertyNode.ToolTipText = "Association Property"; } break; } classNode.Nodes.Add(propertyNode); } }
public void TestCase_ClrFdoTypeMap() { Assert.AreEqual(typeof(byte[]), ClrFdoTypeMap.GetClrType(DataPropertyType.Blob)); Assert.AreEqual(typeof(bool), ClrFdoTypeMap.GetClrType(DataPropertyType.Boolean)); Assert.AreEqual(typeof(byte), ClrFdoTypeMap.GetClrType(DataPropertyType.Byte)); Assert.AreEqual(typeof(char[]), ClrFdoTypeMap.GetClrType(DataPropertyType.Clob)); Assert.AreEqual(typeof(DateTime), ClrFdoTypeMap.GetClrType(DataPropertyType.DateTime)); Assert.AreEqual(typeof(double), ClrFdoTypeMap.GetClrType(DataPropertyType.Double)); Assert.AreEqual(typeof(short), ClrFdoTypeMap.GetClrType(DataPropertyType.Int16)); Assert.AreEqual(typeof(int), ClrFdoTypeMap.GetClrType(DataPropertyType.Int32)); Assert.AreEqual(typeof(long), ClrFdoTypeMap.GetClrType(DataPropertyType.Int64)); Assert.AreEqual(typeof(float), ClrFdoTypeMap.GetClrType(DataPropertyType.Single)); Assert.AreEqual(typeof(string), ClrFdoTypeMap.GetClrType(DataPropertyType.String)); DataPropertyDefinition dp = null; dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.Blob; Assert.AreEqual(typeof(byte[]), ClrFdoTypeMap.GetClrType(dp)); dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.Boolean; Assert.AreEqual(typeof(bool), ClrFdoTypeMap.GetClrType(dp)); dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.Byte; Assert.AreEqual(typeof(byte), ClrFdoTypeMap.GetClrType(dp)); dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.Clob; Assert.AreEqual(typeof(char[]), ClrFdoTypeMap.GetClrType(dp)); dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.DateTime; Assert.AreEqual(typeof(DateTime), ClrFdoTypeMap.GetClrType(dp)); dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.Double; Assert.AreEqual(typeof(double), ClrFdoTypeMap.GetClrType(dp)); dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.Int16; Assert.AreEqual(typeof(short), ClrFdoTypeMap.GetClrType(dp)); dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.Int32; Assert.AreEqual(typeof(int), ClrFdoTypeMap.GetClrType(dp)); dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.Int64; Assert.AreEqual(typeof(long), ClrFdoTypeMap.GetClrType(dp)); dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.Single; Assert.AreEqual(typeof(float), ClrFdoTypeMap.GetClrType(dp)); dp = new DataPropertyDefinition("Data", ""); dp.DataType = DataPropertyType.String; Assert.AreEqual(typeof(string), ClrFdoTypeMap.GetClrType(dp)); var gp = new GeometricPropertyDefinition("Geom", ""); Assert.AreEqual(typeof(IGeometry), ClrFdoTypeMap.GetClrType(gp)); var op = new RasterPropertyDefinition("Raster", ""); Assert.Throws <ArgumentException>(() => { var t = ClrFdoTypeMap.GetClrType(op); }); Assert.AreEqual(typeof(byte[]), ClrFdoTypeMap.GetClrType(PropertyValueType.Blob)); Assert.AreEqual(typeof(bool), ClrFdoTypeMap.GetClrType(PropertyValueType.Boolean)); Assert.AreEqual(typeof(byte), ClrFdoTypeMap.GetClrType(PropertyValueType.Byte)); Assert.AreEqual(typeof(char[]), ClrFdoTypeMap.GetClrType(PropertyValueType.Clob)); Assert.AreEqual(typeof(DateTime), ClrFdoTypeMap.GetClrType(PropertyValueType.DateTime)); Assert.AreEqual(typeof(double), ClrFdoTypeMap.GetClrType(PropertyValueType.Double)); Assert.AreEqual(typeof(IFeature[]), ClrFdoTypeMap.GetClrType(PropertyValueType.Feature)); Assert.AreEqual(typeof(IGeometry), ClrFdoTypeMap.GetClrType(PropertyValueType.Geometry)); Assert.AreEqual(typeof(short), ClrFdoTypeMap.GetClrType(PropertyValueType.Int16)); Assert.AreEqual(typeof(int), ClrFdoTypeMap.GetClrType(PropertyValueType.Int32)); Assert.AreEqual(typeof(long), ClrFdoTypeMap.GetClrType(PropertyValueType.Int64)); Assert.AreEqual(typeof(float), ClrFdoTypeMap.GetClrType(PropertyValueType.Single)); Assert.AreEqual(typeof(string), ClrFdoTypeMap.GetClrType(PropertyValueType.String)); }