예제 #1
0
파일: FlickrPlugin.cs 프로젝트: Fav/testww
 /// <summary>
 /// Initialize graphics objects
 /// </summary>
 /// <param name="drawArgs"></param>
 public override void Initialize(WorldWind.DrawArgs drawArgs)
 {
     base.Initialize(drawArgs);
     lastUpdatelat = lastUpdatelon = WorldWind.Angle.Zero;
     lastUpdatealt = 0.0;
     m_needsupdate = true;
     Image         = new System.Drawing.Bitmap(Directory.GetParent(Application.ExecutablePath) + "\\Plugins\\Flickr\\flickr.ico");
 }
예제 #2
0
파일: FlickrPlugin.cs 프로젝트: Fav/testww
        /// <summary>
        /// This method updates the Icons to reflect only those in view
        /// </summary>
        /// <param name="drawArgs"></param>
        public override void Update(WorldWind.DrawArgs drawArgs)
        {
            base.Update(drawArgs);

            double distance = WorldWind.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);
                        WorldWind.Renderable.Icon ic = new WorldWind.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);
                    }
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Compute the tile number (used in file names) for given longitude and tile size.
 /// </summary>
 /// <param name="longitude">Longitude (decimal degrees)</param>
 /// <param name="tileSize">Tile size  (decimal degrees)</param>
 /// <returns>The tile number</returns>
 public static int GetColFromLongitude(Angle longitude, double tileSize)
 {
     return((int)Math.Round((Math.Abs(-180.0 - longitude.Degrees) % 360) / tileSize, 1));
 }
예제 #4
0
 /// <summary>
 /// Compute the tile number (used in file names) for given latitude and tile size.
 /// </summary>
 /// <param name="latitude">Latitude (decimal degrees)</param>
 /// <param name="tileSize">Tile size  (decimal degrees)</param>
 /// <returns>The tile number</returns>
 public static int GetRowFromLatitude(Angle latitude, double tileSize)
 {
     return((int)Math.Round((Math.Abs(-90.0 - latitude.Degrees) % 180) / tileSize, 1));
 }
예제 #5
0
        public void Update(DrawArgs drawArgs)
        {
            try
            {
                double centerLatitude  = 0.5 * (m_geographicBoundingBox.North + m_geographicBoundingBox.South);
                double centerLongitude = 0.5 * (m_geographicBoundingBox.West + m_geographicBoundingBox.East);
                double tileSize        = m_geographicBoundingBox.North - m_geographicBoundingBox.South;

                if (!m_Initialized)
                {
                    if (drawArgs.WorldCamera.ViewRange * 0.5f < Angle.FromDegrees(ShapeTileArgs.TileDrawDistance * tileSize) &&
                        MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude),
                                                     drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) < Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor * tileSize * 1.25f) &&
                        drawArgs.WorldCamera.ViewFrustum.Intersects(BoundingBox)
                        )
                    {
                        Initialize(drawArgs);
                    }
                }

                if (m_Initialized)
                {
                    if (m_LastUpdate < m_parentProjectedLayer.LastUpdate)
                    {
                        UpdateImageLayers(drawArgs);
                    }

                    if (m_NwImageLayer != null)
                    {
                        m_NwImageLayer.Update(drawArgs);
                    }
                    if (m_NeImageLayer != null)
                    {
                        m_NeImageLayer.Update(drawArgs);
                    }
                    if (m_SwImageLayer != null)
                    {
                        m_SwImageLayer.Update(drawArgs);
                    }
                    if (m_SeImageLayer != null)
                    {
                        m_SeImageLayer.Update(drawArgs);
                    }

                    if (
                        drawArgs.WorldCamera.ViewRange < Angle.FromDegrees(ShapeTileArgs.TileDrawDistance * tileSize) &&
                        MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude),
                                                     drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) < Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor * tileSize) &&
                        drawArgs.WorldCamera.ViewFrustum.Intersects(BoundingBox)
                        )
                    {
                        if (m_NorthEastChild == null && m_NorthWestChild == null && m_SouthEastChild == null && m_SouthWestChild == null)
                        {
                            ComputeChildren(drawArgs);
                        }
                        else
                        {
                            if (m_NorthEastChild != null)
                            {
                                m_NorthEastChild.Update(drawArgs);
                            }

                            if (m_NorthWestChild != null)
                            {
                                m_NorthWestChild.Update(drawArgs);
                            }

                            if (m_SouthEastChild != null)
                            {
                                m_SouthEastChild.Update(drawArgs);
                            }

                            if (m_SouthWestChild != null)
                            {
                                m_SouthWestChild.Update(drawArgs);
                            }
                        }
                    }
                    else
                    {
                        if (m_NorthWestChild != null)
                        {
                            m_NorthWestChild.Dispose();
                            m_NorthWestChild = null;
                        }

                        if (m_NorthEastChild != null)
                        {
                            m_NorthEastChild.Dispose();
                            m_NorthEastChild = null;
                        }

                        if (m_SouthEastChild != null)
                        {
                            m_SouthEastChild.Dispose();
                            m_SouthEastChild = null;
                        }

                        if (m_SouthWestChild != null)
                        {
                            m_SouthWestChild.Dispose();
                            m_SouthWestChild = null;
                        }
                    }
                }

                if (m_Initialized)
                {
                    if (drawArgs.WorldCamera.ViewRange > Angle.FromDegrees(ShapeTileArgs.TileDrawDistance * tileSize * 1.5f) ||
                        MathEngine.SphericalDistance(Angle.FromDegrees(centerLatitude), Angle.FromDegrees(centerLongitude), drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude) > Angle.FromDegrees(ShapeTileArgs.TileSpreadFactor * tileSize * 1.5f))
                    {
                        if (this.Level != 0)
                        {
                            //{
                            Dispose();
                        }
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
        }
예제 #6
0
        //TODO: Improve rendering code to segment spherical coordinates
        //which are too far apart to follow curvature
        public Vector3[] BuildSegment(Angle startLatitude, Angle startLongitude, Angle endLatitude, Angle endLongitude, float heightAboveSurface)
        {
            //check how far the point being added is from the last point
            Angle angularDistance = World.ApproxAngularDistance(
                startLatitude,
                startLongitude,
                endLatitude,
                endLongitude);

            Vector3[] newPoints = null;
            if (angularDistance.Degrees >= 2.0)
            {
                int samples = (int)(angularDistance.Radians * 30);                // 1 point for every 2 degrees.
                if (samples < 2)
                {
                    samples = 2;
                }

                Angle lat, lon = Angle.Zero;
                newPoints = new Vector3[samples];
                for (int i = 0; i < samples; i++)
                {
                    float t = (float)i / (samples - 1);
                    World.IntermediateGCPoint(t, startLatitude, startLongitude, endLatitude, endLongitude,
                                              angularDistance, out lat, out lon);
                    newPoints[i] = MathEngine.SphericalToCartesian(lat, lon, this._parentWorld.EquatorialRadius + this.verticalExaggeration * heightAboveSurface);
                }
            }
            return(newPoints);
        }
예제 #7
0
        public void AddPointToPath(float latitude, float longitude, bool terrainMapped, float heightAboveSurface)
        {
/*			if(terrainMapped)
 *                      {
 *                              heightAboveSurface += this.terrainManager.GetHeightAt(latitude, longitude) * this.verticalExaggeration;
 *                      }*/
            //Always add first coordinate

            Vector3[] newPoints = null;

            if (this.sphericalCoordinates.Length > 0)
            {
                float startLatitude  = this.sphericalCoordinates[this.sphericalCoordinates.Length - 1].X;
                float startLongitude = this.sphericalCoordinates[this.sphericalCoordinates.Length - 1].Y;
                newPoints = this.BuildSegment(Angle.FromDegrees(startLatitude), Angle.FromDegrees(startLongitude),
                                              Angle.FromDegrees(latitude), Angle.FromDegrees(longitude),
                                              heightAboveSurface);
            }


            Vector3[] newCoords = new Vector3[this.sphericalCoordinates.Length + 1];

            this.sphericalCoordinates.CopyTo(newCoords, 0);

            newCoords[newCoords.Length - 1].X = latitude;
            newCoords[newCoords.Length - 1].Y = longitude;
            newCoords[newCoords.Length - 1].Z = heightAboveSurface;

            this.sphericalCoordinates = newCoords;

            //TODO: HACK work fix this
            if (newPoints == null)
            {
                CustomVertex.PositionColored[] newLine = new CustomVertex.PositionColored[this.linePoints.Length + 1];
                this.linePoints.CopyTo(newLine, 0);


                Vector3 newPoint = MathEngine.SphericalToCartesian(latitude, longitude, this._parentWorld.EquatorialRadius + this.verticalExaggeration * heightAboveSurface);
                newLine[newLine.Length - 1] = new PositionColored(newPoint.X, newPoint.Y, newPoint.Z, this.lineColor);

                //Need to build path if points are spread too far apart

                lock (this.linePoints.SyncRoot)
                {
                    this.linePoints = newLine;
                }
            }
            else
            {
                foreach (Vector3 newPoint in newPoints)
                {
                    CustomVertex.PositionColored[] newLine = new CustomVertex.PositionColored[this.linePoints.Length + 1];
                    this.linePoints.CopyTo(newLine, 0);


                    //Vector3 newPoint = MathEngine.SphericalToCartesian(latitude, longitude, this._parentWorld.EquatorialRadius + this.verticalExaggeration * heightAboveSurface );
                    newLine[newLine.Length - 1] = new PositionColored(newPoint.X, newPoint.Y, newPoint.Z, this.lineColor);

                    //Need to build path if points are spread too far apart

                    lock (this.linePoints.SyncRoot)
                    {
                        this.linePoints = newLine;
                    }
                }
            }
            if (this.linePoints.Length == 1)
            {
                this.north = latitude;
                this.south = latitude;
                this.west  = longitude;
                this.east  = longitude;
            }
            else
            {
                if (latitude > this.north)
                {
                    this.north = latitude;
                }
                if (latitude < this.south)
                {
                    this.south = latitude;
                }
                if (longitude < this.west)
                {
                    this.west = longitude;
                }
                if (longitude > this.east)
                {
                    this.east = longitude;
                }
            }
        }