/// <summary>Создаёт вектор между двумя точками на поверхности</summary>
 /// <param name="StartPoint">Начальная точка</param>
 /// <param name="EndPoint">Конечная точка</param>
 public EarthVector(EarthPoint StartPoint, EarthPoint EndPoint)
     : this()
 {
     _lazyLength = new Lazy<double>(GetLength, true);
     this.EndPoint = EndPoint;
     this.StartPoint = StartPoint;
 }
Beispiel #2
0
 public TrackSegment(EarthPoint StartPoint, EarthPoint EndPoint, double StartOffset)
 {
     this.EndPoint = EndPoint;
     this.StartPoint = StartPoint;
     Length = StartPoint.DistanceTo(EndPoint);
     this.StartOffset = StartOffset;
     EndOffset = StartOffset + Length;
 }
Beispiel #3
0
 private void EmitPosition(ICanPort Port, EarthPoint Position, bool Reliability)
 {
     CanFrame frame = new MmAltLongFrame(Position.Latitude,
                                         Position.Longitude,
                                         Reliability).GetCanFrame();
     CanFrame fx = CanFrame.NewWithId(0x5c0, frame.Data);
     Port.BeginSend(fx);
 }
Beispiel #4
0
 /// <summary>Возвращает расстояние между точками по теореме гаверсинусов</summary>
 /// <seealso href="http://en.wikipedia.org/wiki/Haversine_formula" />
 /// <param name="p1">Первая точка</param>
 /// <param name="p2">Вторая точка</param>
 /// <returns>Расстояние между точками в метрах</returns>
 public static Double DistanceTo(this EarthPoint p1, EarthPoint p2)
 {
     return 2 * R
            * Math.Asin(
                        Math.Sqrt(HaverSin((Radian)p2.Latitude - (Radian)p1.Latitude)
                                  + Math.Cos((Radian)p1.Latitude) * Math.Cos((Radian)p2.Latitude)
                                  * HaverSin((Radian)p2.Longitude - (Radian)p1.Longitude)));
 }
Beispiel #5
0
        public MapViewModel()
        {
            //MapCenter = new EarthPoint(new Degree(56.8779), new Degree(60.5905));
            MapCenter = new EarthPoint(new Degree(55.729959), new Degree(37.540420));
            ZoomLevel = 14;

            _mapClickedCommand = ReactiveCommand.Create();

            Clicks = _mapClickedCommand.OfType<MapMouseActionEventArgs>();
        }
 public static bool TryParse(string Value, out EarthPoint Point)
 {
     Match m = _parsingExpression.Match(Value);
     if (!m.Success)
     {
         Point = default(EarthPoint);
         return false;
     }
     Point = new EarthPoint(Double.Parse(m.Groups["lat"].Value.Replace(',', '.'), CultureInfo.InvariantCulture),
                            Double.Parse(m.Groups["lon"].Value.Replace(',', '.'), CultureInfo.InvariantCulture));
     return true;
 }
Beispiel #7
0
 private void EmitPosition(UdpClient Client, EarthPoint Position, bool Reliability)
 {
     using (var ms = new MemoryStream())
     {
         var writer = new BinaryWriter(ms);
         writer.Write((byte)PacketType.Position);
         writer.Write(Position.Latitude);
         writer.Write(Position.Longitude);
         writer.Write((byte)(Reliability ? 1 : 0));
         byte[] dat = ms.ToArray();
         Client.Send(dat, dat.Length);
     }
 }
Beispiel #8
0
        public void EmitPosition(EarthPoint Position, double Speed)
        {
            var doc = new XDocument(
                new XElement("Information",
                             new XElement("Position",
                                          new XAttribute("Latitude", Position.Latitude.Value),
                                          new XAttribute("Longitude", Position.Longitude.Value)),
                             new XElement("Speed", Speed),
                             new XElement("Time", (_time + (DateTime.Now - _beginTime)))));

            using (var ms = new MemoryStream())
            {
                doc.Save(ms);
                byte[] a = ms.ToArray();
                _udpClient.Send(a, a.Length, _remodeEp);
            }
        }
 public MapPointElement(EarthPoint Position)
 {
     _position = Position;
 }
 private void RefreshPosition(EarthPoint Position)
 {
     _mappingService.Remove(_currentElement);
     _currentElement = new PositionMapElement(Position);
     _mappingService.Display(_currentElement);
 }
 public NavigationInformation(EarthPoint Position, double Speed, bool Reliability)
 {
     this.Reliability = Reliability;
     this.Position = Position;
     this.Speed = Speed;
 }
Beispiel #12
0
 /// <summary>Прямое преобразование Меркатора (со сферы на плоскость)</summary>
 /// <param name="p">Координаты точки на сфере</param>
 /// <returns>Координаты точки на поверхности</returns>
 public static SurfacePoint Direct(EarthPoint p)
 {
     return new SurfacePoint(LongitudeToX(p.Longitude), LatitudeToY(p.Latitude));
 }
Beispiel #13
0
 public MapMouseActionEventArgs(EarthPoint Point, MouseAction Action)
 {
     this.Action = Action;
     this.Point = Point;
 }
Beispiel #14
0
        protected virtual void OnCentralPointChanged(EarthPoint newCentralPoint)
        {
            Point screenCentralPoint = Projector.Project(newCentralPoint, ZoomLevel);
            _globalTransform.X = Math.Round(-screenCentralPoint.X + ActualWidth / 2);
            _globalTransform.Y = Math.Round(-screenCentralPoint.Y + ActualHeight / 2);

            VisibleArea = new EarthArea(
                // Top Left
                Projector.InverseProject(screenCentralPoint + new Vector(-ActualWidth / 2, -ActualHeight / 2), ZoomLevel),
                // Bottom Left
                Projector.InverseProject(screenCentralPoint + new Vector(-ActualWidth / 2, +ActualHeight / 2), ZoomLevel),
                // Top Right
                Projector.InverseProject(screenCentralPoint + new Vector(+ActualWidth / 2, -ActualHeight / 2), ZoomLevel),
                // BottomRight
                Projector.InverseProject(screenCentralPoint + new Vector(+ActualWidth / 2, +ActualHeight / 2), ZoomLevel)
                );

            RefreshTiles();
        }
 public Point Project(EarthPoint p, int Zoom)
 {
     var surfacePoint = (SurfacePoint)p;
     double mpp = Scales[Zoom];
     return new Point(Math.Round(surfacePoint.X / mpp), Math.Round(-surfacePoint.Y / mpp));
 }
Beispiel #16
0
 public void Navigate(EarthPoint ToPoint)
 {
     MapCenter = ToPoint;
 }
Beispiel #17
0
 /// <summary>Получает точку, лежащую между указанными точками</summary>
 /// <param name="Point1">Точка 1</param>
 /// <param name="Point2">Точка 2</param>
 /// <param name="Ratio">Доля участка между точками 1 и 2</param>
 public static EarthPoint MiddlePoint(EarthPoint Point1, EarthPoint Point2, Double Ratio = 0.5)
 {
     return new EarthPoint(
         (1 - Ratio) * Point1.Latitude + Ratio * Point2.Latitude,
         (1 - Ratio) * Point1.Longitude + Ratio * Point2.Longitude);
 }
 public PositionMapElement(EarthPoint Position)
     : base(Position)
 {
 }
 private void AppendPointToTrack(EarthPoint Point) { _track.Add(Point); }