public void ProcessWay(PrimitiveBlock block, Way way) { this.Ways.Add(way); }
public void TestDecodeBlockWithWay() { var block = new PrimitiveBlock(); block.date_granularity = 1000; block.granularity = 100; block.lat_offset = 0; block.lon_offset = 0; block.stringtable = new StringTable(); block.stringtable.s.Add(System.Text.Encoding.UTF8.GetBytes("highway")); block.stringtable.s.Add(System.Text.Encoding.UTF8.GetBytes("residential")); block.stringtable.s.Add(System.Text.Encoding.UTF8.GetBytes("Ben")); var pbfWay = new Way() { id = 1, info = new Info() { changeset = 10, timestamp = 10, uid = 100, user_sid = 2, version = 2 } }; pbfWay.keys.Add(0); pbfWay.vals.Add(1); pbfWay.refs.Add(0); pbfWay.refs.Add(1); var primitiveGroup = new PrimitiveGroup(); primitiveGroup.ways.Add(pbfWay); block.primitivegroup.Add(primitiveGroup); var primitivesConsumer = new PrimitivesConsumerMock(); block.Decode(primitivesConsumer, false, false, false); Assert.AreEqual(0, primitivesConsumer.Nodes.Count); Assert.AreEqual(1, primitivesConsumer.Ways.Count); Assert.AreEqual(0, primitivesConsumer.Relations.Count); }
public void TestDecodeWay() { var block = new PrimitiveBlock(); block.date_granularity = 1000; block.granularity = 100; block.lat_offset = 0; block.lon_offset = 0; block.stringtable = new StringTable(); block.stringtable.s.Add(System.Text.Encoding.UTF8.GetBytes(string.Empty)); // always encode empty string as '0'. block.stringtable.s.Add(System.Text.Encoding.UTF8.GetBytes("highway")); block.stringtable.s.Add(System.Text.Encoding.UTF8.GetBytes("residential")); block.stringtable.s.Add(System.Text.Encoding.UTF8.GetBytes("Ben")); var pbfWay = new Way() { id = 1, info = new Info() { changeset = 10, timestamp = 10, uid = 100, user_sid = 3, version = 2 } }; pbfWay.keys.Add(1); pbfWay.vals.Add(2); pbfWay.refs.Add(0); pbfWay.refs.Add(1); var way = Encoder.DecodeWay(block, pbfWay); Assert.IsNotNull(way); Assert.AreEqual(1, way.Id); Assert.AreEqual(10, way.ChangeSetId); Assert.AreEqual(Utilities.FromUnixTime(10000), way.TimeStamp); Assert.AreEqual(OsmSharp.Osm.OsmGeoType.Way, way.Type); Assert.AreEqual(100, way.UserId); Assert.AreEqual("Ben", way.UserName); Assert.AreEqual(2, way.Version); Assert.AreEqual(2, way.Nodes.Count); Assert.AreEqual(0, way.Nodes[0]); Assert.AreEqual(1, way.Nodes[1]); }
public static OsmSharp.Osm.Way DecodeWay(PrimitiveBlock block, Way pbfWay) { OsmSharp.Osm.Way way = new OsmSharp.Osm.Way(); Encoder.DecodeWay(block, pbfWay, way); return(way); }