Пример #1
0
 /// <summary>
 /// Maptapped event.
 /// </summary>
 /// <param name="pos">Position where the tapped event is raised.</param>
 /// <param name="zoomLevel">Zoom level where the tapped event is raised.</param>
 public void MapTappedEvent(Position pos, double zoomLevel)
 {
     if (this.MapTapped != null)
     {
         this.MapTapped(this, new MapTappedEventArgs(pos, zoomLevel));
     }
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TreeWatch.Note"/> class.
 /// </summary>
 /// <param name="title">Title of the note.</param>
 /// <param name="description">Description of the note.</param>
 /// <param name="imagePath">Image path of the note.</param>
 /// <param name="timeStamp">Time stamp of the note.</param>
 /// <param name="position">Position of the note.</param>
 public Note(string title, string description, string imagePath, DateTime timeStamp, Position position)
 {
     this.Title = title;
     this.Description = description;
     this.ImagePath = imagePath;
     this.TimeStamp = timeStamp;
     this.Position = position;
 }
Пример #3
0
        /// <summary>
        /// Determines if a position is inside the polygon defined by the coordinates.
        /// </summary>
        /// <returns><c>true</c> is inside the polygon defined by the coordinates; otherwise, <c>false</c>.</returns>
        /// <param name="coordinates">coordinates of polygon.</param>
        /// <param name="position">Position which should be tested if in.</param>
        public static bool IsInsideCoords(List<Position> coordinates, Position position)
        {
            int i, j;
            int nvert = coordinates.Count;

            bool inside = false;

            if (coordinates.Count < 3)
            {
                return inside;
            }

            for (i = 0, j = nvert - 1; i < nvert; j = i++)
            {
                if (((coordinates[i].Latitude > position.Latitude) != (coordinates[j].Latitude > position.Latitude))
                    && (position.Longitude < ((coordinates[j].Longitude - coordinates[i].Longitude) * (position.Latitude - coordinates[i].Latitude) / ((coordinates[j].Latitude - coordinates[i].Latitude) + coordinates[i].Longitude))))
                {
                    inside = !inside;
                }
            }

            return inside;
        }
Пример #4
0
        /// <summary>
        /// Checks the block clicked.
        /// </summary>
        /// <returns>The block clicked.</returns>
        /// <param name="touchPos">Touch position.</param>
        public Block CheckBlockClicked(Position touchPos)
        {
            foreach (Block block in this.SelectedField.Blocks)
            {
                if (GeoHelper.IsInsideCoords(block.BoundingCoordinates, touchPos))
                {
                    return block;
                }
            }

            return null;
        }
Пример #5
0
        /// <summary>
        /// Checks the field clicked.
        /// </summary>
        /// <returns>The field clicked.</returns>
        /// <param name="touchPos">Touch position.</param>
        public Field CheckFieldClicked(Position touchPos)
        {
            foreach (Field field in this.Fields)
            {
                if (GeoHelper.IsInsideCoords(field.BoundingCoordinates, touchPos))
                {
                    return field;
                }
            }

            return null;
        }
Пример #6
0
        /// <summary>
        /// Gets the current device position.
        /// </summary>
        /// <returns>The current device position.</returns>
        public static Position GetCurrentDevicePosition()
        {
            // Todo: make this not static
            var pos = new Position();
            pos.Latitude = 51.39202;
            pos.Longitude = 6.04745;

            return pos;
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TreeWatch.MapTappedEventArgs"/> class.
 /// </summary>
 /// <param name="pos">Position of the map tapped event.</param>
 /// <param name="zoomLevel">Zoom level of the map tapped event.</param>
 public MapTappedEventArgs(Position pos, double zoomLevel)
 {
     this.Position = pos;
     this.Zoomlevel = zoomLevel;
 }
Пример #8
0
        /// <summary>
        /// Gets the coordinates from XML.
        /// </summary>
        /// <returns>The coordinates.</returns>
        /// <param name="coords">The list of XML elements.</param>
        public static List<Position> GetCoordinates(IEnumerable<XElement> coords)
        {
            var listOfCords = coords.First().Value.Trim().Split(' ');
            var posList = new List<Position>();

            foreach (var cord in listOfCords)
            {
                var longitude = Convert.ToDouble(cord.Split(',')[0], new CultureInfo("en-US"));
                var latitude = Convert.ToDouble(cord.Split(',')[1], new CultureInfo("en-US"));
                var pos = new Position(latitude, longitude);
                posList.Add(pos);
            }

            return posList;
        }
Пример #9
0
		public Row (Position StartingPoint, Position EndPoint, TreeType TreeType)
		{
			this.StartingPoint = StartingPoint;
			this.EndPoint = EndPoint;
			this.TreeType = TreeType;
		}
Пример #10
0
        /// <summary>
        /// Calculates the bounding box for a list of coordinates.
        /// </summary>
        /// <returns>The bounding box.</returns>
        /// <param name="boundingCoordinates">List of coordinates.</param>
        public static BoundingBox CalculateBoundingBox(List<Position> boundingCoordinates)
        {
            if (boundingCoordinates.Count < 2)
            {
                return new BoundingBox { Width = 0d, Height = 0d };
            }
            
            double smallestLongitude = boundingCoordinates[0].Longitude;
            double biggestLongitude = smallestLongitude;
            double smallestLatitude = boundingCoordinates[0].Latitude;
            double biggestLatitude = smallestLatitude;

            for (int i = 1; i < boundingCoordinates.Count; i++)
            {
                smallestLongitude = Math.Min(boundingCoordinates[i].Longitude, smallestLongitude);
                biggestLongitude = Math.Max(boundingCoordinates[i].Longitude, biggestLongitude);

                smallestLatitude = Math.Min(boundingCoordinates[i].Latitude, smallestLatitude);
                biggestLatitude = Math.Max(boundingCoordinates[i].Latitude, biggestLatitude);
            }

            double width = biggestLongitude - smallestLongitude;
            double height = biggestLatitude - smallestLatitude;
            var center = new Position(smallestLatitude + (height * 0.5), smallestLongitude + (width * 0.5));

            return new BoundingBox
            {
                Width = width,
                Height = height,
                Center = center,
                WidthInMeters = DistanceInMeters(smallestLatitude, smallestLongitude, smallestLatitude, biggestLongitude),
                HeightInMeters = DistanceInMeters(smallestLatitude, smallestLongitude, biggestLatitude, smallestLongitude)
            };
        }