Exemple #1
0
        public static BoundingBox GetCenterPhotoData(int currentlevel, int level)
        {
            EasyMap.Geometries.Point center = Map.Center;
            int       rootlevel             = level / 4 + 1;
            TreeNode  node  = _PhotoRoot;
            DataTable table = MapDBClass.GetCenterTifInformation(center.X, center.Y);
            bool      find  = false;
            PhotoData data  = new PhotoData();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                string name = table.Rows[i]["Name"] as string;
                node = FindNode(_PhotoRoot, name);
                PhotoData tempdata = null;
                if (node != null)
                {
                    if (node.Parent != null)
                    {
                        tempdata = node.Parent.Tag as PhotoData;
                    }
                }
                if (node != null && (node.Level == rootlevel || (tempdata != null && (tempdata.FileName == "" || tempdata.FileName == null) && node.Level - 1 == rootlevel)))
                {
                    data.PhotoId    = (int)table.Rows[i]["PhotoId"];
                    data.Name       = (string)table.Rows[i]["Name"];
                    data.FileName   = (string)table.Rows[i]["FileName"];
                    data.MinX       = (double)table.Rows[i]["MinX"];
                    data.MinY       = (double)table.Rows[i]["MinY"];
                    data.MaxX       = (double)table.Rows[i]["MaxX"];
                    data.MaxY       = (double)table.Rows[i]["MaxY"];
                    data.Transform1 = (double)table.Rows[i]["Transform1"];
                    data.Transform2 = (double)table.Rows[i]["Transform2"];
                    data.Transform3 = (double)table.Rows[i]["Transform3"];
                    data.Transform4 = (double)table.Rows[i]["Transform4"];
                    data.Transform5 = (double)table.Rows[i]["Transform5"];
                    data.Transform6 = (double)table.Rows[i]["Transform6"];
                    data.Width      = (int)table.Rows[i]["Width"];
                    data.Height     = (int)table.Rows[i]["Height"];
                    find            = true;
                    break;
                }
            }
            if (!find)
            {
                return(Map.Envelope);
            }
            int step = -100;

            if (currentlevel < level)
            {
                step = -100;
            }
            int overviewlevel = 0;
            int overviewzoom  = 0;

            find = false;
            BoundingBox box = Map.Envelope;

            box = new BoundingBox(box.Min.X, box.Min.Y, box.Max.X, box.Max.Y);

            if (currentlevel < level)
            {
                while (overviewlevel != (4 - level % 4) && box.Min.X < box.Max.X && box.Min.Y < box.Max.Y)
                {
                    box.Min.X -= step;
                    box.Min.Y -= step;
                    box.Max.X += step;
                    box.Max.Y += step;

                    find = SetOverView(data, out overviewlevel, out overviewzoom);
                }
            }
            else
            {
                BoundingBox maxbox = Map.GetExtents();
                while (overviewlevel != (4 - level % 4) && box.Min.X > maxbox.Min.X && box.Min.Y > maxbox.Min.Y && box.Max.X < maxbox.Max.X && box.Max.Y < maxbox.Max.Y)
                {
                    box.Min.X -= step;
                    box.Min.Y -= step;
                    box.Max.X += step;
                    box.Max.Y += step;

                    find = SetOverView(data, out overviewlevel, out overviewzoom);
                }
            }
            return(box);
        }