public void BinaryOsmStreamTarget_ShouldWriteWay() { using (var stream = new MemoryStream()) { var targetStream = new BinaryOsmStreamTarget(stream); targetStream.Initialize(); targetStream.AddWay(new Way() { Id = 1, ChangeSetId = 1, TimeStamp = DateTime.Now, Tags = new TagsCollection(new Tag("name", "hu?")), Nodes = new long[] { 1, 2, 3 }, UserId = 1, UserName = "******", Version = 1, Visible = true }); stream.Seek(0, SeekOrigin.Begin); var sourceStream = new BinaryOsmStreamSource(stream); var osmGeos = sourceStream.ToList(); Assert.AreEqual(1, osmGeos.Count); } }
public void BinaryOsmStreamTarget_ShouldWriteNode() { using (var stream = new MemoryStream()) { var targetStream = new BinaryOsmStreamTarget(stream); targetStream.Initialize(); targetStream.AddNode(new Node() { Id = 1, ChangeSetId = 2, Latitude = 10, TimeStamp = DateTime.Now, Longitude = 11, Tags = new TagsCollection(new Tag("name", "hu?")), UserId = 12, UserName = "******", Version = 123, Visible = true }); stream.Seek(0, SeekOrigin.Begin); var sourceStream = new BinaryOsmStreamSource(stream); var nodes = sourceStream.ToList(); Assert.AreEqual(1, nodes.Count); } }
public void BinaryOsmStreamSource_ShouldReadRelation() { using (var stream = Staging.TestStreams.GetRelationTestStream()) { var sourceStream = new BinaryOsmStreamSource(stream); var relations = sourceStream.ToList(); Assert.AreEqual(1, relations.Count); } }
public void BinaryOsmStreamSource_ShouldReadWay() { using (var stream = Staging.TestStreams.GetWayTestStream()) { var sourceStream = new BinaryOsmStreamSource(stream); var ways = sourceStream.ToList(); Assert.AreEqual(1, ways.Count); } }
public void BinaryOsmStreamSource_ShouldReadNode() { using (var stream = Staging.TestStreams.GetNodeTestStream()) { var sourceStream = new BinaryOsmStreamSource(stream); var nodes = sourceStream.ToList(); Assert.AreEqual(1, nodes.Count); } }
static void Main(string[] args) { using (var sourceStream = File.OpenRead(args[0])) using (var targetStream = File.Open(args[1], FileMode.Create)) { var sourceBinary = new BinaryOsmStreamSource(sourceStream); var targetXml = new XmlOsmStreamTarget(targetStream); targetXml.RegisterSource(sourceBinary); targetXml.Pull(); } }
public void BinaryOsmStreamSource_ShouldReadFomDeflateStream() { using (var stream = new MemoryStream()) { using (var streamCompressed = new DeflateStream(stream, CompressionMode.Compress, true)) { var targetStream = new BinaryOsmStreamTarget(streamCompressed); targetStream.Initialize(); targetStream.AddRelation(new Relation() { Id = 1, ChangeSetId = 1, TimeStamp = DateTime.Now, Tags = new TagsCollection(new Tag("name", "hu?")), Members = new RelationMember[] { new RelationMember() { Id = 1, Role = "node", Type = OsmGeoType.Node }, new RelationMember() { Id = 2, Role = "way", Type = OsmGeoType.Way }, new RelationMember() { Id = 3, Role = "relation", Type = OsmGeoType.Relation } }, UserId = 1, UserName = "******", Version = 1, Visible = true }); } stream.Seek(0, SeekOrigin.Begin); using (var streamCompressed = new DeflateStream(stream, CompressionMode.Decompress)) { var sourceStream = new BinaryOsmStreamSource(streamCompressed); var osmGeos = sourceStream.ToList(); Assert.AreEqual(1, osmGeos.Count); } } }
public void BinaryOsmStreamSource_ShouldReadNodeWayAndRelation() { using (var stream = Staging.TestStreams.GetNodeWayAndRelationTestStream()) { var sourceStream = new BinaryOsmStreamSource(stream); var osmGeos = sourceStream.ToList(); Assert.AreEqual(3, osmGeos.Count); Assert.IsInstanceOfType(osmGeos[0], typeof(Node)); Assert.IsInstanceOfType(osmGeos[1], typeof(Way)); Assert.IsInstanceOfType(osmGeos[2], typeof(Relation)); } }
public void BinaryOsmStreamSource_ShouldIgnoreNode() { using (var stream = Staging.TestStreams.GetNodeWayAndRelationTestStream()) { var sourceStream = new BinaryOsmStreamSource(stream); var osmGeos = sourceStream.ToList(); sourceStream.Reset(); osmGeos = sourceStream.EnumerateAndIgore(true, false, false).ToList(); Assert.AreEqual(2, osmGeos.Count); Assert.IsInstanceOfType(osmGeos[0], typeof(Way)); Assert.IsInstanceOfType(osmGeos[1], typeof(Relation)); } }