using System; namespace Core.Gis.GeoApi.Geometries { /// /// Constants representing the dimensions of a point, a curve and a surface. /// Also, constants representing the dimensions of the empty point and /// non-empty geometries, and a wildcard dimension meaning "any dimension". /// public enum Dimensions : int { /// /// Dimension value of a point (0). /// Point = 0, /// /// Dimension value of a curve (1). /// Curve = 1, /// /// Dimension value of a surface (2). /// Surface = 2, /// /// Dimension value of a empty point (-1). /// False = -1, /// /// Dimension value of non-empty geometries (= {Point,Curve,A}). /// True = -2, /// /// Dimension value for any dimension (= {False, True}). /// Dontcare = -3 } /// /// Class containing static methods for conversions /// between dimension values and characters. /// public class Dimension { private Dimension() {} /// /// Converts the dimension value to a dimension symbol, /// for example, True => 'T' /// /// Number that can be stored in the IntersectionMatrix. /// Possible values are True, False, Dontcare, 0, 1, 2. /// Character for use in the string representation of an IntersectionMatrix. /// Possible values are T, F, * , 0, 1, 2. public static char ToDimensionSymbol(Dimensions dimensionValue) { switch (dimensionValue) { case Dimensions.False: return 'F'; case Dimensions.True: return 'T'; case Dimensions.Dontcare: return '*'; case Dimensions.Point: return '0'; case Dimensions.Curve: return '1'; case Dimensions.Surface: return '2'; default: throw new ArgumentOutOfRangeException ("Unknown dimension value: " + dimensionValue); } } /// /// Converts the dimension symbol to a dimension value, /// for example, '*' => Dontcare /// /// Character for use in the string representation of an IntersectionMatrix. /// Possible values are T, F, * , 0, 1, 2. /// Number that can be stored in the IntersectionMatrix. /// Possible values are True, False, Dontcare, 0, 1, 2. public static Dimensions ToDimensionValue(char dimensionSymbol) { switch (Char.ToUpper(dimensionSymbol)) { case 'F': return Dimensions.False; case 'T': return Dimensions.True; case '*': return Dimensions.Dontcare; case '0': return Dimensions.Point; case '1': return Dimensions.Curve; case '2': return Dimensions.Surface; default: throw new ArgumentOutOfRangeException ("Unknown dimension symbol: " + dimensionSymbol); } } } }