コード例 #1
0
 /// <summary>
 /// Applies this transformation to the i'th coordinate
 /// in the given CoordinateSequence.
 /// </summary>
 ///<param name="seq"> a <code>CoordinateSequence</code></param>
 ///<param name="i"> the index of the coordinate to transform</param>
 public void Transform(ICoordinateSequence seq, int i)
 {
     double xp = _m00 * seq.GetOrdinate(i, Ordinate.X) + _m01 * seq.GetOrdinate(i, Ordinate.Y) + _m02;
     double yp = _m10 * seq.GetOrdinate(i, Ordinate.X) + _m11 * seq.GetOrdinate(i, Ordinate.Y) + _m12;
     seq.SetOrdinate(i, Ordinate.X, xp);
     seq.SetOrdinate(i, Ordinate.Y, yp);
 }
コード例 #2
0
            public void Filter(ICoordinateSequence seq, int i)
            {
                double x = seq.GetX(i);
                double y = seq.GetY(i);

                if (_ctx.IsGeo() && _normalizeGeomCoords)
                {
                    double xNorm = DistanceUtils.NormLonDEG(x);
                    if (x != xNorm)
                    {
                        changed = true;
                        seq.SetOrdinate(i, Ordinate.X, xNorm);
                    }

                    double yNorm = DistanceUtils.NormLatDEG(y);
                    if (y != yNorm)
                    {
                        changed = true;
                        seq.SetOrdinate(i, Ordinate.Y, yNorm);
                    }
                }
                else
                {
                    _ctx.VerifyX(x);
                    _ctx.VerifyY(y);
                }
            }
コード例 #3
0
        /// <summary>
        /// Shifts the positions of the coordinates until the coordinate at  <code>firstCoordinateIndex</code>
        /// is first.
        /// </summary>
        /// <param name="seq">The coordinate sequence to rearrange</param>
        /// <param name="indexOfFirstCoordinate">The index of the coordinate to make first</param>
        /// <param name="ensureRing">Makes sure that <paramref name="seq"/> will be a closed ring upon exit</param>
        public static void Scroll(ICoordinateSequence seq, int indexOfFirstCoordinate, bool ensureRing)
        {
            int i = indexOfFirstCoordinate;

            if (i <= 0)
            {
                return;
            }

            // make a copy of the sequence
            var copy = seq.Copy();

            // test if ring, determine last index
            int last = ensureRing ? seq.Count - 1 : seq.Count;

            // fill in values
            for (int j = 0; j < last; j++)
            {
                for (int k = 0; k < seq.Dimension; k++)
                {
                    seq.SetOrdinate(j, (Ordinate)k, copy.GetOrdinate((indexOfFirstCoordinate + j) % last, (Ordinate)k));
                }
            }

            // Fix the ring (first == last)
            if (ensureRing)
            {
                for (int k = 0; k < seq.Dimension; k++)
                {
                    seq.SetOrdinate(last, (Ordinate)k, seq.GetOrdinate(0, (Ordinate)k));
                }
            }
        }
コード例 #4
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="seq">The coordinate sequence</param>
            public void Filter(ICoordinateSequence seq, int i)
            {
                var xp = seq.GetOrdinate(i, Ordinate.X) + _trans.X;
                var yp = seq.GetOrdinate(i, Ordinate.Y) + _trans.Y;

                seq.SetOrdinate(i, Ordinate.X, xp);
                seq.SetOrdinate(i, Ordinate.Y, yp);
            }
コード例 #5
0
 public static void SetCoordinate(this ICoordinateSequence self, int index, Coordinate coord)
 {
     self.SetOrdinate(index, Ordinate.X, coord.X);
     self.SetOrdinate(index, Ordinate.Y, coord.Y);
     if (self.Dimension > 2)
     {
         self.SetOrdinate(index, Ordinate.Z, coord.Z);
     }
 }
コード例 #6
0
 private static ICoordinateSequence CopyToSequence(Coordinate[] coords, ICoordinateSequence sequence)
 {
     for (int i = 0; i < coords.Length; i++)
     {
         sequence.SetOrdinate(i, Ordinate.X, coords[i].X);
         sequence.SetOrdinate(i, Ordinate.Y, coords[i].Y);                
     }
     return sequence;
 }
コード例 #7
0
 private static ICoordinateSequence CopyToSequence(Coordinate[] coords, ICoordinateSequence sequence)
 {
     for (int i = 0; i < coords.Length; i++)
     {
         sequence.SetOrdinate(i, Ordinate.X, coords[i].X);
         sequence.SetOrdinate(i, Ordinate.Y, coords[i].Y);
     }
     return(sequence);
 }
コード例 #8
0
        public WhenCreatingAPointFromAnCoordinateSequence()
        {
            _fixture = new Fixture();

            _xySequence = new DotSpatialAffineCoordinateSequence(1, Ordinates.XYZ);
            _xySequence.SetOrdinate(0, Ordinate.X, _fixture.Create <double>());
            _xySequence.SetOrdinate(0, Ordinate.Y, _fixture.Create <double>());
            _xySequence.SetOrdinate(0, Ordinate.Z, _fixture.Create <double>());

            _sut = new PointM(_xySequence);
        }
コード例 #9
0
 public void Filter(ICoordinateSequence seq, int i)
 {
     var result = _transform.Transform(
         new[]
         {
         seq.GetOrdinate(i, Ordinate.X),
         seq.GetOrdinate(i, Ordinate.Y)
         });
     seq.SetOrdinate(i, Ordinate.X, result[0]);
     seq.SetOrdinate(i, Ordinate.Y, result[1]);
 }
コード例 #10
0
        /// <summary>
        /// Swaps two coordinates in a sequence.
        /// </summary>
        /// <param name="seq"></param>
        /// <param name="i"></param>
        /// <param name="j"></param>
        public static void Swap(ICoordinateSequence seq, int i, int j)
        {
            if (i == j)
                return;

            for (int dim = 0; dim < seq.Dimension; dim++)
            {
                double tmp = seq.GetOrdinate(i, (Ordinates)dim);
                seq.SetOrdinate(i, (Ordinates)dim, seq.GetOrdinate(j, (Ordinates)dim));
                seq.SetOrdinate(j, (Ordinates)dim, tmp);
            }
        }
コード例 #11
0
 ///<summary>
 /// Copies a coordinate of a <see cref="ICoordinateSequence"/> to another <see cref="ICoordinateSequence"/>.
 /// The sequences may contain different <see cref="Ordinates"/>; in this case only the common ordinates are copied.
 ///</summary>
 /// <param name="src">The sequence to copy coordinate from</param>
 /// <param name="srcPos">The index of the coordinate to copy</param>
 /// <param name="dest">The sequence to which the coordinate should be copied to</param>
 /// <param name="destPos">The index of the coordinate in <see paramref="dest"/></param>
 protected static void CopyCoord(ICoordinateSequence src, int srcPos, ICoordinateSequence dest, int destPos)
 {
     dest.SetOrdinate(destPos, Ordinate.X, src.GetOrdinate(srcPos, Ordinate.X));
     dest.SetOrdinate(destPos, Ordinate.Y, src.GetOrdinate(srcPos, Ordinate.Y));
     if ((src.Ordinates & dest.Ordinates & Ordinates.Z) == Ordinates.Z)
     {
         dest.SetOrdinate(destPos, Ordinate.Z, src.GetOrdinate(srcPos, Ordinate.Z));
     }
     if ((src.Ordinates & dest.Ordinates & Ordinates.M) == Ordinates.M)
     {
         dest.SetOrdinate(destPos, Ordinate.M, src.GetOrdinate(srcPos, Ordinate.M));
     }
 }
コード例 #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="n"></param>
 /// <returns></returns>
 public virtual ICoordinate this[int n]
 {
     get
     {
         return(points.GetCoordinate(n));
     }
     set
     {
         points.SetOrdinate(n, Ordinates.X, value.X);
         points.SetOrdinate(n, Ordinates.Y, value.Y);
         points.SetOrdinate(n, Ordinates.Z, value.Z);
     }
 }
コード例 #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="n"></param>
 /// <returns></returns>
 public Coordinate this[int n]
 {
     get
     {
         return(_points.GetCoordinate(n));
     }
     set
     {
         _points.SetOrdinate(n, Ordinate.X, value.X);
         _points.SetOrdinate(n, Ordinate.Y, value.Y);
         _points.SetOrdinate(n, Ordinate.Z, value.Z);
     }
 }
コード例 #14
0
                private static void FixSpike(ICoordinateSequence seq, int fixIndex, int fixWithIndex)
                {
                    seq.SetOrdinate(fixIndex, Ordinate.X, seq.GetOrdinate(fixWithIndex, Ordinate.X));
                    seq.SetOrdinate(fixIndex, Ordinate.Y, seq.GetOrdinate(fixWithIndex, Ordinate.Y));

                    if ((seq.Ordinates & Ordinates.Z) == Ordinates.Z)
                    {
                        seq.SetOrdinate(fixIndex, Ordinate.Z, seq.GetOrdinate(fixWithIndex, Ordinate.Z));
                    }
                    if ((seq.Ordinates & Ordinates.M) == Ordinates.M)
                    {
                        seq.SetOrdinate(fixIndex, Ordinate.M, seq.GetOrdinate(fixWithIndex, Ordinate.M));
                    }
                }
コード例 #15
0
ファイル: LineString.cs プロジェクト: Sony-NS/SharpMap
 /// <summary>
 ///
 /// </summary>
 /// <param name="n"></param>
 /// <returns></returns>
 public ICoordinate this[int n]
 {
     get
     {
         return(points.GetCoordinate(n));
     }
     set
     {
         points.SetOrdinate(n, Ordinates.X, value.X);
         points.SetOrdinate(n, Ordinates.Y, value.Y);
         points.SetOrdinate(n, Ordinates.Z, value.Z);
         GeometryChangedAction();
     }
 }
コード例 #16
0
	    public virtual ICoordinateSequence Transform(ICoordinateSequence coordinateSequence)
	    {
            var clone = new Coordinate();
            for (var i = 0; i < coordinateSequence.Count; i++)
            {
                clone.CoordinateValue = coordinateSequence.GetCoordinate(i);
                clone = Transform(clone);
                coordinateSequence.SetOrdinate(i, Ordinate.X, clone.X);
                coordinateSequence.SetOrdinate(i, Ordinate.Y, clone.Y);
                if (DimTarget > 2)
                    coordinateSequence.SetOrdinate(i, Ordinate.Z, clone.Z);
            }
	        return coordinateSequence;
	    }
コード例 #17
0
        /// <summary>
        /// Swaps two coordinates in a sequence.
        /// </summary>
        /// <param name="seq">seq the sequence to modify</param>
        /// <param name="i">the index of a coordinate to swap</param>
        /// <param name="j">the index of a coordinate to swap</param>
        public static void Swap(ICoordinateSequence seq, int i, int j)
        {
            if (i == j)
            {
                return;
            }

            for (int dim = 0; dim < seq.Dimension; dim++)
            {
                double tmp = seq.GetOrdinate(i, (Ordinate)dim);
                seq.SetOrdinate(i, (Ordinate)dim, seq.GetOrdinate(j, (Ordinate)dim));
                seq.SetOrdinate(j, (Ordinate)dim, tmp);
            }
        }
        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));
        }
コード例 #19
0
        public void TestCreateBySizeAndModify()
        {
            Coordinate[] coords = CreateArray(Size);

            ICoordinateSequence seq = CsFactory.Create(Size, 3);

            for (int i = 0; i < seq.Count; i++)
            {
                seq.SetOrdinate(i, Ordinate.X, coords[i].X);
                seq.SetOrdinate(i, Ordinate.Y, coords[i].Y);
                seq.SetOrdinate(i, Ordinate.Z, coords[i].Z);
            }

            Assert.IsTrue(IsEqual(seq, coords));
        }
コード例 #20
0
 ///<summary>
 /// Copies a coordinate of a <see cref="ICoordinateSequence"/> to another <see cref="ICoordinateSequence"/>.
 /// The sequences must have the same dimension.
 ///</summary>
 /// <param name="src">The sequence to copy coordinate from</param>
 /// <param name="srcPos">The index of the coordinate to copy</param>
 /// <param name="dest">The sequence to which the coordinate should be copied to</param>
 /// <param name="destPos">The index of the coordinate in <see paramref="dest"/></param>
 public static void CopyCoord(ICoordinateSequence src, int srcPos, ICoordinateSequence dest, int destPos)
 {
     for (Ordinate dim = 0; (int)dim < src.Dimension; dim++)
     {
         dest.SetOrdinate(destPos, dim, src.GetOrdinate(srcPos, dim));
     }
 }
コード例 #21
0
            public void Filter(ICoordinateSequence seq, int i)
            {
                double x = seq.GetX(i);
                double y = seq.GetY(i);

                //Note: we don't simply call ctx.normX & normY because
                //  those methods use the precisionModel, but WKTReader already
                //  used the precisionModel. It's be nice to turn that off somehow but alas.
                if (outerInstance.m_ctx.IsGeo && outerInstance.m_ctx.IsNormWrapLongitude)
                {
                    double xNorm = DistanceUtils.NormLonDEG(x);
                    if (x.CompareTo(xNorm) != 0)
                    {//handles NaN
                        changed = true;
                        seq.SetOrdinate(i, Ordinate.X, xNorm);
                    }
                    //          double yNorm = DistanceUtils.normLatDEG(y);
                    //          if (y != yNorm) {
                    //            changed = true;
                    //            seq.setOrdinate(i,CoordinateSequence.Y,yNorm);
                    //          }
                }
                outerInstance.m_ctx.VerifyX(x);
                outerInstance.m_ctx.VerifyY(y);
            }
コード例 #22
0
        /// <summary>
        /// Function to return a coordinate sequence that is ensured to be closed.
        /// </summary>
        /// <param name="sequence">The base sequence</param>
        /// <param name="factory">The factory to use in case we need to create a new sequence</param>
        /// <returns>A closed coordinate sequence</returns>
        private static ICoordinateSequence EnsureClosedSequence(ICoordinateSequence sequence,
                                                                ICoordinateSequenceFactory factory)
        {
            //This sequence won't serve a valid linear ring
            if (sequence.Count < 3)
            {
                return(null);
            }

            //The sequence is closed
            var start     = sequence.GetCoordinate(0);
            var lastIndex = sequence.Count - 1;
            var end       = sequence.GetCoordinate(lastIndex);

            if (start.Equals2D(end))
            {
                return(sequence);
            }

            // The sequence is not closed
            // 1. Test for a little offset, in that case simply correct x- and y- ordinate values
            const double eps = 1E-7;

            if (start.Distance(end) < eps)
            {
                sequence.SetOrdinate(lastIndex, Ordinate.X, start.X);
                sequence.SetOrdinate(lastIndex, Ordinate.Y, start.Y);
                return(sequence);
            }

            // 2. Close the sequence by adding a new point, this is heavier
            var newSequence = factory.Create(sequence.Count + 1, sequence.Ordinates);
            var ordinates   = OrdinatesUtility.ToOrdinateArray(sequence.Ordinates);

            for (var i = 0; i < sequence.Count; i++)
            {
                foreach (var ordinate in ordinates)
                {
                    newSequence.SetOrdinate(i, ordinate, sequence.GetOrdinate(i, ordinate));
                }
            }
            foreach (var ordinate in ordinates)
            {
                newSequence.SetOrdinate(sequence.Count, ordinate, sequence.GetOrdinate(0, ordinate));
            }
            return(newSequence);
        }
コード例 #23
0
        public virtual void Test2DZOrdinate()
        {
            Coordinate[] coords = CreateArray(Size);

            ICoordinateSequence seq = CsFactory.Create(Size, 2);

            for (int i = 0; i < seq.Count; i++)
            {
                seq.SetOrdinate(i, Ordinate.X, coords[i].X);
                seq.SetOrdinate(i, Ordinate.Y, coords[i].Y);
            }

            for (int i = 0; i < seq.Count; i++)
            {
                Coordinate p = seq.GetCoordinate(i);
                Assert.IsTrue(Double.IsNaN(p.Z));
            }
        }
コード例 #24
0
 ///<summary>
 /// Copies a coordinate of a <see cref="ICoordinateSequence"/> to another <see cref="ICoordinateSequence"/>.
 /// The sequences may have different dimensions;
 /// in this case only the common dimensions are copied.
 ///</summary>
 /// <param name="src">The sequence to copy coordinate from</param>
 /// <param name="srcPos">The index of the coordinate to copy</param>
 /// <param name="dest">The sequence to which the coordinate should be copied to</param>
 /// <param name="destPos">The index of the coordinate in <see paramref="dest"/></param>
 public static void CopyCoord(ICoordinateSequence src, int srcPos, ICoordinateSequence dest, int destPos)
 {
     int minDim = Math.Min(src.Dimension, dest.Dimension);
     for (int dim = 0; dim < minDim; dim++)
     {
         Ordinate ordinate = (Ordinate)dim;
         double value = src.GetOrdinate(srcPos, ordinate);
         dest.SetOrdinate(destPos, ordinate, value);
     }
 }
コード例 #25
0
        public void TestCopyGeometryWithNonDefaultDimension()
        {
            GeometryFactory     gf    = new GeometryFactory(CoordinateArraySequenceFactory.Instance);
            ICoordinateSequence mpSeq = gf.CoordinateSequenceFactory.Create(1, 2);

            mpSeq.SetOrdinate(0, Ordinate.X, 50);
            mpSeq.SetOrdinate(0, Ordinate.Y, -2);

            IPoint g                 = gf.CreatePoint(mpSeq);
            IPoint geometryN         = (IPoint)g.GetGeometryN(0);
            ICoordinateSequence gSeq = geometryN.CoordinateSequence;

            Assert.AreEqual(2, gSeq.Dimension);

            IPoint g2 = (IPoint)Factory.CreateGeometry(g);
            ICoordinateSequence g2Seq = g2.CoordinateSequence;

            Assert.AreEqual(2, g2Seq.Dimension);
        }
コード例 #26
0
        public void TestMultiPointDim4()
        {
            GeometryFactory     gf    = new GeometryFactory(new PackedCoordinateSequenceFactory());
            ICoordinateSequence mpSeq = gf.CoordinateSequenceFactory.Create(1, Ordinates.XYZM);

            mpSeq.SetOrdinate(0, Ordinate.X, 50);
            mpSeq.SetOrdinate(0, Ordinate.Y, -2);
            mpSeq.SetOrdinate(0, Ordinate.Z, 10);
            mpSeq.SetOrdinate(0, Ordinate.M, 20);

            IMultiPoint         mp   = gf.CreateMultiPoint(mpSeq);
            ICoordinateSequence pSeq = ((Point)mp.GetGeometryN(0)).CoordinateSequence;

            Assert.AreEqual(4, pSeq.Dimension);
            Assert.AreEqual(Ordinates.XYZM, pSeq.Ordinates);
            for (int i = 0; i < 4; i++)
            {
                Assert.AreEqual(mpSeq.GetOrdinate(0, (Ordinate)i), pSeq.GetOrdinate(0, (Ordinate)i));
            }
        }
コード例 #27
0
        ///<summary>
        /// Copies a coordinate of a <see cref="ICoordinateSequence"/> to another <see cref="ICoordinateSequence"/>.
        /// The sequences may have different dimensions;
        /// in this case only the common dimensions are copied.
        ///</summary>
        /// <param name="src">The sequence to copy coordinate from</param>
        /// <param name="srcPos">The index of the coordinate to copy</param>
        /// <param name="dest">The sequence to which the coordinate should be copied to</param>
        /// <param name="destPos">The index of the coordinate in <see paramref="dest"/></param>
        public static void CopyCoord(ICoordinateSequence src, int srcPos, ICoordinateSequence dest, int destPos)
        {
            int minDim = Math.Min(src.Dimension, dest.Dimension);

            for (int dim = 0; dim < minDim; dim++)
            {
                var    ordinate = (Ordinate)dim;
                double value    = src.GetOrdinate(srcPos, ordinate);
                dest.SetOrdinate(destPos, ordinate, value);
            }
        }
コード例 #28
0
        private static ICoordinateSequence CreateTestSequence(ICoordinateSequenceFactory csFactory, int size, int dim)
        {
            ICoordinateSequence cs = csFactory.Create(size, dim);

            // initialize with a data signature where coords look like [1, 10, 100, ...]
            for (int i = 0; i < size; i++)
            {
                for (int d = 0; d < dim; d++)
                {
                    cs.SetOrdinate(i, (Ordinate)d, i * Math.Pow(10, d));
                }
            }
            return(cs);
        }
コード例 #29
0
        private static ICoordinateSequence FillNonPlanarDimensions(ICoordinateSequence seq)
        {
            if (seq.Dimension < 3)
            {
                return(seq);
            }

            for (int i = 0; i < seq.Count; i++)
            {
                for (int j = 2; j < seq.Dimension; j++)
                {
                    seq.SetOrdinate(i, (Ordinate)j, i * Math.Pow(10, j - 1));
                }
            }

            return(seq);
        }
コード例 #30
0
 public void Filter(ICoordinateSequence seq, int i)
 {
     double x = seq.GetX(i);
     double xNorm = _ctx.NormX(x);
     if (x != xNorm)
     {
         changed = true;
         seq.SetOrdinate(i, Ordinate.X, xNorm);
     }
     double y = seq.GetY(i);
     double yNorm = _ctx.NormY(y);
     if (y != yNorm)
     {
         changed = true;
         seq.SetOrdinate(i, Ordinate.Y, yNorm);
     }
 }
コード例 #31
0
        /// <summary>
        /// Function to return a coordinate sequence that is ensured to be closed.
        /// </summary>
        /// <param name="sequence">The base sequence</param>
        /// <param name="factory">The factory to use in case we need to create a new sequence</param>
        /// <returns>A closed coordinate sequence</returns>
        private static ICoordinateSequence EnsureClosedSequence(ICoordinateSequence sequence,
                                                                ICoordinateSequenceFactory factory)
        {
            //This sequence won't serve a valid linear ring
            if (sequence.Count < 3)
                return null;

            //The sequence is closed
            var start = sequence.GetCoordinate(0);
            var lastIndex = sequence.Count - 1;
            var end = sequence.GetCoordinate(lastIndex);
            if (start.Equals2D(end))
                return sequence;

            // The sequence is not closed
            // 1. Test for a little offset, in that case simply correct x- and y- ordinate values
            const double eps = 1E-7;
            if (start.Distance(end) < eps)
            {
                sequence.SetOrdinate(lastIndex, Ordinate.X, start.X);
                sequence.SetOrdinate(lastIndex, Ordinate.Y, start.Y);
                return sequence;
            }

            // 2. Close the sequence by adding a new point, this is heavier
            var newSequence = factory.Create(sequence.Count + 1, sequence.Ordinates);
            var ordinates = OrdinatesUtility.ToOrdinateArray(sequence.Ordinates);
            for (var i = 0; i < sequence.Count; i++)
            {
                foreach (var ordinate in ordinates)
                    newSequence.SetOrdinate(i, ordinate, sequence.GetOrdinate(i, ordinate));
            }
            foreach (var ordinate in ordinates)
                newSequence.SetOrdinate(sequence.Count, ordinate, sequence.GetOrdinate(0, ordinate));
            return newSequence;
        }
コード例 #32
0
ファイル: NtsGeometry.cs プロジェクト: h0st1le/Spatial4n
 public void Filter(ICoordinateSequence seq, int i)
 {
     seq.SetOrdinate(i, Ordinate.X, seq.GetX(i) + _xShift);
 }
コード例 #33
0
            public void Filter(ICoordinateSequence seq, int i)
            {
                double x = seq.GetX(i);
                double y = seq.GetY(i);

                if (_ctx.IsGeo() && _normalizeGeomCoords)
                {
                    double xNorm = DistanceUtils.NormLonDEG(x);
                    if (x != xNorm)
                    {
                        changed = true;
                        seq.SetOrdinate(i, Ordinate.X, xNorm);
                    }

                    double yNorm = DistanceUtils.NormLatDEG(y);
                    if (y != yNorm)
                    {
                        changed = true;
                        seq.SetOrdinate(i, Ordinate.Y, yNorm);
                    }
                }
                else
                {
                    _ctx.VerifyX(x);
                    _ctx.VerifyY(y);
                }
            }
コード例 #34
0
 /// <summary>
 /// Rounds the Coordinates in the sequence to match the PrecisionModel
 /// </summary>
 public void Filter(ICoordinateSequence seq, int i)
 {
     seq.SetOrdinate(i, Ordinate.X, _precModel.MakePrecise(seq.GetOrdinate(i, Ordinate.X)));
     seq.SetOrdinate(i, Ordinate.Y, _precModel.MakePrecise(seq.GetOrdinate(i, Ordinate.Y)));
 }
コード例 #35
0
 ///<summary>
 /// Rounds the Coordinates in the sequence to match the PrecisionModel
 ///</summary>
 public void Filter(ICoordinateSequence seq, int i)
 {
     seq.SetOrdinate(i, Ordinate.X, _precModel.MakePrecise(seq.GetOrdinate(i, Ordinate.X)));
     seq.SetOrdinate(i, Ordinate.Y, _precModel.MakePrecise(seq.GetOrdinate(i, Ordinate.Y)));
 }
コード例 #36
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="seq">The coordinate sequence</param>
 public void Filter(ICoordinateSequence seq, int i)
 {
     var xp = seq.GetOrdinate(i, Ordinate.X) + _trans.X;
     var yp = seq.GetOrdinate(i, Ordinate.Y) + _trans.Y;
     seq.SetOrdinate(i, Ordinate.X, xp);
     seq.SetOrdinate(i, Ordinate.Y, yp);
 }
コード例 #37
0
ファイル: WKBReader.cs プロジェクト: klosejay/Gisoft.Map
        /// <summary>
        /// Function to read a coordinate sequence.
        /// </summary>
        /// <param name="reader">The reader</param>
        /// <param name="size">The number of ordinates</param>
        /// <param name="cs">The coordinate system</param>
        /// <returns>The read coordinate sequence.</returns>
        protected ICoordinateSequence ReadCoordinateSequence(BinaryReader reader, int size, CoordinateSystem cs)
        {
            ICoordinateSequence sequence = _sequenceFactory.Create(size, ToOrdinates(cs));

            for (int i = 0; i < size; i++)
            {
                double x = reader.ReadDouble();
                double y = reader.ReadDouble();

                if (_precisionModel != null)
                {
                    x = _precisionModel.MakePrecise(x);
                }
                if (_precisionModel != null)
                {
                    y = _precisionModel.MakePrecise(y);
                }

                sequence.SetOrdinate(i, Ordinate.X, x);
                sequence.SetOrdinate(i, Ordinate.Y, y);

                switch (cs)
                {
                case CoordinateSystem.XY:
                    continue;

                case CoordinateSystem.XYZ:
                    double z = reader.ReadDouble();
                    if (HandleOrdinate(Ordinate.Z))
                    {
                        sequence.SetOrdinate(i, Ordinate.Z, z);
                    }
                    break;

                case CoordinateSystem.XYM:
                    double m = reader.ReadDouble();
                    if (HandleOrdinate(Ordinate.M))
                    {
                        sequence.SetOrdinate(i, Ordinate.M, m);
                    }
                    break;

                case CoordinateSystem.XYZM:
                    z = reader.ReadDouble();
                    if (HandleOrdinate(Ordinate.Z))
                    {
                        sequence.SetOrdinate(i, Ordinate.Z, z);
                    }
                    m = reader.ReadDouble();
                    if (HandleOrdinate(Ordinate.M))
                    {
                        sequence.SetOrdinate(i, Ordinate.M, m);
                    }
                    break;

                default:
                    throw new ArgumentException(String.Format("Coordinate system not supported: {0}", cs));
                }
            }
            return(sequence);
        }
コード例 #38
0
 public void Filter(ICoordinateSequence seq, int i)
 {
     seq.SetOrdinate(i, Ordinate.X, seq.GetX(i) + _xShift);
 }
コード例 #39
0
 public ICoordinateSequence Transform(ICoordinateSequence coordinateSequence)
 {
     var clone = new Coordinate();
     for (var i = 0; i < coordinateSequence.Count; i++)
     {
         clone.CoordinateValue = coordinateSequence.GetCoordinate(i);
         clone = Transform(clone);
         coordinateSequence.SetOrdinate(i, Ordinate.X, clone.X);
         coordinateSequence.SetOrdinate(i, Ordinate.Y, clone.Y);
         if (DimTarget > 2)
             coordinateSequence.SetOrdinate(i, Ordinate.Z, clone.Z);
     }
     return coordinateSequence;
 }