示例#1
0
    public static MapBounds MaxBounds(params MapBounds[] list)
    {
        MapBounds result = new MapBounds();

        // TODO: real Bounds are overflowing...   work with the real values
        if (list.Length > 0)
        {
            // start with first listitem so that the zero is no problem
            int count = 0;
            do
            {
                result = list[count++].Copy();
            } while (result.Equals(new MapBounds()));


            foreach (MapBounds bounds2 in list)
            {
                // sort out the (0,0,0,0) bounds
                if (!bounds2.Equals(new MapBounds()))
                {
                    // is northern ?
                    if (result.North < bounds2.North)
                    {
                        result.North = bounds2.North;
                    }

                    // is eastern ?
                    if (result.East < bounds2.East)
                    {
                        result.East = bounds2.East;
                    }

                    // is southern ?
                    if (result.South > bounds2.South)
                    {
                        result.South = bounds2.South;
                    }

                    // is western ?
                    if (result.West > bounds2.West)
                    {
                        result.West = bounds2.West;
                    }
                }
            }
        }
        return(result);
    }