public void ConnectLayrsCreatesConnectionsAmongPoints()
        {
            CandidatesGraph target = new CandidatesGraph();

            CandidatePoint pt11 = new CandidatePoint() { MapPoint = new PointGeo() { Latitude = 1, Longitude = 1 } };
            CandidatePoint pt21 = new CandidatePoint() { MapPoint = new PointGeo() { Latitude = 2.1, Longitude = 2.1} };
            CandidatePoint pt22 = new CandidatePoint() { MapPoint = new PointGeo() { Latitude = 2.2, Longitude = 2.2} };

            CandidateGraphLayer layer1 = new CandidateGraphLayer();
            layer1.Candidates.Add(pt11);
            target.Layers.Add(layer1);

            CandidateGraphLayer layer2 = new CandidateGraphLayer();
            layer2.Candidates.AddRange(new CandidatePoint[] { pt21, pt22 });
            target.Layers.Add(layer2);

            target.ConnectLayers();

            Assert.Equal(0, target.Layers[0].Candidates[0].IncomingConnections.Count);
            Assert.Equal(1, target.Layers[0].Candidates[0].OutgoingConnections.Where(c => c.From == pt11 && c.To == pt21).Count());
            Assert.Equal(1, target.Layers[0].Candidates[0].OutgoingConnections.Where(c => c.From == pt11 && c.To == pt22).Count());

            Assert.Equal(0, target.Layers[1].Candidates[0].OutgoingConnections.Count);
            Assert.Equal(0, target.Layers[1].Candidates[1].OutgoingConnections.Count);

            Assert.Equal(1, target.Layers[1].Candidates[0].IncomingConnections.Where(c => c.From == pt11 && c.To == pt21).Count());
            Assert.Equal(1, target.Layers[1].Candidates[1].IncomingConnections.Where(c => c.From == pt11 && c.To == pt22).Count());
        }
Пример #2
0
        /// <summary>
        /// Creates a new layer in the CandidatesGraph
        /// </summary>
        /// <param name="originalPoint">GPX track point</param>
        /// <param name="candidates">Candidate points for the original point</param>
        public void CreateLayer(GPXPoint originalPoint, IEnumerable <CandidatePoint> candidates)
        {
            CandidateGraphLayer result = new CandidateGraphLayer()
            {
                TrackPoint = originalPoint
            };

            result.Candidates.AddRange(candidates);

            foreach (var candidate in candidates)
            {
                candidate.Layer = result;
            }
            _layers.Add(result);
        }
Пример #3
0
        /// <summary>
        /// Creates a new layer in the CandidatesGraph
        /// </summary>
        /// <param name="originalPoint">GPX track point</param>
        /// <param name="candidates">Candidate points for the original point</param>
        public void CreateLayer(GPXPoint originalPoint, IEnumerable<CandidatePoint> candidates)
        {
            CandidateGraphLayer result = new CandidateGraphLayer() { TrackPoint = originalPoint };
            result.Candidates.AddRange(candidates);

            foreach (var candidate in candidates) {
                candidate.Layer = result;
            }
            _layers.Add(result);
        }