/// <summary> /// Converts the PBF node into an OsmSharp-node. /// </summary> /// <param name="block"></param> /// <param name="node"></param> /// <returns></returns> internal OsmSharp.Osm.Node ConvertNode(PrimitiveBlock block, OsmSharp.Osm.PBF.Node node) { var simpleNode = new OsmSharp.Osm.Node(); simpleNode.ChangeSetId = node.info.changeset; simpleNode.Id = node.id; simpleNode.Latitude = .000000001 * ((double)block.lat_offset + ((double)block.granularity * (double)node.lat)); simpleNode.Longitude = .000000001 * ((double)block.lon_offset + ((double)block.granularity * (double)node.lon)); simpleNode.Tags = new TagsCollection(node.keys.Count); if (node.keys.Count > 0) { for (int tag_idx = 0; tag_idx < node.keys.Count; tag_idx++) { string key = Encoding.UTF8.GetString(block.stringtable.s[(int)node.keys[tag_idx]]); string value = Encoding.UTF8.GetString(block.stringtable.s[(int)node.vals[tag_idx]]); simpleNode.Tags.Add(new Tag() { Key = key, Value = value }); } } simpleNode.TimeStamp = Utilities.FromUnixTime((long)node.info.timestamp * (long)block.date_granularity); simpleNode.Visible = true; simpleNode.Version = (uint)node.info.version; simpleNode.UserId = node.info.uid; simpleNode.UserName = Encoding.UTF8.GetString(block.stringtable.s[node.info.user_sid]); simpleNode.Version = (ulong)node.info.version; simpleNode.Visible = true; return(simpleNode); }
/// <summary> /// Converts the PBF node into an OsmSharp-node. /// </summary> /// <returns></returns> public static OsmSharp.Osm.Node DecodeNode(PrimitiveBlock block, OsmSharp.Osm.PBF.Node pbfNode) { var node = new OsmSharp.Osm.Node(); Encoder.DecodeNode(block, pbfNode, node); return(node); }
public override void AddNode(OsmSharp.Osm.Node node) { this._currentEntities.Add((OsmGeo)node); if (this._currentEntities.Count <= 8000) { return; } this.FlushBlock(); }
/// <summary> /// Sets all the nodes into the global variable nodes /// </summary> private void getNodes() { xmlSource.Initialize(); while (xmlSource.MoveNextNode()) { OsmSharp.Osm.Node node = (OsmSharp.Osm.Node)xmlSource.Current(); if ((node != null) && (node.Id.HasValue && (node.Visible.HasValue) && (bool)(node.Visible))) { nodes.Add((long)node.Id, node); } } }
public void TestEncodeNode() { var block = new PrimitiveBlock(); block.date_granularity = 1000; block.granularity = 100; block.lat_offset = 0; block.lon_offset = 0; var node = new OsmSharp.Osm.Node(); node.Id = 1; node.ChangeSetId = 1; node.Latitude = 10; node.Longitude = 11; node.Tags = new OsmSharp.Collections.Tags.TagsCollection(); node.Tags.Add("name", "Ben"); node.TimeStamp = DateTime.Now; node.UserId = 1; node.UserName = "******"; node.Version = 1; node.Visible = true; var pbfNode = Encoder.EncodeNode(block, new Dictionary <string, int>(), node); Assert.IsNotNull(pbfNode); Assert.AreEqual(1, pbfNode.id); Assert.AreEqual(Encoder.EncodeLatLon(10, block.lat_offset, block.granularity), pbfNode.lat); Assert.AreEqual(Encoder.EncodeLatLon(11, block.lon_offset, block.granularity), pbfNode.lon); Assert.AreEqual(1, pbfNode.info.changeset); Assert.AreEqual(Encoder.EncodeTimestamp(node.TimeStamp.Value, block.date_granularity), pbfNode.info.timestamp); Assert.AreEqual(1, pbfNode.info.uid); Assert.AreEqual("Ben", System.Text.Encoding.UTF8.GetString(block.stringtable.s[(int)pbfNode.info.user_sid])); Assert.AreEqual(1, pbfNode.info.version); Assert.AreEqual(1, pbfNode.keys.Count); Assert.AreEqual("name", System.Text.Encoding.UTF8.GetString(block.stringtable.s[(int)pbfNode.keys[0]])); Assert.AreEqual(1, pbfNode.vals.Count); Assert.AreEqual("Ben", System.Text.Encoding.UTF8.GetString(block.stringtable.s[(int)pbfNode.vals[0]])); }
private void read() { while (xmlSource.MoveNextNode()) { OsmSharp.Osm.Node node = (OsmSharp.Osm.Node)xmlSource.Current(); //Does node have a lattitude and longitude? if ((node != null) && (node.Latitude.HasValue) && (node.Longitude.HasValue)) { //Does the node have the correct tag? string naturalValue; if ((node.Tags.TryGetValue("natural", out naturalValue)) && (naturalValue.Equals("peak"))) { Coordinates coordinates = new Coordinates((float)node.Latitude.Value, (float)node.Longitude.Value); string name; if (!node.Tags.TryGetValue("name", out name)) { name = "unknown"; } string elevation; if (!node.Tags.TryGetValue("ele", out elevation)) { elevation = "0"; } NumberFormatInfo nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; float floatele; float.TryParse(elevation, NumberStyles.Any, nfi, out floatele); _peeks.Add(new Peek(coordinates, name, floatele)); } } } }
/// <summary> /// Converts simple primitives. /// </summary> /// <param name="pbfPrimitive"></param> /// <returns></returns> internal OsmSharp.Osm.OsmGeo Convert(KeyValuePair<PrimitiveBlock, object> pbfPrimitive) { if (pbfPrimitive.Value == null || pbfPrimitive.Key == null) { throw new ArgumentNullException("pbfPrimitive"); } PrimitiveBlock block = pbfPrimitive.Key; // get the block properties this object comes from. if (pbfPrimitive.Value is OsmSharp.Osm.PBF.Node) { var node = (pbfPrimitive.Value as OsmSharp.Osm.PBF.Node); var simpleNode = new OsmSharp.Osm.Node(); simpleNode.ChangeSetId = node.info.changeset; simpleNode.Id = node.id; simpleNode.Latitude = .000000001 * ((double)block.lat_offset + ((double)block.granularity * (double)node.lat)); simpleNode.Longitude = .000000001 * ((double)block.lon_offset + ((double)block.granularity * (double)node.lon)); if (node.keys.Count > 0) { simpleNode.Tags = new TagsCollection(); for (int tag_idx = 0; tag_idx < node.keys.Count; tag_idx++) { string key = Encoding.UTF8.GetString(block.stringtable.s[(int)node.keys[tag_idx]]); string value = Encoding.UTF8.GetString(block.stringtable.s[(int)node.vals[tag_idx]]); if (!simpleNode.Tags.ContainsKey(key)) { simpleNode.Tags.Add(new Tag() { Key = key, Value = value }); } } } simpleNode.TimeStamp = Utilities.FromUnixTime((long)node.info.timestamp * (long)block.date_granularity); simpleNode.Visible = true; simpleNode.Version = (uint)node.info.version; simpleNode.UserId = node.info.uid; simpleNode.UserName = Encoding.UTF8.GetString(block.stringtable.s[node.info.user_sid]); simpleNode.Version = (ulong)node.info.version; simpleNode.Visible = true; return simpleNode; } else if (pbfPrimitive.Value is OsmSharp.Osm.PBF.Way) { var way = (pbfPrimitive.Value as OsmSharp.Osm.PBF.Way); var simple_way = new OsmSharp.Osm.Way(); simple_way.Id = way.id; simple_way.Nodes = new List<long>(way.refs.Count); long node_id = 0; for (int node_idx = 0; node_idx < way.refs.Count; node_idx++) { node_id = node_id + way.refs[node_idx]; simple_way.Nodes.Add(node_id); } if (way.keys.Count > 0) { simple_way.Tags = new TagsCollection(); for (int tag_idx = 0; tag_idx < way.keys.Count; tag_idx++) { string key = Encoding.UTF8.GetString(block.stringtable.s[(int)way.keys[tag_idx]]); string value = Encoding.UTF8.GetString(block.stringtable.s[(int)way.vals[tag_idx]]); if (!simple_way.Tags.ContainsKey(key)) { simple_way.Tags.Add(new Tag(key, value)); } } } if (way.info != null) { // add the metadata if any. simple_way.ChangeSetId = way.info.changeset; simple_way.TimeStamp = Utilities.FromUnixTime((long)way.info.timestamp * (long)block.date_granularity); simple_way.UserId = way.info.uid; simple_way.UserName = Encoding.UTF8.GetString(block.stringtable.s[way.info.user_sid]); simple_way.Version = (ulong)way.info.version; } simple_way.Visible = true; return simple_way; } else if (pbfPrimitive.Value is OsmSharp.Osm.PBF.Relation) { var relation = (pbfPrimitive.Value as OsmSharp.Osm.PBF.Relation); var simple_relation = new OsmSharp.Osm.Relation(); simple_relation.Id = relation.id; if (relation.types.Count > 0) { simple_relation.Members = new List<OsmSharp.Osm.RelationMember>(); long member_id = 0; for (int member_idx = 0; member_idx < relation.types.Count; member_idx++) { member_id = member_id + relation.memids[member_idx]; string role = Encoding.UTF8.GetString( block.stringtable.s[relation.roles_sid[member_idx]]); var member = new OsmSharp.Osm.RelationMember(); member.MemberId = member_id; member.MemberRole = role; switch (relation.types[member_idx]) { case Relation.MemberType.NODE: member.MemberType = OsmSharp.Osm.OsmGeoType.Node; break; case Relation.MemberType.WAY: member.MemberType = OsmSharp.Osm.OsmGeoType.Way; break; case Relation.MemberType.RELATION: member.MemberType = OsmSharp.Osm.OsmGeoType.Relation; break; } simple_relation.Members.Add(member); } } if (relation.keys.Count > 0) { simple_relation.Tags = new TagsCollection(); for (int tag_idx = 0; tag_idx < relation.keys.Count; tag_idx++) { string key = Encoding.UTF8.GetString(block.stringtable.s[(int)relation.keys[tag_idx]]); string value = Encoding.UTF8.GetString(block.stringtable.s[(int)relation.vals[tag_idx]]); if (!simple_relation.Tags.ContainsKey(key)) { simple_relation.Tags.Add(new Tag(key, value)); } } } if (relation.info != null) { // read metadata if any. simple_relation.ChangeSetId = relation.info.changeset; simple_relation.TimeStamp = Utilities.FromUnixTime((long)relation.info.timestamp * (long)block.date_granularity); simple_relation.UserId = relation.info.uid; simple_relation.UserName = Encoding.UTF8.GetString(block.stringtable.s[relation.info.user_sid]); simple_relation.Version = (ulong)relation.info.version; } simple_relation.Visible = true; return simple_relation; } throw new Exception(string.Format("PBF primitive with type {0} not supported!", pbfPrimitive.GetType().ToString())); }
/// <summary> /// Converts simple primitives. /// </summary> /// <param name="pbfPrimitive"></param> /// <returns></returns> internal OsmSharp.Osm.OsmGeo Convert(KeyValuePair <PrimitiveBlock, object> pbfPrimitive) { if (pbfPrimitive.Value == null || pbfPrimitive.Key == null) { throw new ArgumentNullException("pbfPrimitive"); } PrimitiveBlock block = pbfPrimitive.Key; // get the block properties this object comes from. if (pbfPrimitive.Value is OsmSharp.Osm.Data.PBF.Node) { var node = (pbfPrimitive.Value as OsmSharp.Osm.Data.PBF.Node); var simpleNode = new OsmSharp.Osm.Node(); simpleNode.ChangeSetId = node.info.changeset; simpleNode.Id = node.id; simpleNode.Latitude = .000000001 * ((double)block.lat_offset + ((double)block.granularity * (double)node.lat)); simpleNode.Longitude = .000000001 * ((double)block.lon_offset + ((double)block.granularity * (double)node.lon)); if (node.keys.Count > 0) { simpleNode.Tags = new SimpleTagsCollection(); for (int tag_idx = 0; tag_idx < node.keys.Count; tag_idx++) { string key = ASCIIEncoding.ASCII.GetString(block.stringtable.s[(int)node.keys[tag_idx]]); string value = ASCIIEncoding.ASCII.GetString(block.stringtable.s[(int)node.vals[tag_idx]]); if (!simpleNode.Tags.ContainsKey(key)) { simpleNode.Tags.Add(new Tag() { Key = key, Value = value }); } } } simpleNode.TimeStamp = Utilities.FromUnixTime((long)node.info.timestamp * (long)block.date_granularity); simpleNode.Visible = true; simpleNode.Version = (uint)node.info.version; simpleNode.UserId = node.info.uid; simpleNode.UserName = ASCIIEncoding.ASCII.GetString(block.stringtable.s[node.info.user_sid]); simpleNode.Version = (ulong)node.info.version; simpleNode.Visible = true; return(simpleNode); } else if (pbfPrimitive.Value is OsmSharp.Osm.Data.PBF.Way) { var way = (pbfPrimitive.Value as OsmSharp.Osm.Data.PBF.Way); var simple_way = new OsmSharp.Osm.Way(); simple_way.Id = way.id; simple_way.Nodes = new List <long>(way.refs.Count); long node_id = 0; for (int node_idx = 0; node_idx < way.refs.Count; node_idx++) { node_id = node_id + way.refs[node_idx]; simple_way.Nodes.Add(node_id); } if (way.keys.Count > 0) { simple_way.Tags = new SimpleTagsCollection(); for (int tag_idx = 0; tag_idx < way.keys.Count; tag_idx++) { string key = ASCIIEncoding.ASCII.GetString(block.stringtable.s[(int)way.keys[tag_idx]]); string value = ASCIIEncoding.ASCII.GetString(block.stringtable.s[(int)way.vals[tag_idx]]); if (!simple_way.Tags.ContainsKey(key)) { simple_way.Tags.Add(new Tag(key, value)); } } } if (way.info != null) { // add the metadata if any. simple_way.ChangeSetId = way.info.changeset; simple_way.TimeStamp = Utilities.FromUnixTime((long)way.info.timestamp * (long)block.date_granularity); simple_way.UserId = way.info.uid; simple_way.UserName = ASCIIEncoding.ASCII.GetString(block.stringtable.s[way.info.user_sid]); simple_way.Version = (ulong)way.info.version; } simple_way.Visible = true; return(simple_way); } else if (pbfPrimitive.Value is OsmSharp.Osm.Data.PBF.Relation) { var relation = (pbfPrimitive.Value as OsmSharp.Osm.Data.PBF.Relation); var simple_relation = new OsmSharp.Osm.Relation(); simple_relation.Id = relation.id; if (relation.types.Count > 0) { simple_relation.Members = new List <OsmSharp.Osm.RelationMember>(); long member_id = 0; for (int member_idx = 0; member_idx < relation.types.Count; member_idx++) { member_id = member_id + relation.memids[member_idx]; string role = ASCIIEncoding.ASCII.GetString( block.stringtable.s[relation.roles_sid[member_idx]]); var member = new OsmSharp.Osm.RelationMember(); member.MemberId = member_id; member.MemberRole = role; switch (relation.types[member_idx]) { case Relation.MemberType.NODE: member.MemberType = OsmSharp.Osm.OsmGeoType.Node; break; case Relation.MemberType.WAY: member.MemberType = OsmSharp.Osm.OsmGeoType.Way; break; case Relation.MemberType.RELATION: member.MemberType = OsmSharp.Osm.OsmGeoType.Relation; break; } simple_relation.Members.Add(member); } } if (relation.keys.Count > 0) { simple_relation.Tags = new SimpleTagsCollection(); for (int tag_idx = 0; tag_idx < relation.keys.Count; tag_idx++) { string key = ASCIIEncoding.ASCII.GetString(block.stringtable.s[(int)relation.keys[tag_idx]]); string value = ASCIIEncoding.ASCII.GetString(block.stringtable.s[(int)relation.vals[tag_idx]]); if (!simple_relation.Tags.ContainsKey(key)) { simple_relation.Tags.Add(new Tag(key, value)); } } } if (relation.info != null) { // read metadata if any. simple_relation.ChangeSetId = relation.info.changeset; simple_relation.TimeStamp = Utilities.FromUnixTime((long)relation.info.timestamp * (long)block.date_granularity); simple_relation.UserId = relation.info.uid; simple_relation.UserName = ASCIIEncoding.ASCII.GetString(block.stringtable.s[relation.info.user_sid]); simple_relation.Version = (ulong)relation.info.version; } simple_relation.Visible = true; return(simple_relation); } throw new Exception(string.Format("PBF primitive with type {0} not supported!", pbfPrimitive.GetType().ToString())); }
/// <summary> /// Converts the PBF node into an OsmSharp-node. /// </summary> /// <param name="block"></param> /// <param name="node"></param> /// <returns></returns> internal OsmSharp.Osm.Node ConvertNode(PrimitiveBlock block, OsmSharp.Osm.PBF.Node node) { var simpleNode = new OsmSharp.Osm.Node(); simpleNode.ChangeSetId = node.info.changeset; simpleNode.Id = node.id; simpleNode.Latitude = .000000001 * ((double)block.lat_offset + ((double)block.granularity * (double)node.lat)); simpleNode.Longitude = .000000001 * ((double)block.lon_offset + ((double)block.granularity * (double)node.lon)); simpleNode.Tags = new TagsCollection(node.keys.Count); if (node.keys.Count > 0) { for (int tag_idx = 0; tag_idx < node.keys.Count; tag_idx++) { string key = Encoding.UTF8.GetString(block.stringtable.s[(int)node.keys[tag_idx]]); string value = Encoding.UTF8.GetString(block.stringtable.s[(int)node.vals[tag_idx]]); simpleNode.Tags.Add(new Tag() { Key = key, Value = value }); } } simpleNode.TimeStamp = Utilities.FromUnixTime((long)node.info.timestamp * (long)block.date_granularity); simpleNode.Visible = true; simpleNode.Version = (uint)node.info.version; simpleNode.UserId = node.info.uid; simpleNode.UserName = Encoding.UTF8.GetString(block.stringtable.s[node.info.user_sid]); simpleNode.Version = (ulong)node.info.version; simpleNode.Visible = true; return simpleNode; }
/// <summary> /// Converts the PBF node into an OsmSharp-node. /// </summary> /// <returns></returns> public static OsmSharp.Osm.Node DecodeNode(PrimitiveBlock block, OsmSharp.Osm.PBF.Node pbfNode) { var node = new OsmSharp.Osm.Node(); Encoder.DecodeNode(block, pbfNode, node); return node; }
/// <summary> /// Converts the PBF node into an OsmSharp-node. /// </summary> /// <returns></returns> public static OsmSharp.Osm.Node DecodeNode(PrimitiveBlock block, OsmSharp.Osm.PBF.Node pbfNode, OsmSharp.Osm.Node node) { // clear old data. if (node.Tags != null) { // clear tags. node.Tags.Clear(); } if (node.Tags == null) { // create tags collection. node.Tags = new TagsCollection(); } // set new stuff. node.ChangeSetId = pbfNode.info.changeset; node.Id = pbfNode.id; node.Latitude = Encoder.DecodeLatLon(pbfNode.lat, block.lat_offset, block.granularity); node.Longitude = Encoder.DecodeLatLon(pbfNode.lon, block.lon_offset, block.granularity); for (var i = 0; i < pbfNode.keys.Count; i++) { node.Tags.Add(new Tag() { Key = System.Text.Encoding.UTF8.GetString(block.stringtable.s[(int)pbfNode.keys[i]]), Value = System.Text.Encoding.UTF8.GetString(block.stringtable.s[(int)pbfNode.vals[i]]) }); } if (pbfNode.info != null) { // add the metadata if any. node.TimeStamp = Encoder.DecodeTimestamp(pbfNode.info.timestamp, block.date_granularity); node.Visible = true; node.Version = (uint)pbfNode.info.version; node.UserId = pbfNode.info.uid; node.UserName = null; if (block.stringtable != null) { node.UserName = System.Text.Encoding.UTF8.GetString(block.stringtable.s[pbfNode.info.user_sid]); } node.Version = (ulong)pbfNode.info.version; } node.Visible = true; return(node); }
public void TestEncodeNode() { var block = new PrimitiveBlock(); block.date_granularity = 1000; block.granularity = 100; block.lat_offset = 0; block.lon_offset = 0; var node = new OsmSharp.Osm.Node(); node.Id = 1; node.ChangeSetId = 1; node.Latitude = 10; node.Longitude = 11; node.Tags = new OsmSharp.Collections.Tags.TagsCollection(); node.Tags.Add("name", "Ben"); node.TimeStamp = DateTime.Now; node.UserId = 1; node.UserName = "******"; node.Version = 1; node.Visible = true; var pbfNode = Encoder.EncodeNode(block, new Dictionary<string,int>(), node); Assert.IsNotNull(pbfNode); Assert.AreEqual(1, pbfNode.id); Assert.AreEqual(Encoder.EncodeLatLon(10, block.lat_offset, block.granularity), pbfNode.lat); Assert.AreEqual(Encoder.EncodeLatLon(11, block.lon_offset, block.granularity), pbfNode.lon); Assert.AreEqual(1, pbfNode.info.changeset); Assert.AreEqual(Encoder.EncodeTimestamp(node.TimeStamp.Value, block.date_granularity), pbfNode.info.timestamp); Assert.AreEqual(1, pbfNode.info.uid); Assert.AreEqual("Ben", System.Text.Encoding.UTF8.GetString(block.stringtable.s[(int)pbfNode.info.user_sid])); Assert.AreEqual(1, pbfNode.info.version); Assert.AreEqual(1, pbfNode.keys.Count); Assert.AreEqual("name", System.Text.Encoding.UTF8.GetString(block.stringtable.s[(int)pbfNode.keys[0]])); Assert.AreEqual(1, pbfNode.vals.Count); Assert.AreEqual("Ben", System.Text.Encoding.UTF8.GetString(block.stringtable.s[(int)pbfNode.vals[0]])); }
public static Node EncodeNode(PrimitiveBlock block, Dictionary <string, int> reverseStringTable, Node pbfNode, OsmSharp.Osm.Node node) { pbfNode.id = node.Id.Value; pbfNode.info = new Info(); pbfNode.info.version = 0; pbfNode.info.changeset = !node.ChangeSetId.HasValue ? 0L : node.ChangeSetId.Value; DateTime?timeStamp = node.TimeStamp; if (timeStamp.HasValue) { Info info = pbfNode.info; timeStamp = node.TimeStamp; int num = Encoder.EncodeTimestamp(timeStamp.Value, (long)block.date_granularity); info.timestamp = num; } else { pbfNode.info.timestamp = 0; } long?userId = node.UserId; if (userId.HasValue) { Info info = pbfNode.info; userId = node.UserId; int num = (int)userId.Value; info.uid = num; } else { pbfNode.info.uid = 0; } pbfNode.info.user_sid = Encoder.EncodeString(block, reverseStringTable, node.UserName); pbfNode.info.version = !node.Version.HasValue ? 0 : (int)node.Version.Value; pbfNode.lat = Encoder.EncodeLatLon(node.Latitude.Value, block.lat_offset, (long)block.granularity); pbfNode.lon = Encoder.EncodeLatLon(node.Longitude.Value, block.lon_offset, (long)block.granularity); if (node.Tags != null) { foreach (Tag tag in node.Tags) { pbfNode.keys.Add((uint)Encoder.EncodeString(block, reverseStringTable, tag.Key)); pbfNode.vals.Add((uint)Encoder.EncodeString(block, reverseStringTable, tag.Value)); } } else { pbfNode.keys.Clear(); pbfNode.vals.Clear(); } return(pbfNode); }
public static Node EncodeNode(PrimitiveBlock block, Dictionary <string, int> reverseStringTable, OsmSharp.Osm.Node node) { Node pbfNode = new Node(); Encoder.EncodeNode(block, reverseStringTable, pbfNode, node); return(pbfNode); }
public static OsmSharp.Osm.Node DecodeNode(PrimitiveBlock block, Node pbfNode, OsmSharp.Osm.Node node) { if (node.Tags != null) { node.Tags.Clear(); } if (node.Tags == null) { node.Tags = (TagsCollectionBase) new TagsCollection(); } node.ChangeSetId = new long?(pbfNode.info.changeset); node.Id = new long?(pbfNode.id); node.Latitude = new double?(Encoder.DecodeLatLon(pbfNode.lat, block.lat_offset, (long)block.granularity)); node.Longitude = new double?(Encoder.DecodeLatLon(pbfNode.lon, block.lon_offset, (long)block.granularity)); for (int index = 0; index < pbfNode.keys.Count; ++index) { node.Tags.Add(new Tag() { Key = Encoding.UTF8.GetString(block.stringtable.s[(int)pbfNode.keys[index]]), Value = Encoding.UTF8.GetString(block.stringtable.s[(int)pbfNode.vals[index]]) }); } if (pbfNode.info != null) { node.TimeStamp = new DateTime?(Encoder.DecodeTimestamp(pbfNode.info.timestamp, (long)block.date_granularity)); node.Visible = new bool?(true); node.Version = new ulong?((ulong)(uint)pbfNode.info.version); node.UserId = new long?((long)pbfNode.info.uid); node.UserName = (string)null; if (block.stringtable != null) { node.UserName = Encoding.UTF8.GetString(block.stringtable.s[pbfNode.info.user_sid]); } node.Version = new ulong?((ulong)pbfNode.info.version); } node.Visible = new bool?(true); return(node); }