Пример #1
0
        public static ToastTile Create(int level, int xc, int yc, Imageset dataset, Tile parent)
        {
            ToastTile temp = new ToastTile();
            temp.Parent = parent;
            temp.Level = level;
            temp.tileX = xc;
            temp.tileY = yc;
            temp.dataset = dataset;
            temp.topDown = !dataset.BottomsUp;

            if (temp.tileX != (int)xc)
            {
                Script.Literal("alert('bad')");
            }
            //temp.ComputeQuadrant();

            if (dataset.MeanRadius != 0)
            {
                temp.DemScaleFactor = dataset.MeanRadius;
            }
            else
            {
                if (dataset.DataSetType == ImageSetType.Earth)
                {
                    temp.DemScaleFactor = 6371000;
                }
                else
                {
                    temp.DemScaleFactor = 3396010;
                }
            }

            temp.ComputeBoundingSphere();
            return temp;
        }
        public static Tile GetNewTile(Imageset imageset, int level, int x, int y, Tile parent)
        {
            switch (imageset.Projection)
            {
            case ProjectionType.Mercator:
            {
                MercatorTile newTile = MercatorTile.Create(level, x, y, imageset, parent);
                return(newTile);
            }

            case ProjectionType.Equirectangular:
            {
                return(EquirectangularTile.Create(level, x, y, imageset, parent));
            }

            //case ProjectionType.Spherical:
            //    {
            //        return new SphericalTile(level, x, y, imageset, parent);
            //    }
            default:
            case ProjectionType.Toast:
            {
                return(ToastTile.Create(level, x, y, imageset, parent));
            }

            case ProjectionType.SkyImage:
            {
                return(new SkyImageTile(level, x, y, imageset, parent));
            }

            case ProjectionType.Plotted:
            {
                return(PlotTile.Create(level, x, y, imageset, parent));
            }

            case ProjectionType.Healpix:
            {
                if (imageset.HipsProperties == null)
                {
                    imageset.HipsProperties = new HipsProperties(imageset);
                }
                if (imageset.HipsProperties.DownloadComplete)
                {
                    return(new HealpixTile(level, x, y, imageset, parent));
                }
                else
                {
                    return(null);
                }
            }

            case ProjectionType.Tangent:
            {
                TangentTile newTile = new TangentTile(level, x, y, imageset, parent);
                return(newTile);
            }
            }
        }
Пример #3
0
        public static Tile GetNewTile(Imageset imageset, int level, int x, int y, Tile parent)
        {
            switch (imageset.Projection)
            {
            case ProjectionType.Mercator:
            {
                MercatorTile newTile = MercatorTile.Create(level, x, y, imageset, parent);
                return(newTile);
            }

            case ProjectionType.Equirectangular:
            {
                return(EquirectangularTile.Create(level, x, y, imageset, parent));
            }

            //case ProjectionType.Spherical:
            //    {
            //        return new SphericalTile(level, x, y, imageset, parent);
            //    }
            default:
            case ProjectionType.Toast:
            {
                return(ToastTile.Create(level, x, y, imageset, parent));
            }

            case ProjectionType.SkyImage:
            {
                return(SkyImageTile.Create(level, x, y, imageset, parent));
            }

            case ProjectionType.Plotted:
            {
                return(PlotTile.Create(level, x, y, imageset, parent));
            }

            case ProjectionType.Healpix:
            {
                return(new HealpixTile(level, x, y, imageset, parent));
            }

            case ProjectionType.Tangent:
            {
                TangentTile newTile = TangentTile.Create(level, x, y, imageset, parent);
                return(newTile);
            }
            }
        }
        public static ToastTile Create(int level, int xc, int yc, Imageset dataset, Tile parent)
        {
            ToastTile temp = new ToastTile();

            temp.Parent  = parent;
            temp.Level   = level;
            temp.tileX   = xc;
            temp.tileY   = yc;
            temp.dataset = dataset;
            temp.topDown = !dataset.BottomsUp;


            if (temp.tileX != (int)xc)
            {
                Script.Literal("alert('bad')");
            }
            //temp.ComputeQuadrant();

            if (dataset.MeanRadius != 0)
            {
                temp.DemScaleFactor = dataset.MeanRadius;
            }
            else
            {
                if (dataset.DataSetType == ImageSetType.Earth)
                {
                    temp.DemScaleFactor = 6371000;
                }
                else
                {
                    temp.DemScaleFactor = 3396010;
                }
            }


            temp.ComputeBoundingSphere();
            return(temp);
        }
        public static Tile GetNewTile(IImageSet imageset, int level, int x, int y, Tile parent)
        {
            switch (imageset.Projection)
            {
            //case ProjectionType.Mercator:
            //    {
            //        MercatorTile newTile = new MercatorTile(level, x, y, imageset, parent);
            //        return newTile;
            //    }
            //case ProjectionType.Equirectangular:
            //    {
            //        return new EquirectangularTile(level, x, y, imageset, parent);
            //    }
            //case ProjectionType.Spherical:
            //    {
            //        return new SphericalTile(level, x, y, imageset, parent);
            //    }
            default:
            case ProjectionType.Toast:
            {
                return(ToastTile.Create(level, x, y, imageset, parent));
            }
                //case ProjectionType.SkyImage:
                //    {
                //        return new SkyImageTile(level, x, y, imageset, parent);
                //    }
                //case ProjectionType.Plotted:
                //    {
                //        return new PlotTile(level, x, y, imageset, parent);
                //    }

                //case ProjectionType.Tangent:
                //    {
                //        TangentTile newTile = new TangentTile(level, x, y, imageset, parent);
                //        return newTile;
                //    }
            }
        }
        public override bool CreateDemFromParent()
        {
            ToastTile parent = Parent as ToastTile;

            if (parent == null)
            {
                return(false);
            }

            int offsetX = ((tileX % 2) == 1 ? 8 : 0);
            int offsetY = ((tileY % 2) == 0 ? 8 : 0);


            demArray = new float[17 * 17];
            // Interpolate accross
            for (int yy1 = 0; yy1 < 17; yy1 += 2)
            {
                bool copy = true;
                for (int xx1 = 0; xx1 < 17; xx1++)
                {
                    if (copy)
                    {
                        demArray[(16 - yy1) * 17 + xx1] = parent.GetDemSample((xx1 / 2) + offsetX, (yy1 / 2) + offsetY);
                    }
                    else
                    {
                        demArray[(16 - yy1) * 17 + xx1] =
                            (
                                (
                                    parent.GetDemSample((xx1 / 2) + offsetX, (yy1 / 2) + offsetY) +
                                    parent.GetDemSample(((xx1 / 2) + offsetX) + 1, (yy1 / 2) + offsetY)
                                ) / 2);
                    }
                    copy = !copy;
                }
            }
            // Interpolate down
            for (int yy2 = 1; yy2 < 17; yy2 += 2)
            {
                for (int xx2 = 0; xx2 < 17; xx2++)
                {
                    demArray[(16 - yy2) * 17 + xx2] =
                        (
                            (
                                GetDemSample(xx2, yy2 - 1) +
                                GetDemSample(xx2, yy2 + 1)
                            ) / 2);
                }
            }

            // Convert the dem array back to the arranged DEM list thu slash/backslash mapping tables


            DemData = new float[demSize];
            for (int i = 0; i < demSize; i++)
            {
                if (backslash)
                {
                    DemData[i] = demArray[backslashXIndex[i] + backslashYIndex[i] * 17];
                }
                else
                {
                    DemData[i] = demArray[slashXIndex[i] + slashYIndex[i] * 17];
                }
                demAverage += DemData[i];
            }

            // Get Average value for new DemData table

            demAverage /= DemData.Length;

            DemReady = true;
            return(true);
        }
        private void InitializeGrids()
        {
            vertexList           = new List <PositionTexture>();
            childTriangleList    = new List <Triangle> [4];
            childTriangleList[0] = new List <Triangle>();
            childTriangleList[1] = new List <Triangle>();
            childTriangleList[2] = new List <Triangle>();
            childTriangleList[3] = new List <Triangle>();

            bounds = new PositionTexture[9];

            if (Level > 0)
            {
                // Set in constuctor now
                //ToastTile parent = (ToastTile)TileCache.GetTile(level - 1, x / 2, y / 2, dataset, null);
                if (Parent == null)
                {
                    Parent = TileCache.GetTile(Level - 1, tileX / 2, tileY / 2, dataset, null);
                }

                ToastTile parent = (ToastTile)Parent;

                int xIndex = tileX % 2;
                int yIndex = tileY % 2;

                if (Level > 1)
                {
                    backslash = parent.backslash;
                }
                else
                {
                    backslash = xIndex == 1 ^ yIndex == 1;
                }


                bounds[0 + 3 * 0] = parent.bounds[xIndex + 3 * yIndex].Copy();
                bounds[1 + 3 * 0] = Midpoint(parent.bounds[xIndex + 3 * yIndex], parent.bounds[xIndex + 1 + 3 * yIndex]);
                bounds[2 + 3 * 0] = parent.bounds[xIndex + 1 + 3 * yIndex].Copy();
                bounds[0 + 3 * 1] = Midpoint(parent.bounds[xIndex + 3 * yIndex], parent.bounds[xIndex + 3 * (yIndex + 1)]);

                if (backslash)
                {
                    bounds[1 + 3 * 1] = Midpoint(parent.bounds[xIndex + 3 * yIndex], parent.bounds[xIndex + 1 + 3 * (yIndex + 1)]);
                }
                else
                {
                    bounds[1 + 3 * 1] = Midpoint(parent.bounds[xIndex + 1 + 3 * yIndex], parent.bounds[xIndex + 3 * (yIndex + 1)]);
                }

                bounds[2 + 3 * 1] = Midpoint(parent.bounds[xIndex + 1 + 3 * yIndex], parent.bounds[xIndex + 1 + 3 * (yIndex + 1)]);
                bounds[0 + 3 * 2] = parent.bounds[xIndex + 3 * (yIndex + 1)].Copy();
                bounds[1 + 3 * 2] = Midpoint(parent.bounds[xIndex + 3 * (yIndex + 1)], parent.bounds[xIndex + 1 + 3 * (yIndex + 1)]);
                bounds[2 + 3 * 2] = parent.bounds[xIndex + 1 + 3 * (yIndex + 1)].Copy();

                bounds[0 + 3 * 0].Tu = 0 * uvMultiple;
                bounds[0 + 3 * 0].Tv = 0 * uvMultiple;
                bounds[1 + 3 * 0].Tu = .5f * uvMultiple;
                bounds[1 + 3 * 0].Tv = 0 * uvMultiple;
                bounds[2 + 3 * 0].Tu = 1 * uvMultiple;
                bounds[2 + 3 * 0].Tv = 0 * uvMultiple;

                bounds[0 + 3 * 1].Tu = 0 * uvMultiple;
                bounds[0 + 3 * 1].Tv = .5f * uvMultiple;
                bounds[1 + 3 * 1].Tu = .5f * uvMultiple;
                bounds[1 + 3 * 1].Tv = .5f * uvMultiple;
                bounds[2 + 3 * 1].Tu = 1 * uvMultiple;
                bounds[2 + 3 * 1].Tv = .5f * uvMultiple;

                bounds[0 + 3 * 2].Tu = 0 * uvMultiple;
                bounds[0 + 3 * 2].Tv = 1 * uvMultiple;
                bounds[1 + 3 * 2].Tu = .5f * uvMultiple;
                bounds[1 + 3 * 2].Tv = 1 * uvMultiple;
                bounds[2 + 3 * 2].Tu = 1 * uvMultiple;
                bounds[2 + 3 * 2].Tv = 1 * uvMultiple;

                vertexList.Add(bounds[0 + 3 * 0]);
                vertexList.Add(bounds[1 + 3 * 0]);
                vertexList.Add(bounds[2 + 3 * 0]);
                vertexList.Add(bounds[0 + 3 * 1]);
                vertexList.Add(bounds[1 + 3 * 1]);
                vertexList.Add(bounds[2 + 3 * 1]);
                vertexList.Add(bounds[0 + 3 * 2]);
                vertexList.Add(bounds[1 + 3 * 2]);
                vertexList.Add(bounds[2 + 3 * 2]);



                if (backslash)
                {
                    childTriangleList[0].Add(Triangle.Create(4, 1, 0));
                    childTriangleList[0].Add(Triangle.Create(3, 4, 0));
                    childTriangleList[1].Add(Triangle.Create(5, 2, 1));
                    childTriangleList[1].Add(Triangle.Create(4, 5, 1));
                    childTriangleList[2].Add(Triangle.Create(7, 4, 3));
                    childTriangleList[2].Add(Triangle.Create(6, 7, 3));
                    childTriangleList[3].Add(Triangle.Create(8, 5, 4));
                    childTriangleList[3].Add(Triangle.Create(7, 8, 4));
                }
                else
                {
                    childTriangleList[0].Add(Triangle.Create(3, 1, 0));
                    childTriangleList[0].Add(Triangle.Create(4, 1, 3));
                    childTriangleList[1].Add(Triangle.Create(4, 2, 1));
                    childTriangleList[1].Add(Triangle.Create(5, 2, 4));
                    childTriangleList[2].Add(Triangle.Create(6, 4, 3));
                    childTriangleList[2].Add(Triangle.Create(7, 4, 6));
                    childTriangleList[3].Add(Triangle.Create(7, 5, 4));
                    childTriangleList[3].Add(Triangle.Create(8, 5, 7));
                }
            }
            else
            {
                bounds[0 + 3 * 0] = PositionTexture.Create(0, -1, 0, 0, 0);
                bounds[1 + 3 * 0] = PositionTexture.Create(0, 0, 1, .5f, 0);
                bounds[2 + 3 * 0] = PositionTexture.Create(0, -1, 0, 1, 0);
                bounds[0 + 3 * 1] = PositionTexture.Create(-1, 0, 0, 0, .5f);
                bounds[1 + 3 * 1] = PositionTexture.Create(0, 1, 0, .5f, .5f);
                bounds[2 + 3 * 1] = PositionTexture.Create(1, 0, 0, 1, .5f);
                bounds[0 + 3 * 2] = PositionTexture.Create(0, -1, 0, 0, 1);
                bounds[1 + 3 * 2] = PositionTexture.Create(0, 0, -1, .5f, 1);
                bounds[2 + 3 * 2] = PositionTexture.Create(0, -1, 0, 1, 1);

                vertexList.Add(bounds[0 + 3 * 0]);
                vertexList.Add(bounds[1 + 3 * 0]);
                vertexList.Add(bounds[2 + 3 * 0]);
                vertexList.Add(bounds[0 + 3 * 1]);
                vertexList.Add(bounds[1 + 3 * 1]);
                vertexList.Add(bounds[2 + 3 * 1]);
                vertexList.Add(bounds[0 + 3 * 2]);
                vertexList.Add(bounds[1 + 3 * 2]);
                vertexList.Add(bounds[2 + 3 * 2]);

                childTriangleList[0].Add(Triangle.Create(3, 1, 0));
                childTriangleList[0].Add(Triangle.Create(4, 1, 3));
                childTriangleList[1].Add(Triangle.Create(5, 2, 1));
                childTriangleList[1].Add(Triangle.Create(4, 5, 1));
                childTriangleList[2].Add(Triangle.Create(7, 4, 3));
                childTriangleList[2].Add(Triangle.Create(6, 7, 3));
                childTriangleList[3].Add(Triangle.Create(7, 5, 4));
                childTriangleList[3].Add(Triangle.Create(8, 5, 7));
                // Setup default matrix of points.
            }
        }