Beispiel #1
0
 /// <summary>
 /// Initialize graphics objects
 /// </summary>
 /// <param name="drawArgs"></param>
 public override void Initialize(MFW3D.DrawArgs drawArgs)
 {
     base.Initialize(drawArgs);
     lastUpdatelat = lastUpdatelon = MFW3D.Angle.Zero;
     lastUpdatealt = 0.0;
     m_needsupdate = true;
     Image         = new System.Drawing.Bitmap(Directory.GetParent(Application.ExecutablePath) + "\\Plugins\\Flickr\\flickr.ico");
 }
Beispiel #2
0
        /// <summary>
        /// This method updates the Icons to reflect only those in view
        /// </summary>
        /// <param name="drawArgs"></param>
        public override void Update(MFW3D.DrawArgs drawArgs)
        {
            base.Update(drawArgs);

            double distance = MFW3D.World.ApproxAngularDistance(drawArgs.WorldCamera.Latitude,
                                                                drawArgs.WorldCamera.Longitude, this.lastUpdatelat, this.lastUpdatelon).Degrees;
            double altchange = Math.Abs(this.lastUpdatealt - drawArgs.WorldCamera.Altitude);


            if (distance > 10 || altchange < 10000.0 || m_needsupdate)
            {
                this.lastUpdatelon = drawArgs.WorldCamera.Longitude;
                this.lastUpdatelat = drawArgs.WorldCamera.Latitude;
                this.lastUpdatealt = drawArgs.WorldCamera.Altitude;
                this.m_needsupdate = false;

                double viewNorth = drawArgs.WorldCamera.Latitude.Degrees + drawArgs.WorldCamera.TrueViewRange.Degrees * 0.5;
                double viewSouth = drawArgs.WorldCamera.Latitude.Degrees - drawArgs.WorldCamera.TrueViewRange.Degrees * 0.5;
                double viewWest  = drawArgs.WorldCamera.Longitude.Degrees - drawArgs.WorldCamera.TrueViewRange.Degrees * 0.5;
                double viewEast  = drawArgs.WorldCamera.Longitude.Degrees + drawArgs.WorldCamera.TrueViewRange.Degrees * 0.5;



                //Need lock on the folder
                lock (this)
                {
                    //TODO: Implement temporary caching and redownload on request
                    PhotoCollection allPhotos = GetPhotoCollection(viewWest, viewSouth,
                                                                   viewEast, viewNorth);

                    this.RemoveAll();
                    foreach (Photo photo in allPhotos)
                    {
                        double photolat          = Convert.ToDouble(photo.Latitude);
                        double photolon          = Convert.ToDouble(photo.Longitude);
                        MFW3D.Renderable.Icon ic = new MFW3D.Renderable.Icon(photo.Title, photolat
                                                                             , photolon);
                        ic.Image  = Image;
                        ic.Width  = 16;
                        ic.Height = 16;
                        //ic.MinimumDisplayDistance = 100000;
                        //WorldWind.Renderable.ScreenOverlay overlay
                        //= new WorldWind.Renderable.ScreenOverlay(ic.Name,0.0f,0.0f,photo.ThumbnailUrl);
                        //ic.AddOverlay(overlay);
                        ic.isSelectable = true;
                        ic.Description  = "<img src=\"" + photo.ThumbnailUrl + "\"/><br>" +
                                          photo.License + "<br>" +
                                          photo.DateTaken;
                        double distanceToIcon = Vector3.Length(ic.Position - drawArgs.WorldCamera.Position);

                        //If Camera is far render as icon
                        //if(ic.MinimumDisplayDistance < distanceToIcon)
                        this.Add(ic);
                        //if Camera is near render as textured polygon

                        /*
                         * else
                         * {
                         *  Point3d[] lineends = new Point3d[2];
                         *  lineends[0].X = photolon - 0.1;
                         *  lineends[0].Y = photolat - 0.1;
                         *  lineends[0].Z = 1000;
                         *  lineends[1].X = photolon + 0.1;
                         *  lineends[1].Y = photolat + 0.1;
                         *  lineends[1].Z = 1000;
                         *
                         *  WorldWind.LineFeature line = new LineFeature(photo.Title,
                         *      m_world,lineends,photo.ThumbnailUrl);
                         *  line.AltitudeMode = AltitudeMode.RelativeToGround;
                         *  line.DistanceAboveSurface = 0;
                         *  line.Extrude = true;
                         *
                         *  this.Add(line);
                         * }
                         */

                        //Console.WriteLine("Photos title is " + photo.Title + photo.Latitude + photo.Longitude);
                    }
                }
            }
        }