Example #1
0
        /// <summary>
        /// Converts a domain model way to an Xml way.
        /// </summary>
        /// <param name="way"></param>
        /// <returns></returns>
        public static way ConvertTo(this OsmSharp.Osm.Way way)
        {
            way xmlWay = new way();

            // set the changeset.
            if (way.ChangeSetId.HasValue)
            {
                xmlWay.changeset          = way.ChangeSetId.Value;
                xmlWay.changesetSpecified = true;
            }

            // set the id.
            if (way.Id.HasValue)
            {
                xmlWay.id          = way.Id.Value;
                xmlWay.idSpecified = true;
            }
            else
            {
                xmlWay.idSpecified = false;
            }

            if (way.Tags != null)
            {
                xmlWay.tag = new tag[way.Tags.Count];
                int idx = 0;
                foreach (var tag in way.Tags)
                {
                    var t = new tag();
                    t.k             = tag.Key;
                    t.v             = tag.Value;
                    xmlWay.tag[idx] = t;
                    idx++;
                }
            }

            // set the timestamp.
            if (way.TimeStamp.HasValue)
            {
                xmlWay.timestamp          = way.TimeStamp.Value;
                xmlWay.timestampSpecified = true;
            }

            // set the user data.
            if (way.UserId.HasValue)
            {
                xmlWay.uid          = way.UserId.Value;
                xmlWay.uidSpecified = true;
            }
            xmlWay.user = xmlWay.user;

            // set the version.
            if (way.Version.HasValue)
            {
                xmlWay.version          = (ulong)way.Version.Value;
                xmlWay.versionSpecified = true;
            }

            // set the visible.
            if (way.Visible.HasValue)
            {
                xmlWay.visible          = way.Visible.Value;
                xmlWay.visibleSpecified = true;
            }
            else
            {
                xmlWay.visibleSpecified = false;
            }

            // set the way-specific properties.
            xmlWay.nd = new nd[way.Nodes.Count];
            for (int i = 0; i < way.Nodes.Count; i++)
            {
                var n = new nd();
                n.@ref         = way.Nodes[i];
                n.refSpecified = true;
                xmlWay.nd[i]   = n;
            }

            return(xmlWay);
        }
Example #2
0
        /// <summary>
        /// Converts a domain model relation to an Xml relation.
        /// </summary>
        /// <returns></returns>
        public static relation ConvertTo(this OsmSharp.Osm.Relation relation)
        {
            relation xmlRelation = new relation();

            // set the changeset.
            if (relation.ChangeSetId.HasValue)
            {
                xmlRelation.changeset          = relation.ChangeSetId.Value;
                xmlRelation.changesetSpecified = true;
            }

            // set the id.
            if (relation.Id.HasValue)
            {
                xmlRelation.id          = relation.Id.Value;
                xmlRelation.idSpecified = true;
            }
            else
            {
                xmlRelation.idSpecified = false;
            }

            if (relation.Tags != null)
            {
                xmlRelation.tag = new tag[relation.Tags.Count];
                int idx = 0;
                foreach (var tag in relation.Tags)
                {
                    tag t = new tag();
                    t.k = tag.Key;
                    t.v = tag.Value;
                    xmlRelation.tag[idx] = t;
                    idx++;
                }
            }

            // set the timestamp.
            if (relation.TimeStamp.HasValue)
            {
                xmlRelation.timestamp          = relation.TimeStamp.Value;
                xmlRelation.timestampSpecified = true;
            }

            // set the user data.
            if (relation.UserId.HasValue)
            {
                xmlRelation.uid          = relation.UserId.Value;
                xmlRelation.uidSpecified = true;
            }
            xmlRelation.user = xmlRelation.user;

            // set the version.
            if (relation.Version.HasValue)
            {
                xmlRelation.version          = (ulong)relation.Version.Value;
                xmlRelation.versionSpecified = true;
            }

            // set the visible.
            if (relation.Visible.HasValue)
            {
                xmlRelation.visible          = relation.Visible.Value;
                xmlRelation.visibleSpecified = true;
            }
            else
            {
                xmlRelation.visibleSpecified = false;
            }

            // set the way-specific properties.
            xmlRelation.member = new member[relation.Members.Count];
            for (int i = 0; i < relation.Members.Count; i++)
            {
                var member = relation.Members[i];
                var m      = new member();

                if (member.MemberType.HasValue)
                {
                    switch (member.MemberType.Value)
                    {
                    case OsmGeoType.Node:
                        m.type          = memberType.node;
                        m.typeSpecified = true;
                        break;

                    case OsmGeoType.Relation:
                        m.type          = memberType.relation;
                        m.typeSpecified = true;
                        break;

                    case OsmGeoType.Way:
                        m.type          = memberType.way;
                        m.typeSpecified = true;
                        break;
                    }
                }
                else
                {
                    m.typeSpecified = false;
                }

                if (member.MemberId.HasValue)
                {
                    m.@ref         = member.MemberId.Value;
                    m.refSpecified = true;
                }
                else
                {
                    m.refSpecified = false;
                }
                m.role = member.MemberRole;

                xmlRelation.member[i] = m;
            }

            return(xmlRelation);
        }
Example #3
0
        /// <summary>
        /// Converts a domain model way to an Xml way.
        /// </summary>
        /// <param name="dom_obj"></param>
        /// <returns></returns>
        public static way ConvertTo(this OsmSharp.Osm.Way dom_obj)
        {
            way xml_obj = new way();

            // set the changeset.
            if (dom_obj.ChangeSetId.HasValue)
            {
                xml_obj.changeset          = dom_obj.ChangeSetId.Value;
                xml_obj.changesetSpecified = true;
            }

            // set the id.
            if (dom_obj.Id.HasValue)
            {
                xml_obj.id          = dom_obj.Id.Value;
                xml_obj.idSpecified = true;
            }
            else
            {
                xml_obj.idSpecified = false;
            }

            if (dom_obj.Tags != null)
            {
                xml_obj.tag = new tag[dom_obj.Tags.Count];
                int idx = 0;
                foreach (var tag in dom_obj.Tags)
                {
                    tag t = new tag();
                    t.k = tag.Key;
                    t.v = tag.Value;
                    xml_obj.tag[idx] = t;
                    idx++;
                }
            }

            // set the timestamp.
            if (dom_obj.TimeStamp.HasValue)
            {
                xml_obj.timestamp          = dom_obj.TimeStamp.Value;
                xml_obj.timestampSpecified = true;
            }

            // set the user data.
            if (dom_obj.UserId.HasValue)
            {
                xml_obj.uid          = dom_obj.UserId.Value;
                xml_obj.uidSpecified = true;
            }
            xml_obj.user = xml_obj.user;

            // set the version.
            if (dom_obj.Version.HasValue)
            {
                xml_obj.version          = (ulong)dom_obj.Version.Value;
                xml_obj.versionSpecified = true;
            }

            // set the visible.
            if (dom_obj.Visible.HasValue)
            {
                xml_obj.visible          = dom_obj.Visible.Value;
                xml_obj.visibleSpecified = true;
            }
            else
            {
                xml_obj.visibleSpecified = false;
            }

            // set the way-specific properties.
            xml_obj.nd = new nd[dom_obj.Nodes.Count];
            for (int idx = 0; idx < dom_obj.Nodes.Count; idx++)
            {
                nd n = new nd();
                n.@ref          = dom_obj.Nodes[idx];
                n.refSpecified  = true;
                xml_obj.nd[idx] = n;
            }

            return(xml_obj);
        }
Example #4
0
        /// <summary>
        /// Converts an Xml node to an Osm domain model node.
        /// </summary>
        /// <returns></returns>
        public static node ConvertTo(this OsmSharp.Osm.Node node)
        {
            var xmlNode = new node();

            // set the changeset.
            if (node.ChangeSetId.HasValue)
            {
                xmlNode.changeset          = node.ChangeSetId.Value;
                xmlNode.changesetSpecified = true;
            }

            // set the id.
            if (node.Id.HasValue)
            {
                xmlNode.id          = node.Id.Value;
                xmlNode.idSpecified = true;
            }

            if (node.Tags != null)
            {
                xmlNode.tag = new tag[node.Tags.Count];
                int idx = 0;
                foreach (var tag in node.Tags)
                {
                    var t = new tag();
                    t.k = tag.Key;
                    t.v = tag.Value;
                    xmlNode.tag[idx] = t;
                    idx++;
                }
            }

            // set the timestamp.
            if (node.TimeStamp.HasValue)
            {
                xmlNode.timestamp          = node.TimeStamp.Value;
                xmlNode.timestampSpecified = true;
            }

            // set the user data.
            if (node.UserId.HasValue)
            {
                xmlNode.uid          = node.UserId.Value;
                xmlNode.uidSpecified = true;
            }
            xmlNode.user = xmlNode.user;

            // set the version.
            if (node.Version.HasValue)
            {
                xmlNode.version          = (ulong)node.Version.Value;
                xmlNode.versionSpecified = true;
            }

            // set the visible.
            if (node.Visible.HasValue)
            {
                xmlNode.visible          = node.Visible.Value;
                xmlNode.visibleSpecified = true;
            }

            // set the node-specific properties.
            if (node.Latitude.HasValue)
            {
                xmlNode.lat          = node.Latitude.Value;
                xmlNode.latSpecified = true;
            }
            if (node.Longitude.HasValue)
            {
                xmlNode.lon          = node.Longitude.Value;
                xmlNode.lonSpecified = true;
            }

            return(xmlNode);
        }
Example #5
0
        /// <summary>
        /// Converts a domain model relation to an Xml relation.
        /// </summary>
        /// <param name="dom_obj"></param>
        /// <returns></returns>
        public static relation ConvertTo(this OsmSharp.Osm.Relation dom_obj)
        {
            relation xml_obj = new relation();

            // set the changeset.
            if (dom_obj.ChangeSetId.HasValue)
            {
                xml_obj.changeset = dom_obj.ChangeSetId.Value;
                xml_obj.changesetSpecified = true;
            }

            // set the id.
            if (dom_obj.Id.HasValue)
            {
                xml_obj.id = dom_obj.Id.Value;
                xml_obj.idSpecified = true;
            }
            else
            {
                xml_obj.idSpecified = false;
            }

            if (dom_obj.Tags != null)
            {
                xml_obj.tag = new tag[dom_obj.Tags.Count];
                int idx = 0;
                foreach (var tag in dom_obj.Tags)
                {
                    tag t = new tag();
                    t.k = tag.Key;
                    t.v = tag.Value;
                    xml_obj.tag[idx] = t;
                    idx++;
                }
            }

            // set the timestamp.
            if (dom_obj.TimeStamp.HasValue)
            {
                xml_obj.timestamp = dom_obj.TimeStamp.Value;
                xml_obj.timestampSpecified = true;
            }

            // set the user data.
            if (dom_obj.UserId.HasValue)
            {
                xml_obj.uid = dom_obj.UserId.Value;
                xml_obj.uidSpecified = true;
            }
            xml_obj.user = xml_obj.user;

            // set the version.
            if (dom_obj.Version.HasValue)
            {
                xml_obj.version = (ulong)dom_obj.Version.Value;
                xml_obj.versionSpecified = true;
            }

            // set the visible.
            if (dom_obj.Visible.HasValue)
            {
                xml_obj.visible = dom_obj.Visible.Value;
                xml_obj.visibleSpecified = true;
            }
            else
            {
                xml_obj.visibleSpecified = false;
            }

            // set the way-specific properties.
            xml_obj.member = new member[dom_obj.Members.Count];
            for (int idx = 0; idx < dom_obj.Members.Count; idx++)
            {
                RelationMember dom_member = dom_obj.Members[idx];
                member m = new member();

                if (dom_member.MemberType.HasValue)
                {
                    switch (dom_member.MemberType.Value)
                    {
                        case OsmGeoType.Node:
                            m.type = memberType.node;
                            m.typeSpecified = true;
                            break;
                        case OsmGeoType.Relation:
                            m.type = memberType.relation;
                            m.typeSpecified = true;
                            break;
                        case OsmGeoType.Way:
                            m.type = memberType.way;
                            m.typeSpecified = true;
                            break;
                    }
                }
                else
                {
                    m.typeSpecified = false;
                }

                if (dom_member.MemberId.HasValue)
                {
                    m.@ref = dom_member.MemberId.Value;
                    m.refSpecified = true;
                }
                else
                {
                    m.refSpecified = false;
                }
                m.role = dom_member.MemberRole;

                xml_obj.member[idx] = m;
            }

            return xml_obj;
        }
Example #6
0
        ///// <summary>
        ///// Converts an domain model changeset to and Xml changeset.
        ///// </summary>
        ///// <param name="changeset"></param>
        ///// <returns></returns>
        //public static changeset ConvertTo(this ChangeSet changeset)
        //{
        //    throw new NotImplementedException();
        //}

        ///// <summary>
        ///// Converts a domain model relation to an Xml relation.
        ///// </summary>
        ///// <param name="dom_obj"></param>
        ///// <returns></returns>
        //public static relation ConvertTo(this SimpleRelation dom_obj)
        //{
        //    relation xml_obj = new relation();

        //    // set the changeset.
        //    if (dom_obj.ChangeSetId.HasValue)
        //    {
        //        xml_obj.changeset = dom_obj.ChangeSetId.Value;
        //        xml_obj.changesetSpecified = true;
        //    }

        //    // set the id.
        //    if (dom_obj.Id.HasValue)
        //    {
        //        xml_obj.id = dom_obj.Id.Value;
        //        xml_obj.idSpecified = true;
        //    }
        //    else
        //    {
        //        xml_obj.idSpecified = false;
        //    }

        //    if (dom_obj.Tags != null)
        //    {
        //        xml_obj.tag = new tag[dom_obj.Tags.Count];
        //        int idx = 0;
        //        foreach (var tag in dom_obj.Tags)
        //        {
        //            tag t = new tag();
        //            t.k = tag.Key;
        //            t.v = tag.Value;
        //            xml_obj.tag[idx] = t;
        //            idx++;
        //        }
        //    }

        //    // set the timestamp.
        //    if (dom_obj.TimeStamp.HasValue)
        //    {
        //        xml_obj.timestamp = dom_obj.TimeStamp.Value;
        //        xml_obj.timestampSpecified = true;
        //    }

        //    // set the user data.
        //    if (dom_obj.UserId.HasValue)
        //    {
        //        xml_obj.uid = dom_obj.UserId.Value;
        //        xml_obj.uidSpecified = true;
        //    }
        //    xml_obj.user = xml_obj.user;

        //    // set the version.
        //    if (dom_obj.Version.HasValue)
        //    {
        //        xml_obj.version = (ulong)dom_obj.Version.Value;
        //        xml_obj.versionSpecified = true;
        //    }

        //    // set the visible.
        //    if (dom_obj.Visible.HasValue)
        //    {
        //        xml_obj.visible = dom_obj.Visible.Value;
        //        xml_obj.visibleSpecified = true;
        //    }
        //    else
        //    {
        //        xml_obj.visibleSpecified = false;
        //    }

        //    // set the way-specific properties.
        //    xml_obj.member = new member[dom_obj.Members.Count];
        //    for (int idx = 0; idx < dom_obj.Members.Count; idx++)
        //    {
        //        RelationMember dom_member = dom_obj.Members[idx];
        //        member m = new member();

        //        switch(dom_member.Member.Type)
        //        {
        //            case OsmType.Node:
        //                m.type = memberType.node;
        //                m.typeSpecified = true;
        //                break;
        //            case OsmType.Relation:
        //                m.type = memberType.relation;
        //                m.typeSpecified = true;
        //                break;
        //            case OsmType.Way:
        //                m.type = memberType.way;
        //                m.typeSpecified = true;
        //                break;
        //        }

        //        m.@ref = dom_member.Member.Id;
        //        m.refSpecified = true;
        //        m.role = dom_member.Role;

        //        xml_obj.member[idx] = m;
        //    }

        //    return xml_obj;
        //}

        ///// <summary>
        ///// Converts a domain model way to an Xml way.
        ///// </summary>
        ///// <param name="dom_obj"></param>
        ///// <returns></returns>
        //public static way ConvertTo(this Way dom_obj)
        //{
        //    way xml_obj = new way();

        //    // set the changeset.
        //    if (dom_obj.ChangeSetId.HasValue)
        //    {
        //        xml_obj.changeset = dom_obj.ChangeSetId.Value;
        //        xml_obj.changesetSpecified = true;
        //    }

        //    // set the id.
        //    xml_obj.id = dom_obj.Id;
        //    xml_obj.idSpecified = true;

        //    if (dom_obj.Tags != null)
        //    {
        //        xml_obj.tag = new tag[dom_obj.Tags.Count];
        //        int idx = 0;
        //        foreach (var tag in dom_obj.Tags)
        //        {
        //            tag t = new tag();
        //            t.k = tag.Key;
        //            t.v = tag.Value;
        //            xml_obj.tag[idx] = t;
        //            idx++;
        //        }
        //    }

        //    // set the timestamp.
        //    if (dom_obj.TimeStamp.HasValue)
        //    {
        //        xml_obj.timestamp = dom_obj.TimeStamp.Value;
        //        xml_obj.timestampSpecified = true;
        //    }

        //    // set the user data.
        //    if (dom_obj.UserId.HasValue)
        //    {
        //        xml_obj.uid = dom_obj.UserId.Value;
        //        xml_obj.uidSpecified = true;
        //    }
        //    xml_obj.user = xml_obj.user;

        //    // set the version.
        //    if (dom_obj.Version.HasValue)
        //    {
        //        xml_obj.version = (ulong)dom_obj.Version.Value;
        //        xml_obj.versionSpecified = true;
        //    }

        //    // set the visible.
        //    xml_obj.visible = dom_obj.Visible;
        //    xml_obj.visibleSpecified = true;

        //    // set the way-specific properties.
        //    xml_obj.nd = new nd[dom_obj.Nodes.Count];
        //    for(int idx = 0;idx < dom_obj.Nodes.Count;idx++)
        //    {
        //        nd n = new nd();
        //        n.@ref =  dom_obj.Nodes[idx].Id;
        //        n.refSpecified = true;
        //        xml_obj.nd[idx] = n;
        //    }

        //    return xml_obj;
        //}

        ///// <summary>
        ///// Converts an Xml node to an Osm domain model node.
        ///// </summary>
        ///// <param name="dom_obj"></param>
        ///// <returns></returns>
        //public static node ConvertTo(this Node dom_obj)
        //{
        //    node xml_obj = new node();

        //    // set the changeset.
        //    if(dom_obj.ChangeSetId.HasValue)
        //    {
        //        xml_obj.changeset = dom_obj.ChangeSetId.Value;
        //        xml_obj.changesetSpecified = true;
        //    }

        //    // set the id.
        //    xml_obj.id = dom_obj.Id;
        //    xml_obj.idSpecified = true;

        //    if (dom_obj.Tags != null)
        //    {
        //        xml_obj.tag = new tag[dom_obj.Tags.Count];
        //        int idx = 0;
        //        foreach (var tag in dom_obj.Tags)
        //        {
        //            tag t = new tag();
        //            t.k = tag.Key;
        //            t.v = tag.Value;
        //            xml_obj.tag[idx] = t;
        //            idx++;
        //        }
        //    }

        //    // set the timestamp.
        //    if (dom_obj.TimeStamp.HasValue)
        //    {
        //        xml_obj.timestamp = dom_obj.TimeStamp.Value;
        //        xml_obj.timestampSpecified = true;
        //    }

        //    // set the user data.
        //    if (dom_obj.UserId.HasValue)
        //    {
        //        xml_obj.uid = dom_obj.UserId.Value;
        //        xml_obj.uidSpecified = true;
        //    }
        //    xml_obj.user = xml_obj.user;

        //    // set the version.
        //    if (dom_obj.Version.HasValue)
        //    {
        //        xml_obj.version = (ulong)dom_obj.Version.Value;
        //        xml_obj.versionSpecified = true;
        //    }

        //    // set the visible.
        //    xml_obj.visible = dom_obj.Visible;
        //    xml_obj.visibleSpecified = true;

        //    // set the node-specific properties.
        //    xml_obj.lat = dom_obj.Coordinate.Latitude;
        //    xml_obj.latSpecified = true;
        //    xml_obj.lon = dom_obj.Coordinate.Longitude;
        //    xml_obj.lonSpecified = true;

        //    return xml_obj;
        //}

        /// <summary>
        /// Converts an Xml node to an Osm domain model node.
        /// </summary>
        /// <param name="dom_obj"></param>
        /// <returns></returns>
        public static node ConvertTo(this OsmSharp.Osm.Node dom_obj)
        {
            node xml_obj = new node();

            // set the changeset.
            if (dom_obj.ChangeSetId.HasValue)
            {
                xml_obj.changeset          = dom_obj.ChangeSetId.Value;
                xml_obj.changesetSpecified = true;
            }

            // set the id.
            if (dom_obj.Id.HasValue)
            {
                xml_obj.id          = dom_obj.Id.Value;
                xml_obj.idSpecified = true;
            }

            if (dom_obj.Tags != null)
            {
                xml_obj.tag = new tag[dom_obj.Tags.Count];
                int idx = 0;
                foreach (var tag in dom_obj.Tags)
                {
                    tag t = new tag();
                    t.k = tag.Key;
                    t.v = tag.Value;
                    xml_obj.tag[idx] = t;
                    idx++;
                }
            }

            // set the timestamp.
            if (dom_obj.TimeStamp.HasValue)
            {
                xml_obj.timestamp          = dom_obj.TimeStamp.Value;
                xml_obj.timestampSpecified = true;
            }

            // set the user data.
            if (dom_obj.UserId.HasValue)
            {
                xml_obj.uid          = dom_obj.UserId.Value;
                xml_obj.uidSpecified = true;
            }
            xml_obj.user = xml_obj.user;

            // set the version.
            if (dom_obj.Version.HasValue)
            {
                xml_obj.version          = (ulong)dom_obj.Version.Value;
                xml_obj.versionSpecified = true;
            }

            // set the visible.
            xml_obj.visible          = dom_obj.Visible.Value;
            xml_obj.visibleSpecified = true;

            // set the node-specific properties.
            xml_obj.lat          = dom_obj.Latitude.Value;
            xml_obj.latSpecified = true;
            xml_obj.lon          = dom_obj.Longitude.Value;
            xml_obj.lonSpecified = true;

            return(xml_obj);
        }
Example #7
0
        ///// <summary>
        ///// Converts an domain model changeset to and Xml changeset.
        ///// </summary>
        ///// <param name="changeset"></param>
        ///// <returns></returns>
        //public static changeset ConvertTo(this ChangeSet changeset)
        //{
        //    throw new NotImplementedException();
        //}
        ///// <summary>
        ///// Converts a domain model relation to an Xml relation.
        ///// </summary>
        ///// <param name="dom_obj"></param>
        ///// <returns></returns>
        //public static relation ConvertTo(this SimpleRelation dom_obj)
        //{
        //    relation xml_obj = new relation();
        //    // set the changeset.
        //    if (dom_obj.ChangeSetId.HasValue)
        //    {
        //        xml_obj.changeset = dom_obj.ChangeSetId.Value;
        //        xml_obj.changesetSpecified = true;
        //    }
        //    // set the id.
        //    if (dom_obj.Id.HasValue)
        //    {
        //        xml_obj.id = dom_obj.Id.Value;
        //        xml_obj.idSpecified = true;
        //    }
        //    else
        //    {
        //        xml_obj.idSpecified = false;
        //    }
        //    if (dom_obj.Tags != null)
        //    {
        //        xml_obj.tag = new tag[dom_obj.Tags.Count];
        //        int idx = 0;
        //        foreach (var tag in dom_obj.Tags)
        //        {
        //            tag t = new tag();
        //            t.k = tag.Key;
        //            t.v = tag.Value;
        //            xml_obj.tag[idx] = t;
        //            idx++;
        //        }
        //    }
        //    // set the timestamp.
        //    if (dom_obj.TimeStamp.HasValue)
        //    {
        //        xml_obj.timestamp = dom_obj.TimeStamp.Value;
        //        xml_obj.timestampSpecified = true;
        //    }
        //    // set the user data.
        //    if (dom_obj.UserId.HasValue)
        //    {
        //        xml_obj.uid = dom_obj.UserId.Value;
        //        xml_obj.uidSpecified = true;
        //    }
        //    xml_obj.user = xml_obj.user;
        //    // set the version.
        //    if (dom_obj.Version.HasValue)
        //    {
        //        xml_obj.version = (ulong)dom_obj.Version.Value;
        //        xml_obj.versionSpecified = true;
        //    }
        //    // set the visible.
        //    if (dom_obj.Visible.HasValue)
        //    {
        //        xml_obj.visible = dom_obj.Visible.Value;
        //        xml_obj.visibleSpecified = true;
        //    }
        //    else
        //    {
        //        xml_obj.visibleSpecified = false;
        //    }
        //    // set the way-specific properties.
        //    xml_obj.member = new member[dom_obj.Members.Count];
        //    for (int idx = 0; idx < dom_obj.Members.Count; idx++)
        //    {
        //        RelationMember dom_member = dom_obj.Members[idx];
        //        member m = new member();
        //        switch(dom_member.Member.Type)
        //        {
        //            case OsmType.Node:
        //                m.type = memberType.node;
        //                m.typeSpecified = true;
        //                break;
        //            case OsmType.Relation:
        //                m.type = memberType.relation;
        //                m.typeSpecified = true;
        //                break;
        //            case OsmType.Way:
        //                m.type = memberType.way;
        //                m.typeSpecified = true;
        //                break;
        //        }
        //        m.@ref = dom_member.Member.Id;
        //        m.refSpecified = true;
        //        m.role = dom_member.Role;
        //        xml_obj.member[idx] = m;
        //    }
        //    return xml_obj;
        //}
        ///// <summary>
        ///// Converts a domain model way to an Xml way.
        ///// </summary>
        ///// <param name="dom_obj"></param>
        ///// <returns></returns>
        //public static way ConvertTo(this Way dom_obj)
        //{
        //    way xml_obj = new way();
        //    // set the changeset.
        //    if (dom_obj.ChangeSetId.HasValue)
        //    {
        //        xml_obj.changeset = dom_obj.ChangeSetId.Value;
        //        xml_obj.changesetSpecified = true;
        //    }
        //    // set the id.
        //    xml_obj.id = dom_obj.Id;
        //    xml_obj.idSpecified = true;
        //    if (dom_obj.Tags != null)
        //    {
        //        xml_obj.tag = new tag[dom_obj.Tags.Count];
        //        int idx = 0;
        //        foreach (var tag in dom_obj.Tags)
        //        {
        //            tag t = new tag();
        //            t.k = tag.Key;
        //            t.v = tag.Value;
        //            xml_obj.tag[idx] = t;
        //            idx++;
        //        }
        //    }
        //    // set the timestamp.
        //    if (dom_obj.TimeStamp.HasValue)
        //    {
        //        xml_obj.timestamp = dom_obj.TimeStamp.Value;
        //        xml_obj.timestampSpecified = true;
        //    }
        //    // set the user data.
        //    if (dom_obj.UserId.HasValue)
        //    {
        //        xml_obj.uid = dom_obj.UserId.Value;
        //        xml_obj.uidSpecified = true;
        //    }
        //    xml_obj.user = xml_obj.user;
        //    // set the version.
        //    if (dom_obj.Version.HasValue)
        //    {
        //        xml_obj.version = (ulong)dom_obj.Version.Value;
        //        xml_obj.versionSpecified = true;
        //    }
        //    // set the visible.
        //    xml_obj.visible = dom_obj.Visible;
        //    xml_obj.visibleSpecified = true;
        //    // set the way-specific properties.
        //    xml_obj.nd = new nd[dom_obj.Nodes.Count];
        //    for(int idx = 0;idx < dom_obj.Nodes.Count;idx++)
        //    {
        //        nd n = new nd();
        //        n.@ref =  dom_obj.Nodes[idx].Id;
        //        n.refSpecified = true;
        //        xml_obj.nd[idx] = n;
        //    }
        //    return xml_obj;
        //}
        ///// <summary>
        ///// Converts an Xml node to an Osm domain model node.
        ///// </summary>
        ///// <param name="dom_obj"></param>
        ///// <returns></returns>
        //public static node ConvertTo(this Node dom_obj)
        //{
        //    node xml_obj = new node();
        //    // set the changeset.
        //    if(dom_obj.ChangeSetId.HasValue)
        //    {
        //        xml_obj.changeset = dom_obj.ChangeSetId.Value;
        //        xml_obj.changesetSpecified = true;
        //    }
        //    // set the id.
        //    xml_obj.id = dom_obj.Id;
        //    xml_obj.idSpecified = true;
        //    if (dom_obj.Tags != null)
        //    {
        //        xml_obj.tag = new tag[dom_obj.Tags.Count];
        //        int idx = 0;
        //        foreach (var tag in dom_obj.Tags)
        //        {
        //            tag t = new tag();
        //            t.k = tag.Key;
        //            t.v = tag.Value;
        //            xml_obj.tag[idx] = t;
        //            idx++;
        //        }
        //    }
        //    // set the timestamp.
        //    if (dom_obj.TimeStamp.HasValue)
        //    {
        //        xml_obj.timestamp = dom_obj.TimeStamp.Value;
        //        xml_obj.timestampSpecified = true;
        //    }
        //    // set the user data.
        //    if (dom_obj.UserId.HasValue)
        //    {
        //        xml_obj.uid = dom_obj.UserId.Value;
        //        xml_obj.uidSpecified = true;
        //    }
        //    xml_obj.user = xml_obj.user;
        //    // set the version.
        //    if (dom_obj.Version.HasValue)
        //    {
        //        xml_obj.version = (ulong)dom_obj.Version.Value;
        //        xml_obj.versionSpecified = true;
        //    }
        //    // set the visible.
        //    xml_obj.visible = dom_obj.Visible;
        //    xml_obj.visibleSpecified = true;
        //    // set the node-specific properties.
        //    xml_obj.lat = dom_obj.Coordinate.Latitude;
        //    xml_obj.latSpecified = true;
        //    xml_obj.lon = dom_obj.Coordinate.Longitude;
        //    xml_obj.lonSpecified = true;
        //    return xml_obj;
        //}
        /// <summary>
        /// Converts an Xml node to an Osm domain model node.
        /// </summary>
        /// <param name="dom_obj"></param>
        /// <returns></returns>
        public static node ConvertTo(this OsmSharp.Osm.Node dom_obj)
        {
            node xml_obj = new node();

            // set the changeset.
            if (dom_obj.ChangeSetId.HasValue)
            {
                xml_obj.changeset = dom_obj.ChangeSetId.Value;
                xml_obj.changesetSpecified = true;
            }

            // set the id.
            if (dom_obj.Id.HasValue)
            {
                xml_obj.id = dom_obj.Id.Value;
                xml_obj.idSpecified = true;
            }

            if (dom_obj.Tags != null)
            {
                xml_obj.tag = new tag[dom_obj.Tags.Count];
                int idx = 0;
                foreach (var tag in dom_obj.Tags)
                {
                    tag t = new tag();
                    t.k = tag.Key;
                    t.v = tag.Value;
                    xml_obj.tag[idx] = t;
                    idx++;
                }
            }

            // set the timestamp.
            if (dom_obj.TimeStamp.HasValue)
            {
                xml_obj.timestamp = dom_obj.TimeStamp.Value;
                xml_obj.timestampSpecified = true;
            }

            // set the user data.
            if (dom_obj.UserId.HasValue)
            {
                xml_obj.uid = dom_obj.UserId.Value;
                xml_obj.uidSpecified = true;
            }
            xml_obj.user = xml_obj.user;

            // set the version.
            if (dom_obj.Version.HasValue)
            {
                xml_obj.version = (ulong)dom_obj.Version.Value;
                xml_obj.versionSpecified = true;
            }

            // set the visible.
            xml_obj.visible = dom_obj.Visible.Value;
            xml_obj.visibleSpecified = true;

            // set the node-specific properties.
            xml_obj.lat = dom_obj.Latitude.Value;
            xml_obj.latSpecified = true;
            xml_obj.lon = dom_obj.Longitude.Value;
            xml_obj.lonSpecified = true;

            return xml_obj;
        }
Example #8
0
        /// <summary>
        /// Converts a domain model way to an Xml way.
        /// </summary>
        /// <param name="dom_obj"></param>
        /// <returns></returns>
        public static way ConvertTo(this OsmSharp.Osm.Way dom_obj)
        {
            way xml_obj = new way();

            // set the changeset.
            if (dom_obj.ChangeSetId.HasValue)
            {
                xml_obj.changeset = dom_obj.ChangeSetId.Value;
                xml_obj.changesetSpecified = true;
            }

            // set the id.
            if (dom_obj.Id.HasValue)
            {
                xml_obj.id = dom_obj.Id.Value;
                xml_obj.idSpecified = true;
            }
            else
            {
                xml_obj.idSpecified = false;
            }

            if (dom_obj.Tags != null)
            {
                xml_obj.tag = new tag[dom_obj.Tags.Count];
                int idx = 0;
                foreach (var tag in dom_obj.Tags)
                {
                    tag t = new tag();
                    t.k = tag.Key;
                    t.v = tag.Value;
                    xml_obj.tag[idx] = t;
                    idx++;
                }
            }

            // set the timestamp.
            if (dom_obj.TimeStamp.HasValue)
            {
                xml_obj.timestamp = dom_obj.TimeStamp.Value;
                xml_obj.timestampSpecified = true;
            }

            // set the user data.
            if (dom_obj.UserId.HasValue)
            {
                xml_obj.uid = dom_obj.UserId.Value;
                xml_obj.uidSpecified = true;
            }
            xml_obj.user = xml_obj.user;

            // set the version.
            if (dom_obj.Version.HasValue)
            {
                xml_obj.version = (ulong)dom_obj.Version.Value;
                xml_obj.versionSpecified = true;
            }

            // set the visible.
            if (dom_obj.Visible.HasValue)
            {
                xml_obj.visible = dom_obj.Visible.Value;
                xml_obj.visibleSpecified = true;
            }
            else
            {
                xml_obj.visibleSpecified = false;
            }

            // set the way-specific properties.
            xml_obj.nd = new nd[dom_obj.Nodes.Count];
            for (int idx = 0; idx < dom_obj.Nodes.Count; idx++)
            {
                nd n = new nd();
                n.@ref = dom_obj.Nodes[idx];
                n.refSpecified = true;
                xml_obj.nd[idx] = n;
            }

            return xml_obj;
        }
Example #9
0
        /// <summary>
        /// Converts an Xml node to an Osm domain model node.
        /// </summary>
        /// <param name="dom_obj"></param>
        /// <returns></returns>
        public static node ConvertTo(this OsmSharp.Osm.Simple.SimpleNode dom_obj)
        {
            node xml_obj = new node();

            // set the changeset.
            if (dom_obj.ChangeSetId.HasValue)
            {
                xml_obj.changeset = dom_obj.ChangeSetId.Value;
                xml_obj.changesetSpecified = true;
            }

            // set the id.
            if (dom_obj.Id.HasValue)
            {
                xml_obj.id = dom_obj.Id.Value;
                xml_obj.idSpecified = true;
            }

            if (dom_obj.Tags != null)
            {
                xml_obj.tag = new tag[dom_obj.Tags.Count];
                IList<KeyValuePair<string, string>> tags_list = dom_obj.Tags.ToList<KeyValuePair<string, string>>();
                for (int idx = 0; idx < tags_list.Count; idx++)
                {
                    KeyValuePair<string, string> tag_pair = tags_list[idx];
                    tag t = new tag();
                    t.k = tag_pair.Key;
                    t.v = tag_pair.Value;
                    xml_obj.tag[idx] = t;
                }
            }

            // set the timestamp.
            if (dom_obj.TimeStamp.HasValue)
            {
                xml_obj.timestamp = dom_obj.TimeStamp.Value;
                xml_obj.timestampSpecified = true;
            }

            // set the user data.
            if (dom_obj.UserId.HasValue)
            {
                xml_obj.uid = dom_obj.UserId.Value;
                xml_obj.uidSpecified = true;
            }
            xml_obj.user = xml_obj.user;

            // set the version.
            if (dom_obj.Version.HasValue)
            {
                xml_obj.version = (ulong)dom_obj.Version.Value;
                xml_obj.versionSpecified = true;
            }

            // set the visible.
            xml_obj.visible = dom_obj.Visible.Value;
            xml_obj.visibleSpecified = true;

            // set the node-specific properties.
            xml_obj.lat = dom_obj.Latitude.Value;
            xml_obj.latSpecified = true;
            xml_obj.lon = dom_obj.Longitude.Value;
            xml_obj.lonSpecified = true;

            return xml_obj;
        }
Example #10
0
        /// <summary>
        /// Converts a domain model way to an Xml way.
        /// </summary>
        /// <param name="dom_obj"></param>
        /// <returns></returns>
        public static way ConvertTo(this Way dom_obj)
        {
            way xml_obj = new way();

            // set the changeset.
            if (dom_obj.ChangeSetId.HasValue)
            {
                xml_obj.changeset = dom_obj.ChangeSetId.Value;
                xml_obj.changesetSpecified = true;
            }

            // set the id.
            xml_obj.id = dom_obj.Id;
            xml_obj.idSpecified = true;

            if (dom_obj.Tags != null)
            {
                xml_obj.tag = new tag[dom_obj.Tags.Count];
                IList<KeyValuePair<string, string>> tags_list = dom_obj.Tags.ToList<KeyValuePair<string, string>>();
                for (int idx = 0; idx < tags_list.Count; idx++)
                {
                    KeyValuePair<string, string> tag_pair = tags_list[idx];
                    tag t = new tag();
                    t.k = tag_pair.Key;
                    t.v = tag_pair.Value;
                    xml_obj.tag[idx] = t;
                }
            }

            // set the timestamp.
            if (dom_obj.TimeStamp.HasValue)
            {
                xml_obj.timestamp = dom_obj.TimeStamp.Value;
                xml_obj.timestampSpecified = true;
            }

            // set the user data.
            if (dom_obj.UserId.HasValue)
            {
                xml_obj.uid = dom_obj.UserId.Value;
                xml_obj.uidSpecified = true;
            }
            xml_obj.user = xml_obj.user;

            // set the version.
            if (dom_obj.Version.HasValue)
            {
                xml_obj.version = (ulong)dom_obj.Version.Value;
                xml_obj.versionSpecified = true;
            }

            // set the visible.
            xml_obj.visible = dom_obj.Visible;
            xml_obj.visibleSpecified = true;

            // set the way-specific properties.
            xml_obj.nd = new nd[dom_obj.Nodes.Count];
            for(int idx = 0;idx < dom_obj.Nodes.Count;idx++)
            {
                nd n = new nd();
                n.@ref =  dom_obj.Nodes[idx].Id;
                n.refSpecified = true;
                xml_obj.nd[idx] = n;
            }

            return xml_obj;
        }
Example #11
0
        /// <summary>
        /// Converts a domain model relation to an Xml relation.
        /// </summary>
        /// <param name="dom_obj"></param>
        /// <returns></returns>
        public static relation ConvertTo(this Relation dom_obj)
        {
            relation xml_obj = new relation();

            // set the changeset.
            if (dom_obj.ChangeSetId.HasValue)
            {
                xml_obj.changeset = dom_obj.ChangeSetId.Value;
                xml_obj.changesetSpecified = true;
            }

            // set the id.
            xml_obj.id = dom_obj.Id;
            xml_obj.idSpecified = true;

            if (dom_obj.Tags != null)
            {
                xml_obj.tag = new tag[dom_obj.Tags.Count];
                IList<KeyValuePair<string, string>> tags_list = dom_obj.Tags.ToList<KeyValuePair<string, string>>();
                for (int idx = 0; idx < tags_list.Count; idx++)
                {
                    KeyValuePair<string, string> tag_pair = tags_list[idx];
                    tag t = new tag();
                    t.k = tag_pair.Key;
                    t.v = tag_pair.Value;
                    xml_obj.tag[idx] = t;
                }
            }

            // set the timestamp.
            if (dom_obj.TimeStamp.HasValue)
            {
                xml_obj.timestamp = dom_obj.TimeStamp.Value;
                xml_obj.timestampSpecified = true;
            }

            // set the user data.
            if (dom_obj.UserId.HasValue)
            {
                xml_obj.uid = dom_obj.UserId.Value;
                xml_obj.uidSpecified = true;
            }
            xml_obj.user = xml_obj.user;

            // set the version.
            if (dom_obj.Version.HasValue)
            {
                xml_obj.version = (ulong)dom_obj.Version.Value;
                xml_obj.versionSpecified = true;
            }

            // set the visible.
            xml_obj.visible = dom_obj.Visible;
            xml_obj.visibleSpecified = true;

            // set the way-specific properties.
            xml_obj.member = new member[dom_obj.Members.Count];
            for (int idx = 0; idx < dom_obj.Members.Count; idx++)
            {
                RelationMember dom_member = dom_obj.Members[idx];
                member m = new member();

                switch(dom_member.Member.Type)
                {
                    case OsmType.Node:
                        m.type = memberType.node;
                        m.typeSpecified = true;
                        break;
                    case OsmType.Relation:
                        m.type = memberType.relation;
                        m.typeSpecified = true;
                        break;
                    case OsmType.Way:
                        m.type = memberType.way;
                        m.typeSpecified = true;
                        break;
                }

                m.@ref = dom_member.Member.Id;
                m.refSpecified = true;
                m.role = dom_member.Role;

                xml_obj.member[idx] = m;
            }

            return xml_obj;
        }
Example #12
0
        /// <summary>
        /// Converts a domain model way to an Xml way.
        /// </summary>
        /// <param name="way"></param>
        /// <returns></returns>
        public static way ConvertTo(this OsmSharp.Osm.Way way)
        {
            way xmlWay = new way();

            // set the changeset.
            if (way.ChangeSetId.HasValue)
            {
                xmlWay.changeset = way.ChangeSetId.Value;
                xmlWay.changesetSpecified = true;
            }

            // set the id.
            if (way.Id.HasValue)
            {
                xmlWay.id = way.Id.Value;
                xmlWay.idSpecified = true;
            }
            else
            {
                xmlWay.idSpecified = false;
            }

            if (way.Tags != null)
            {
                xmlWay.tag = new tag[way.Tags.Count];
                int idx = 0;
                foreach (var tag in way.Tags)
                {
                    var t = new tag();
                    t.k = tag.Key;
                    t.v = tag.Value;
                    xmlWay.tag[idx] = t;
                    idx++;
                }
            }

            // set the timestamp.
            if (way.TimeStamp.HasValue)
            {
                xmlWay.timestamp = way.TimeStamp.Value;
                xmlWay.timestampSpecified = true;
            }

            // set the user data.
            if (way.UserId.HasValue)
            {
                xmlWay.uid = way.UserId.Value;
                xmlWay.uidSpecified = true;
            }
            xmlWay.user = xmlWay.user;

            // set the version.
            if (way.Version.HasValue)
            {
                xmlWay.version = (ulong)way.Version.Value;
                xmlWay.versionSpecified = true;
            }

            // set the visible.
            if (way.Visible.HasValue)
            {
                xmlWay.visible = way.Visible.Value;
                xmlWay.visibleSpecified = true;
            }
            else
            {
                xmlWay.visibleSpecified = false;
            }

            // set the way-specific properties.
            xmlWay.nd = new nd[way.Nodes.Count];
            for (int i = 0; i < way.Nodes.Count; i++)
            {
                var n = new nd();
                n.@ref = way.Nodes[i];
                n.refSpecified = true;
                xmlWay.nd[i] = n;
            }

            return xmlWay;
        }
Example #13
0
        /// <summary>
        /// Converts an Xml node to an Osm domain model node.
        /// </summary>
        /// <returns></returns>
        public static node ConvertTo(this OsmSharp.Osm.Node node)
        {
            var xmlNode = new node();

            // set the changeset.
            if (node.ChangeSetId.HasValue)
            {
                xmlNode.changeset = node.ChangeSetId.Value;
                xmlNode.changesetSpecified = true;
            }

            // set the id.
            if (node.Id.HasValue)
            {
                xmlNode.id = node.Id.Value;
                xmlNode.idSpecified = true;
            }

            if (node.Tags != null)
            {
                xmlNode.tag = new tag[node.Tags.Count];
                int idx = 0;
                foreach (var tag in node.Tags)
                {
                    var t = new tag();
                    t.k = tag.Key;
                    t.v = tag.Value;
                    xmlNode.tag[idx] = t;
                    idx++;
                }
            }

            // set the timestamp.
            if (node.TimeStamp.HasValue)
            {
                xmlNode.timestamp = node.TimeStamp.Value;
                xmlNode.timestampSpecified = true;
            }

            // set the user data.
            if (node.UserId.HasValue)
            {
                xmlNode.uid = node.UserId.Value;
                xmlNode.uidSpecified = true;
            }
            xmlNode.user = xmlNode.user;

            // set the version.
            if (node.Version.HasValue)
            {
                xmlNode.version = (ulong)node.Version.Value;
                xmlNode.versionSpecified = true;
            }

            // set the visible.
            if (node.Visible.HasValue)
            {
                xmlNode.visible = node.Visible.Value;
                xmlNode.visibleSpecified = true;
            }

            // set the node-specific properties.
            if (node.Latitude.HasValue)
            {
                xmlNode.lat = node.Latitude.Value;
                xmlNode.latSpecified = true;
            }
            if (node.Longitude.HasValue)
            {
                xmlNode.lon = node.Longitude.Value;
                xmlNode.lonSpecified = true;
            }

            return xmlNode;
        }