コード例 #1
0
ファイル: GMapMarkerCross.cs プロジェクト: LeoTosti/x-drone
 public GMapMarkerCross(PointLatLng p)
     : base(p)
 {
     #if !PocketPC
      Pen = new Pen(Brushes.Red, 1);
     #else
      Pen = new Pen(Color.Red, 1);
     #endif
 }
コード例 #2
0
      public GMarkerCross(PointLatLng p)
         : base(p)
      {
#if !PocketPC
         Pen = new Pen(Brushes.Red, 1);
#else
         Pen = new Pen(Color.Red, 1);
#endif
         IsHitTestVisible = false;
      }
コード例 #3
0
ファイル: GMapMarkerRect.cs プロジェクト: gipasoft/Sfera
        public GMapMarkerRect(PointLatLng p)
            : base(p)
        {
            Pen = new Pen(Brushes.Transparent, 5);

            // do not forget set Size of the marker
            // if so, you shall have no event on it ;}
            Size = new System.Drawing.Size(20, 20);
            Offset = new System.Drawing.Point(-Size.Width / 2, -Size.Height / 2);
        }
コード例 #4
0
      public GMarkerGoogle(PointLatLng p, GMarkerGoogleType type)
         : base(p)
      {
         this.Type = type;

         if(type != GMarkerGoogleType.none)
         {
            LoadBitmap();
         }
      }
コード例 #5
0
ファイル: GMarkerGoogle.cs プロジェクト: redmanmale/greatmaps
       public GMarkerGoogle(PointLatLng p, GMarkerGoogleType type, bool showShadow = true)
         : base(p)
      {
         this.Type = type;
         this.ShowShadow = showShadow;

         if(type != GMarkerGoogleType.none)
         {
            LoadBitmap();
         }
      }
コード例 #6
0
      public GMapMarkerTransparentGoogleGreen(PointLatLng p)
         : base(p)
      {
         System.Reflection.Assembly ass = System.Reflection.Assembly.GetExecutingAssembly();

         String resShadow = "GMap.NET.WindowsMobile.Resources.shadow50.png";
         String resMarker = "GMap.NET.WindowsMobile.Resources.bigMarkerGreen.png";

         IGMapTransparentBitmap shadow = GMapMarkerTransparent.LoadTransparentBitmap(ass.GetManifestResourceStream(resShadow));
         IGMapTransparentBitmap marker = GMapMarkerTransparent.LoadTransparentBitmap(ass.GetManifestResourceStream(resMarker));

         bitmaps = new IGMapTransparentBitmap[] { shadow, marker };

         Size = new System.Drawing.Size(marker.Width, marker.Height);
         Offset = new System.Drawing.Point(-10, -34);
      }
コード例 #7
0
 /// <summary>
 /// marker using manual bitmap, NonSerialized
 /// </summary>
 /// <param name="p"></param>
 /// <param name="Bitmap"></param>
 public GMarkerGoogle(PointLatLng p, Bitmap Bitmap)
    : base(p)
 {
    this.Bitmap = Bitmap;
    Size = new System.Drawing.Size(Bitmap.Width, Bitmap.Height);
    Offset = new Point(-Size.Width / 2, -Size.Height);
 }
コード例 #8
0
 /// <summary>
 /// NotImplemented
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="start"></param>
 /// <param name="wayPoints"></param>
 /// <param name="avoidHighways"></param>
 /// <param name="avoidTolls"></param>
 /// <param name="walkingMode"></param>
 /// <param name="sensor"></param>
 /// <param name="metric"></param>
 /// <returns></returns>
 public DirectionsStatusCode GetDirections(out GDirections direction, PointLatLng start, IEnumerable<PointLatLng> wayPoints, PointLatLng end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
 string MakeRoutingUrl(PointLatLng start, PointLatLng end, string travelType, string language, string units)
 {
    // http://developers.cloudmade.com/projects/routing-http-api/examples/
    // http://routes.cloudmade.com/YOUR-API-KEY-GOES-HERE/api/0.3/start_point,[[transit_point1,...,transit_pointN]],end_point/route_type[/route_type_modifier].output_format[?lang=(en|de)][&units=(km|miles)]
    return string.Format(CultureInfo.InvariantCulture, UrlFormat, Key, Version, start.Lat, start.Lng, end.Lat, end.Lng, travelType, language, units);
 }
コード例 #10
0
 public GeoCoderStatusCode GetPlacemarks(PointLatLng location, out List<Placemark> placemarkList)
 {
     return GetPlacemarkFromReverseGeocoderUrl(MakeReverseGeocoderUrl(location, LanguageStr), out placemarkList);
 }
コード例 #11
0
 /// <summary>
 /// return local coordinates from lat/lng
 /// </summary>
 /// <param name="latlng"></param>
 /// <returns></returns>
 public GPoint FromLatLngToLocal(PointLatLng latlng)
 {
    GPoint pLocal = Provider.Projection.FromLatLngToPixel(latlng, Zoom);
    pLocal.Offset(renderOffset);
    pLocal.OffsetNegative(compensationOffset);
    return pLocal;
 }
コード例 #12
0
        /// <summary>
        /// ищет наиболее подходящую к заданной точке МС и получает её ряд. Если ряд не найден, то возвращает null
        /// </summary>
        /// <param name="coordinates"></param>
        /// <param name="r"></param>
        /// <param name="actionPercent"></param>
        /// <param name="Range">ряд, для которого подбирается функция</param>
        /// <exception cref="GetBaseRangeException">Возвращает иснформацию о параметрах, мешающих получить ближайшую МС</exception>
        /// <returns></returns>
        internal static RawRange TryGetBaseRange(RawRange Range, PointLatLng coordinates, out double r, Action <int, string> actionPercent)
        {
            bool nlaw = CheckNormalLaw(Range, Vars.Options.NormalLawPirsonCoefficientDiapason);

            if (!nlaw)
            {
                throw new WindEnergyException("Исходный ряд не подчиняется нормальному закону распределения");
            }

            DateTime from = Range.Min((ri) => ri.Date).Date, to = Range.Max((ri) => ri.Date).Date;

            List <RP5MeteostationInfo>  mts = Vars.RP5Meteostations.GetNearestMS(coordinates, Vars.Options.NearestMSRadius, false);
            Dictionary <double, double> funcSpeed = Range.GetFunction(MeteorologyParameters.Speed); //функция скорости на заданном ряде
            RawRange res = null;
            double   rmax = double.MinValue, total_rmax = double.MinValue;
            RP5ru    provider = new RP5ru(Vars.Options.CacheFolder + "\\rp5.ru");

            for (int i = 0; i < mts.Count; i++)
            {
                if (actionPercent != null)
                {
                    actionPercent.Invoke((int)((i * 1d / mts.Count) * 100d), "Поиск подходящей МС...");
                }

                RP5MeteostationInfo m = mts[i];

                //если нет диапазона измерений в БД, то загружаем с сайта
                if (m.MonitoringFrom == DateTime.MinValue)
                {
                    provider.GetMeteostationExtInfo(ref m);
                }

                //если для этой МС нет наблюдений в этом периоде, то переходим на другую
                if (m.MonitoringFrom > from)
                {
                    continue;
                }

                //загрузка ряда с очередной МС
                RawRange curRange = null;
                try
                { curRange = provider.GetRange(from, to, m); }
                catch (WindEnergyException wex) // если не удалось получить ряд этой МС, то переходим к следующей
                { continue; }


                curRange = new Checker().ProcessRange(curRange, new CheckerParameters(LimitsProviders.StaticLimits, curRange.Position), out CheckerInfo info, null); //исправляем ошибки


                //СКОРОСТЬ
                MeteorologyParameters parameter = MeteorologyParameters.Speed;

                Dictionary <double, double> funcSpeedCurrentNearest = curRange.GetFunction(parameter); //функция скорости на текущей МС

                //проверка на нормальный закон распределения
                bool normal = CheckNormalLaw(curRange, Vars.Options.NormalLawPirsonCoefficientDiapason);
                if (!normal)
                {
                    continue;
                }

                //расчёт и проверка коэфф корреляции
                List <double>[] table     = calcTableCoeff(funcSpeed, funcSpeedCurrentNearest); //таблица для расчет коэффициентов
                double          current_r = getParameterR(table);                               //коэффициент корреляции

                //общий максимальный коэфф корреляции
                if (current_r > total_rmax)
                {
                    total_rmax = current_r;
                }

                //проверяем, можно ли взять эту МС
                if (current_r > rmax)
                {
                    //истина, если надо проверять этот параметр на допустимый диапазон корреляции
                    bool needCheck = Vars.Options.MinimalCorrelationControlParametres.Contains(parameter);
                    if ((needCheck && current_r >= Vars.Options.MinimalCorrelationCoeff) || !needCheck)
                    {
                        rmax = current_r;
                        res  = curRange;
                    }
                }
            }
            r = rmax;
            if (res == null)
            {
                RP5MeteostationInfo mi = Vars.RP5Meteostations.GetNearestMS(coordinates);
                double l = EarthModel.CalculateDistance(mi.Position, coordinates);
                throw new GetBaseRangeException(total_rmax, Vars.Options.MinimalCorrelationCoeff, l, mts.Count, Vars.Options.NearestMSRadius, coordinates);
            }
            return(res);
        }
コード例 #13
0
        // The Coogle Directions API: http://tinyurl.com/6vv4cac

        string MakeDirectionsUrl(PointLatLng start, PointLatLng end, string language, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
        {
            string av = (avoidHighways ? "&avoid=highways" : string.Empty) + (avoidTolls ? "&avoid=tolls" : string.Empty); // 6
            string mt = "&units=" + (metric ? "metric" : "imperial");     // 7
            string wk = "&mode=" + (walkingMode ? "walking" : "driving"); // 8

            return string.Format(CultureInfo.InvariantCulture, DirectionUrlFormatPoint, start.Lat, start.Lng, end.Lat, end.Lng, sensor.ToString().ToLower(), language, av, mt, wk, ServerAPIs);
        }
コード例 #14
0
 string MakeRoutingUrl(PointLatLng start, PointLatLng end, string travelType)
 {
     return(string.Format(CultureInfo.InvariantCulture, RoutingUrlFormat, start.Lat, start.Lng, end.Lat, end.Lng, travelType));
 }
コード例 #15
0
        public PointLatLng Point()
        {
            PointLatLng pnt = new PointLatLng(Lat, Lng);

            return(pnt);
        }
コード例 #16
0
 public GeoCoderStatusCode GetPlacemarks(PointLatLng location, out List <Placemark> placemarkList)
 {
     throw new NotImplementedException("use GetPlacemark");
 }
コード例 #17
0
 string MakeReverseGeocoderUrl(PointLatLng pt)
 {
     return(string.Format(CultureInfo.InvariantCulture, ReverseGeocoderUrlFormat, pt.Lat, pt.Lng));
 }
コード例 #18
0
ファイル: GMapControl.cs プロジェクト: m-kosina/GEDKeeper
 /// <summary>
 /// gets local coordinate from world coordinate
 /// </summary>
 /// <param name="point"></param>
 /// <returns></returns>
 public GPoint FromLatLngToLocal(PointLatLng point)
 {
     return(fCore.FromLatLngToLocal(point));
 }
コード例 #19
0
ファイル: Form1.cs プロジェクト: zzhukanton/PolygonValidator
        private PointLatLng?CheckForIntersection(PointLatLng p1, PointLatLng p2, PointLatLng p3, PointLatLng p4)
        {
            // сортируем точки
            if (p2.Lat < p1.Lat)
            {
                PointLatLng tmp = p1;
                p1 = p2;
                p2 = tmp;
            }

            if (p4.Lat < p3.Lat)
            {
                PointLatLng tmp = p3;
                p3 = p4;
                p4 = tmp;
            }

            //проверим существование потенциального интервала для точки пересечения отрезков
            if (p2.Lat < p1.Lat)
            {
                //ибо у отрезков нету взаимной абсциссы
                return(null);
            }

            //найдём коэффициенты уравнений, содержащих отрезки
            //f1(x) = A1*x + b1 = y
            //f2(x) = A2*x + b2 = y
            //если первый отрезок вертикальный
            if (p1.Lat - p2.Lat == 0)
            {
                //найдём Xa, Ya - точки пересечения двух прямых
                double resX  = p1.Lat;
                double tg    = (p3.Lng - p4.Lng) / (p3.Lat - p4.Lat);
                double shift = p3.Lng - tg * p4.Lat;

                double resultY = tg * resX + shift;

                if (p3.Lat <= resX &&
                    p4.Lat >= resX &&
                    Math.Min(p1.Lng, p2.Lng) <= resultY &&
                    Math.Max(p1.Lng, p2.Lng) >= resultY)
                {
                    return(new PointLatLng(resX, resultY));
                }

                return(null);
            }

            //если второй отрезок вертикальный
            if (p3.Lat - p4.Lat == 0)
            {
                //найдём Xa, Ya - точки пересечения двух прямых
                double resX    = p3.Lat;
                double tg      = (p1.Lng - p2.Lng) / (p1.Lat - p2.Lat);
                double shift   = p1.Lng - tg * p1.Lat;
                double resultY = tg * resX + shift;

                if (p1.Lat <= resX &&
                    p2.Lat >= resX &&
                    Math.Min(p3.Lng, p4.Lng) <= resultY &&
                    Math.Max(p3.Lng, p4.Lng) >= resultY)
                {
                    return(new PointLatLng(resX, resultY));
                }

                return(null);
            }

            //оба отрезка невертикальные
            double tg1    = (p1.Lng - p2.Lng) / (p1.Lat - p2.Lat);
            double tg2    = (p3.Lng - p4.Lng) / (p3.Lat - p4.Lat);
            double shift1 = p1.Lng - tg1 * p1.Lat;
            double shift2 = p3.Lng - tg2 * p3.Lat;

            if (tg1 == tg2)
            {
                //отрезки параллельны
                return(null);
            }

            //Xa - абсцисса точки пересечения двух прямых
            double resultX = (shift2 - shift1) / (tg1 - tg2);

            if ((resultX < Math.Max(p1.Lat, p3.Lat)) || (resultX > Math.Min(p2.Lat, p4.Lat)))
            {
                //точка Xa находится вне пересечения проекций отрезков на ось X
                return(null);
            }
            else
            {
                double resultY = tg1 * resultX + shift1;
                return(new PointLatLng(resultX, resultY));
            }
        }
コード例 #20
0
 /// <summary>
 /// создаёт новый интерполятор для заданной точки с заданной функций и типом расчетного параметра
 /// </summary>
 /// <param name="func">известные значения функции в заданной точке</param>
 /// <param name="coordinates">координаты точки, для которой известны значения func</param>
 /// <param name="parameterType">тип мтеорологического параметра</param>
 /// <param name="replaceExistMeasurements">Заменять существующие измерения в исходном ряде на расчетные</param>
 public NearestMSInterpolateMethod(Dictionary <double, double> func, PointLatLng coordinates, MeteorologyParameters parameterType, bool replaceExistMeasurements)
     : this(func, getNearestRange(func, coordinates), parameterType, replaceExistMeasurements)
 {
 }
コード例 #21
0
 public GMapMarkerGoogleRed(PointLatLng p)
    : base(p)
 {
    Size = SizeSt;
    Offset = new Point(-10, -34);
 }
コード例 #22
0
        private void Map_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (searchDist.IsChecked == true)
            {
                PointLatLng point = Map.FromLocalToLatLng((int)e.GetPosition(Map).X, (int)e.GetPosition(Map).Y);

                //pts.Add(point);

                sorting(objs, point);

                objectList.Items.Clear();

                foreach (MapObject cm in objs)
                {
                    objectList.Items.Add(cm.getTitle() + " " + Math.Round(cm.getDistance(point)).ToString());
                }
            }
            else
            {

                PointLatLng point = Map.FromLocalToLatLng((int)e.GetPosition(Map).X, (int)e.GetPosition(Map).Y);

                pts.Add(point);

                if (objType.SelectedIndex > -1)
                {
                    if (objType.SelectedIndex == 0)
                    {
                        //if (car == null)

                        Car car = new Car(objTitle.Text, point, Map);
                        objs.Add(car);
                        cars.Add(car);
                        carMarker = car.getMarker();
                    }

                    if (objType.SelectedIndex == 1)
                    {
                        if (human == null)
                        {
                            human = new Human(objTitle.Text, point);
                            objs.Add(human);
                            humMarker = human.getMarker();

                            human.setPosition(point);
                            humMarker.Position = point;

                        }

                    }

                    if (objType.SelectedIndex == 2)
                    {
                        if ((human != null) && (loc == null))
                        {
                            human.moveTo(point);


                            loc = new Location(objTitle.Text, point);
                            objs.Add(loc);
                            locMarker = loc.getMarker();

                        }
                    }

                    if (objType.SelectedIndex == 3)
                    {
                        Area a = new Area(objTitle.Text, pts);
                        objs.Add(a);
                        Map.Markers.Add(a.getMarker());
                    }

                    Map.Markers.Clear();

                    foreach (MapObject cm in objs)
                    {
                        Map.Markers.Add(cm.getMarker());
                    }

                    //Map.Markers.Add(dst);

                    pts.Clear();
                }
            }
        }
コード例 #23
0
 public GMapMarker(PointLatLng pos)
 {
    this.Position = pos;
 }
コード例 #24
0
ファイル: MapForm.cs プロジェクト: culiniac/quavs
 // current point changed
 void MainMap_OnCurrentPositionChanged(PointLatLng point)
 {
     //center.Position = point;
     //textBoxLat.Text = point.Lat.ToString(CultureInfo.InvariantCulture);
     //textBoxLng.Text = point.Lng.ToString(CultureInfo.InvariantCulture);
 }
コード例 #25
0
        /// <summary>
        /// NotImplemented
        /// </summary>
        /// <param name="status"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="avoidHighways"></param>
        /// <param name="avoidTolls"></param>
        /// <param name="walkingMode"></param>
        /// <param name="sensor"></param>
        /// <param name="metric"></param>
        /// <returns></returns>
        public IEnumerable<GDirections> GetDirections(out DirectionsStatusCode status, PointLatLng start, PointLatLng end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
        {
            // TODO: add alternative directions

            throw new NotImplementedException();
        }
コード例 #26
0
 private void DrawDot(PointLatLng latlng)
 {
 }
コード例 #27
0
 public MapRoute GetRoute(PointLatLng start, PointLatLng end, bool avoidHighways, bool walkingMode, int Zoom)
 {
     string tooltip;
     int numLevels;
     int zoomFactor;
     MapRoute ret = null;
     List<PointLatLng> points = GetRoutePoints(MakeRouteUrl(start, end, LanguageStr, avoidHighways, walkingMode), Zoom, out tooltip, out numLevels, out zoomFactor);
     if (points != null)
     {
         ret = new MapRoute(points, tooltip);
     }
     return ret;
 }
コード例 #28
0
        void DrawMap()
        {
            int a = 0;

            DateTime starttime   = DateTime.MinValue;
            int      startdelta  = 0;
            DateTime workingtime = starttime;

            DateTime lastdrawn = DateTime.MinValue;

            List <PointLatLng> routelist = new List <PointLatLng>();

            //zg1.GraphPane.GraphObjList.Clear();

            foreach (DataGridViewRow datarow in dataGridView1.Rows)
            {
                if (datarow.Cells[1].Value.ToString() == "GPS")
                {
                    if (!logformat.ContainsKey("GPS"))
                    {
                        break;
                    }

                    int index = FindInArray(logformat["GPS"].FieldNames, "Lat");
                    if (index == -1)
                    {
                        a++;
                        continue;
                    }

                    int index2 = FindInArray(logformat["GPS"].FieldNames, "Lng");
                    if (index2 == -1)
                    {
                        a++;
                        continue;
                    }

                    int index3 = FindInArray(logformat["GPS"].FieldNames, "Status");
                    if (index3 == -1)
                    {
                        a++;
                        continue;
                    }

                    if (double.Parse(datarow.Cells[index3 + 2].Value.ToString()) != 3)
                    {
                        a++;
                        continue;
                    }

                    string lat = datarow.Cells[index + 2].Value.ToString();
                    string lng = datarow.Cells[index2 + 2].Value.ToString();

                    PointLatLng pnt = new PointLatLng()
                    {
                    };
                    pnt.Lat = double.Parse(lat);
                    pnt.Lng = double.Parse(lng);

                    routelist.Add(pnt);
                }
                a++;
            }

            GMapRoute route = new GMapRoute(routelist, "route");

            mapoverlay.Routes.Add(route);
            myGMAP1.ZoomAndCenterRoute(route);
            myGMAP1.RoutesEnabled = true;
        }
コード例 #29
0
 string MakeReverseGeocoderUrl(PointLatLng pt, string language)
 {
     return string.Format(CultureInfo.InvariantCulture, ReverseGeocoderUrlFormat, ServerAPIs, pt.Lat, pt.Lng, language);
 }
コード例 #30
0
ファイル: GMarkerArrow.cs プロジェクト: clzdl/GreatMap.Net
 public GMarkerArrow(PointLatLng p)
     : base(p)
 {
     Scale = 1;
 }
コード例 #31
0
        public void dibujarSolucion(bool ponderado)
        {
            mapaSolucion.Overlays.Clear();

            GMapOverlay marcadores = new GMapOverlay("ciudades");

            GMapOverlay lineas = new GMapOverlay("rutas");

            for (int i = 0; i < grafoViajero.Count; i++)
            {
                Ciudad        ciudad  = grafoViajero.ElementAt(i);
                GMarkerGoogle iniciom = null;
                if (i == 0)
                {
                    iniciom = new GMarkerGoogle(new PointLatLng(ciudad.Latitud, ciudad.Longitud), GMarkerGoogleType.red_dot);
                }
                else
                {
                    iniciom = new GMarkerGoogle(new PointLatLng(ciudad.Latitud, ciudad.Longitud), GMarkerGoogleType.blue_dot);
                }

                iniciom.ToolTipText = "Nombre: " + ciudad.Nombre + "\n" +
                                      "Latitud : " + ciudad.Latitud + "\n" +
                                      "Longitud : " + ciudad.Longitud + "\n" +
                                      "Poblacion : " + ciudad.TotalPoblacion;
                marcadores.Markers.Add(iniciom);

                if (ponderado)
                {
                    Ciudad otraciudad = null;
                    if (i == grafoViajero.Count - 1)
                    {
                        otraciudad = grafoViajero.ElementAt(0);
                    }
                    else
                    {
                        otraciudad = grafoViajero.ElementAt(i + 1);
                    }

                    List <PointLatLng> points = new List <PointLatLng>();
                    points.Add(new PointLatLng(ciudad.Latitud, ciudad.Longitud));
                    points.Add(new PointLatLng(otraciudad.Latitud, otraciudad.Longitud));
                    GMapPolygon polygon = new GMapPolygon(points, "mypolygon");
                    polygon.Fill   = new SolidBrush(Color.FromArgb(50, Color.Red));
                    polygon.Stroke = new Pen(Color.Red, 5);
                    lineas.Polygons.Add(polygon);
                    double       lat               = (ciudad.Latitud + otraciudad.Latitud) / 2;
                    double       lon               = (ciudad.Longitud + otraciudad.Longitud) / 2;
                    PointLatLng  puntoDistancia    = new PointLatLng(lat, lon);
                    GMarkerCross marcadorDistancia = new GMarkerCross(puntoDistancia);

                    double distancia = Math.Round(ciudad.distancia(otraciudad, 'K'), 2);

                    marcadorDistancia.ToolTipText = distancia + " Km";
                    marcadorDistancia.ToolTipMode = MarkerTooltipMode.Always;

                    marcadores.Markers.Add(marcadorDistancia);

                    mapaSolucion.Overlays.Add(lineas);
                }

                mapaSolucion.Overlays.Add(marcadores);
            }

            mapaSolucion.Zoom = 1;
            mapaSolucion.Zoom = 0;
        }
コード例 #32
0
        public async void UpdateWidgets(object sender, EventArgs e)
        {
            //162;-0.02;-0.12;0.88;0.06;0.12;0.00;277.36;247.41;384.70;1028.69;25.00;X;X;X;X;X;1:0:0;0.00;1.57;-7.42;-43.99
            // RSSI; framenr; xaccel; yaccel; zaccel; xtilt; ytilt; ztilt; xmag; ymag; zmag; pressure; temp; lat; long; alt; speed; course; h:m:s:ms; hall
            DataStream.AppendText(rxString);
            string[] packetElems = Utils.ParsePacket(rxString);
            double   time        = Convert.ToInt32(timer.Elapsed.TotalSeconds);

            if (packetElems == null || packetElems.Length != 24)
            {
                Console.WriteLine("Skipped corrupted packet");
                return;
            }

            rssitxt.Text    = packetElems[0] + " dBm";
            framenrtxt.Text = packetElems[1];
            xacceltxt.Text  = packetElems[2] + " G";
            yacceltxt.Text  = packetElems[3] + " G";
            zacceltxt.Text  = packetElems[4] + " G";
            xtilttxt.Text   = packetElems[5] + " °/s";
            ytilttxt.Text   = packetElems[6] + " °/s";
            ztilttxt.Text   = packetElems[7] + " °/s";
            xmagtxt.Text    = packetElems[8] + " µT";
            ymagtxt.Text    = packetElems[9] + " µT";
            zmagtxt.Text    = packetElems[10] + " µT";
            psrtxt.Text     = packetElems[11] + " hPa";
            temptxt.Text    = packetElems[12] + " C";

            speedtxt.Text  = packetElems[16] + "m/s";
            coursetxt.Text = packetElems[17] + " °";
            timetxt.Text   = packetElems[18];
            halltxt.Text   = packetElems[19] + " Hz";
            pitchtxt.Text  = packetElems[20] + " °";
            rolltxt.Text   = packetElems[21] + " °";
            yawtxt.Text    = packetElems[22] + " °";
            volttxt.Text   = packetElems[23];

            double pressure    = Convert.ToDouble(packetElems[11]);
            double temperature = Convert.ToDouble(packetElems[12]);

            Upd.UpdateChart(chart2, pressure, time);

            if (packetElems[13] == "x" || packetElems[13] == "X")
            {
                lattxt.Text      = "NO GPS";
                longtxt.Text     = "NO GPS";
                previousAltitude = -1;
            }
            else
            {
                // lat; long; alt; speed; course
                lattxt.Text  = packetElems[13];
                longtxt.Text = packetElems[14];

                double latitude  = Convert.ToDouble(packetElems[13]);
                double Longitude = Convert.ToDouble(packetElems[14]);

                double Altitude;
                if (checkBox2.Checked)
                {
                    Altitude    = Utils.HypsometricFormula(P0, pressure, temperature);
                    alttxt.Text = Altitude + " m";
                }
                else
                {
                    alttxt.Text = packetElems[15] + " m";
                    Altitude    = Convert.ToDouble(packetElems[15]);
                }


                double speed  = Convert.ToDouble(packetElems[16]);
                double course = Convert.ToDouble(packetElems[17]);

                double fallingSpeed;
                if (previousAltitude == -1)
                {
                    fallingSpeed = 0;
                }
                else
                {
                    fallingSpeed = previousAltitude - Altitude;
                }
                gauge1.Update(fallingSpeed);


                Upd.UpdateMap(map, latitude, Longitude, Altitude, fallingSpeed, speed, (int)course);
                lastPoint = new PointLatLng(latitude, Longitude);
                chart3D.Update(latitude, Longitude, Altitude);

                vertveltxt.Text = fallingSpeed.ToString() + " m/s";

                previousAltitude = Altitude;
                Upd.UpdateChart(chart4, Altitude, time);

                Upd.UpdateChart(chart6, speed, time);

                pictureBox1.Image = Compass.DrawCompass(course / 100, 0, 80, 0, 80, pictureBox1.Size);
            }

            pitch = float.Parse(packetElems[20], CultureInfo.InvariantCulture.NumberFormat);
            roll  = float.Parse(packetElems[21], CultureInfo.InvariantCulture.NumberFormat);
            yaw   = float.Parse(packetElems[22], CultureInfo.InvariantCulture.NumberFormat);

            Upd.UpdateChart(chart1, temperature, time);



            // double course = (Convert.ToDouble(packetElems[17])/100);
            //Upd.UpdateChart(chart7, course, time);

            double Hall      = Convert.ToDouble(packetElems[19]);
            double windSpeed = Utils.WindSpeed(Hall);

            Upd.UpdateChart(chart3, windSpeed, time);


            windtxt.Text = Convert.ToString(windSpeed);;


            double signal = Convert.ToDouble(packetElems[0]);
            //gauge2.Update(chart5, signal, time);
            double signalPercent = Utils.SignalStrengthInPercent(signal);

            gauge2.Update(signalPercent);



            // socketio
            string json = JsonConvert.SerializeObject(new { psrtxt = psrtxt.Text, tmptxt = temptxt.Text, txtLat = lattxt.Text, txtLong = longtxt.Text, hghttext = alttxt.Text });

            try
            {
                _ = client.EmitAsync("data", json);
            }
            catch { }
        }
コード例 #33
0
 public MapRoute GetRoute(PointLatLng start, PointLatLng end, bool avoidHighways, bool walkingMode, int Zoom)
 {
    List<PointLatLng> points = GetRoutePoints(MakeRoutingUrl(start, end, walkingMode ? TravelTypeFoot : TravelTypeMotorCar, LanguageStr, "km"));
    MapRoute route = points != null ? new MapRoute(points, walkingMode ? WalkingStr : DrivingStr) : null;
    return route;
 }
コード例 #34
0
        public GMapMarkerElevation(byte [,] imageData, int idx, int idy, RectLatLng rect, PointLatLng currentloc)
            : base(currentloc)
        {
            this.rect = rect;

            IsHitTestVisible = false;

            //create a new Bitmap
            Bitmap bmp = new Bitmap(idx, idy, PixelFormat.Format32bppArgb);

            //lock it to get the BitmapData Object
            BitmapData bmData =
                bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);

            //now we have to convert the 2 dimensional array into a one dimensional byte-array for use with 8bpp bitmaps
            // use stride and height to prevent stride mod 4 issues
            int[] pixels = new int[(bmData.Stride / 4) * bmData.Height];
            for (int y = 0; y < idy; y++)
            {
                for (int x = 0; x < idx; x++)
                {
                    pixels[(y * (bmData.Stride / 4) + x)] = ConvertColor(imageData[x, y]);
                }
            }

            //copy the bytes
            System.Runtime.InteropServices.Marshal.Copy(pixels, 0, bmData.Scan0, (bmData.Stride / 4) * bmData.Height);

            //never forget to unlock the bitmap
            bmp.UnlockBits(bmData);

            bmp.MakeTransparent();

            //display
            elevation = bmp;
        }
コード例 #35
0
ファイル: Core.cs プロジェクト: helgef/flysight
 /// <summary>
 /// return local coordinates from lat/lng
 /// </summary>
 /// <param name="latlng"></param>
 /// <returns></returns>
 public Point FromLatLngToLocal(PointLatLng latlng)
 {
     Point pLocal = Projection.FromLatLngToPixel(latlng, Zoom);
     pLocal.Offset(renderOffset);
     return pLocal;
 }
コード例 #36
0
 public Placemark? GetPlacemark(PointLatLng location, out GeoCoderStatusCode status)
 {
     // http://msdn.microsoft.com/en-us/library/ff701713.aspx
      throw new NotImplementedException();
 }
コード例 #37
0
ファイル: Human.cs プロジェクト: Balkhanakovv/OOP_Lab3
 public Human(string title, PointLatLng point) : base(title)
 {
     this.point = point;
 }
コード例 #38
0
        string MakeRouteUrl(PointLatLng start, PointLatLng end, string language, bool avoidHighways, bool walkingMode)
        {
            string addition = avoidHighways ? "&avoid=highways" : string.Empty;
             string mode = walkingMode ? "Walking" : "Driving";

             return string.Format(CultureInfo.InvariantCulture, RouteUrlFormatPointLatLng, mode, start.Lat, start.Lng, end.Lat, end.Lng, addition, ClientKey);
        }
コード例 #39
0
ファイル: BingMapProvider.cs プロジェクト: zews/GMap.NET
 public Placemark?GetPlacemark(PointLatLng location, out GeoCoderStatusCode status)
 {
     // http://msdn.microsoft.com/en-us/library/ff701713.aspx
     throw new NotImplementedException();
 }
コード例 #40
0
 string MakeReverseGeocoderUrl(PointLatLng pt)
 {
    return string.Format(CultureInfo.InvariantCulture, ReverseGeocoderUrlFormat, pt.Lat, pt.Lng, AppId, !string.IsNullOrEmpty(LanguageStr) ? "&locale=" + LanguageStr : "");
 }
コード例 #41
0
 public GeoCoderStatusCode GetPlacemarks(PointLatLng location, out List <Placemark> placemarkList)
 {
     placemarkList = this.GetPlacemarksByLocation(location);
     return(GeoCoderStatusCode.G_GEO_SUCCESS);
 }
コード例 #42
0
 public Location(string title, PointLatLng point) : base(title)
 {
     Point = point;
 }
コード例 #43
0
 public GeoCoderStatusCode GetPlacemarks(PointLatLng location, out List<Placemark> placemarkList)
 {
     // http://msdn.microsoft.com/en-us/library/ff701713.aspx
      throw new NotImplementedException();
 }
コード例 #44
0
        public GMapRoute GetRoute(PointLatLng start, PointLatLng end, string cityName)
        {
            List <PointLatLng> points      = new List <PointLatLng>();
            string             origin      = string.Format("{0},{1}", start.Lng, start.Lat);
            string             destination = string.Format("{0},{1}", end.Lng, end.Lat);
            string             city        = HttpUtility.UrlEncode(cityName);
            string             url         = string.Format("http://restapi.amap.com/v3/direction/transit/integrated?origin={0}&destination={1}&city={2}&output=json&key={3}", origin, destination, city, KEY);
            string             result      = HttpUtil.GetData(url);

            if (!string.IsNullOrEmpty(result))
            {
                JObject resJosn = JObject.Parse(result);
                string  isOk    = resJosn["info"].ToString();
                if (isOk == "OK")
                {
                    JObject route    = (JObject)resJosn["route"];
                    string  ori      = route["origin"].ToString();
                    string  des      = route["destination"].ToString();
                    string  distance = route["distance"].ToString();
                    JObject transit  = (JObject)route["transits"][0]; //公交换乘方案
                    JArray  segments = (JArray)transit["segments"];   //换乘路段列表
                    JObject firstSeg = (JObject)segments[0];
                    JObject walk     = (JObject)firstSeg["walking"];
                    if (walk != null)
                    {
                        JArray steps = (JArray)walk["steps"];
                        foreach (JObject step in steps)
                        {
                            string   polyline     = step["polyline"].ToString();
                            string[] pointsString = polyline.Split(';');
                            foreach (string pStr in pointsString)
                            {
                                string[]    pointStr = pStr.Split(',');
                                PointLatLng p        = new PointLatLng(double.Parse(pointStr[1]), double.Parse(pointStr[0]));
                                points.Add(p);
                            }
                        }
                    }
                    JObject bus = (JObject)firstSeg["bus"];
                    if (bus != null)
                    {
                        JArray steps = (JArray)bus["buslines"];
                        //foreach (JObject step in steps)
                        if (steps != null && steps.Count > 0)
                        {
                            JObject  step      = (JObject)steps[0];
                            string   polyline  = step["polyline"].ToString();
                            string[] pointsStr = polyline.Split(';');
                            foreach (string pStr in pointsStr)
                            {
                                string[]    pointStr = pStr.Split(',');
                                PointLatLng p        = new PointLatLng(double.Parse(pointStr[1]), double.Parse(pointStr[0]));
                                points.Add(p);
                            }
                        }
                    }
                }
            }

            GMapRoute mapRoute = points != null ? new GMapRoute(points, "") : null;

            return(mapRoute);
        }
コード例 #45
0
      public GeoCoderStatusCode GetPlacemarks(PointLatLng location, out List<Placemark> placemarkList)
      {
          // http://where.yahooapis.com/geocode?q=54.689850,25.269260&appid=1234&flags=G&gflags=QRL&locale=LT-lt

          #region -- response --
          //<ResultSet version="1.0"><Error>0</Error><ErrorMessage>No error</ErrorMessage><Locale>LT-lt</Locale><Quality>99</Quality><Found>1</Found><Result><quality>99</quality><latitude>54.689850</latitude><longitude>25.269260</longitude><offsetlat>54.689850</offsetlat><offsetlon>25.269260</offsetlon><radius>500</radius><name>54.689850,25.269260</name><line1>2 J. Tumo-Vaizganto Gatve</line1><line2>01108 Naujamiestis</line2><line3/><line4>Lietuvos Respublika</line4><house>2</house><street>J. Tumo-Vaizganto Gatve</street><xstreet/><unittype/><unit/><postal>01108</postal><level4>Naujamiestis</level4><level3>Vilnius</level3><level2>Vilniaus Miesto Savivaldybe</level2><level1>Vilniaus Apskritis</level1><level0>Lietuvos Respublika</level0><level0code>LT</level0code><level1code/><level2code/><hash/><woeid>12758362</woeid><woetype>11</woetype><uzip>01108</uzip></Result></ResultSet>
          #endregion

          return GetPlacemarksFromReverseGeocoderUrl(MakeReverseGeocoderUrl(location), out placemarkList);
      }
コード例 #46
0
        // 区别飞行器是正常机、凸显机还是中心机;记录轨迹点
        private void flyTimer_Tick(object sender, EventArgs e)
        {
            if (dataSource.Count == 0)
            {
                return;
            }
            Cat021Data tmpData        = dataSource.GetData();
            int        isCheckedPlane = 0; // 0-普通飞行器,1-凸显飞行器,2-中心机,3-告警机器

            // 获取中心机
            String my_sAddress = ConfigHelper.Instance.GetConfig("my_sAddress");
            int    iAddress    = Convert.ToInt32(my_sAddress);

            if (!string.IsNullOrWhiteSpace(my_sAddress) && tmpData.sModeAddress == iAddress)
            {
                isCheckedPlane = 1;
                initCenterPlane(tmpData);
            }

            PointLatLng pointLatLng = new PointLatLng(tmpData.latitude, tmpData.longtitude);

            // 看飞机是否在凸显列表中
            if (1 != isCheckedPlane)
            {
                if (listAirplaneCheck.ContainsKey(tmpData.sModeAddress))
                {
                    isCheckedPlane = 2;

                    if (pointPlaneLand.ContainsKey(tmpData.sModeAddress))
                    {
                        pointPlaneLand.Remove(tmpData.sModeAddress);
                    }
                    pointPlaneLand.Add(tmpData.sModeAddress, pointLatLng);
                }

                if (AirplaneManager.Instance.checkAlermPlane(tmpData.sModeAddress))
                {
                    isCheckedPlane = 3;
                }
            }

            GMapAirPlane tmpAirplane  = new GMapAirPlane(new PointLatLng(tmpData.latitude, tmpData.longtitude), tmpData, isCheckedPlane);
            int          sModeAddress = tmpData.sModeAddress;

            // 轨迹点处理
            List <PointLatLng> points;

            if (keyValuePairs.ContainsKey(sModeAddress))
            {
                points = keyValuePairs[sModeAddress];
                showValue[sModeAddress] = showValue[sModeAddress] + 1;
                if (29 == showValue[sModeAddress])
                {
                    pointMax(points);
                }
                points.Add(pointLatLng);
            }
            else
            {
                points = new List <PointLatLng>(showPointMax);
                points.Add(pointLatLng);
                keyValuePairs.Add(sModeAddress, points);
                showValue[sModeAddress] = 0;
            }

            // 同一架飞机来了新的先从list里面移除掉
            if (listAirplane.ContainsKey(sModeAddress))
            {
                listAirplane.Remove(sModeAddress);
                //showAllPalne();
                //planeOverlay.Markers.Remove(tmpAirplane);
            }
            else
            {
                listAirplane.Add(sModeAddress, tmpAirplane);
            }
            //showOnePlane(tmpAirplane);

            AirplaneManager.Instance.Add(tmpData);


            /*
             *
             *
             * // 全部飞机展示
             * if (airPlaneShow)
             * {
             *  showAllPalne();
             * }
             *
             * // 展示关注飞机与指定地面站的虚线距离
             * showLandStation();
             *
             * gMapControl1.Refresh();
             */
        }
コード例 #47
0
 public GMapMarkerCondominioLarge(PointLatLng p) : base(p)
 {
     Size = new System.Drawing.Size(global::Gipasoft.Stabili.UI.GeoLocation.Properties.Resources.stabile_large.Width, global::Gipasoft.Stabili.UI.GeoLocation.Properties.Resources.stabile_large.Height);
     Offset = new System.Drawing.Point(-10, -34);
 }
コード例 #48
0
ファイル: MainWindow.xaml.cs プロジェクト: Gevil/Projects
 void MainMap_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     System.Windows.Point p = e.GetPosition(MainMap);
     currentMarker.Position = MainMap.FromLocalToLatLng((int)p.X, (int)p.Y);
     currentposition        = currentMarker.Position;
 }
コード例 #49
0
 public DirectionsStatusCode GetDirections(out GDirections direction, PointLatLng start, IEnumerable<PointLatLng> wayPoints, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
 {
     return GetDirectionsUrl(MakeDirectionsUrl(start, wayPoints, LanguageStr, avoidHighways, avoidTolls, walkingMode, sensor, metric), out direction);
 }
コード例 #50
0
ファイル: MainWindow.xaml.cs プロジェクト: Gevil/Projects
 // sets route start
 private void button11_Click(object sender, RoutedEventArgs e)
 {
     start = currentMarker.Position;
 }
コード例 #51
0
        string MakeDirectionsUrl(PointLatLng start, IEnumerable<PointLatLng> wayPoints, string language, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric)
        {
            string av = (avoidHighways ? "&avoid=highways" : string.Empty) + (avoidTolls ? "&avoid=tolls" : string.Empty); // 6
            string mt = "&units=" + (metric ? "metric" : "imperial"); // 7
            string wk = "&mode=" + (walkingMode ? "walking" : "driving"); // 8

            string wpLatLng = string.Empty;
            int i = 0;
            foreach (var wp in wayPoints)
            {
                wpLatLng += string.Format(CultureInfo.InvariantCulture, i++ == 0 ? "{0},{1}" : "|{0},{1}", wp.Lat, wp.Lng);
            }

            return string.Format(CultureInfo.InvariantCulture, DirectionUrlFormatWaypoint, start.Lat, start.Lng, wpLatLng, sensor.ToString().ToLower(), language, av, mt, wk, ServerAPIs);
        }
コード例 #52
0
ファイル: MainWindow.xaml.cs プロジェクト: Gevil/Projects
 // sets route end
 private void btnEndRoute_Click(object sender, RoutedEventArgs e)
 {
     end = currentMarker.Position;
 }
コード例 #53
0
 string MakeRouteUrl(PointLatLng start, PointLatLng end, string language, bool avoidHighways, bool walkingMode)
 {
     string opt = walkingMode ? WalkingStr : (avoidHighways ? RouteWithoutHighwaysStr : RouteStr);
     return string.Format(CultureInfo.InvariantCulture, RouteUrlFormatPointLatLng, language, opt, start.Lat, start.Lng, end.Lat, end.Lng, Server);
 }
コード例 #54
0
        /// <summary>
        /// 添加点图元
        /// </summary>
        /// <param name="kml">kml对象</param>
        /// <param name="gmapOverlay">图层</param>
        /// <returns></returns>
        public IMFElement CreateElement(Kml kml, GMapOverlay gmapOverlay)
        {
            KmlPoint point = kml.Placemark.Graph as KmlPoint;

            if (point == null)
            {
                return(null);
            }
            if (point.Position == null)
            {
                return(null);
            }

            PointLatLng p = new PointLatLng(point.Position.Lat, point.Position.Lng, point.Position.Alt);

            IMFElement element = null;
            // 位置和图标
            Point_GMap pointElement = new Point_GMap(p, point, kml.Placemark.Name);

            // 大小
            pointElement.Size = new Size(pointElement.Size.Width, pointElement.Size.Height);
            // Tip
            if (!string.IsNullOrEmpty(point.TipText))
            {
                pointElement.ToolTipText = point.TipText;
                pointElement.ToolTipMode = MarkerTooltipMode.OnMouseOver;
                pointElement.ToolTip.Format.Alignment = System.Drawing.StringAlignment.Near; // Tip文字左对齐
            }

            element = pointElement;

            //if (string.IsNullOrEmpty(point.IcoUrl))//纯点
            //{
            //    // 位置和图标
            //    Point_GMap pointElement = new Point_GMap(p, point, kml.Placemark.Name);
            //    // 大小
            //    pointElement.Size = new Size(pointElement.Size.Width, pointElement.Size.Height);
            //    // Tip
            //    if (!string.IsNullOrEmpty(point.TipText))
            //    {
            //        pointElement.ToolTipText = point.TipText;
            //        pointElement.ToolTipMode = MarkerTooltipMode.OnMouseOver;
            //        pointElement.ToolTip.Format.Alignment = System.Drawing.StringAlignment.Near; // Tip文字左对齐
            //    }

            //    element = pointElement;
            //}
            //else                                //目标点
            //{
            //    Picture_GMap moveObj = new Picture_GMap(p, point, kml.Placemark.Name);
            //    // Tip
            //    if (!string.IsNullOrEmpty(point.TipText))
            //    {
            //        moveObj.ToolTipText = point.TipText;
            //        moveObj.ToolTipMode = MarkerTooltipMode.OnMouseOver;
            //        moveObj.ToolTip.Format.Alignment = System.Drawing.StringAlignment.Near; // Tip文字左对齐
            //    }

            //    // 设置图元的类型
            //    moveObj.ElementType = ElementTypeEnum.Point;
            //    // 设置图元的描述信息
            //    moveObj.Description = point.Description;
            //    // 鼠标经过可见
            //    moveObj.IsHitTestVisible = true;
            //    element = moveObj;
            //}

            // 添加图元到图层
            if (gmapOverlay.Control.InvokeRequired)
            {
                gmapOverlay.Control.BeginInvoke(new Action(delegate
                {
                    gmapOverlay.Markers.Add((element as GMapMarker));
                }));
            }
            else
            {
                gmapOverlay.Markers.Add((element as GMapMarker));
            }

            return(element);
        }
コード例 #55
0
 public Placemark? GetPlacemark(PointLatLng location, out GeoCoderStatusCode status)
 {
     List<Placemark> pointList;
     status = GetPlacemarks(location, out pointList);
     return pointList != null && pointList.Count > 0 ? pointList [0] : (Placemark?)null;
 }
コード例 #56
0
 string MakeRoutingUrl(PointLatLng start, PointLatLng end, string travelType, bool withInstructions = false)
 {
     return(string.Format(CultureInfo.InvariantCulture, RoutingUrlFormat, start.Lat, start.Lng, end.Lat, end.Lng, travelType, withInstructions ? "1" : "0", LanguageStr));
 }
コード例 #57
0
      /// <summary>
      /// sets zoom to max to fit rect
      /// </summary>
      /// <param name="rect"></param>
      /// <returns></returns>
      public bool SetZoomToFitRect(RectLatLng rect)
      {
         int mmaxZoom = GetMaxZoomToFitRect(rect);
         if(mmaxZoom > 0)
         {
            PointLatLng center = new PointLatLng(rect.Lat - (rect.HeightLat / 2), rect.Lng + (rect.WidthLng / 2));
            Position = center;

            if(mmaxZoom > maxZoom)
            {
               mmaxZoom = maxZoom;
            }

            if(Zoom != mmaxZoom)
            {
               Zoom = (int)mmaxZoom;
            }

            return true;
         }
         return false;
      }
コード例 #58
0
ファイル: BingMapProvider.cs プロジェクト: zews/GMap.NET
 public GeoCoderStatusCode GetPlacemarks(PointLatLng location, out List <Placemark> placemarkList)
 {
     // http://msdn.microsoft.com/en-us/library/ff701713.aspx
     throw new NotImplementedException();
 }
コード例 #59
0
        //if count of buoy less then 3, return false and do nothing
        public bool Valid(ref PointLatLng center)
        {
            if (Buoys.Count < 3)
            {
                return(false);
            }
            var      sorttable = new Hashtable();
            DateTime t         = DateTime.Today;

            for (int i = Buoys.Count - 1; i >= 0; i--)
            {
                if (sorttable.ContainsKey(Buoys.Values[i].Time))
                {
                    int n = (int)sorttable[Buoys.Values[i].Time];
                    sorttable[Buoys.Values[i].Time] = n + 1;
                    if (n + 1 >= 3)
                    {
                        t = Buoys.Values[i].Time;//most
                    }
                }
                else
                {
                    sorttable.Add(Buoys.Values[i].Time, 1);
                }
            }

            if (!sorttable.ContainsValue(3) && !sorttable.ContainsValue(4))
            {
                return(false);
            }
            if (sorttable.ContainsValue(3) && Buoys.Count == 4)
            {
                //remove unused buoy
                for (int i = Buoys.Count - 1; i >= 0; i--)
                {
                    if (Buoys.Values[i].Time != t)
                    {
                        Buoys.RemoveAt(i);
                        break;
                    }
                }
            }
            //find latest 3 data
            if (Buoys.Count == 4 && UseMatrix)
            {
                int      indexOld = 1;
                DateTime oldtime  = Buoys[indexOld].Time;
                for (int i = 1; i <= Buoys.Count; i++)
                {
                    if (Buoys[i].Time < oldtime)
                    {
                        oldtime  = Buoys[i].Time;
                        indexOld = i;
                    }
                }
                Buoys.Remove(indexOld);
            }
            center = new PointLatLng((Buoys.Values[0].Lat + Buoys.Values[1].Lat + Buoys.Values[2].Lat) / 3,
                                     (Buoys.Values[0].Lng + Buoys.Values[1].Lng + Buoys.Values[2].Lng) / 3);
            //used for matrix
            if (UseMatrix)
            {
                var buoy1 = new PointLatLng(Buoys.Values[0].Lat, Buoys.Values[0].Lng);
                Utility.Util.GetReltXY(buoy1, center, out x1, out y1);

                z1 = 0;
                var buoy2 = new PointLatLng(Buoys.Values[1].Lat, Buoys.Values[1].Lng);
                Utility.Util.GetReltXY(buoy2, center, out x2, out y2);
                z2 = 0;
                var buoy3 = new PointLatLng(Buoys.Values[2].Lat, Buoys.Values[2].Lng);
                Utility.Util.GetReltXY(buoy3, center, out x3, out y3);
                z3     = 0;
                range1 = Buoys.Values[0].Range;
                range2 = Buoys.Values[1].Range;
                range3 = Buoys.Values[2].Range;
            }
            else//used for Approach /km
            {
                geoCoordinate1[0] = Buoys.Values[0].Lat;
                geoCoordinate1[1] = Buoys.Values[0].Lng;
                geoCoordinate1[2] = earthRadius - SonarDepth;
                geoCoordinate2[0] = Buoys.Values[1].Lat;
                geoCoordinate2[1] = Buoys.Values[1].Lng;
                geoCoordinate2[2] = earthRadius - SonarDepth;
                geoCoordinate3[0] = Buoys.Values[2].Lat;
                geoCoordinate3[1] = Buoys.Values[2].Lng;
                geoCoordinate3[2] = earthRadius - SonarDepth;
                distanceBuoy[0]   = Buoys.Values[0].Range / 1000;
                distanceBuoy[1]   = Buoys.Values[1].Range / 1000;
                distanceBuoy[2]   = Buoys.Values[2].Range / 1000;

                if (Buoys.Count == 4)
                {
                    geoCoordinate4[0] = Buoys.Values[3].Lat;
                    geoCoordinate4[1] = Buoys.Values[3].Lng;
                    geoCoordinate4[2] = earthRadius - SonarDepth;
                    distanceBuoy[3]   = Buoys.Values[3].Range / 1000;
                }
            }

            Buoys.Clear();
            return(true);
        }
コード例 #60
0
 public Flight(int CAT, string ACID, string ADDRESS, TimeSpan time, string coordinates, double lat, double lon, int realindex, PointLatLng punto)
 {
     this.CAT         = CAT;
     this.ACID        = ACID;
     this.ADDRESS     = ADDRESS;
     this.time        = time;
     this.coordinates = coordinates;
     this.lat         = lat;
     this.lon         = lon;
     this.realindex   = realindex;
     this.punto       = punto;
 }