示例#1
0
        public static CompleteWay CreateFrom(Way simpleWay, INodeSource nodeSource)
        {
            if (simpleWay == null)
            {
                throw new ArgumentNullException("simpleWay");
            }
            if (nodeSource == null)
            {
                throw new ArgumentNullException("nodeSource");
            }
            if (!simpleWay.Id.HasValue)
            {
                throw new Exception("simpleWay.id is null");
            }
            CompleteWay completeWay = CompleteWay.Create(simpleWay.Id.Value);

            completeWay.ChangeSetId = simpleWay.ChangeSetId;
            if (simpleWay.Tags != null)
            {
                foreach (Tag tag in simpleWay.Tags)
                {
                    completeWay.Tags.Add(tag);
                }
            }
            if (simpleWay.Nodes != null)
            {
                for (int index = 0; index < simpleWay.Nodes.Count; ++index)
                {
                    long node1 = simpleWay.Nodes[index];
                    Node node2 = nodeSource.GetNode(node1);
                    if (node2 == null)
                    {
                        return((CompleteWay)null);
                    }
                    Node node3 = node2;
                    if (node3 == null)
                    {
                        return((CompleteWay)null);
                    }
                    completeWay.Nodes.Add(node3);
                }
            }
            completeWay.TimeStamp = simpleWay.TimeStamp;
            completeWay.User      = simpleWay.UserName;
            completeWay.UserId    = simpleWay.UserId;
            completeWay.Version   = simpleWay.Version.HasValue ? new long?((long)simpleWay.Version.Value) : new long?();
            completeWay.Visible   = simpleWay.Visible.HasValue && simpleWay.Visible.Value;
            return(completeWay);
        }
示例#2
0
        public static CompleteWay CreateFrom(ObjectTable <string> table, Way simpleWay, IDictionary <long, Node> nodes)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }
            if (simpleWay == null)
            {
                throw new ArgumentNullException("simpleWay");
            }
            if (nodes == null)
            {
                throw new ArgumentNullException("nodes");
            }
            if (!simpleWay.Id.HasValue)
            {
                throw new Exception("simpleWay.id is null");
            }
            CompleteWay completeWay = CompleteWay.Create(table, simpleWay.Id.Value);

            completeWay.ChangeSetId = simpleWay.ChangeSetId;
            foreach (Tag tag in simpleWay.Tags)
            {
                completeWay.Tags.Add(tag);
            }
            for (int index = 0; index < simpleWay.Nodes.Count; ++index)
            {
                long node1 = simpleWay.Nodes[index];
                Node node2 = (Node)null;
                if (!nodes.TryGetValue(node1, out node2))
                {
                    return((CompleteWay)null);
                }
                completeWay.Nodes.Add(node2);
            }
            completeWay.TimeStamp = simpleWay.TimeStamp;
            completeWay.User      = simpleWay.UserName;
            completeWay.UserId    = simpleWay.UserId;
            completeWay.Version   = simpleWay.Version.HasValue ? new long?((long)simpleWay.Version.Value) : new long?();
            completeWay.Visible   = simpleWay.Visible.HasValue && simpleWay.Visible.Value;
            return(completeWay);
        }