/// <summary> /// Event when map is clicked. /// Creates a new marker at location clicked, /// adds it to the treelistview and draws on the map /// </summary> /// <param name="PointClick">Point coordinate of click</param> /// <param name="e"></param> private void Map_OnMapClick(PointLatLng PointClick, MouseEventArgs e) { PointItem point = new PointItem(PointClick.Lat, PointClick.Lng, 1); point.DrawOnMap(map, polygons, markers); treeListView1.AddObject(point); CenterMapToPoint(map.Position); }
public CameraTrigger(PointItem point, double radius, int id) { Point = point; Radius = radius; Id = id; Label = Id.ToString(); Child = new List <object>(); Child.Add(Point); Captured = false; }
/// <summary> /// Calculates the distance in metres to given point. /// </summary> /// <param name="q">Point</param> /// <returns>Distance to point</returns> public double DistanceBetweenPoints(PointItem q) { const double earthRadius = 6371e3; var latrad1 = Latitude * Math.PI / 180; var lonrad1 = Longitude * Math.PI / 180; var latrad2 = q.Latitude * Math.PI / 180; var lonrad2 = q.Longitude * Math.PI / 180; var deltalat = (q.Latitude - Latitude) * Math.PI / 180; var deltalon = (q.Longitude - Longitude) * Math.PI / 180; double a = Math.Sin(deltalat / 2) * Math.Sin(deltalat / 2) + Math.Cos(latrad1) * Math.Cos(latrad2) * Math.Sin(deltalon / 2) * Math.Sin(deltalon / 2); double distance = earthRadius * 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); return(distance); }
/// <summary> /// Constructor for use when a point and bearing are known. /// </summary> /// <param name="q"></param> /// <param name="deltalat"></param> /// <param name="deltalon"></param> /// <param name="id"></param> public LineItem(PointItem q, double deltalat, double deltalon, int id) { Id = id; c = Color.Black; PointItems = new List <PointItem>(); PointItems.Add(q); PointItem item; Label = id.ToString(); item = new PointItem(q.Latitude + deltalat, q.Longitude + deltalon, 1); PointItems.Add(item); Length = PointItems[0].DistanceBetweenPoints(PointItems[1]); CreateGMapPolygon(); RefreshChildren(); }
public NMEAHandler(string[] delimited) { if (delimited[0] == "$GPRMC" && delimited[3] != "") { double lat = double.Parse(delimited[3]); double lon = double.Parse(delimited[5]); double latdec = ConvertToDecimalDegrees(lat); double londec = ConvertToDecimalDegrees(lon); // Negates latitude if in Southern Hemisphere if (delimited[4] == "S") { latdec = -latdec; } //Negates longitude if in Western Hemisphere if (delimited[6] == "W") { londec = -londec; } Point = new PointItem(latdec, londec, 0); } }