Ejemplo n.º 1
0
        internal static Way ConvertToSimple(way wa)
        {
            Way way = new Way();

            if (wa.idSpecified)
            {
                way.Id = new long?(wa.id);
            }
            if (wa.changesetSpecified)
            {
                way.ChangeSetId = new long?(wa.changeset);
            }
            if (wa.visibleSpecified)
            {
                way.Visible = new bool?(wa.visible);
            }
            else
            {
                way.Visible = new bool?(true);
            }
            if (wa.timestampSpecified)
            {
                way.TimeStamp = new DateTime?(wa.timestamp);
            }
            if (wa.uidSpecified)
            {
                way.UserId = new long?(wa.uid);
            }
            if (wa.versionSpecified)
            {
                way.Version = new ulong?(wa.version);
            }
            way.UserName = wa.user;
            way.Tags     = XmlSimpleConverter.ConvertToTags(wa.tag);
            if (wa.nd != null && wa.nd.Length != 0)
            {
                way.Nodes = new List <long>();
                for (int index = 0; index < wa.nd.Length; ++index)
                {
                    way.Nodes.Add(wa.nd[index].@ref);
                }
            }
            return(way);
        }
Ejemplo n.º 2
0
        internal static Node ConvertToSimple(node nd)
        {
            Node node = new Node();

            if (nd.idSpecified)
            {
                node.Id = new long?(nd.id);
            }
            if (nd.changesetSpecified)
            {
                node.ChangeSetId = new long?(nd.changeset);
            }
            if (nd.visibleSpecified)
            {
                node.Visible = new bool?(nd.visible);
            }
            else
            {
                node.Visible = new bool?(true);
            }
            if (nd.timestampSpecified)
            {
                node.TimeStamp = new DateTime?(nd.timestamp);
            }
            if (nd.latSpecified)
            {
                node.Latitude = new double?(nd.lat);
            }
            if (nd.lonSpecified)
            {
                node.Longitude = new double?(nd.lon);
            }
            if (nd.uidSpecified)
            {
                node.UserId = new long?(nd.uid);
            }
            if (nd.versionSpecified)
            {
                node.Version = new ulong?(nd.version);
            }
            node.UserName = nd.user;
            node.Tags     = XmlSimpleConverter.ConvertToTags(nd.tag);
            return(node);
        }
Ejemplo n.º 3
0
        internal static Relation ConvertToSimple(relation re)
        {
            Relation relation = new Relation();

            if (re.idSpecified)
            {
                relation.Id = new long?(re.id);
            }
            if (re.changesetSpecified)
            {
                relation.ChangeSetId = new long?(re.changeset);
            }
            if (re.visibleSpecified)
            {
                relation.Visible = new bool?(re.visible);
            }
            else
            {
                relation.Visible = new bool?(true);
            }
            if (re.timestampSpecified)
            {
                relation.TimeStamp = new DateTime?(re.timestamp);
            }
            if (re.uidSpecified)
            {
                relation.UserId = new long?(re.uid);
            }
            if (re.versionSpecified)
            {
                relation.Version = new ulong?(re.version);
            }
            relation.UserName = re.user;
            relation.Tags     = XmlSimpleConverter.ConvertToTags(re.tag);
            if (re.member != null && re.member.Length != 0)
            {
                relation.Members = new List <RelationMember>();
                for (int index = 0; index < re.member.Length; ++index)
                {
                    member         member         = re.member[index];
                    RelationMember relationMember = new RelationMember();
                    if (member.refSpecified)
                    {
                        relationMember.MemberId = new long?(member.@ref);
                    }
                    relationMember.MemberRole = member.role;
                    if (member.typeSpecified)
                    {
                        switch (member.type)
                        {
                        case memberType.node:
                            relationMember.MemberType = new OsmGeoType?(OsmGeoType.Node);
                            break;

                        case memberType.way:
                            relationMember.MemberType = new OsmGeoType?(OsmGeoType.Way);
                            break;

                        case memberType.relation:
                            relationMember.MemberType = new OsmGeoType?(OsmGeoType.Relation);
                            break;
                        }
                    }
                    relation.Members.Add(relationMember);
                }
            }
            return(relation);
        }
Ejemplo n.º 4
0
        internal static Relation ConvertToSimple(Osm.Xml.v0_6.relation re)
        {
            Relation relation = new Relation();

            // set id
            if (re.idSpecified)
            {
                relation.Id = re.id;
            }

            // set changeset.
            if (re.changesetSpecified)
            {
                relation.ChangeSetId = re.changeset;
            }

            // set visible.
            if (re.visibleSpecified)
            {
                relation.Visible = re.visible;
            }
            else
            { // if visible is not specified it is default true.
                relation.Visible = true;
            }

            // set timestamp.
            if (re.timestampSpecified)
            {
                relation.TimeStamp = re.timestamp;
            }

            // set uid
            if (re.uidSpecified)
            {
                relation.UserId = re.uid;
            }

            // set version
            if (re.versionSpecified)
            {
                relation.Version = re.version;
            }

            // set user
            relation.UserName = re.user;

            // set tags.
            relation.Tags = XmlSimpleConverter.ConvertToTags(re.tag);

            // set members.
            if (re.member != null && re.member.Length > 0)
            {
                relation.Members = new List <RelationMember>();
                for (int idx = 0; idx < re.member.Length; idx++)
                {
                    OsmSharp.Osm.Xml.v0_6.member mem = re.member[idx];
                    RelationMember relation_member   = new RelationMember();
                    // set memberid
                    if (mem.refSpecified)
                    {
                        relation_member.MemberId = mem.@ref;
                    }

                    // set role.
                    relation_member.MemberRole = mem.role;

                    // set type.
                    if (mem.typeSpecified)
                    {
                        switch (mem.type)
                        {
                        case OsmSharp.Osm.Xml.v0_6.memberType.node:
                            relation_member.MemberType = OsmGeoType.Node;
                            break;

                        case OsmSharp.Osm.Xml.v0_6.memberType.way:
                            relation_member.MemberType = OsmGeoType.Way;
                            break;

                        case OsmSharp.Osm.Xml.v0_6.memberType.relation:
                            relation_member.MemberType = OsmGeoType.Relation;
                            break;
                        }
                    }

                    relation.Members.Add(relation_member);
                }
            }

            return(relation);
        }
Ejemplo n.º 5
0
        internal static Way ConvertToSimple(Osm.Xml.v0_6.way wa)
        {
            Way way = new Way();

            // set id
            if (wa.idSpecified)
            {
                way.Id = wa.id;
            }

            // set changeset.
            if (wa.changesetSpecified)
            {
                way.ChangeSetId = wa.changeset;
            }

            // set visible.
            if (wa.visibleSpecified)
            {
                way.Visible = wa.visible;
            }
            else
            { // if visible is not specified it is default true.
                way.Visible = true;
            }

            // set timestamp.
            if (wa.timestampSpecified)
            {
                way.TimeStamp = wa.timestamp;
            }

            // set uid
            if (wa.uidSpecified)
            {
                way.UserId = wa.uid;
            }

            // set version
            if (wa.versionSpecified)
            {
                way.Version = wa.version;
            }

            // set user
            way.UserName = wa.user;

            // set tags.
            way.Tags = XmlSimpleConverter.ConvertToTags(wa.tag);

            // set nodes.
            if (wa.nd != null && wa.nd.Length > 0)
            {
                way.Nodes = new List <long>();
                for (int idx = 0; idx < wa.nd.Length; idx++)
                {
                    way.Nodes.Add(wa.nd[idx].@ref);
                }
            }

            return(way);
        }
Ejemplo n.º 6
0
        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);
        }