Example #1
0
        /// <summary>
        /// Creates a <see cref="LineString" /> whose coordinates are in the reverse order of this objects.
        /// </summary>
        /// <returns>A <see cref="LineString" /> with coordinates in the reverse order.</returns>
        public ILineString Reverse()
        {
            ICoordinateSequence seq = (ICoordinateSequence)points.Clone();

            // Personalized implementation using Array.Reverse: maybe it's faster?
            ICoordinate[] array = seq.ToCoordinateArray();
            Array.Reverse(array);
            return(Factory.CreateLineString(array));
        }
Example #2
0
        /// <summary>
        /// Creates a <see cref="LineString" /> whose coordinates are in the reverse order of this objects.
        /// </summary>
        /// <returns>A <see cref="LineString" /> with coordinates in the reverse order.</returns>
        public virtual ILineString Reverse()
        {
            ICoordinateSequence seq = (ICoordinateSequence)points.Clone();

            // Personalized implementation using Array.Reverse: maybe it's faster?
            ICoordinate[] array = seq.ToCoordinateArray();
            Array.Reverse(array);
            return(Factory.CreateLineString(array));

            /*
             * // Standard implementation : direct port of JTS code
             * CoordinateSequences.Reverse(seq);
             * return Factory.CreateLineString(seq);
             */
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            Point p = (Point)base.Clone();

            p.coordinates = (ICoordinateSequence)coordinates.Clone();
            return(p);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            LineString ls = (LineString)base.Clone();

            ls._points = (ICoordinateSequence)_points.Clone();
            return(ls);
        }
        public void TestClone()
        {
            ICoordinateSequence s1 = CoordinateArraySequenceFactory.Instance.Create(
                new[] { new Coordinate(1, 2), new Coordinate(3, 4) });
            ICoordinateSequence s2 = (ICoordinateSequence)s1.Clone();

            Assert.IsTrue(s1.GetCoordinate(0).Equals(s2.GetCoordinate(0)));
            Assert.IsTrue(s1.GetCoordinate(0) != s2.GetCoordinate(0));
        }
Example #6
0
            /// <summary>
            /// Transforms a coordinate sequence. The input coordinate sequence remains unchanged.
            /// </summary>
            /// <param name="coordinateSequence">The coordinate sequence to transform.</param>
            /// <returns>The transformed coordinate sequence.</returns>
            public ICoordinateSequence Transform(ICoordinateSequence coordinateSequence)
            {
                var c = (ICoordinateSequence)coordinateSequence.Clone();

                for (var i = 0; i < c.Count; i++)
                {
                    _affineTransformation.Transform(c, i);
                }
                return(c);
            }
Example #7
0
        public override ICoordinateSequence Transform(ICoordinateSequence coordinateSequence)
        {
            var res = (ICoordinateSequence)coordinateSequence.Clone();

            foreach (var ct in _coordinateTransformationList)
            {
                res = ct.MathTransform.Transform(res);
            }
            return(res);
        }
Example #8
0
        public ICoordinateSequence Transform(ICoordinateSequence coordinateSequence)
        {
            //use shortcut if possible
            var sequence = coordinateSequence as DotSpatialAffineCoordinateSequence;

            if (sequence != null)
            {
                return(TransformDotSpatialAffine(sequence));
            }

            var xy = new double[2 * coordinateSequence.Count];

            double[] z = null;
            if (!double.IsNaN(coordinateSequence.GetOrdinate(0, Ordinate.Z)))
            {
                z = new double[coordinateSequence.Count];
            }

            var j = 0;

            for (var i = 0; i < coordinateSequence.Count; i++)
            {
                xy[j++] = coordinateSequence.GetOrdinate(i, Ordinate.X);
                xy[j++] = coordinateSequence.GetOrdinate(i, Ordinate.Y);
                if (z != null)
                {
                    z[i] = coordinateSequence.GetOrdinate(i, Ordinate.Z);
                }
            }

            Reproject.ReprojectPoints(xy, z, Source, Target, 0, coordinateSequence.Count);

            var ret = (ICoordinateSequence)coordinateSequence.Clone();

            j = 0;
            for (var i = 0; i < coordinateSequence.Count; i++)
            {
                ret.SetOrdinate(i, Ordinate.X, xy[j++]);
                ret.SetOrdinate(i, Ordinate.Y, xy[j++]);
                if (z != null && DimTarget > 2)
                {
                    ret.SetOrdinate(i, Ordinate.Z, z[i]);
                }
                else
                {
                    ret.SetOrdinate(i, Ordinate.Z, coordinateSequence.GetOrdinate(i, Ordinate.Z));
                }
            }

            return(ret);
        }
Example #9
0
        /// <summary>
        /// Transforms a coordinate sequence. The input coordinate sequence remains unchanged.
        /// </summary>
        /// <param name="coordinateSequence">The coordinate sequence to transform.</param>
        /// <returns>The transformed coordinate sequence.</returns>
        public ICoordinateSequence Transform(ICoordinateSequence coordinateSequence)
        {
            //if (coordinateSequence)

            var xy           = new double[coordinateSequence.Count * 2];
            var numOrdinates = coordinateSequence.Dimension;
            var z            = numOrdinates > 2 ? new double[coordinateSequence.Count] : null;
            var m            = numOrdinates > 3 ? new double[coordinateSequence.Count] : null;

            var j = 0;

            for (var i = 0; i < coordinateSequence.Count; i++)
            {
                xy[j++] = coordinateSequence.GetX(i);
                xy[j++] = coordinateSequence.GetY(i);
                if (numOrdinates > 2)
                {
                    z[i] = coordinateSequence.GetOrdinate(i, Ordinate.Z);
                }
                if (numOrdinates > 3)
                {
                    m[i] = coordinateSequence.GetOrdinate(i, Ordinate.M);
                }
            }

            // Do the reprojection
            Reproject.ReprojectPoints(xy, z, _order[0], _order[1], 0, coordinateSequence.Count);

            // Set up result
            j = 0;
            var res = (ICoordinateSequence)coordinateSequence.Clone();

            for (var i = 0; i < coordinateSequence.Count; i++)
            {
                res.SetOrdinate(i, Ordinate.X, xy[j++]);
                res.SetOrdinate(i, Ordinate.Y, xy[j++]);
                if (numOrdinates > 2)
                {
                    res.SetOrdinate(i, Ordinate.Z, z[i]);
                }
                else if (numOrdinates > 3)
                {
                    res.SetOrdinate(i, Ordinate.M, m[i]);
                }
            }

            // return it
            return(res);
        }
        public void TestCloneDimension2()
        {
            ICoordinateSequence s1 = CoordinateArraySequenceFactory.Instance.Create(2, 2);

            s1.SetOrdinate(0, Ordinate.X, 1);
            s1.SetOrdinate(0, Ordinate.Y, 2);
            s1.SetOrdinate(1, Ordinate.X, 3);
            s1.SetOrdinate(1, Ordinate.Y, 4);

            ICoordinateSequence s2 = (ICoordinateSequence)s1.Clone();

            Assert.IsTrue(s1.Dimension == s2.Dimension);
            Assert.IsTrue(s1.GetCoordinate(0).Equals(s2.GetCoordinate(0)));
            Assert.IsTrue(s1.GetCoordinate(0) != s2.GetCoordinate(0));
        }
 /// <summary> 
 /// Convenience method which provides statndard way of copying {CoordinateSequence}s
 /// </summary>
 /// <param name="seq">The sequence to copy.</param>
 /// <returns>A deep copy of the sequence.</returns>
 protected virtual ICoordinateSequence Copy(ICoordinateSequence seq)
 {
     return (ICoordinateSequence) seq.Clone();
 }
Example #12
0
 /// <summary>
 /// Convenience method which provides statndard way of copying {CoordinateSequence}s
 /// </summary>
 /// <param name="seq">The sequence to copy.</param>
 /// <returns>A deep copy of the sequence.</returns>
 protected virtual ICoordinateSequence Copy(ICoordinateSequence seq)
 {
     return((ICoordinateSequence)seq.Clone());
 }
        public ICoordinateSequence Transform(ICoordinateSequence coordinateSequence)
        {
            //use shortcut if possible
            var sequence = coordinateSequence as DotSpatialAffineCoordinateSequence;
            if (sequence != null)
                return TransformDotSpatialAffine(sequence);

            var xy = new double[2*coordinateSequence.Count];
            double[] z = null;
            if (!double.IsNaN(coordinateSequence.GetOrdinate(0, Ordinate.Z)))
                z = new double[coordinateSequence.Count];

            var j = 0;
            for (var i = 0; i < coordinateSequence.Count; i++)
            {
                xy[j++] = coordinateSequence.GetOrdinate(i, Ordinate.X);
                xy[j++] = coordinateSequence.GetOrdinate(i, Ordinate.Y);
                if (z != null) z[i] = coordinateSequence.GetOrdinate(i, Ordinate.Z);
            }

            Reproject.ReprojectPoints(xy, z, Source, Target, 0, coordinateSequence.Count);

            var ret = (ICoordinateSequence) coordinateSequence.Clone();
            j = 0;
            for (var i = 0; i < coordinateSequence.Count; i++)
            {
                ret.SetOrdinate(i, Ordinate.X, xy[j++]);
                ret.SetOrdinate(i, Ordinate.Y, xy[j++]);
                if (z != null && DimTarget>2) 
                    ret.SetOrdinate(i, Ordinate.Z, z[i]);
                else 
                    ret.SetOrdinate(i,Ordinate.Z, coordinateSequence.GetOrdinate(i, Ordinate.Z));
            }

            return ret;
        }
 public override ICoordinateSequence Transform(ICoordinateSequence coordinateSequence)
 {
     var res = (ICoordinateSequence)coordinateSequence.Clone();
     foreach (var ct in _coordinateTransformationList)
     {
         res = ct.MathTransform.Transform(res);
     }
     return res;
 }
 /// <summary>
 /// Transforms a coordinate sequence. The input coordinate sequence remains unchanged.
 /// </summary>
 /// <param name="coordinateSequence">The coordinate sequence to transform.</param>
 /// <returns>The transformed coordinate sequence.</returns>
 public ICoordinateSequence Transform(ICoordinateSequence coordinateSequence)
 {
     var c = (ICoordinateSequence)coordinateSequence.Clone();
     for (var i = 0; i < c.Count; i++)
         _affineTransformation.Transform(c, i);
     return c;
 }