/// <summary> /// Converts a MultiLineString to <MultiLineString Text> /// format, then Appends it to the writer. /// </summary> /// <param name="multiLineString">The MultiLineString to process.</param> /// <param name="level"></param> /// <param name="indentFirst"></param> /// <param name="writer">The output stream writer to Append to.</param> protected void AppendMultiLineStringText(MultiLineString multiLineString, int level, bool indentFirst, StringWriter writer) { if (multiLineString.isEmpty()) { writer.Write("EMPTY"); } else { int level2 = level; bool doIndent = indentFirst; writer.Write("("); for (int i = 0; i < multiLineString.getNumGeometries(); i++) { if (i > 0) { writer.Write(", "); level2 = level + 1; doIndent = true; } AppendLineStringText((LineString)multiLineString.getGeometryN(i), level2, doIndent, writer); } writer.Write(")"); } }
private void WriteMultiLineString(MultiLineString mls, WKBByteOrder byteOrder) { // Write byte order _writer.Write((byte)byteOrder); // Write type this.WriteType(mls, byteOrder); //Write the number of linestrings. this.Write((uint)mls.getNumGeometries(), byteOrder); //Loop on the number of linestrings. for (int i = 0; i < mls.getNumGeometries(); i++) { // Write each linestring. this.WriteLineString((LineString)mls.getGeometryN(i), byteOrder, true); } }
/// <summary> /// Converts a MultiLineString to <MultiLineString Text> /// format, then Appends it to the writer. /// </summary> /// <param name="multiLineString">The MultiLineString to process.</param> /// <param name="writer">The output stream writer to Append to.</param> protected void AppendMultiLineStringText(MultiLineString multiLineString, TextWriter writer) { if (multiLineString.isEmpty()) { writer.Write("EMPTY"); } else { for (int i = 0; i < multiLineString.getNumGeometries(); i++) { if (i > 0) { writer.Write(", "); } //AppendLineStringText((LineString) multiLineString.GetGeometryN(i), level2, doIndent, writer); AppendLineStringText((LineString)multiLineString.getGeometryN(i), writer); } //writer.Write(")"); } }
/// <summary> /// Writes to the given stream the equilivent shape file record given a Geometry object. /// </summary> /// <param name="geometry">The geometry object to write.</param> /// <param name="writer">The stream to write to.</param> /// <param name="factory">The geometry factory to use.</param> public override void Write(Geometry geometry, BinaryWriter writer, GeometryFactory factory) { MultiLineString multi = (MultiLineString)geometry; writer.Write((int)this.ShapeType); this.WriteBoundingBox(multi.getEnvelopeInternal(), writer); int numParts = multi.getNumGeometries(); int numPoints = multi.getNumPoints(); writer.Write(numParts); writer.Write(numPoints); //LineString[] lines = new LineString[numParts]; // write the offsets int offset = 0; for (int i = 0; i < numParts; i++) { Geometry g = multi.getGeometryN(i); writer.Write(offset); offset = offset + g.getNumPoints(); } for (int part = 0; part < numParts; part++) { Coordinate[] coords = multi.getGeometryN(part).getCoordinates(); for (int i = 0; i < coords.Length; i++) { factory.getPrecisionModel().makePrecise(coords[i]); writer.Write(coords[i].x); writer.Write(coords[i].y); } } }
public void TestMultiLineString1() { string wkt = "MULTILINESTRING (( 10.05 10.28 , 20.95 20.89 ),( 20.95 20.89, 31.92 21.45)) "; GeometryFactory factory = new GeometryFactory(); Geometry geometry = new GeometryWKTReader(factory).Create(wkt); MultiLineString multilineString = (MultiLineString)geometry; Assertion.AssertEquals("Multilinestring 1", 2, multilineString.getNumGeometries()); LineString linestring1 = (LineString)multilineString.getGeometryN(0); LineString linestring2 = (LineString)multilineString.getGeometryN(1); Assertion.AssertEquals("MLS 1", 10.05, linestring1.getCoordinates()[0].x); Assertion.AssertEquals("MLS 2", 10.28, linestring1.getCoordinates()[0].y); Assertion.AssertEquals("MLS 3", 20.95, linestring1.getCoordinates()[1].x); Assertion.AssertEquals("MLS 4", 20.89, linestring1.getCoordinates()[1].y); Assertion.AssertEquals("MLS 1", 20.95, linestring2.getCoordinates()[0].x); Assertion.AssertEquals("MLS 2", 20.89, linestring2.getCoordinates()[0].y); Assertion.AssertEquals("MLS 3", 31.92, linestring2.getCoordinates()[1].x); Assertion.AssertEquals("MLS 4", 21.45, linestring2.getCoordinates()[1].y); string wkt2 = new GeometryWKTWriter().Write(multilineString); Assertion.AssertEquals("wkt", true, Compare.WktStrings(wkt, wkt2)); }
/// <summary> /// Converts a MultiLineString to <MultiLineString Text> /// format, then Appends it to the writer. /// </summary> /// <param name="multiLineString">The MultiLineString to process.</param> /// <param name="level"></param> /// <param name="indentFirst"></param> /// <param name="writer">The output stream writer to Append to.</param> protected void AppendMultiLineStringText(MultiLineString multiLineString, int level, bool indentFirst, StringWriter writer) { if ( multiLineString.isEmpty() ) { writer.Write("EMPTY"); } else { int level2 = level; bool doIndent = indentFirst; writer.Write("("); for (int i = 0; i < multiLineString.getNumGeometries(); i++) { if (i > 0) { writer.Write(", "); level2 = level + 1; doIndent = true; } AppendLineStringText((LineString) multiLineString.getGeometryN(i), level2, doIndent, writer); } writer.Write(")"); } }
private void WriteMultiLineString(MultiLineString mls, WKBByteOrder byteOrder) { // Write byte order _writer.Write((byte)byteOrder); // Write type this.WriteType(mls, byteOrder); //Write the number of linestrings. this.Write((uint)mls.getNumGeometries(), byteOrder); //Loop on the number of linestrings. for (int i = 0; i < mls.getNumGeometries(); i++) { // Write each linestring. this.WriteLineString((LineString)mls.getGeometryN(i), byteOrder, true); } }
/// <summary> /// Converts a MultiLineString to <MultiLineString Text> /// format, then Appends it to the writer. /// </summary> /// <param name="multiLineString">The MultiLineString to process.</param> /// <param name="writer">The output stream writer to Append to.</param> protected void AppendMultiLineStringText(MultiLineString multiLineString, TextWriter writer) { if (multiLineString.isEmpty()) { writer.Write("EMPTY"); } else { for (int i = 0; i < multiLineString.getNumGeometries(); i++) { if (i > 0) { writer.Write(", "); } //AppendLineStringText((LineString) multiLineString.GetGeometryN(i), level2, doIndent, writer); AppendLineStringText((LineString) multiLineString.getGeometryN(i), writer); } //writer.Write(")"); } }