예제 #1
0
        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));
            }

            case ProjectionType.Toast:
            {
                return(new ToastTile(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));
            }

            default:
            case ProjectionType.Tangent:
            {
                TangentTile newTile = new TangentTile(level, x, y, imageset, parent);
                return(newTile);
            }
            }
        }
예제 #2
0
        protected void ComputeBoundingSphere(MercatorTile parent, double altitude)
        {
            var tileDegrees = 360 / (Math.Pow(2, level));

            latMin = AbsoluteMetersToLatAtZoom(y * 256, level);
            latMax = AbsoluteMetersToLatAtZoom((y + 1) * 256, level);
            lngMin = ((x * tileDegrees) - 180.0);
            lngMax = (((x + 1) * tileDegrees) - 180.0);

            var latCenter = AbsoluteMetersToLatAtZoom(((y * 2) + 1) * 256, level + 1);
            var lngCenter = (lngMin + lngMax) / 2.0;

            if (level == 12 || level == 17 )
            {
                localCenter = Coordinates.GeoTo3dDouble(latCenter, lngCenter);
            }
            else if (level > 12)
            {
                localCenter = parent.localCenter;
            }

            demIndex = 0;

            if (parent != null && parent.DemData != null)
            {
                sphereCenter = GeoTo3dWithAltitude(latCenter, lngCenter, parent.GetAltitudeAtLatLng(latCenter, lngCenter, 1), false);
                TopLeft = GeoTo3dWithAltitude(latMin, lngMin, parent.GetAltitudeAtLatLng(latMin, lngMin, 1), false);
                BottomRight = GeoTo3dWithAltitude(latMax, lngMax, parent.GetAltitudeAtLatLng(latMax, lngMax, 1), false);
                TopRight = GeoTo3dWithAltitude(latMin, lngMax, parent.GetAltitudeAtLatLng(latMin, lngMax, 1), false);
                BottomLeft = GeoTo3dWithAltitude(latMax, lngMin, parent.GetAltitudeAtLatLng(latMax, lngMin, 1), false);
            }
            else
            {
                sphereCenter = GeoTo3dWithAltitude(latCenter, lngCenter, altitude, false);

                TopLeft = GeoTo3dWithAltitude(latMin, lngMin, altitude, false);
                BottomRight = GeoTo3dWithAltitude(latMax, lngMax, altitude, false);
                TopRight = GeoTo3dWithAltitude(latMin, lngMax, altitude, false);
                BottomLeft = GeoTo3dWithAltitude(latMax, lngMin, altitude, false);
            }

            center = sphereCenter;

            if (Y == 0)
            {
                TopLeft = new Vector3d(0, 1, 0);
                TopRight = new Vector3d(0, 1, 0);
            }

            if (Y == Math.Pow(2, level) - 1)
            {
                BottomRight = new Vector3d(0, -1, 0);
                BottomLeft = new Vector3d(0, -1, 0);

            }

            var distVect1 = TopLeft;
            distVect1.Subtract(sphereCenter);
            var distVect2 = BottomRight;
            distVect2.Subtract(sphereCenter);
            var distVect3 = TopRight;
            distVect3.Subtract(sphereCenter);
            var distVect4 = BottomLeft;
            distVect4.Subtract(sphereCenter);

            sphereRadius = Math.Max(Math.Max(distVect1.Length(),distVect2.Length()),Math.Max(distVect3.Length(),distVect4.Length()));
            tileDegrees = lngMax - lngMin;

              //  if (level > 14)
            {
              //              this.sphereCenter.Add(localCenter);
            }
        }
예제 #3
0
        public static Tile GetNewTile(IImageSet imageset, int level, int x, int y, Tile parent)
        {
            switch (imageset.Projection)
            {
                case ProjectionType.Mercator:
                    {
                        var 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);
                    }

                case ProjectionType.Toast:
                    {
                        return new ToastTile(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);
                    }
                default:
                case ProjectionType.Tangent:
                    {
                        var newTile = new TangentTile(level, x, y, imageset, parent);
                        return newTile;
                    }
            }
        }
        public override bool CreateDemFromParent()
        {
            MercatorTile parent = Parent as MercatorTile;

            if (parent == null || parent.DemData == null)
            {
                return(false);
            }

            DemGeneration = parent.DemGeneration + 1;

            if (DemGeneration < 4 && parent.isHdTile)
            {
                if (MakeDemFromHDParent())
                {
                    return(true);
                }
            }

            int offsetX = ((X % 2) == 1 ? 16:0);
            int offsetY = ((Y % 2) == 1 ? 16:0);


            DemData = new double[demSize];
            // Interpolate accross
            for (int y = 0; y < 33; y += 2)
            {
                bool copy = true;
                for (int x = 0; x < 33; x++)
                {
                    if (copy)
                    {
                        DemData[(32 - y) * 33 + x] = parent.GetDemSample((x / 2) + offsetX, (y / 2) + offsetY);
                    }
                    else
                    {
                        DemData[(32 - y) * 33 + x] =
                            (
                                (
                                    parent.GetDemSample((x / 2) + offsetX, (y / 2) + offsetY) +
                                    parent.GetDemSample(((x / 2) + offsetX) + 1, (y / 2) + offsetY)
                                ) / 2);
                    }
                    copy = !copy;
                }
            }
            // Interpolate down
            for (int y = 1; y < 33; y += 2)
            {
                for (int x = 0; x < 33; x++)
                {
                    DemData[(32 - y) * 33 + x] =
                        (
                            (
                                GetDemSample(x, y - 1) +
                                GetDemSample(x, y + 1)
                            ) / 2);
                }
            }

            foreach (double sample in DemData)
            {
                demAverage += sample;
            }

            demAverage /= DemData.Length;
            DemReady    = true;
            return(true);
        }
        protected void ComputeBoundingSphere(MercatorTile parent, double altitude)
        {
            double tileDegrees = 360 / (Math.Pow(2, this.level));

            latMin = AbsoluteMetersToLatAtZoom(y * 256, level);
            latMax = AbsoluteMetersToLatAtZoom((y + 1) * 256, level);
            lngMin = (((double)this.x * tileDegrees) - 180.0);
            lngMax = ((((double)(this.x + 1)) * tileDegrees) - 180.0);

            double latCenter = AbsoluteMetersToLatAtZoom(((y * 2) + 1) * 256, level + 1);
            double lngCenter = (lngMin + lngMax) / 2.0;


            if (level == 12 || level == 17)
            {
                localCenter = Coordinates.GeoTo3dDouble(latCenter, lngCenter);
            }
            else if (level > 12)
            {
                localCenter = parent.localCenter;
            }


            demIndex = 0;

            if (parent != null && parent.DemData != null)
            {
                this.sphereCenter = GeoTo3dWithAltitude(latCenter, lngCenter, parent.GetAltitudeAtLatLng(latCenter, lngCenter, 1), false);
                TopLeft           = GeoTo3dWithAltitude(latMin, lngMin, parent.GetAltitudeAtLatLng(latMin, lngMin, 1), false);
                BottomRight       = GeoTo3dWithAltitude(latMax, lngMax, parent.GetAltitudeAtLatLng(latMax, lngMax, 1), false);
                TopRight          = GeoTo3dWithAltitude(latMin, lngMax, parent.GetAltitudeAtLatLng(latMin, lngMax, 1), false);
                BottomLeft        = GeoTo3dWithAltitude(latMax, lngMin, parent.GetAltitudeAtLatLng(latMax, lngMin, 1), false);
            }
            else
            {
                this.sphereCenter = GeoTo3dWithAltitude(latCenter, lngCenter, altitude, false);

                TopLeft     = GeoTo3dWithAltitude(latMin, lngMin, altitude, false);
                BottomRight = GeoTo3dWithAltitude(latMax, lngMax, altitude, false);
                TopRight    = GeoTo3dWithAltitude(latMin, lngMax, altitude, false);
                BottomLeft  = GeoTo3dWithAltitude(latMax, lngMin, altitude, false);
            }

            center = sphereCenter;

            if (Y == 0)
            {
                TopLeft  = new Vector3d(0, 1, 0);
                TopRight = new Vector3d(0, 1, 0);
            }

            if (Y == Math.Pow(2, level) - 1)
            {
                BottomRight = new Vector3d(0, -1, 0);
                BottomLeft  = new Vector3d(0, -1, 0);
            }

            Vector3d distVect1 = TopLeft;

            distVect1.Subtract(sphereCenter);
            Vector3d distVect2 = BottomRight;

            distVect2.Subtract(sphereCenter);
            Vector3d distVect3 = TopRight;

            distVect3.Subtract(sphereCenter);
            Vector3d distVect4 = BottomLeft;

            distVect4.Subtract(sphereCenter);


            this.sphereRadius = Math.Max(Math.Max(distVect1.Length(), distVect2.Length()), Math.Max(distVect3.Length(), distVect4.Length()));
            tileDegrees       = lngMax - lngMin;

            //  if (level > 14)
            {
                //              this.sphereCenter.Add(localCenter);
            }
        }