예제 #1
0
        public void CanCalculateLonDistance()
        {
            double latCorrection = Math.Cos(lat * (Math.PI / 180));
            double dist          = GeoTools.LonDistance(lon - 1, lon, lat);

            Assert.AreEqual(GeoTools.NauticalMile * -60 * latCorrection, dist);

            double leftTopLon = GeoTools.DistanceToLon(lon, lat, -MapSize / 2);

            dist = GeoTools.LonDistance(leftTopLon, lon, lat);
            Assert.AreEqual(-MapSize / 2, dist, 0.01);
        }
예제 #2
0
        protected virtual void AddSegmentToTrack(Track track, Segment segment)
        {
            foreach (Osm.Node node in segment.Nodes)
            {
                int x = (int)GeoTools.LonDistance(node.Lon, lon, lat);
                int y = (int)GeoTools.LatDistance(node.Lat, lat);

                // do not add segments that are outside the map
                if (!OnMap(x, y))
                {
                    // TODO: try to make outside connection
                    continue;
                }

                track.Nodes.Add(CreateNode(track, segment, node, x, y));
            }
        }