/// <summary> /// Writes PBF file header to the underlaying stream. /// </summary> private void WriteHeader() { OsmHeader header = new OsmHeader(); header.RequiredFeatures.Add("OsmSchema-V0.6"); if (this.Settings.UseDenseFormat) { header.RequiredFeatures.Add("DenseNodes"); } if (this.Settings.WriteMetadata) { header.OptionalFeatures.Add("Has_Metadata"); } using (MemoryStream stream = new MemoryStream()) { Serializer.Serialize<OsmHeader>(stream, header); byte[] buffer = new byte[stream.Length]; Array.Copy(stream.GetBuffer(), buffer, stream.Length); this.WriteBlob("OSMHeader", buffer); } }
/// <summary> /// Checks OsmHeader required features and if any of required features isn't supported, NotSupportedException is thrown. /// </summary> /// <param name="header">OsmHeader object to process.</param> private void ProcessOsmHeader(OsmHeader header) { string[] supportedFeatures = new string[] { "OsmSchema-V0.6", "DenseNodes" }; foreach (var required in header.RequiredFeatures) { if (supportedFeatures.Contains(required) == false) { throw new NotSupportedException(string.Format("Processing specified PBF file requires '{0}' feature which isn't supported by PbfReader.", required)); } } }