コード例 #1
0
        /*
        private static int badTileSize = -1;
        public static int BadTileSize
        {
            get{return badTileSize;}
        }

        private static byte [] badTileBytes;
        public static bool IsBadTile(MemoryStream newTile)
        {
            byte [] newTileBuffer = new byte[badTileBytes.Length];
            newTile.Position = badTileSize / 2;
            newTile.Read(newTileBuffer, 0, newTileBuffer.Length);
            bool isBad = true;
            for(int i=0; i<badTileBytes.Length; i++)
            {
                byte badByte = badTileBytes[i];
                byte newByte = newTileBuffer[i];
                if(badByte != newByte)
                {
                    isBad = false;
                    break;
                }
            }
            newTile.Position = 0;
            return isBad;
        }
        */

        /// <summary>
        /// Layer initialization code
        /// </summary>
        public override void Initialize(DrawArgs drawArgs)
        {
            try
            {
                if (this.isInitialized == true)
                {
                    return;
                }

                //init the sprite for PushPins
                pushpinsprite = new Sprite(drawArgs.device);
                //#if DEBUG
                string spritePath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Plugins\\VirtualEarth\\VirtualEarthPushPin.png";
                //#else
                //				string spritePath = VirtualEarthPlugin.PluginDir + @"\VirtualEarthPushPin.png";
                //
                //#endif
                if (File.Exists(spritePath) == false)
                {
                    Utility.Log.Write(new Exception("spritePath not found " + spritePath));
                }
                spriteSize = new Rectangle(0, 0, iconWidth, iconHeight);
                ppspriteTexture = TextureLoader.FromFile(drawArgs.device, spritePath);

                /*
                try
                {
                    //purposefully download the bad tile
                    //so it is not displayed or cached later on
                    Downloader d = new Downloader();
                    string badTileUrl = "http://r2.ortho.tiles.virtualearth.net/tiles/r0.png?g=1";
                    MemoryStream ms = d.DownloadImageStream(badTileUrl);
                    if(ms != null && ms.Length > 0)
                    {
                        //save off bad tile size for comparison
                        badTileSize = (int) ms.Length;
                        //save off some bytes to compare for false positives
                        ms.Position = badTileSize / 2;
                        badTileBytes = new byte[8];
                        ms.Read(badTileBytes, 0, badTileBytes.Length);
                        ms.Close();
                        ms = null;
                    }
                }
                catch(Exception ex)
                {
                    Utility.Log.Write(ex);
                }
                */

                earthRadius = parentApplication.WorldWindow.CurrentWorld.EquatorialRadius;
                earthCircum = earthRadius * 2.0 * Math.PI; //40075016.685578488
                earthHalfCirc = earthCircum / 2; //20037508.

                //NOTE tiles did not line up properly with ellps=WGS84
                //string [] projectionParameters = new string[]{"proj=merc", "ellps=WGS84", "no.defs"};
                //+proj=longlat +ellps=sphere +a=6370997.0 +es=0.0
                string[] projectionParameters = new string[] { "proj=merc", "ellps=sphere", "a=" + earthRadius.ToString(), "es=0.0", "no.defs" };
                proj = new Projection(projectionParameters);

                //static
                VeTile.Init(this.proj, parentApplication.WorldWindow.CurrentWorld.TerrainAccessor, parentApplication.WorldWindow.CurrentWorld.EquatorialRadius, veForm);

                prevVe = World.Settings.VerticalExaggeration;

                this.isInitialized = true;
            }
            catch (Exception ex)
            {
                Utility.Log.Write(ex);
                throw;
            }
        }
コード例 #2
0
 public static void Init(Projection proj, TerrainAccessor terrainAccessor, double layerRadius, VirtualEarthForm veForm)
 {
     _proj = proj;
     _terrainAccessor = terrainAccessor;
     _layerRadius = layerRadius;
     _veForm = veForm;
     _font = new System.Drawing.Font("Verdana", 15, FontStyle.Bold);
     _brush = new SolidBrush(Color.Green);
 }