/// <summary> /// Adds a way to this target. /// </summary> /// <param name="simpleWay"></param> public override void AddWay(Way simpleWay) { var wa = new OsmSharp.Osm.Xml.v0_6.way(); wa.idSpecified = false; if (simpleWay.Id.HasValue) { wa.idSpecified = true; wa.id = simpleWay.Id.Value; } // set changeset. wa.changesetSpecified = false; if (simpleWay.ChangeSetId.HasValue) { wa.changeset = simpleWay.ChangeSetId.Value; wa.changesetSpecified = true; } // set visible. wa.visibleSpecified = false; if (simpleWay.Visible.HasValue) { wa.visible = simpleWay.Visible.Value; wa.visibleSpecified = true; } // set timestamp. wa.timestampSpecified = false; if (simpleWay.TimeStamp.HasValue) { wa.timestamp = simpleWay.TimeStamp.Value; wa.timestampSpecified = true; } // set uid wa.uidSpecified = false; if (simpleWay.UserId.HasValue) { wa.uid = simpleWay.UserId.Value; wa.uidSpecified = true; } // set user wa.user = simpleWay.UserName; // set tags. wa.tag = this.ConvertToXmlTags(simpleWay.Tags); // set nodes. if (simpleWay.Nodes != null) { wa.nd = new OsmSharp.Osm.Xml.v0_6.nd[simpleWay.Nodes.Count]; for (int idx = 0; idx < simpleWay.Nodes.Count; idx++) { var nd = new OsmSharp.Osm.Xml.v0_6.nd(); nd.refSpecified = true; nd.@ref = simpleWay.Nodes[idx]; wa.nd[idx] = nd; } } // set version. if (simpleWay.Version.HasValue) { wa.version = simpleWay.Version.Value; wa.versionSpecified = true; } // serialize way. _serWay.Serialize(_writer, wa); _writer.Flush(); _textWriter.Write(_textWriter.NewLine); }
/// <summary> /// Adds a way to this target. /// </summary> /// <param name="simpleWay"></param> public override void AddWay(Way simpleWay) { var wa = new OsmSharp.Osm.Xml.v0_6.way(); wa.idSpecified = false; if (simpleWay.Id.HasValue) { wa.idSpecified = true; wa.id = simpleWay.Id.Value; } // set changeset. wa.changesetSpecified = false; if (simpleWay.ChangeSetId.HasValue) { wa.changeset = simpleWay.ChangeSetId.Value; wa.changesetSpecified = true; } // set visible. wa.visibleSpecified = false; if (simpleWay.Visible.HasValue) { wa.visible = simpleWay.Visible.Value; wa.visibleSpecified = true; } // set timestamp. wa.timestampSpecified = false; if (simpleWay.TimeStamp.HasValue) { wa.timestamp = simpleWay.TimeStamp.Value; wa.timestampSpecified = true; } // set uid wa.uidSpecified = false; if (simpleWay.UserId.HasValue) { wa.uid = simpleWay.UserId.Value; wa.uidSpecified = true; } // set user wa.user = simpleWay.UserName; // set tags. wa.tag = this.ConvertToXmlTags(simpleWay.Tags); // set nodes. if (simpleWay.Nodes != null) { wa.nd = new OsmSharp.Osm.Xml.v0_6.nd[simpleWay.Nodes.Count]; for (int idx = 0; idx < simpleWay.Nodes.Count; idx++) { var nd = new OsmSharp.Osm.Xml.v0_6.nd(); nd.refSpecified = true; nd.@ref = simpleWay.Nodes[idx]; wa.nd[idx] = nd; } } // set version. if (simpleWay.Version.HasValue) { wa.version = simpleWay.Version.Value; wa.versionSpecified = true; } XmlSerializerNamespaces emptyNamespace = new XmlSerializerNamespaces(); emptyNamespace.Add(String.Empty, String.Empty); // serialize node. var memoryStream = new MemoryStream(); XmlWriter writer = XmlWriter.Create(memoryStream, _settings); var serWay = new XmlSerializer(typeof(Osm.Xml.v0_6.way), string.Empty); serWay.Serialize(writer, wa, emptyNamespace); memoryStream.WriteTo(_stream); _stream.Flush(); _streamWriter.WriteLine(); _streamWriter.Flush(); }