Ejemplo n.º 1
0
        public override DVector2 WorldToTilePos(double lon, double lat, int zoom)
        {
            lat = DMathUtil.Clamp(lat, MinLatitude, MaxLatitude);
            lon = DMathUtil.Clamp(lon, MinLongitude, MaxLongitude);

            lat = lat <MinLatitude?MinLatitude : lat> MaxLatitude ? MaxLatitude : lat;
            lon = lon <MinLongitude?MinLongitude : lon> MaxLongitude ? MaxLongitude : lon;

            double rLon = lon * DEG_RAD;             // Math.PI / 180;
            double rLat = lat * DEG_RAD;             // Math.PI / 180;

            double a = 6378137;
            double k = 0.0818191908426;

            double z  = Math.Tan(MathPiDiv4 + rLat / 2) / Math.Pow((Math.Tan(MathPiDiv4 + Math.Asin(k * Math.Sin(rLat)) / 2)), k);
            double z1 = Math.Pow(2, 23 - zoom);

            double DX = ((20037508.342789 + a * rLon) * 53.5865938 / z1) / 256.0;
            double DY = ((20037508.342789 - a * Math.Log(z)) * 53.5865938 / z1) / 256.0;

            DVector2 ret = DVector2.Zero;

            ret.X = DX;
            ret.Y = DY;

            return(ret);
        }
Ejemplo n.º 2
0
        void UpdateCamera()
        {
            var input = Game.InputDevice;

            if (input.IsKeyDown(Keys.LeftShift) && input.IsKeyDown(Keys.MiddleButton))
            {
                FreeCamYaw   += input.RelativeMouseOffset.X * 0.003;
                FreeCamPitch -= input.RelativeMouseOffset.Y * 0.003;

                FreeCamPitch = DMathUtil.Clamp(FreeCamPitch, -Math.PI / 2.01, 0.0);
            }
        }