Beispiel #1
0
        /// <summary>
        /// Creates a complete way.
        /// </summary>
        public static CompleteWay CreateComplete(this Way way, IOsmGeoSource osmGeoSource)
        {
            if (way == null)
            {
                throw new ArgumentNullException("simpleWay");
            }
            if (way.Id == null)
            {
                throw new Exception("simpleWay.id is null");
            }
            if (osmGeoSource == null)
            {
                throw new ArgumentNullException("osmGeoSource");
            }

            var completeWay = new CompleteWay();

            completeWay.Id          = way.Id.Value;
            completeWay.ChangeSetId = way.ChangeSetId;
            if (way.Tags != null)
            {
                completeWay.Tags = new TagsCollection(way.Tags);
            }
            if (way.Nodes != null)
            {
                var nodes = new List <Node>();
                for (int i = 0; i < way.Nodes.Length; i++)
                {
                    var node = osmGeoSource.GetNode(way.Nodes[i]);
                    if (node == null)
                    {
                        return(null);
                    }
                    nodes.Add(node);
                }
                completeWay.Nodes = nodes.ToArray();
            }
            completeWay.TimeStamp = way.TimeStamp;
            completeWay.UserName  = way.UserName;
            completeWay.UserId    = way.UserId;
            completeWay.Version   = way.Version;
            completeWay.Visible   = way.Visible;
            return(completeWay);
        }
Beispiel #2
0
 /// <summary>
 /// Converts a complete way into its simple counterpart,
 /// including the simple versions of nodes.
 /// </summary>
 public static OsmGeo[] ToSimpleWithChildren(this CompleteWay way)
 {
     return(way.Nodes.DistinctByGeoKey().Append(way.ToSimple()).ToArray());
 }
Beispiel #3
0
 /// <summary>
 /// Returns true if this way is closed.
 /// </summary>
 public static bool IsClosed(this CompleteWay way)
 {
     return(way.Nodes != null &&
            way.Nodes.Length > 1 &&
            way.Nodes[0].Id == way.Nodes[way.Nodes.Length - 1].Id);
 }