private static IMathTransform CreateFittedTransform(IFittedCoordinateSystem fittedSystem) { //create transform From fitted to base and inverts it if (fittedSystem is FittedCoordinateSystem) { return(((FittedCoordinateSystem)fittedSystem).ToBaseTransform); } //MathTransformFactory mtFac = new MathTransformFactory (); ////create transform From fitted to base and inverts it //return mtFac.CreateFromWKT (fittedSystem.ToBase ()); throw new NotImplementedException(); }
public void ParseFittedCoordinateSystemWkt() { CoordinateSystemFactory fac = new CoordinateSystemFactory(); IFittedCoordinateSystem fcs = null; string wkt = "FITTED_CS[\"Local coordinate system MNAU (based on Gauss-Krueger)\"," + "PARAM_MT[\"Affine\"," + "PARAMETER[\"num_row\",3],PARAMETER[\"num_col\",3],PARAMETER[\"elt_0_0\", 0.883485346527455],PARAMETER[\"elt_0_1\", -0.468458794848877],PARAMETER[\"elt_0_2\", 3455869.17937689],PARAMETER[\"elt_1_0\", 0.468458794848877],PARAMETER[\"elt_1_1\", 0.883485346527455],PARAMETER[\"elt_1_2\", 5478710.88035753],PARAMETER[\"elt_2_2\", 1]]," + "PROJCS[\"DHDN / Gauss-Kruger zone 3\"," + "GEOGCS[\"DHDN\"," + "DATUM[\"Deutsches_Hauptdreiecksnetz\"," + "SPHEROID[\"Bessel 1841\", 6377397.155, 299.1528128, AUTHORITY[\"EPSG\", \"7004\"]]," + "TOWGS84[612.4, 77, 440.2, -0.054, 0.057, -2.797, 0.525975255930096]," + "AUTHORITY[\"EPSG\", \"6314\"]]," + "PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]]," + "UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9122\"]]," + "AUTHORITY[\"EPSG\", \"4314\"]]," + "UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]]," + "PROJECTION[\"Transverse_Mercator\"]," + "PARAMETER[\"latitude_of_origin\", 0]," + "PARAMETER[\"central_meridian\", 9]," + "PARAMETER[\"scale_factor\", 1]," + "PARAMETER[\"false_easting\", 3500000]," + "PARAMETER[\"false_northing\", 0]," + "AUTHORITY[\"EPSG\", \"31467\"]]" + "]"; try { fcs = fac.CreateFromWkt(wkt) as IFittedCoordinateSystem; } catch (Exception ex) { Assert.Fail("Could not create fitted coordinate system from:\r\n" + wkt + "\r\n" + ex.Message); } Assert.IsNotNull(fcs); Assert.IsNotNullOrEmpty(fcs.ToBase()); Assert.IsNotNull(fcs.BaseCoordinateSystem); Assert.AreEqual("Local coordinate system MNAU (based on Gauss-Krueger)", fcs.Name); //Assert.AreEqual ("CUSTOM", fcs.Authority); //Assert.AreEqual (123456, fcs.AuthorityCode); Assert.AreEqual("EPSG", fcs.BaseCoordinateSystem.Authority); Assert.AreEqual(31467, fcs.BaseCoordinateSystem.AuthorityCode); }
/// <summary> /// Checks whether the values of this instance is equal to the values of another instance. /// Only parameters used for coordinate system are used for comparison. /// Name, abbreviation, authority, alias and remarks are ignored in the comparison. /// </summary> /// <param name="obj"></param> /// <returns>True if equal</returns> public override bool EqualParams(object obj) { IFittedCoordinateSystem fcs = obj as IFittedCoordinateSystem; if (fcs != null) { if (fcs.BaseCoordinateSystem.EqualParams(this.BaseCoordinateSystem)) { string fcsToBase = fcs.ToBase(); string thisToBase = this.ToBase(); if (string.Equals(fcsToBase, thisToBase)) { return(true); } } } return(false); }
/// <summary> /// Creates transformation from source coordinate system to specified target system which is the fitted one /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> private static ICoordinateTransformation Any2Fitt(ICoordinateSystem source, IFittedCoordinateSystem target) { //Transform form base system of fitted to target coordinate system - use invered math transform IMathTransform invMt = CreateFittedTransform(target).Inverse(); //case when source system is equal to base system of the fitted if (target.BaseCoordinateSystem.EqualParams(source)) { //Transform form base system of fitted to target coordinate system return(CreateTransform(source, target, TransformType.Transformation, invMt)); } ConcatenatedTransform ct = new ConcatenatedTransform(); //First transform from source to base system of fitted CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(source, target.BaseCoordinateSystem)); //Transform form base system of fitted to target coordinate system - use invered math transform ct.CoordinateTransformationList.Add(CreateTransform(target.BaseCoordinateSystem, target, TransformType.Transformation, invMt)); return(CreateTransform(source, target, TransformType.Transformation, ct)); }
/// <summary> /// Creates transformation from fitted coordinate system to the target one /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> private static ICoordinateTransformation Fitt2Any(IFittedCoordinateSystem source, ICoordinateSystem target) { //transform from fitted to base system of fitted (which is equal to target) IMathTransform mt = CreateFittedTransform(source); //case when target system is equal to base system of the fitted if (source.BaseCoordinateSystem.EqualParams(target)) { //Transform form base system of fitted to target coordinate system return(CreateTransform(source, target, TransformType.Transformation, mt)); } //Transform form base system of fitted to target coordinate system ConcatenatedTransform ct = new ConcatenatedTransform(); ct.CoordinateTransformationList.Add(CreateTransform(source, source.BaseCoordinateSystem, TransformType.Transformation, mt)); //Transform form base system of fitted to target coordinate system CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(source.BaseCoordinateSystem, target)); return(CreateTransform(source, target, TransformType.Transformation, ct)); }
public static void WriteFittedCoordinateSystem(IFittedCoordinateSystem fiitedCoordinateSystem, IndentedTextWriter writer) { throw new NotImplementedException(); }
private static IMathTransform CreateFittedTransform (IFittedCoordinateSystem fittedSystem) { //create transform From fitted to base and inverts it if (fittedSystem is FittedCoordinateSystem) { return ((FittedCoordinateSystem)fittedSystem).ToBaseTransform; } //MathTransformFactory mtFac = new MathTransformFactory (); ////create transform From fitted to base and inverts it //return mtFac.CreateFromWKT (fittedSystem.ToBase ()); throw new NotImplementedException (); }
/// <summary> /// Creates transformation from source coordinate system to specified target system which is the fitted one /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> private static ICoordinateTransformation Any2Fitt (ICoordinateSystem source, IFittedCoordinateSystem target) { //Transform form base system of fitted to target coordinate system - use invered math transform IMathTransform invMt = CreateFittedTransform (target).Inverse (); //case when source system is equal to base system of the fitted if (target.BaseCoordinateSystem.EqualParams (source)) { //Transform form base system of fitted to target coordinate system return CreateTransform (source, target, TransformType.Transformation, invMt); } ConcatenatedTransform ct = new ConcatenatedTransform (); //First transform from source to base system of fitted CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory (); ct.CoordinateTransformationList.Add (ctFac.CreateFromCoordinateSystems (source, target.BaseCoordinateSystem)); //Transform form base system of fitted to target coordinate system - use invered math transform ct.CoordinateTransformationList.Add (CreateTransform (target.BaseCoordinateSystem, target, TransformType.Transformation, invMt)); return CreateTransform (source, target, TransformType.Transformation, ct); }
/// <summary> /// Creates transformation from fitted coordinate system to the target one /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> private static ICoordinateTransformation Fitt2Any (IFittedCoordinateSystem source, ICoordinateSystem target) { //transform from fitted to base system of fitted (which is equal to target) IMathTransform mt = CreateFittedTransform (source); //case when target system is equal to base system of the fitted if (source.BaseCoordinateSystem.EqualParams (target)) { //Transform form base system of fitted to target coordinate system return CreateTransform (source, target, TransformType.Transformation, mt); } //Transform form base system of fitted to target coordinate system ConcatenatedTransform ct = new ConcatenatedTransform (); ct.CoordinateTransformationList.Add (CreateTransform (source, source.BaseCoordinateSystem, TransformType.Transformation, mt)); //Transform form base system of fitted to target coordinate system CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory (); ct.CoordinateTransformationList.Add (ctFac.CreateFromCoordinateSystems (source.BaseCoordinateSystem, target)); return CreateTransform (source, target, TransformType.Transformation, ct); }