/// <summary> /// Converts a LineString to <LineString Text> format, then /// Appends it to the writer. /// </summary> /// <param name="lineString">The LineString to process.</param> /// <param name="writer">The output stream to Append to.</param> public void AppendLineStringTextRelative(LineString lineString, TextWriter writer) { if (lineString.IsEmpty()) { //writer.Write("EMPTY"); } else { writer.Write(" M "); double currentX = lineString.GetCoordinateN(0).X; double currentY = lineString.GetCoordinateN(0).Y; double x=0; double y=0; AppendCoordinate(lineString.GetCoordinateN(0), writer, _precisionModel); Coordinate relativeCoordinate = new Coordinate(); writer.Write(" l "); for (int i = 1; i < lineString.GetNumPoints(); i++) { x = lineString.GetCoordinateN(i).X; y = lineString.GetCoordinateN(i).Y; relativeCoordinate.X= x- currentX; relativeCoordinate.Y= y - currentY; AppendCoordinate(relativeCoordinate, writer, _precisionModel); currentX = x; currentY = y; if (i%5==4) { writer.WriteLine(); } } } }
protected void AppendLineStringTextAbsolute(LineString lineString, TextWriter writer) { if (lineString.IsEmpty()) { //writer.Write("EMPTY"); } else { writer.Write(" M "); AppendCoordinate(lineString.GetCoordinateN(0), writer, _precisionModel); for (int i = 1; i < lineString.GetNumPoints(); i++) { writer.Write(" L "); AppendCoordinate(lineString.GetCoordinateN(i), writer, _precisionModel); if (i%5==4) { writer.WriteLine(); } } } }
/// <summary> /// Converts a LineString to <LineString Text> format, then /// Appends it to the writer. /// </summary> /// <param name="lineString">The LineString to process.</param> /// <param name="level"></param> /// <param name="doIndent"></param> /// <param name="writer">The output stream to Append to.</param> protected void AppendLineStringText(LineString lineString, int level, bool doIndent, StringWriter writer) { if ( lineString.IsEmpty() ) { writer.Write("EMPTY"); } else { if (doIndent) { Indent(level, writer); } writer.Write("("); for (int i = 0; i < lineString.GetNumPoints(); i++) { if (i > 0) { writer.Write(", "); if (i % 10 == 0) Indent(level + 2, writer); } //AppendCoordinate(lineString.GetCoordinateN(i), writer, lineString.PrecisionModel); AppendCoordinate( lineString.GetCoordinates()[i], writer, lineString.PrecisionModel ); } writer.Write(")"); } }