示例#1
2
        public double getDistance(PointLatLng p1, PointLatLng p2)
        {
            GMapRoute route = new GMapRoute("getDistance");
            route.Points.Add(p1);
            route.Points.Add(p2);
            double distance = route.Distance;
            route.Clear();
            route = null;

            return distance;
        }
        void mapa_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var p = e.GetPosition(mapa);

            if (dibujando)
            {
                ZonaActual.Points.Add(mapa.FromLocalToLatLng((int)p.X, (int)p.Y));
                ZonaActual.RegenerateShape(mapa);

                if (Keyboard.Modifiers == ModifierKeys.Control)
                {
                    this.dibujando = false;
                    mapa.Markers.Remove(Linea);
                    Linea.Clear();
                    Linea = null;
                    this.TerminarDibujo();
                }
            }
            else
            {
                dibujando = true;
                PointLatLng[] points = { mapa.FromLocalToLatLng((int)p.X, (int)p.Y) };
                this.ZonaActual = CrearPoligono(points, Brushes.Red);
                mapa.Markers.Add(this.ZonaActual);
                mapa.MouseMove += mapa_MouseMove;
            }
        }
示例#3
0
 private void ClearAllDiagrams()
 {
     Elevation_Cartesian_Series.Points.Clear();
     Elevation_Polar_Series.Points.Clear();
     Distance_Cartesian_Series.Points.Clear();
     Distance_Cartesian_Series.Points.Clear();
     horizon.Clear();
 }
示例#4
0
 private void button6_Click(object sender, EventArgs e)
 {
     gMapControl1.Overlays[(int)OVERLAYS.LINE].Clear();
     line_overlay.Routes.Clear();
     line_layer.Clear();
     m_latList.Clear();
     m_lonList.Clear();
     gMapControl1.Refresh();
 }
 private void ClearTempData()
 {
     m_tempPoints.Clear();
     if (m_tempRoute != null)
     {
         m_tempRoute.Clear();
     }
     m_tempRouteOverlay.Routes.Clear();
 }
示例#6
0
 public void updateLocation(string updatedLocation)
 {
     r.Clear();
     markerOverlay.Clear();
     routeOverlay.Clear();
     form.map.Overlays.Clear();
     form.lblDistance.Text = "";
     currentLocation       = findLocation(updatedLocation);
     draw();
 }
示例#7
0
        public double getDistance(PointLatLng p1, PointLatLng p2)
        {
            GMapRoute route = new GMapRoute("getDistance");

            route.Points.Add(p1);
            route.Points.Add(p2);
            double distance = route.Distance;

            route.Clear();
            route = null;

            return(distance);
        }
        private void MapButton_Click(object sender, RoutedEventArgs e)
        {
            gMap.Markers?.Clear();
            gMapRoute?.Clear();
            gMapRoute = null;

            gMap.Markers.Add(stationMarker);
            gMap.Markers.Add(planeMarker);

            foreach (var marker in wayMarkerList)
            {
                gMap.Markers.Add(marker);
            }
        }
示例#9
0
        private void RegenerateWPRoute(List <PointLatLngAlt> fullpointlist, PointLatLngAlt HomeLocation)
        {
            route.Clear();
            homeroute.Clear();

            PointLatLngAlt        lastpnt       = fullpointlist[0];
            PointLatLngAlt        lastpnt2      = fullpointlist[0];
            PointLatLngAlt        lastnonspline = fullpointlist[0];
            List <PointLatLngAlt> splinepnts    = new List <PointLatLngAlt>();
            List <PointLatLngAlt> wproute       = new List <PointLatLngAlt>();

            // add home - this causeszx the spline to always have a straight finish
            fullpointlist.Add(fullpointlist[0]);

            for (int a = 0; a < fullpointlist.Count; a++)
            {
                if (fullpointlist[a] == null)
                {
                    continue;
                }

                if (fullpointlist[a].Tag2 == "spline")
                {
                    if (splinepnts.Count == 0)
                    {
                        splinepnts.Add(lastpnt);
                    }

                    splinepnts.Add(fullpointlist[a]);
                }
                else
                {
                    if (splinepnts.Count > 0)
                    {
                        List <PointLatLng> list = new List <PointLatLng>();

                        splinepnts.Add(fullpointlist[a]);

                        Spline2 sp = new Spline2(HomeLocation);

                        sp.set_wp_origin_and_destination(sp.pv_location_to_vector(lastpnt2),
                                                         sp.pv_location_to_vector(lastpnt));

                        sp._flags.reached_destination = true;

                        for (int no = 1; no < (splinepnts.Count - 1); no++)
                        {
                            Spline2.spline_segment_end_type segtype =
                                Spline2.spline_segment_end_type.SEGMENT_END_STRAIGHT;

                            if (no < (splinepnts.Count - 2))
                            {
                                segtype = Spline2.spline_segment_end_type.SEGMENT_END_SPLINE;
                            }

                            sp.set_spline_destination(sp.pv_location_to_vector(splinepnts[no]), false, segtype,
                                                      sp.pv_location_to_vector(splinepnts[no + 1]));

                            //sp.update_spline();

                            while (sp._flags.reached_destination == false)
                            {
                                float t = 1f;
                                //sp.update_spline();
                                sp.advance_spline_target_along_track(t);
                                // Console.WriteLine(sp.pv_vector_to_location(sp.target_pos).ToString());
                                list.Add(sp.pv_vector_to_location(sp.target_pos));
                            }

                            list.Add(splinepnts[no]);
                        }

                        list.ForEach(x => { wproute.Add(x); });


                        splinepnts.Clear();

                        lastnonspline = fullpointlist[a];
                    }

                    wproute.Add(fullpointlist[a]);

                    lastpnt2 = lastpnt;
                    lastpnt  = fullpointlist[a];
                }
            }

            int            count      = wproute.Count;
            int            counter    = 0;
            PointLatLngAlt homepoint  = new PointLatLngAlt();
            PointLatLngAlt firstpoint = new PointLatLngAlt();
            PointLatLngAlt lastpoint  = new PointLatLngAlt();

            if (count > 2)
            {
                // homeroute = last, home, first
                wproute.ForEach(x =>
                {
                    counter++;
                    if (counter == 1)
                    {
                        homepoint = x;
                        return;
                    }
                    if (counter == 2)
                    {
                        firstpoint = x;
                    }
                    if (counter == count - 1)
                    {
                        lastpoint = x;
                    }
                    if (counter == count)
                    {
                        homeroute.Points.Add(lastpoint);
                        homeroute.Points.Add(homepoint);
                        homeroute.Points.Add(firstpoint);
                        return;
                    }
                    route.Points.Add(x);
                });

                homeroute.Stroke = new Pen(Color.Yellow, 2);
                // if we have a large distance between home and the first/last point, it hangs on the draw of a the dashed line.
                if (homepoint.GetDistance(lastpoint) < 5000 && homepoint.GetDistance(firstpoint) < 5000)
                {
                    homeroute.Stroke.DashStyle = DashStyle.Dash;
                }

                overlay.Routes.Add(homeroute);

                route.Stroke           = new Pen(Color.Yellow, 4);
                route.Stroke.DashStyle = DashStyle.Custom;
                overlay.Routes.Add(route);
            }
        }