/// <summary> /// Creates a custom transformation chain out of coordinate reference system description. /// </summary> /// <param name="wkt">The projection parameters, specified as Proj4 well known text.</param> /// <param name="param">The name of the parameter containing the custom transformation description.</param> /// <param name="remove">If set to true, removes the custom transformation description from the well known text after processing it.</param> /// <returns>The <see cref="CustomTransformation"/> matching the description.</returns> public static CustomTransformation Parse(ref string wkt, string param, bool remove) { // i: index of parameter in wkt // j: index of parameter's value in wkt // k: index of follow up parameter, if any // l: adjusted begin of follow up parameter. // Points to string end if there is no follow up parameter. int i = wkt.IndexOf("+" + param + "="); if (i < 0) { return(null); } int j = i == -1 ? -1 : i + 2 + param.Length; int k = i == -1 ? -1 : wkt.IndexOf('+', j); int l = k < 0 ? wkt.Length : k; Stack <string> args = new Stack <string>(wkt.Substring(j, l - j).Trim().Split(',').Reverse()); CustomTransformation ct = args.Count < 1 ? null : Parse(args); if (remove) { wkt = wkt.Substring(0, i) + (l < wkt.Length ? wkt.Substring(l) : ""); } return(ct); }
/// <summary> /// Creates a custom transformation chain out of a textual description. /// </summary> /// <param name="args">The custom transformation description.</param> /// <returns>The <see cref="CustomTransformation"/> matching the description.</returns> private static CustomTransformation Parse(Stack <string> args) { CustomTransformation ct = null; while (args.Count > 0) { ConstructorInfo c = Type.GetType(args.Pop()).GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new[] { typeof(Stack <string>) }, null); var instance = (CustomTransformation)c.Invoke(new object[] { args }); if (ct == null) { ct = instance; } else { ct.InnerMost = instance; } } return(ct); }
/// <summary> /// Initializes a new instance of the <see cref="CustomTransformation"/> class. /// </summary> /// <param name="innerTransformation">The inner <see cref="CustomTransformation"/> instance, non-null for nested transformations.</param> public CustomTransformation(CustomTransformation innerTransformation = null) { InnerTransformation = innerTransformation; }
/// <summary> /// Initializes a new instance of the <see cref="GeoMinSekTransformation"/> class. /// </summary> /// <param name="inner">Inner custom transformation (optional).</param> public GeoMinSekTransformation(CustomTransformation inner = null) : base(inner) { }
/// <summary> /// Initializes a new instance of the <see cref="ShiftScaleTransformation"/> class. /// </summary> /// <param name="shift">Shift value for the x- and y-coordinate.</param> /// <param name="scale">Scale factor for the x- and y-coordinate.</param> /// <param name="inner">Inner custom transformation (optional).</param> public ShiftScaleTransformation(double shift, double scale, CustomTransformation inner = null) : base(inner) { shx = shy = shift; scx = scy = scale; }
/// <summary> /// Initializes a new instance of the <see cref="ShiftScaleTransformation"/> class. /// </summary> /// <param name="shx">Shift value for the x-coordinate.</param> /// <param name="shy">Shift value for the y-coordinate.</param> /// <param name="scx">Scale factor for the x-coordinate.</param> /// <param name="scy">Scale factor for the y-coordinate.</param> /// <param name="inner">Inner custom transformation (optional).</param> public ShiftScaleTransformation(double shx, double shy, double scx, double scy, CustomTransformation inner = null) : base(inner) { this.shx = shx; this.shy = shy; this.scx = scx; this.scy = scy; }
/// <summary> /// Initializes a new instance of the <see cref="ShiftScaleTransformation"/> class. /// </summary> /// <param name="inner">Inner custom transformation (optional).</param> public ShiftScaleTransformation(CustomTransformation inner) : base(inner) { }