public override void OnClick() { Folder folderMapItem = new Folder(); MapDisplay mdisp = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay; //use this to change the projections 35,-106 FeatureLayer proj = FeatureLayer.OpenShapefile("C:\\Documents and Settings\\user\\My Documents\\dbox\\Dropbox\\Public\\GISdata\\forProjection.shp"); // Path for Windows 7: FeatureLayer proj = FeatureLayer.OpenShapefile("C:\\Users\\user\\Dropbox\\Public\\GISdata\\forProjection.shp"); mdisp.CoordinateSystem2D = proj.CoordinateSystem; string center = mdisp.Center.ToString(); folderMapItem.Name = "Close To Me"; string[] c = center.Split(null); String lon = c[3]; String lat = c[6]; MongoClient client = new MongoClient(); // connect to localhost. Deploy at: "mongodb://143.120.143.163:27017" MongoServer server = client.GetServer(); MongoDatabase db = server.GetDatabase("rtcc"); var collection = db.GetCollection<BsonDocument>("cnau"); var query = Query.Near("loc", double.Parse(c[3]), double.Parse(c[6])); //var cursor = collection.Find(query); Put this in foreach so dont need it anymore. foreach (BsonDocument item in collection.Find(query).SetLimit(5)) { BsonElement loc = item.GetElement("loc"); string g = loc.Value.ToString(); string x = g.Trim(new Char[] { '[', ']' }); String[] a = x.Split(','); // BsonElement name = item.GetElement("name"); Work for all indexes in MongoDB // Pass the other data to the notes popups below ESRI.ArcGISExplorer.Geometry.Point mypoint = new ESRI.ArcGISExplorer.Geometry.Point(double.Parse(a[0]), double.Parse(a[1])); // Create a Note using the Point geometry. Note mypointNote = new Note("MyNote", mypoint, Symbol.Marker.Pushpin.Orange); // Populate the Note popup with information about the Point geometry using the ToString method. StringBuilder info = new StringBuilder(@"<p><a href=""http://google.com"">Google</a></p>"); info.AppendLine(@"<p>" + mypoint.ToString() + @"</p>"); //MapDisplay disp = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay; mypointNote.Popup.Content = info.ToString(); // Add the Note to the current Map. //mdisp.Map.ChildItems.Add(mypointNote); folderMapItem.ChildItems.Add(mypointNote); } mdisp.Map.ChildItems.Add(folderMapItem); }
/// <summary> /// Makes footprint envelope for a metadata record /// </summary> /// <param name="record">CswRecord object</param> /// <returns>envelope polygon</returns> private AGXG.Polygon makeFootPrint(CswRecord record) { AGXG.Envelope envelope = new AGXG.Envelope(); try { envelope.XMax = record.BoundingBox.Maxx; envelope.YMax = record.BoundingBox.Maxy; envelope.XMin = record.BoundingBox.Minx; envelope.YMin = record.BoundingBox.Miny; } catch (System.ArgumentException e) { try { envelope.XMax = record.BoundingBox.Minx; envelope.YMax = record.BoundingBox.Maxy; envelope.XMin = record.BoundingBox.Maxx; envelope.YMin = record.BoundingBox.Miny; } catch (System.ArgumentException e1) { try { envelope.XMax = record.BoundingBox.Minx; envelope.YMax = record.BoundingBox.Miny; envelope.XMin = record.BoundingBox.Maxx; envelope.YMin = record.BoundingBox.Maxy; } catch (System.ArgumentException e2) { envelope.XMax = record.BoundingBox.Maxx; envelope.YMax = record.BoundingBox.Miny; envelope.XMin = record.BoundingBox.Minx; envelope.YMin = record.BoundingBox.Maxy; } } } AGXG.Point p1 = new AGXG.Point(); p1.SetCoordinates(record.BoundingBox.Maxx, record.BoundingBox.Maxy); AGXG.Point p2 = new AGXG.Point(); p2.SetCoordinates(record.BoundingBox.Maxx, record.BoundingBox.Miny); AGXG.Point p3 = new AGXG.Point(); p3.SetCoordinates(record.BoundingBox.Minx, record.BoundingBox.Miny); AGXG.Point p4 = new AGXG.Point(); p4.SetCoordinates(record.BoundingBox.Minx, record.BoundingBox.Maxy); AGXG.Polygon footPrint = new AGXG.Polygon(); footPrint.AddPoint(p1); footPrint.AddPoint(p2); footPrint.AddPoint(p3); footPrint.AddPoint(p4); footPrint.AddPoint(p1); return footPrint; }