File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 33
44 <!-- - Package information, Version -->
55 <PropertyGroup >
6- <PackageVersion >7.0.0-pre020 </PackageVersion >
6+ <PackageVersion >7.0.0-pre021 </PackageVersion >
77 <LangVersion >latest</LangVersion >
88 <Company >Itinero BV</Company >
99 <Authors >OsmSharp Contributors</Authors >
Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using System . IO ;
3+ using System . Threading . Tasks ;
4+
5+ namespace OsmSharp . Streams ;
6+
7+ /// <summary>
8+ /// Extension methods to easily save/load OSM data.
9+ /// </summary>
10+ public static class IEnumerableExtensions
11+ {
12+ /// <summary>
13+ /// Creates a new file and write the data as an OSM-XML file.
14+ /// </summary>
15+ /// <param name="data">The data to write.</param>
16+ /// <param name="file">The file to create.</param>
17+ public static void CreateAsOsmFile ( this IEnumerable < OsmGeo > data , string file )
18+ {
19+ using var stream = File . Create ( file ) ;
20+ using var outputStream = new OsmSharp . Streams . XmlOsmStreamTarget ( stream ) ;
21+ outputStream . RegisterSource ( data ) ;
22+ outputStream . Pull ( ) ;
23+ outputStream . Flush ( ) ;
24+ }
25+
26+ /// <summary>
27+ /// Creates a new file and write the data as OSM-PBF file.
28+ /// </summary>
29+ /// <param name="data">The data to write.</param>
30+ /// <param name="file">The file to create.</param>
31+ public static void CreateAsOsmPbfFile ( this IEnumerable < OsmGeo > data , string file )
32+ {
33+ using var stream = File . Create ( file ) ;
34+ var outputStream = new OsmSharp . Streams . PBFOsmStreamTarget ( stream ) ;
35+ outputStream . RegisterSource ( data ) ;
36+ outputStream . Pull ( ) ;
37+ outputStream . Flush ( ) ;
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments