public void Filter(CoordinateSequence seq, int i) { var(x, y, z) = _mathTransform.Transform(seq.GetX(i), seq.GetY(i), seq.GetZ(i)); seq.SetX(i, x); seq.SetY(i, y); seq.SetZ(i, z); }
public void Filter(CoordinateSequence seq, int i) { var x = seq.GetX(i); var y = seq.GetY(i); var z = seq.GetZ(i); _transform.Transform(ref x, ref y, ref z); seq.SetX(i, x); seq.SetY(i, y); seq.SetZ(i, z); }
///<summary> /// Copies a coordinate of a <see cref="CoordinateSequence"/> to another <see cref="CoordinateSequence"/>. /// 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(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos) { dest.SetX(destPos, src.GetX(srcPos)); dest.SetY(destPos, src.GetY(srcPos)); if (src.HasZ && dest.HasZ) { dest.SetZ(destPos, src.GetZ(srcPos)); } if (src.HasM && dest.HasM) { dest.SetM(destPos, src.GetM(srcPos)); } }
/// <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 CoordinateSequence EnsureClosedSequence(CoordinateSequence sequence, CoordinateSequenceFactory 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); int 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.SetX(lastIndex, start.X); sequence.SetY(lastIndex, start.Y); return(sequence); } // 2. Close the sequence by adding a new point, this is heavier var newSequence = factory.Create(sequence.Count + 1, sequence.Dimension, sequence.Measures); int maxDim = sequence.Dimension; for (int i = 0; i < sequence.Count; i++) { for (int dim = 0; dim < maxDim; dim++) { newSequence.SetOrdinate(i, dim, sequence.GetOrdinate(i, dim)); } } for (int dim = 0; dim < maxDim; dim++) { newSequence.SetOrdinate(sequence.Count, dim, sequence.GetOrdinate(0, dim)); } return(newSequence); }