#region Disclaimer / License // Copyright (C) 2010, Jackie Ng // http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie@gmail.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // #endregion using System; using System.Collections.Generic; using System.Text; namespace OSGeo.MapGuide.MaestroAPI.Schema { /// /// Has the information needed to create or completely describe a raster property. This class encapsulates the information /// necessary to insert a 'new' raster, in the absence of any other information, for the properties defined using this schema element. /// public class RasterPropertyDefinition : PropertyDefinition { /// /// Initializes a new instance of the class. /// /// The name. /// The description. public RasterPropertyDefinition(string name, string description) { this.Name = name; this.Description = description; } /// /// Gets or sets the default size of image file in the horizontal direction in pixels (number of columns). /// public int DefaultImageXSize { get; set; } /// /// Gets or sets the default size of an image file in the vertical direction in pixels (number of rows). /// public int DefaultImageYSize { get; set; } /// /// Gets or sets whether this property's value can be null. /// public bool IsNullable { get; set; } /// /// Gets or sets whether this property is read-only. /// public bool IsReadOnly { get; set; } /// /// Gets or sets the Spatial Context name associated to this raster property. /// public string SpatialContextAssociation { get; set; } /// /// Gets the type of property definition /// public override PropertyDefinitionType Type { get { return PropertyDefinitionType.Raster; } } /// /// Writes the current element's content /// /// /// public override void WriteXml(System.Xml.XmlDocument doc, System.Xml.XmlNode currentNode) { var en = Utility.EncodeFDOName(this.Name); var geom = doc.CreateElement("xs", "element", XmlNamespaces.XS); //NOXLATE geom.SetAttribute("name", en); //NOXLATE geom.SetAttribute("type", "fdo:RasterPropertyType"); //NOXLATE geom.SetAttribute("defaultImageXSize", XmlNamespaces.FDO, this.DefaultImageXSize.ToString()); //NOXLATE geom.SetAttribute("defaultImageYSize", XmlNamespaces.FDO, this.DefaultImageYSize.ToString()); //NOXLATE geom.SetAttribute("srsName", XmlNamespaces.FDO, this.SpatialContextAssociation); //NOXLATE //Write description node var anno = doc.CreateElement("xs", "annotation", XmlNamespaces.XS); //NOXLATE var docN = doc.CreateElement("xs", "documentation", XmlNamespaces.XS); //NOXLATE docN.InnerText = this.Description; geom.AppendChild(anno); anno.AppendChild(docN); currentNode.AppendChild(geom); } /// /// Set the current element's content from the current XML node /// /// /// public override void ReadXml(System.Xml.XmlNode node, System.Xml.XmlNamespaceManager mgr) { var dix = Utility.GetFdoAttribute(node, "defaultImageXSize"); var diy = Utility.GetFdoAttribute(node, "defaultImageYSize"); var srs = Utility.GetFdoAttribute(node, "srsName"); var ro = Utility.GetFdoAttribute(node, "readOnly"); this.DefaultImageXSize = Convert.ToInt32(dix.Value); this.DefaultImageYSize = Convert.ToInt32(diy.Value); //TODO: Just copypasta'd from DataPropertyDefinition assuming the same attributes would be used //to indicate nullability and read-only states. Would be nice to verify with an actual example property this.IsNullable = (node.Attributes["minOccurs"] != null && node.Attributes["minOccurs"].Value == "0"); this.IsReadOnly = (ro != null && ro.Value == "true"); this.SpatialContextAssociation = (srs != null ? srs.Value : string.Empty); } /// /// Gets the expression data type /// public override OSGeo.MapGuide.ObjectModels.Common.ExpressionDataType ExpressionType { get { return OSGeo.MapGuide.ObjectModels.Common.ExpressionDataType.Raster; } } } }