Exemple #1
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;
        }
Exemple #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);
        }