Ejemplo n.º 1
0
        public static ToastTools GetTileForLevelPoint(int targetLevel, double lat, double lng)
        {
            int level = 0;

            ToastTools tile = root;


            while (level < targetLevel + 1)
            {
                //iterate children
                for (int i = 0; i < 4; i++)
                {
                    ToastTools child = tile.GetChild(i);
                    if (child != null)
                    {
                        if (child.IsPointInTile(lat, lng))
                        {
                            tile = child;
                            if (child.Level == targetLevel)
                            {
                                return(tile);
                            }
                            break;
                        }
                    }
                }
                level++;
            }

            return(null);
        }
Ejemplo n.º 2
0
        public ToastTools GetChild(int id)
        {
            if (children[id] == null)
            {
                int x1 = 0;
                int y1 = 0;
                switch (id)
                {
                case 0:
                    y1 = 0;
                    x1 = 0;
                    break;

                case 1:
                    y1 = 0;
                    x1 = 1;
                    break;

                case 2:
                    y1 = 1;
                    x1 = 0;
                    break;

                case 3:
                    y1 = 1;
                    x1 = 1;
                    break;
                }

                children[id] = new ToastTools(this, Level + 1, X * 2 + x1, Y * 2 + y1);
            }

            return(children[id]);
        }
Ejemplo n.º 3
0
 public ToastTools(ToastTools parent, int level, int x, int y)
 {
     Parent = parent;
     X = x;
     Y = y;
     Level = level;
     InitializeGrids();
     TopLeft = new Vector3d(Vector3d.Scale(bounds[0, 0].Position, 1));
     BottomRight = new Vector3d(Vector3d.Scale(bounds[2, 2].Position, 1));
     TopRight = new Vector3d(Vector3d.Scale(bounds[2, 0].Position, 1));
     BottomLeft = new Vector3d(Vector3d.Scale(bounds[0, 2].Position, 1));
 }
Ejemplo n.º 4
0
 public ToastTools(ToastTools parent, int level, int x, int y)
 {
     Parent = parent;
     X      = x;
     Y      = y;
     Level  = level;
     InitializeGrids();
     TopLeft     = new Vector3d(Vector3d.Scale(bounds[0, 0].Position, 1));
     BottomRight = new Vector3d(Vector3d.Scale(bounds[2, 2].Position, 1));
     TopRight    = new Vector3d(Vector3d.Scale(bounds[2, 0].Position, 1));
     BottomLeft  = new Vector3d(Vector3d.Scale(bounds[0, 2].Position, 1));
 }
Ejemplo n.º 5
0
        public ToastTools GetChild(int id)
        {
            if (children[id] == null)
            {
                int x1 =0;
                int y1 = 0;
                switch(id)
                {
                    case 0:
                        y1=0;
                        x1=0;
                        break;
                    case 1:
                        y1=0;
                        x1=1;
                        break;
                    case 2:
                        y1=1;
                        x1=0;
                        break;
                    case 3:
                        y1=1;
                        x1=1;
                        break;
                }

                children[id] = new ToastTools(this, Level + 1, X * 2 + x1, Y * 2 + y1);
            }

            return children[id];
        }