Beispiel #1
0
        /// <summary>
        /// Finds all candidates points for given GPS track point
        /// </summary>
        /// <param name="gpxPt">GPS point</param>
        /// <returns>Collection of points candidate points on road segments</returns>
        public IEnumerable<CandidatePoint> FindCandidatePoints(GPXPoint gpxPt)
        {
            List<CandidatePoint> result = new List<CandidatePoint>();
            BBox gpxBbox = new BBox(new IPointGeo[] { gpxPt });
            gpxBbox.Inflate(0.0007, 0.0011);

            foreach (var road in _trackCutout) {
                if (Topology.Intersects(gpxBbox, road.BBox)) {
                    Segment<IPointGeo> roadSegment;
                    IPointGeo projectedPoint = Topology.ProjectPoint(gpxPt, road, out roadSegment);
                    result.Add(new CandidatePoint() { MapPoint = projectedPoint,
                                                        Road = road, RoadSegment = roadSegment,
                                                                                        ObservationProbability = CalculateObservationProbability(gpxPt, projectedPoint) });
                }
            }

            if (result.Count == 0) {
                throw new Exception(string.Format("Can not find any candidate point for {0}", gpxPt));
            }

            return result;
        }
Beispiel #2
0
        void CreateTrackCutout(GPXTrackSegment track)
        {
            _trackCutout.Clear();

            BBox trackBBox = new BBox();
            foreach (var point in track.Nodes) {
                trackBBox.ExtendToCover(point);
            }
            trackBBox.Inflate(0.0015, 0.0015);

            foreach (var road in _graph.ConnectionGeometries) {
                if (Topology.Intersects(road.BBox, trackBBox)) {
                    _trackCutout.Add(road);
                }
            }
        }
Beispiel #3
0
        public void BBoxInflateIncreasesBBoxSize()
        {
            PointGeo p1 = new PointGeo(1, 0);
            PointGeo p2 = new PointGeo(0, 1);

            BBox target = new BBox(new IPointGeo[] { p1, p2 });

            target.Inflate(0.1, 0.2);

            Assert.Equal(1.1, target.North);
            Assert.Equal(-0.1, target.South);
            Assert.Equal(1.2, target.East);
            Assert.Equal(-0.2, target.West);
        }