/// <summary> /// Converts an API v6 xml node to a SimpleNode object. /// </summary> /// <param name="xml_node"></param> /// <returns></returns> private Node Convertv6XmlNode(Osm.Xml.v0_6.node xml_node) { Node node = new Node(); node.Id = xml_node.id; node.Latitude = xml_node.lat; node.Longitude = xml_node.lon; if (xml_node.tag != null) { node.Tags = new SimpleTagsCollection(); foreach (Osm.Xml.v0_6.tag xml_tag in xml_node.tag) { node.Tags.Add(xml_tag.k, xml_tag.v); } } node.ChangeSetId = xml_node.changeset; node.TimeStamp = xml_node.timestamp; node.UserName = xml_node.user; node.UserId = xml_node.uid; node.Version = xml_node.version; node.Visible = xml_node.visible; return(node); }
/// <summary> /// Returns the node with the given id. /// </summary> /// <param name="id"></param> /// <returns></returns> public Node NodeGet(long id) { string response = this.DoApiCall(false, string.Format( "/api/0.6/node/{0}", id), Method.GET, null); if (response != null && response.Trim().Length > 0) { XmlReaderSource xml_source = new XmlReaderSource(XmlReader.Create(new StringReader(response))); OsmDocument osm = new OsmDocument(xml_source); Osm.Xml.v0_6.node xml_node = (osm.Osm as OsmSharp.Osm.Xml.v0_6.osm).node[0]; return(this.Convertv6XmlNode(xml_node)); } return(null); }
internal static Node ConvertToSimple(Osm.Xml.v0_6.node nd) { Node node = new Node(); // set id if (nd.idSpecified) { node.Id = nd.id; } // set changeset. if (nd.changesetSpecified) { node.ChangeSetId = nd.changeset; } // set visible. if (nd.visibleSpecified) { node.Visible = nd.visible; } else { // if visible is not specified it is default true. node.Visible = true; } // set timestamp. if (nd.timestampSpecified) { node.TimeStamp = nd.timestamp; } // set latitude. if (nd.latSpecified) { node.Latitude = nd.lat; } // set longitude. if (nd.lonSpecified) { node.Longitude = nd.lon; } // set uid if (nd.uidSpecified) { node.UserId = nd.uid; } // set version if (nd.versionSpecified) { node.Version = nd.version; } // set user node.UserName = nd.user; // set tags. node.Tags = XmlSimpleConverter.ConvertToTags(nd.tag); return(node); }