Example #1
0
        public KmlEarthquake(KmlFolder parent, Earthquake eq)
            : base(parent, eq.Name, -1, eq.toStringKmlDescr())
        {
            string eqStyleEqSmall  = "#EarthquakeSmall";
            string eqStyleEqMedium = "#EarthquakeMedium";
            string eqStyleEqBig    = "#EarthquakeBig";

            string eqStyle;

            if (eq.Magn >= 5.0d)
            {
                eqStyle = eqStyleEqBig;
            }
            else if (eq.Magn >= 3.0d)
            {
                eqStyle = eqStyleEqMedium;
            }
            else
            {
                eqStyle = eqStyleEqSmall;
            }

            this.setStyle(eqStyle);

            bool eqClampToGround = true;             // eq.Location.Elev == 0.0d;

            XmlNode point = this.Point(eq.Location, eqClampToGround);

//			if(!eqClampToGround)
//			{
//				XmlNode node = point.OwnerDocument.CreateElement("extrude");
//				node.InnerText = "1";
//				point.AppendChild(node);
//			}
        }
Example #2
0
        // for the LiveMap:isRelevant() method
        // we need to know how big the earthquake is on the map without
        // instantiating the visial object. So, we use static method here.
        public static Rectangle boundingRectEstimate(IDrawingSurface map, Earthquake eq, double magnFactor)
        {
            Point pPoint;

            try
            {
                pPoint =	map.toPixelLocation(eq.Location, null);
            }
            catch (Exception e)
            {
                return Rectangle.Empty;
            }

            int w, h;
            int minSize = 15;
            int maxSize = 300;
            int xFactor = 2;
            int yFactor = 2;
            int yExtra = 0;

            double xMetersPerPixel = map.xMetersPerPixel();

            w = (int)(eq.Magn * magnFactor / map.xMetersPerPixel());
            if(w < minSize)	// we don't want the quake to show up too small or too big
            {
                w = minSize;
            }
            if(w > maxSize)
            {
                w = maxSize;
            }

            h = (int)(eq.Magn * magnFactor / map.yMetersPerPixel());
            if(h < minSize)
            {
                h = minSize;
            }
            if(h > maxSize)
            {
                h = maxSize;
            }

            double cameraElevationKm = map.getCameraElevation() / 1000.0d;

            switch (Project.earthquakeStyle)
            {
                default:
                case STYLE_CONCENTRICCIRCLES:	// concentric circles
                case STYLE_SQUARES:
                case STYLE_FILLSQUARES:
                case STYLE_CIRCLES:
                case STYLE_FILLCIRCLES:		// filled circles Alan Jones "Seismic Eruptions" style
                {
                    double magMin;
                    double magOff;
                    double magFact;

                    if(cameraElevationKm > 4000.0d)  // world map
                    {
                        magMin = 5.0d;
                        magOff = 4.5d;
                        magFact = 7.0d;
                    }
                    else if(cameraElevationKm > 900.0d)
                    {	 // small scale
                        magMin = 4.0d;
                        magOff = 2.5d;
                        magFact = 6.0d;
                    }
                    else if(cameraElevationKm > 370.0d)
                    {	 // medium scale
                        magMin = 2.0d;
                        magOff = 0.5d;
                        magFact = 5.0d;
                    }
                    else
                    {	 // very large scale
                        magMin = 1.0d;
                        magOff = 0.5d;
                        magFact = 4.0d;
                    }

                    if(eq.Magn <= magMin)
                    {
                        w = 3;
                        h = 3;
                    }
                    else
                    {
                        w = h = (int)((eq.Magn - magOff) * magFact);
                    }
                }
                    break;
                case STYLE_TRIANGLE:
                    // triangle pointing down to epicenter; the deeper the quake,
                    // the more narrow the triangle is:
                    h = (int)(((double)h) * (1.0d + cameraElevationKm / 10000.0d));	// make them more visible on small scale maps:
                    w = eq.calcTriWidth(h) * 2;	// triWidth is actually half of the upper side of the triangle.
                    if(w < 50 && Project.displayEqDepth)
                    {
                        w = 50;
                    }
                    yFactor = 1;
                    xFactor = 1;
                    yExtra = 3;			// 3 pixels for the epicenter oval
                    break;
                case STYLE_DOT:			// dot
                    w = 3;
                    h = 3;
                    break;
            }

            Rectangle re = new Rectangle(pPoint.X-(w*xFactor/2), pPoint.Y-h, w*xFactor, h*yFactor + yExtra);

            return re;
        }
Example #3
0
 public bool sameAs(Earthquake other)
 {
     return Magn == other.Magn && Location.sameAs(other.Location);
 }
Example #4
0
        private void addToRoute(GeoCoord location, Waypoint wpt, Earthquake eq)
        {
            rteptNumber++;
            string wptName = "" + rteptNumber;
            if(m_routeTrack == null)
            {
                // first route-making click on the map, create track to hold the new route
                string newTrackSource = "route - user created " + DateTime.Now;

                Project.trackId++;
                rteptNumber = 1;
                m_lastWpt = null;

                string newTrackName = "Route-" + Project.trackId;

                CreateInfo createInfo = new CreateInfo();

                createInfo.init("rte");
                createInfo.id = Project.trackId;
                createInfo.name = newTrackName;
                createInfo.source = newTrackSource;
                createInfo.par1 = "" + rteNumber;
                rteNumber++;
                if(rteNumber > 20)
                {
                    rteNumber = 1;
                }

                m_routeTrack = new Track(createInfo);
                m_routeTrack.isRoute = true;
                WaypointsCache.TracksAll.Add(m_routeTrack);
                wptName = "Start route";
            }

            m_speed = null;

            if(m_lastWpt != null && m_lastWpt.HasSpeed)
            {
                m_speed = new Speed(m_lastWpt.Speed);
            }
            else
            {
                m_speed = new Speed(Project.routeSpeed);
            }

            TimeSpan dur = new TimeSpan(100000);

            Waypoint routeWpt = null;
            bool wasNew = false;

            if(wpt != null)
            {
                routeWpt = new Waypoint(wpt);
                routeWpt.LiveObjectType = LiveObjectTypes.LiveObjectTypeRoutepoint;
                routeWpt.DateTime = m_dateTimeRte;
            }
            else if(eq != null)
            {
                //wptName = eq.ToString();
                wptName = string.Format("{0:F1} - ", eq.Magn) + eq.sDateTime + " - " + eq.Comment;
                routeWpt = new Waypoint(eq.Location, m_dateTimeRte, LiveObjectTypes.LiveObjectTypeRoutepoint, Project.trackId, wptName, eq.Source, eq.Url);
            }
            else
            {
                // location must not be null then:
                routeWpt = new Waypoint(location, m_dateTimeRte, LiveObjectTypes.LiveObjectTypeRoutepoint, Project.trackId, "", "user created", "");		// no URL
                routeWpt.NameDisplayed = wptName;
                wasNew = true;
            }

            if(m_speed != null)
            {
                routeWpt.Speed = (float)m_speed.Meters;
            }

            if(m_lastWpt != null && m_lastWpt.TrackId == Project.trackId)
            {
                Distance dist = routeWpt.distanceFrom(m_lastWpt.Location);
                double durSeconds = m_speed.Meters <= 0.0d ? 0.000001d : (dist.Meters / m_speed.Meters * 3600.0d);
                dur = new TimeSpan((long)(durSeconds * 10000000.0d));

                m_dateTimeRte += dur;
            }

            routeWpt.DateTime = m_dateTimeRte;

            m_lastWpt = routeWpt;

            // we need to make sure that the point added is different from the last point in track.
            // Magellan will not accept routes with zero-length legs.
            Waypoint lastWpt = null;
            if(m_routeTrack.Trackpoints.Count > 0)
            {
                lastWpt = (Waypoint)m_routeTrack.Trackpoints.GetByIndex(m_routeTrack.Trackpoints.Count - 1);
            }

            if(lastWpt == null || lastWpt.Location.distanceFrom(routeWpt.Location).Meters > 2.0d)
            {
                if(wasNew && lastWpt != null)
                {
                    routeWpt.Location.Elev = lastWpt.Location.Elev;
                }
                m_routeTrack.Trackpoints.Add(routeWpt.DateTime, routeWpt);
                m_routeTrack.PutOnMap(this, null, this);

                if(wptName.Length > 2)
                {
                    //m_cameraManager.MarkLocation(mouseGeoLocation, 0);
                    m_cameraManager.ProcessCameraMove();		// make sure label is positionsed on the map
                }
                else
                {
                    // invalidate picture region around just created leg:
                    Waypoint prevWpt = (Waypoint)m_routeTrack.Trackpoints.GetByIndex(m_routeTrack.Trackpoints.Count - 2);
                    Point p1 = m_cameraManager.toPixelLocation(routeWpt.Location, null);
                    Point p2 = m_cameraManager.toPixelLocation(prevWpt.Location, null);
                    int x = Math.Min(p1.X, p2.X);
                    int y = Math.Min(p1.Y, p2.Y);
                    int w = Math.Abs(p1.X - p2.X);
                    int h = Math.Abs(p1.Y - p2.Y);
                    Rectangle toInv = new Rectangle(x, y, w, h);
                    toInv.Offset(-5, -5);
                    toInv.Inflate(10, 10);
                    m_pictureManager.Invalidate(toInv);
                }
            }
        }
Example #5
0
        public Waypoint(Earthquake eq)
        {
            m_id = nextWaypointId++;

            m_location = new GeoCoord(eq.Location);
            m_dateTime = eq.DateTime;		// always UTC; value type is copied
            LiveObjectType = LiveObjectTypes.LiveObjectTypeWaypoint; //eq.LiveObjectType;
            m_name = eq.Name;
            m_url = eq.Url;
            m_wptType = "earthquake";
            m_desc = eq.Comment + " (" + eq.Source + ")";
            m_source = eq.Source;
            m_wptName = String.Format("{0:F1}", eq.Magn);	//eq.Name;
            m_urlName = eq.Name;
            //m_comment = eq.Comment;
            m_sym = "earthquake";

            setBrushes();
        }
Example #6
0
 public void addEqToRoute(Earthquake eq)
 {
     addToRoute(null, null, eq);
 }
Example #7
0
        private static int InsertEarthquakeToDisplay(Earthquake eq)
        {
            if(m_cameraManager == null)
            {
                return 0;
            }

            bool haveTerraTiles = (Project.terraserverAvailable || Project.terraserverDisconnected)
                                    && (m_cameraManager.terraTopLeft.Lng < m_cameraManager.terraBottomRight.Lng)
                                    && (m_cameraManager.terraTopLeft.Lat > m_cameraManager.terraBottomRight.Lat);

            // for PDA we need to cover all area covered by tiles, which is wider than visible window:
            double lngCLeft = haveTerraTiles ? m_cameraManager.terraTopLeft.Lng : m_cameraManager.CoverageTopLeft.Lng;
            double lngCRight = haveTerraTiles ? m_cameraManager.terraBottomRight.Lng : m_cameraManager.CoverageBottomRight.Lng;
            double latCTop = haveTerraTiles ? m_cameraManager.terraTopLeft.Lat : m_cameraManager.CoverageTopLeft.Lat;
            double latCBottom = haveTerraTiles ? m_cameraManager.terraBottomRight.Lat : m_cameraManager.CoverageBottomRight.Lat;

            double lng = eq.Location.Lng;
            double lat = eq.Location.Lat;

            // here is a catch: eq coordinates are <180 >-180 (normaliized) while coverage coordinates are not.
            bool span180W = lngCLeft < -180.0d;
            bool span180E = lngCRight > 180.0d;
            // de-normalize lng for comparisons, if span180 takes place:
            if(span180W && lng > 0)
            {
                lng -= 360.0d;
            }
            if(span180E && lng < 0)
            {
                lng += 360.0d;
            }

            if (lng > lngCRight || lng < lngCLeft || lat > latCTop || lat < latCBottom)
            {
                return 0;
            }

            int ii;
            for (ii=0; ii < m_earthquakesDisplayed.Count ;ii++)
            {
                Earthquake other = (Earthquake)m_earthquakesDisplayed[ii];
                double lato = other.Location.Lat;

                if(lato == lat)
                {
                    if(eq.sameAs(other))
                    {
                        //LibSys.StatusBar.Trace(" ---- ignored duplicate earthquake (orig from " + other.Source + ") : " + eq);
                        return 0;		// ignore if it ain't new
                    }
                }
                else if(lato < lat)	// sort north to south
                {
                    break;
                }
            }
            if(ii == m_earthquakesDisplayed.Count)
            {
                m_earthquakesDisplayed.Add(eq);
            }
            else
            {
                m_earthquakesDisplayed.Insert(ii, eq);
            }
            return 1;
        }
Example #8
0
        public static void insertEarthquake(string[] infos)
        {
            /* DEBUG
            for(int jj=0; jj < infos.Length ;jj++)
            {
                LibSys.StatusBar.Trace("infos: " + jj + " '" + infos[jj] + "'");
            }
            */
            Earthquake eq = new Earthquake(infos);

            /* DEBUG
            if (eq.Location.X > -127 || eq.Location.X < -130 || eq.Location.Y > 45 || eq.Location.Y < 43)
            {
                return;
            }
            */

            // Filter out future quakes:
            DateTime dtInsane = DateTime.Now.AddDays(5);
            if(eq.DateTime.Ticks > dtInsane.Ticks)
            {
                return;
            }

            //double lng = eq.Location.Lng;
            double lat = eq.Location.Lat;

            lock(m_earthquakesAll)
            {

                int ii;
                for (ii=0; ii < m_earthquakesAll.Count ;ii++)
                {
                    Earthquake other = (Earthquake)m_earthquakesAll[ii];
                    double lngo = other.Location.Lng;
                    double lato = other.Location.Lat;

                    //if(lngo == lng)
                    if(lato == lat)
                    {
                        if(eq.sameAs(other))
                        {
                            //LibSys.StatusBar.Trace(" ---- ignored duplicate earthquake (orig from " + other.Source + ") : " + eq);
                            return;		// ignore if it ain't new
                        }
                    }
                        //else if(lngo < lng)	// sort east to west
                        //else if(lato > lat)	// sort south to north
                    else if(lato < lat)	// sort north to south
                    {
                        break;
                    }
                }
                eq.Id = Project.eqId++;		// new earthquake, assign an Id
                if(ii == m_earthquakesAll.Count)
                {
                    m_earthquakesAll.Add(eq);
                }
                else
                {
                    m_earthquakesAll.Insert(ii, eq);
                }

                // invalidating every object's drawing area is VERY expensive, we do PictureManager.Refresh() instead
                // at the end of interpreting all files. So the next line is commented out.
                //DynamicObjectCreateCallback(eq);
            }
        }
Example #9
0
        /// <summary>
        /// build context menu on the right mouse click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mainPictureBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            try
            {
                btnDown = e.Button;
                Project.ClearPopup();
                rightClickWaypoint = null;
                rightClickEarthquake = null;

                LibSys.StatusBar.Trace("mainPictureBox_MouseDown: ctrl=" + controlDown + "  shift=" + shiftDown + "  alt=" + altDown);

                m_pictureManager.pictureMouseDown(e, controlDown, shiftDown, altDown);
                m_cameraManager.pictureMouseDown(e, controlDown, shiftDown, altDown);

                bool backClick = (e.Button == MouseButtons.XButton1);
                if(backClick)
                {
                    doBack();
                }
                bool forwardClick = (e.Button == MouseButtons.XButton2);
                if(forwardClick)
                {
                    doForward();
                }
                rightClick = (e.Button == MouseButtons.Right);
                if(rightClick)
                {
                    rightClickPoint = new Point(e.X, e.Y);
                    if(m_cameraManager.pointInsideDragRectangle(rightClickPoint))
                    {
                        // process right-clicking into drag rectangle here
                        // Clear all previously added MenuItems.
                        mainPictureBox_ContextMenu.MenuItems.Clear();

                        int index = 0;
                        MenuItem menuItem = null;

                        menuItem = new MenuItem("Zoom in");
                        menuItem.Index = index++;
                        menuItem.Click += new System.EventHandler(cm_zoomToDragRectangleMenuItem_Click);
                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                        menuItem = new MenuItem("Preload Tiles");
                        menuItem.Index = index++;
                        menuItem.Click += new System.EventHandler(cm_preloadMenuItem_Click);
                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                        menuItem = new MenuItem("GoogleEarth - show selected area");
                        menuItem.Index = index++;
                        menuItem.Click += new System.EventHandler(cm_areaGoogleEarthMenuItem_Click);
                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                        menuItem = new MenuItem("-");
                        menuItem.Index = index++;
                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                        menuItem = new MenuItem("Help");
                        menuItem.Index = index++;
                        menuItem.Click += new System.EventHandler(cm_helpMenuItem_Click);
                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                    }
                    else
                    {
                        // generic right-click, or right-click outside the drag rectangle
                        m_cameraManager.resetDrag(true);

                        // Clear all previously added MenuItems.
                        mainPictureBox_ContextMenu.MenuItems.Clear();

                        int index = 0;
                        MenuItem menuItem = null;
                        bool putGeTrackItem = false;
                        bool putGeWptItem = false;

                        LiveObject lo = m_pictureManager.evalPictureClick(e, controlDown, shiftDown, altDown);

                        if(LayerWaypoints.This.makeRouteMode)
                        {
                            if(lo != null)
                            {
                                if(lo.GetType().Equals(Waypoint.getType()))
                                {
                                    rightClickWaypoint = (Waypoint)lo;

                                    if(rightClickWaypoint.TrackId == -1)
                                    {
                                        menuItem = new MenuItem("Add waypoint to route");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_addWptToRouteMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    if(rightClickWaypoint.TrackId == LayerWaypoints.This.routeBeingBuilt.Id)
                                    {
                                        menuItem = new MenuItem("Edit routepoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_editMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                        menuItem = new MenuItem("Move routepoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_moveMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                        menuItem = new MenuItem("Remove waypoint from the route");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_removeWptFromRouteMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                }
                                else if(lo.GetType().Equals(Earthquake.getType()))
                                {
                                    rightClickEarthquake = (Earthquake)lo;

                                    menuItem = new MenuItem("Add earthquake to route");
                                    menuItem.Index = index++;
                                    menuItem.Click += new System.EventHandler(cm_addEqToRouteMenuItem_Click);
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                }
                            }
                            menuItem = new MenuItem("End making route [Esc]");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_endrouteMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                        }
                        else
                        {
                            if(lo != null)
                            {
                                if(lo.GetType().Equals(Waypoint.getType()))
                                {
                                    rightClickWaypoint = (Waypoint)lo;
                                    if(!Project.allowMapPopups)
                                    {
                                        menuItem = new MenuItem("Detail (in popup)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_detailMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                    if((cm_trackId=rightClickWaypoint.TrackId) != -1)
                                    {
                                        Track trk = WaypointsCache.getTrackById(cm_trackId);
                                        if(trk != null)
                                        {
                                            menuItem = new MenuItem("Track Detail [" + cm_trackId + ": " + trk.Name + "]");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("View Whole Trip");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackZoomMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("Hide Track");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackHideMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("Break into Trips");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackUngroupMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("Break Here");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackUngroupHereMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("Preload Tiles Along the Route");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_preloadAlongRouteMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            menuItem = new MenuItem("Save Track As...");
                                            menuItem.Index = index++;
                                            menuItem.Click += new System.EventHandler(cm_trackSaveAsMenuItem_Click);
                                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                            putGeTrackItem = true;
                                        }
                                    }
                                    else
                                    {
                                        putGeWptItem = true;
                                    }

                                    if(rightClickWaypoint.Url != null && rightClickWaypoint.Url.StartsWith("http://") && Project.serverAvailable)
                                    {
                                        menuItem = new MenuItem("Detail (in browser)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_browseMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    if(rightClickWaypoint.ThumbImage == null)
                                    {
                                        menuItem = new MenuItem(cm_trackId < 0 ? "Edit waypoint" : "Edit trackpoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_editMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                        menuItem = new MenuItem(cm_trackId < 0 ? "Move waypoint" : "Move trackpoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_moveMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                        menuItem = new MenuItem(cm_trackId < 0 ? "Delete waypoint" : "Delete trackpoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_deleteMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                    else
                                    {
                                        menuItem = new MenuItem("View photo");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_viewPhotoMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                        menuItem = new MenuItem("Edit/Draw over photo");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_viewPhotoDrawMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    if(putGeTrackItem)
                                    {
                                        menuItem = new MenuItem("GoogleEarth - show trip");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_trackGoogleEarthMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                    else if(putGeWptItem)
                                    {
                                        menuItem = new MenuItem("GoogleEarth - show waypoint");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_wptGoogleEarthMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    menuItem = new MenuItem("-");
                                    menuItem.Index = index++;
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                }
                                else if(lo.GetType().Equals(Vehicle.getType()) || lo.GetType().Equals(VehicleGps.getType()))
                                {
                                    rightClickVehicle = (Vehicle)lo;
                                    if(!Project.allowMapPopups)
                                    {
                                        menuItem = new MenuItem("Detail (in popup)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_detailMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                    if(rightClickVehicle.Url != null && rightClickVehicle.Url.StartsWith("http:") && Project.serverAvailable)
                                    {
                                        menuItem = new MenuItem("Detail (in browser)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_browseMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    menuItem = new MenuItem("Delete vehicle");
                                    menuItem.Index = index++;
                                    menuItem.Click += new System.EventHandler(cm_deleteVehicleMenuItem_Click);
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                    menuItem = new MenuItem("-");
                                    menuItem.Index = index++;
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                }
                                else if(lo.GetType().Equals(Earthquake.getType()))
                                {
                                    rightClickEarthquake = (Earthquake)lo;
                                    if(!Project.allowMapPopups)
                                    {
                                        menuItem = new MenuItem("Detail (in popup)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_detailMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }
                                    if(rightClickEarthquake.Url != null && rightClickEarthquake.Url.StartsWith("http:") && Project.serverAvailable)
                                    {
                                        menuItem = new MenuItem("Detail (in browser)");
                                        menuItem.Index = index++;
                                        menuItem.Click += new System.EventHandler(cm_browseMenuItem_Click);
                                        mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                    }

                                    menuItem = new MenuItem("GoogleEarth - show earthquake");
                                    menuItem.Index = index++;
                                    menuItem.Click += new System.EventHandler(cm_eqGoogleEarthMenuItem_Click);
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                                    menuItem = new MenuItem("-");
                                    menuItem.Index = index++;
                                    mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                                }
                            }

                            menuItem = new MenuItem((Project.allowMapPopups ? "Disable" : "Enable") + " Popups");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_popupsMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("New Waypoint");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_newWaypointMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("New Route");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_newRouteMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Waypoints Manager");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(this.trackManagerMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            if(lo == null)
                            {
                                menuItem = new MenuItem("GoogleEarth - this point on map");
                                menuItem.Index = index++;
                                menuItem.Click += new System.EventHandler(cm_pointGoogleEarthMenuItem_Click);
                                mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                            }

                            menuItem = new MenuItem("-");
                            menuItem.Index = index++;
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Center here (same as double click)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_centerMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Zoom In (same as +)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_zoomInMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Zoom Out (same as - or Shift/Click)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_zoomOutMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem((Project.trackElevColor ? "Disable tracks elevation color" : "Color code tracks elevation"));
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_colorCodeMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem((Project.trackSpeedColor ? "Disable tracks speed color" : "Color code tracks by speed"));
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_colorSpeedMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItemWptNaming.Index = index++;
                            menuItemWptNaming.MenuItems.Clear();
                            for (int i=0; i < Project.waypointNameStyleChoices.Length ;i++)
                            {
                                menuItem = new MenuItem(Project.waypointNameStyleChoices[i]);
                                menuItem.Checked = Project.waypointNameStyle == i;
                                menuItem.Click += new System.EventHandler(cm_wptNamingStyleMenuItem_Click);
                                menuItemWptNaming.MenuItems.Add(menuItem);
                            }
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItemWptNaming);

                            menuItem = new MenuItem("-");
                            menuItem.Index = index++;
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItemTools.Index = index++;
                            menuItemTools.MenuItems.Clear();
                            for (int i=0; i < Project.tools.tools.Count ;i++)
                            {
                                ToolDescr td = (ToolDescr)Project.tools.tools[i];
                                menuItem = new MenuItem(td.ToString().Replace("&", "&&"));
                                menuItem.Click += new System.EventHandler(cm_toolMenuItem_Click);
                                menuItemTools.MenuItems.Add(menuItem);
                            }
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItemTools);

                            menuItem = new MenuItem("Street Map (in browser)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_streetMapMenuItem_Click);
                            if(!Project.serverAvailable)
                            {
                                // obviously disconnected, disable Internet-related function:
                                menuItem.Enabled = false;
                            }
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Nearest Geocaches (in browser)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_nearestGeocachesMenuItem_Click);
                            if(!Project.serverAvailable)
                            {
                                // obviously disconnected, disable Internet-related function:
                                menuItem.Enabled = false;
                            }
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);

                            menuItem = new MenuItem("Help (F1)");
                            menuItem.Index = index++;
                            menuItem.Click += new System.EventHandler(cm_helpMenuItem_Click);
                            mainPictureBox_ContextMenu.MenuItems.Add(menuItem);
                        }
                    }
                }
            }
            catch {}
        }
Example #10
0
        // for the LiveMap:isRelevant() method
        // we need to know how big the earthquake is on the map without
        // instantiating the visial object. So, we use static method here.
        public static Rectangle boundingRectEstimate(IDrawingSurface map, Earthquake eq, double magnFactor)
        {
            Point pPoint;

            try
            {
                pPoint = map.toPixelLocation(eq.Location, null);
            }
            catch (Exception e)
            {
                return(Rectangle.Empty);
            }

            int w, h;
            int minSize = 15;
            int maxSize = 300;
            int xFactor = 2;
            int yFactor = 2;
            int yExtra  = 0;

            double xMetersPerPixel = map.xMetersPerPixel();

            w = (int)(eq.Magn * magnFactor / map.xMetersPerPixel());
            if (w < minSize)            // we don't want the quake to show up too small or too big
            {
                w = minSize;
            }
            if (w > maxSize)
            {
                w = maxSize;
            }

            h = (int)(eq.Magn * magnFactor / map.yMetersPerPixel());
            if (h < minSize)
            {
                h = minSize;
            }
            if (h > maxSize)
            {
                h = maxSize;
            }

            double cameraElevationKm = map.getCameraElevation() / 1000.0d;

            switch (Project.earthquakeStyle)
            {
            default:
            case STYLE_CONCENTRICCIRCLES:                       // concentric circles
            case STYLE_SQUARES:
            case STYLE_FILLSQUARES:
            case STYLE_CIRCLES:
            case STYLE_FILLCIRCLES:                             // filled circles Alan Jones "Seismic Eruptions" style
            {
                double magMin;
                double magOff;
                double magFact;

                if (cameraElevationKm > 4000.0d)                         // world map
                {
                    magMin  = 5.0d;
                    magOff  = 4.5d;
                    magFact = 7.0d;
                }
                else if (cameraElevationKm > 900.0d)
                {                                // small scale
                    magMin  = 4.0d;
                    magOff  = 2.5d;
                    magFact = 6.0d;
                }
                else if (cameraElevationKm > 370.0d)
                {                                // medium scale
                    magMin  = 2.0d;
                    magOff  = 0.5d;
                    magFact = 5.0d;
                }
                else
                {                                // very large scale
                    magMin  = 1.0d;
                    magOff  = 0.5d;
                    magFact = 4.0d;
                }

                if (eq.Magn <= magMin)
                {
                    w = 3;
                    h = 3;
                }
                else
                {
                    w = h = (int)((eq.Magn - magOff) * magFact);
                }
            }
            break;

            case STYLE_TRIANGLE:
                // triangle pointing down to epicenter; the deeper the quake,
                // the more narrow the triangle is:
                h = (int)(((double)h) * (1.0d + cameraElevationKm / 10000.0d)); // make them more visible on small scale maps:
                w = eq.calcTriWidth(h) * 2;                                     // triWidth is actually half of the upper side of the triangle.
                if (w < 50 && Project.displayEqDepth)
                {
                    w = 50;
                }
                yFactor = 1;
                xFactor = 1;
                yExtra  = 3;                                            // 3 pixels for the epicenter oval
                break;

            case STYLE_DOT:                                     // dot
                w = 3;
                h = 3;
                break;
            }

            Rectangle re = new Rectangle(pPoint.X - (w * xFactor / 2), pPoint.Y - h, w * xFactor, h * yFactor + yExtra);

            return(re);
        }
Example #11
0
 public bool sameAs(Earthquake other)
 {
     return(Magn == other.Magn && Location.sameAs(other.Location));
 }