Abstract class for creating multi-dimensional coordinate points transformations.
If a client application wishes to query the source and target coordinate systems of a transformation, then it should keep hold of the ICoordinateTransformation interface, and use the contained math transform object whenever it wishes to perform a transform.
상속: IMathTransform
예제 #1
0
 /// <summary>
 /// Returns the inverse of this conversion.
 /// </summary>
 /// <returns>IMathTransform that is the reverse of the current conversion.</returns>
 public override MathTransform Inverse()
 {
     if (_inverse == null)
     {
         _inverse = new GeocentricTransform(this._parameters, !_isInverse);
     }
     return(_inverse);
 }
예제 #2
0
 /// <summary>
 /// Creates the inverse transform of this object.
 /// </summary>
 /// <returns></returns>
 /// <remarks>This method may fail if the transform is not one to one. However, all cartographic projections should succeed.</remarks>
 public override MathTransform Inverse()
 {
     if (_inverse == null)
     {
         _inverse = new DatumTransform(_toWgs94, !_isInverse);
     }
     return(_inverse);
 }
 /// <summary>
 /// Returns the inverse of this conversion.
 /// </summary>
 /// <returns>IMathTransform that is the reverse of the current conversion.</returns>
 public override MathTransform Inverse()
 {
     if (_inverse == null)
     {
         _inverse = Clone();
         _inverse.Invert();
     }
     return(_inverse);
 }
예제 #4
0
        // ReSharper restore InconsistentNaming

        /// <summary>
        /// Creates an instance of this class
        /// </summary>
        /// <param name="parameters">An enumeration of projection parameters</param>
        /// <param name="inverse">Indicator if this projection is inverse</param>
        protected MapProjection(IEnumerable<ProjectionParameter> parameters, MapProjection inverse)
            : this(parameters)
        {
            _inverse = inverse;
            if (_inverse != null)
            {
                inverse._inverse = this;
                _isInverse = !inverse._isInverse;
            }
        }
예제 #5
0
        /// <summary>
        /// Transforms a <see cref="NetTopologySuite.Geometries.MultiPolygon"/>.
        /// </summary>
        /// <param name="polys">MultiPolygon to transform</param>
        /// <param name="transform">MathTransform</param>
        /// <param name="targetFactory">The factory to create the target geometry</param>
        /// <returns>Transformed MultiPolygon</returns>
        public static MultiPolygon TransformMultiPolygon(MultiPolygon polys, MathTransform transform, GeometryFactory targetFactory)
        {
            var polyList = new Polygon[polys.NumGeometries];

            for (var i = 0; i < polys.NumGeometries; i++)
            {
                var poly = (Polygon)polys[i];
                polyList[i] = TransformPolygon(poly, transform, targetFactory);
            }
            return(targetFactory.CreateMultiPolygon(polyList));
        }
예제 #6
0
 /// <summary>
 /// Transforms a <see cref="NetTopologySuite.Geometries.LinearRing"/>.
 /// </summary>
 /// <param name="r">LinearRing to transform</param>
 /// <param name="transform">MathTransform</param>
 /// <param name="targetFactory">The factory to create the target geometry</param>
 /// <returns>Transformed LinearRing</returns>
 public static LinearRing TransformLinearRing(LinearRing r, MathTransform transform, GeometryFactory targetFactory)
 {
     try
     {
         return(targetFactory.CreateLinearRing(TransformCoordinates(r.Coordinates, transform)));
     }
     catch
     {
         return(null);
     }
 }
예제 #7
0
 /// <summary>
 /// Transforms a <see cref="NetTopologySuite.Geometries.Point"/>.
 /// </summary>
 /// <param name="p">Point to transform</param>
 /// <param name="transform">MathTransform</param>
 /// <param name="targetFactory">The factory to create the target geometry</param>
 /// <returns>Transformed Point</returns>
 public static Point TransformPoint(Point p, MathTransform transform, GeometryFactory targetFactory)
 {
     try
     {
         return(targetFactory.CreatePoint(TransformCoordinate(p.Coordinate, transform)));
     }
     catch
     {
         return(null);
     }
 }
예제 #8
0
        /// <summary>
        /// Function to transform <paramref name="c"/> using <paramref name="transform"/>
        /// </summary>
        /// <param name="c">The array of coordinates</param>
        /// <param name="transform">The transformation</param>
        /// <returns>An array of transformed coordinates</returns>
        private static Coordinate[] TransformCoordinates(Coordinate[] c, MathTransform transform)
        {
            var res = new Coordinate[c.Length];

            for (var i = 0; i < c.Length; i++)
            {
                var ordinates = transform.Transform(c[i].ToDoubleArray());
                res[i] = new Coordinate(ordinates[0], ordinates[1]);
            }
            return(res);
        }
예제 #9
0
        /// <summary>
        /// Returns the inverse of this affine transformation.
        /// </summary>
        /// <returns>IMathTransform that is the reverse of the current affine transformation.</returns>
        public override MathTransform Inverse()
        {
            if (_inverse == null)
            {
                //find the inverse transformation matrix - use cloned matrix array
                //remarks about dimensionality: if input dimension is M, and output dimension is N, then the matrix will have size [N+1][M+1].
                double[,] invMatrix = InvertMatrix((double[, ])_transformMatrix.Clone());
                _inverse            = new AffineTransform(invMatrix);
            }

            return(_inverse);
        }
예제 #10
0
 /// <summary>
 /// Initializes an instance of a CoordinateTransformation
 /// </summary>
 /// <param name="sourceCS">Source coordinate system</param>
 /// <param name="targetCS">Target coordinate system</param>
 /// <param name="transformType">Transformation type</param>
 /// <param name="mathTransform">Math transform</param>
 /// <param name="name">Name of transform</param>
 /// <param name="authority">Authority</param>
 /// <param name="authorityCode">Authority code</param>
 /// <param name="areaOfUse">Area of use</param>
 /// <param name="remarks">Remarks</param>
 internal CoordinateTransformation(CoordinateSystem sourceCS, CoordinateSystem targetCS, TransformType transformType, MathTransform mathTransform,
                                   string name, string authority, long authorityCode, string areaOfUse, string remarks)
 {
     TargetCS      = targetCS;
     SourceCS      = sourceCS;
     TransformType = transformType;
     MathTransform = mathTransform;
     Name          = name;
     Authority     = authority;
     AuthorityCode = authorityCode;
     AreaOfUse     = areaOfUse;
     Remarks       = remarks;
 }
예제 #11
0
        /// <summary>
        /// Transforms a <see cref="NetTopologySuite.Geometries.Polygon"/>.
        /// </summary>
        /// <param name="p">Polygon to transform</param>
        /// <param name="transform">MathTransform</param>
        /// <param name="targetFactory">The factory to create the target geometry</param>
        /// <returns>Transformed Polygon</returns>
        public static Polygon TransformPolygon(Polygon p, MathTransform transform, GeometryFactory targetFactory)
        {
            var shell = TransformLinearRing((LinearRing)p.ExteriorRing, transform, targetFactory);

            LinearRing[] holes      = null;
            var          holesCount = p.NumInteriorRings;

            if (holesCount > 0)
            {
                holes = new LinearRing[holesCount];
                for (var i = 0; i < holesCount; i++)
                {
                    holes[i] = TransformLinearRing((LinearRing)p.GetInteriorRingN(i), transform, targetFactory);
                }
            }
            return(targetFactory.CreatePolygon(shell, holes));
        }
예제 #12
0
        /// <summary>
        /// Transforms a <see cref="Envelope"/>.
        /// </summary>
        /// <param name="box">BoundingBox to transform</param>
        /// <param name="transform">Math Transform</param>
        /// <returns>Transformed object</returns>
        public static Envelope TransformBox(Envelope box, MathTransform transform)
        {
            if (box == null)
            {
                return(null);
            }

            var corners = new [] {
                transform.Transform(box.MinX, box.MinY),
                transform.Transform(box.MinX, box.MaxY),
                transform.Transform(box.MaxX, box.MinY),
                transform.Transform(box.MaxX, box.MaxY)
            };

            var result = new Envelope(new Coordinate(corners[0].x, corners[0].y));

            for (var i = 1; i < 4; i++)
            {
                result.ExpandToInclude(new Coordinate(corners[i].x, corners[i].y));
            }
            return(result);
        }
예제 #13
0
 /// <summary>
 /// Transforms a <see cref="NetTopologySuite.Geometries.Geometry"/>.
 /// </summary>
 /// <param name="g">Geometry to transform</param>
 /// <param name="transform">MathTransform</param>
 /// <param name="targetFactory">The factory to create the target geometry</param>
 /// <returns>Transformed Geometry</returns>
 public static Geometry TransformGeometry(Geometry g, MathTransform transform, GeometryFactory targetFactory)
 {
     if (g == null)
     {
         return(null);
     }
     if (g is Point)
     {
         return(TransformPoint(g as Point, transform, targetFactory));
     }
     if (g is LineString)
     {
         return(TransformLineString(g as LineString, transform, targetFactory));
     }
     if (g is Polygon)
     {
         return(TransformPolygon(g as Polygon, transform, targetFactory));
     }
     if (g is MultiPoint)
     {
         return(TransformMultiPoint(g as MultiPoint, transform, targetFactory));
     }
     if (g is MultiLineString)
     {
         return(TransformMultiLineString(g as MultiLineString, transform, targetFactory));
     }
     if (g is MultiPolygon)
     {
         return(TransformMultiPolygon(g as MultiPolygon, transform, targetFactory));
     }
     if (g is GeometryCollection)
     {
         return(TransformGeometryCollection(g as GeometryCollection, transform, targetFactory));
     }
     throw new ArgumentException("Could not transform geometry type '" + g.GetType() + "'");
 }
예제 #14
0
        /// <summary>
        /// Function to transform a <paramref name="c"/> using <paramref name="transform"/>
        /// </summary>
        /// <param name="c">The coordinate</param>
        /// <param name="transform">The transformation</param>
        /// <returns>A transformed coordinate</returns>
        public static Coordinate TransformCoordinate(Coordinate c, MathTransform transform)
        {
            var ordinates = transform.Transform(c.ToDoubleArray());

            return(new Coordinate(ordinates[0], ordinates[1]));
        }
예제 #15
0
 /// <summary>
 /// Returns the inverse of this conversion.
 /// </summary>
 /// <returns>IMathTransform that is the reverse of the current conversion.</returns>
 public override IMathTransform Inverse()
 {
     if (_inverse == null)
         _inverse = new GeocentricTransform(this._Parameters, !_isInverse);
     return _inverse;
 }
 /// <summary>
 /// Creates an instance of CoordinateTransformation as an anonymous transformation without neither autohority nor code defined.
 /// </summary>
 /// <param name="sourceCS">Source coordinate system</param>
 /// <param name="targetCS">Target coordinate system</param>
 /// <param name="transformType">Transformation type</param>
 /// <param name="mathTransform">Math transform</param>
 private static CoordinateTransformation CreateTransform(CoordinateSystem sourceCS, CoordinateSystem targetCS, TransformType transformType, MathTransform mathTransform)
 {
     return(new CoordinateTransformation(sourceCS, targetCS, transformType, mathTransform, string.Empty, string.Empty, -1, string.Empty, string.Empty));
 }
예제 #17
0
        /// <summary>
        /// Transforms a <see cref="NetTopologySuite.Geometries.GeometryCollection"/>.
        /// </summary>
        /// <param name="geoms">GeometryCollection to transform</param>
        /// <param name="transform">MathTransform</param>
        /// <param name="targetFactory">The factory to create the target geometry</param>
        /// <returns>Transformed GeometryCollection</returns>
        public static GeometryCollection TransformGeometryCollection(GeometryCollection geoms, MathTransform transform, GeometryFactory targetFactory)
        {
            var geomList = new Geometry[geoms.NumGeometries];

            for (var i = 0; i < geoms.NumGeometries; i++)
            {
                geomList[i] = TransformGeometry(geoms[i], transform, targetFactory);
            }
            return(targetFactory.CreateGeometryCollection(geomList));
        }
예제 #18
0
        /// <summary>
        /// Transforms a <see cref="NetTopologySuite.Geometries.MultiLineString"/>.
        /// </summary>
        /// <param name="lines">MultiLineString to transform</param>
        /// <param name="transform">MathTransform</param>
        /// <param name="targetFactory">The factory to create the target geometry</param>
        /// <returns>Transformed MultiLineString</returns>
        public static MultiLineString TransformMultiLineString(MultiLineString lines, MathTransform transform, GeometryFactory targetFactory)
        {
            var lineList = new LineString[lines.NumGeometries];

            for (var i = 0; i < lines.NumGeometries; i++)
            {
                var line = (LineString)lines[i];
                lineList[i] = TransformLineString(line, transform, targetFactory);
            }
            return(targetFactory.CreateMultiLineString(lineList));
        }
예제 #19
0
 /// <summary>
 /// Transforms a <see cref="NetTopologySuite.Geometries.MultiPoint"/>.
 /// </summary>
 /// <param name="points">MultiPoint to transform</param>
 /// <param name="transform">MathTransform</param>
 /// <param name="targetFactory">The factory to create the target geometry</param>
 /// <returns>Transformed MultiPoint</returns>
 public static MultiPoint TransformMultiPoint(MultiPoint points, MathTransform transform, GeometryFactory targetFactory)
 {
     return(targetFactory.CreateMultiPointFromCoords(TransformCoordinates(points.Coordinates, transform)));
 }