/// <summary> /// 查询统计范围 /// </summary> private void searchBound() { String key = this.comboBoxQueryKey.Text.Trim(); Double radius = this.doubleInputRadius.Value; if (key.Length == 0 || key == tipDistrictKey) { MessageBox.Show("请输入搜索关键字!", msgCaption); return; } this.listBoxPoiResult.Items.Clear(); this.axSuperMap1.TrackingLayer.ClearEvents(); if (!poiSearch.IsOpen) { MessageBox.Show("找不到POI索引!", msgCaption); return; } // poi查询 PoiResult poiResult = poiSearch.search(key); if (poiResult == null || poiResult.Count == 0) { MessageBox.Show("找不到数据!", msgCaption); } soStyle style = new soStyle(); style.PenColor = Util.ColorToUInt32(Color.Blue); style.SymbolSize = 30; //获取第一个查询结果 PoiInfo poiInfo = poiResult.getPoiInfoAt(0); //坐标转换(wgs84 -> 地图坐标) coordSysTranslator.convert(ref poiInfo); // 加入跟踪层高亮显示 soGeoPoint geoPoint = new soGeoPoint(); geoPoint.x = poiInfo.x; geoPoint.y = poiInfo.y; this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)geoPoint, style, poiInfo.name); //计算扩大一圈的面 searchBoundGeometry = geoPoint.SpatialOperator.Buffer(radius, 25); ////将查询结果加入到选择集中,使其高亮显示 //objSelection = this.axSuperMap1.selection; //objSelection.FromRecordset(objRd); this.axSuperMap1.TrackingLayer.RemoveEvent("SearchBound"); style = new soStyle(); style.PenColor = Util.ColorToUInt32(Color.Blue); style.BrushStyle = 1; this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)searchBoundGeometry, style, "SearchBound"); //刷新地图窗口 viewBounds(searchBoundGeometry.Bounds); if (!this.comboBoxQueryKey.Items.Contains(key)) { this.comboBoxQueryKey.Items.Add(key); } }
private void recordsetToTrackingLayer(soRecordset objRd) { soStyle style = new soStyle(); style.PenColor = Util.ColorToUInt32(Color.Red); //style.BrushStyle = 0; style.BrushOpaqueRate = 50; objRd.MoveFirst(); while (!objRd.IsEOF()) { soGeometry geo = objRd.GetGeometry(); this.axSuperMap1.TrackingLayer.AddEvent(geo, style, "Search"); objRd.MoveNext(); } }
private void listBoxPoiResult_SelectedIndexChanged(object sender, EventArgs e) { this.axSuperMap1.TrackingLayer.RemoveEvent("selectPoiInfo"); PoiInfo poiInfo = (PoiInfo)this.listBoxPoiResult.SelectedItem; if (poiInfo != null) { // 加入跟踪层高亮显示 soStyle style = new soStyle(); style.PenColor = Util.ColorToUInt32(Color.Red); style.SymbolSize = 30; soGeoPoint geoPoint = new soGeoPoint(); geoPoint.x = poiInfo.x; geoPoint.y = poiInfo.y; this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)geoPoint, style, "selectPoiInfo"); this.axSuperMap1.TrackingLayer.Refresh(); } }
private void axSuperMap1_Tracked(object sender, EventArgs e) { //if (e.dTotalArea > 0) this.staregionvalue.Text = e.dTotalArea.ToString(); //if (e.dCurrentLength > 0) this.stadisvalue.Text = e.dCurrentLength.ToString(); //if (e.dTotalLength > 0) this.statotledisvalue.Text = e.dTotalLength.ToString(); if (this.axSuperMap1.Action == SuperMapLib.seAction.scaTrackRectangle || this.axSuperMap1.Action == SuperMapLib.seAction.scaTrackCircle) { //显示绘制的统计范围 if (this.axSuperMap1.TrackedGeometry.Type == seGeometryType.scgRect) { this.searchBoundGeometry = ((soGeoRect)this.axSuperMap1.TrackedGeometry).ConvertToRegion(); } else if (this.axSuperMap1.TrackedGeometry.Type == seGeometryType.scgCircle) { this.searchBoundGeometry = ((soGeoCircle)this.axSuperMap1.TrackedGeometry).ConvertToRegion(72); } this.axSuperMap1.TrackingLayer.RemoveEvent("SearchBound"); soStyle style = new soStyle(); style.PenColor = Util.ColorToUInt32(Color.Blue); style.BrushStyle = 1; this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)searchBoundGeometry, style, "SearchBound"); } }
/// <summary> /// 查询poi /// </summary> private void searchpoi() { String key = this.textBoxItemSearchKey.TextBox.Text.Trim(); if (key.Length == 0 || key == tipPOIKey) { MessageBox.Show("请输入搜索关键字!", msgCaption); return; } this.listBoxPoiResult.Items.Clear(); this.axSuperMap1.TrackingLayer.ClearEvents(); if (!poiSearch.IsOpen) { MessageBox.Show("找不到POI索引!", msgCaption); return; } // poi查询 PoiResult poiResult = poiSearch.search(key); if (poiResult == null || poiResult.Count == 0) { MessageBox.Show("找不到数据!", msgCaption); return; } soStyle style = new soStyle(); style.PenColor = Util.ColorToUInt32(Color.Blue); style.SymbolSize = 30; soRect rect = new soRect(); //获取查询结果 for (int i = 0; i < Math.Min(poiResult.Count,200); i++) { PoiInfo poiInfo = poiResult.getPoiInfoAt(i); //坐标转换(wgs84 -> 地图坐标) coordSysTranslator.convert(ref poiInfo); // 加了结果列表 this.listBoxPoiResult.Items.Add(poiInfo); // 加入跟踪层高亮显示 soGeoPoint geoPoint = new soGeoPoint(); geoPoint.x = poiInfo.x; geoPoint.y = poiInfo.y; this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)geoPoint, style, poiInfo.name); //计算范围 if (i==0) { //第一个 rect.Left = poiInfo.x; rect.Right = poiInfo.x; rect.Bottom = poiInfo.y; rect.Top = poiInfo.y; } else { //向外扩张 if (rect.Left > poiInfo.x) { rect.Left = poiInfo.x; } if (rect.Right < poiInfo.x) { rect.Right = poiInfo.x; } if (rect.Bottom > poiInfo.y) { rect.Bottom = poiInfo.y; } if (rect.Top < poiInfo.y) { rect.Top = poiInfo.y; } } } //viewAllPoi(this.listBoxPoiResult.Items); showRigthPanel(true, 1); if (poiResult.Count == 1) { axSuperMap1.CenterX = rect.CenterPoint().x; axSuperMap1.CenterY = rect.CenterPoint().y; } else { viewBounds(rect); } axSuperMap1.Refresh(); }
/// <summary> /// 查询地块,并统计出来 /// </summary> private void searchdikuai() { if (this.searchBoundGeometry == null) { return; } String dsName = tudi_datasetNames[tudi_curdatasetNameIndex]; //构造查询条件 String expression = ""; Boolean alltype = false; if (this.comboBoxType.Text == allType) { alltype = true; } else { TypeCodeNode selectType = (TypeCodeNode)this.comboBoxType.SelectedItem; if (selectType != null) { expression = String.Format("{0} = {1}", tudi_TypeFields[tudi_curdatasetNameIndex], selectType.code); } } SuperMapLib.soDatasetVector objDtv; //矢量数据集 SuperMapLib.soDataset objDt; SuperMapLib.soRecordset objRd; //记录集 if (this.axSuperWorkspace1.Datasources.Count == 0) { MessageBox.Show("找不到数据源!", msgCaption); return; } //从工作空间中获取数据源 SuperMapLib.soDataSource objDS = this.axSuperWorkspace1.Datasources[tudi_dataSourceIndex]; if (objDS == null || objDS.Datasets.Count == 0) { MessageBox.Show("找不到数据集!", msgCaption); return; } //从数据源中获取数据集 objDt = objDS.Datasets[dsName]; if (objDt == null) { MessageBox.Show("找不到数据集!", msgCaption); return; } objDtv = (SuperMapLib.soDatasetVector)objDt; //使用 SQL 过滤条件从数据集中查询出记录集,SQL 条件的 WHERE 子句部分从编辑框中获取。( Query 方法只适用于 soDatasetVector 类对象) objRd = objDtv.QueryByDistance((soGeometry)searchBoundGeometry, 0, expression); if (objRd == null || objRd.RecordCount == 0) { MessageBox.Show("找不到数据!", msgCaption); return; } //将查询结果加入到选择集中,使其高亮显示 //objSelection = this.axSuperMap1.selection; //objSelection.FromRecordset(objRd); //刷新地图窗口 this.axSuperMap1.Refresh(); //统计查询的数据 Dictionary<String, Double> dic = new Dictionary<String, Double>(); double allArea = 0; this.axSuperMap1.TrackingLayer.ClearEvents(); objRd.MoveFirst(); while (!objRd.IsEOF()) { soGeometry geo = objRd.GetGeometry(); if (geo.Type == SuperMapLib.seGeometryType.scgRegion) { // 对面进行裁剪,保留相交的部分 soGeometry geoIntersection = geo.SpatialOperator.Intersection((soGeometry)searchBoundGeometry); if (geoIntersection != null) { //按分类统计面积 String type = objRd.GetFieldValueText(tudi_TypeFields[tudi_curdatasetNameIndex]);//类型 //type = type.Substring(0, 2); String typeName = typeCodeTable.getNameByCode(type); double area = 0; //面积 if (objDS.PJCoordSys.Type == sePJCoordSysType.scPCS_LONGITUDE_LATITUDE) { area = ((soGeoRegion)geoIntersection).GetPreciseArea(objDS.PJCoordSys); } else { area = ((soGeoRegion)geoIntersection).Area; } if (dic.ContainsKey(typeName)) { dic[typeName] += area; } else { dic.Add(typeName, area); } //统计总面积 allArea += area; // 加入到跟踪层,用以高亮显示 soStyle style = new soStyle(); style.PenColor = Util.ColorToUInt32(Color.Red); //style.BrushStyle = 0; style.BrushOpaqueRate = 50; this.axSuperMap1.TrackingLayer.AddEvent((soGeometry)geoIntersection, style, "SearchDikuai"); } } objRd.MoveNext(); } //显示统计结果 if (alltype) { //图标方式 ChartForm cf = new ChartForm(); cf.initData(dic); cf.ShowDialog(this); } else { //对话框方式 String msg = String.Format("总面积为{0}", Util.formatArea(allArea)); MessageBox.Show(msg, msgCaption); } }