/// <summary> /// Writes GeometryCollection to the output using specified writer. /// </summary> /// <param name="collection">The GeometryCollection to write.</param> /// <param name="writer">The BinaryWriter used to write geometry to the output.</param> private static void WriteGeometryCollection(IGeometryCollection <IGeometry> collection, BinaryWriter writer) { writer.Write((uint)WkbWriter.AdjustGeometryType(collection, WkbGeometryType.GeometryCollection)); writer.Write((uint)collection.Geometries.Count()); foreach (var geometry in collection.Geometries) { WkbWriter.Write(geometry, writer); } }
/// <summary> /// Writes specified Geometry in the WKB format to a binary arrray using default WkbWriterSettings. /// </summary> /// <param name="geometry">The geometry to write.</param> /// <returns>The binary array with WKB representation of the Geometry.</returns> public static byte[] WriteToArray(IGeometry geometry) { using (MemoryStream dataStream = new MemoryStream()) { using (BinaryWriter writer = new BinaryWriter(dataStream)) { WkbWriterSettings defaultSettings = new WkbWriterSettings(); WkbWriter.WriteEncoding(writer, defaultSettings.Encoding); WkbWriter.Write(geometry, writer); return(dataStream.ToArray()); } } }
/// <summary> /// Writes specified Geometry in the WKB format to the output. /// </summary> /// <param name="geometry">The geometry to write.</param> public void Write(IGeometry geometry) { WkbWriter.WriteEncoding(_writer, this.Settings.Encoding); WkbWriter.Write(geometry, _writer); }