public void radiusSearch(MapPoint.Map map, double lat, double lon, double lat_vei, double lon_vei) { //center of search Radius Location origin = map.GetLocation(lat, lon, map.Altitude); //var origin = new VELatLong(43.645, -79.389); //search radius in km int radius = int.Parse(mainFrm.RADIUS_BERSAGLIO); //for (var i = 0; i < dataLayer.GetShapeCount(); i++) //controllo per tutta la flotta //{ Location latlong = map.GetLocation(lat_vei, lon_vei, map.Altitude); double d = distance(origin, latlong); if (Math.Abs(d) <= Math.Abs(radius)) { drawCircle(origin, radius, map); map.GoToLatLong(origin.Latitude, origin.Longitude, map.Altitude); mainFrm.frmAllarm.addNewAllarm(DateTime.Now.ToString(), device.device_number, "Terminale presso obiettivo"); } //} }
private void frmMain_Load(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; status.Text = string.Empty; this.Show(); System.Windows.Forms.Application.DoEvents(); string mapPointFile = string.Empty; openFileDialog1.Filter = "Mappoint Files (*.ptm)|*.ptm"; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { mappointAreas = new AreaCollection(); MapPoint.Application mApp = new MapPoint.Application(); mApp.Visible = false; mApp.UserControl = false; MapPoint.Map map = mApp.OpenMap(openFileDialog1.FileName, false); int i = 0; foreach (MapPoint.Shape shape in map.Shapes) { //try //{ if (shape.Type == GeoShapeType.geoFreeform) { i++; status.Text = "Importing Shape " + i.ToString(); System.Windows.Forms.Application.DoEvents(); AreaCoordinateCollection coordinates = new AreaCoordinateCollection(); System.Object[] objects = (System.Object[])shape.Vertices; foreach (System.Object obj in objects) { if (obj is MapPoint.Location) { MapPoint.Location location = (MapPoint.Location)obj; AreaCoordinate coordinate = new AreaCoordinate(); coordinate.Latitude = location.Latitude; coordinate.Longitude = location.Longitude; coordinates.Add(coordinate); System.Windows.Forms.Application.DoEvents(); } } Area area = new Area(coordinates.MinLatitude(), coordinates.MinLongitude()); if (area == null || area.AreaID == -1) { area.AreaID = int.MinValue; area.OrganizationID = OrganizationId; area.Name = "Area: " + i.ToString(); area.MapHeight = 400; area.MapWidth = 600; } area.Coordinates = coordinates; for (int j = 0; j < area.Coordinates.Count; j++) { AreaCoordinate aCoordinate = area.Coordinates[j]; aCoordinate.AreaID = area.AreaID; aCoordinate.Order = j; } if (area.Blob != null) { area.Blob.DateModified = DateTime.Now; } mappointAreas.Add(area); } //} //catch (System.Exception ex) //{ // MessageBox.Show("Area " + i.ToString() + ": " + ex.Message, "Error Reading Area"); //} } LoadExistingAreas(); LoadMappointAreas(0); } else { btnLink.Enabled = false; btnCreateNew.Enabled = false; btnRemove.Enabled = false; btnImport.Enabled = false; } status.Text = string.Empty; Cursor.Current = Cursors.Default; }
public void drawCircle(Location origin, double radius, MapPoint.Map map) { map.Shapes.AddShape(GeoAutoShapeType.geoShapeOval, origin, radius, radius); }