/// <summary> /// 递归升高/降低给定高度值 /// </summary> /// <param name="folder">要素集</param> /// <param name="height">高度/米</param> private void MoveEachFeature(GSOFeatureFolder folder, double height) { GSOFeatures features = folder.Features; for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; if (feature is GSOFeatureFolder) { MoveEachFeature(feature as GSOFeatureFolder, height); } else { GSOGeometry geometry = feature.Geometry; if (geometry != null) { //为了显示升降效果,需要将ClampToGround模式修改为RelativeToGround模式 if (geometry.AltitudeMode == EnumAltitudeMode.ClampToGround) { geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround; } //将z轴移动height米 geometry.MoveZ(height); } } } }
private void buttonMoveAllZ_Click(object sender, EventArgs e) { if (m_Geometry != null) { double dZAdded = 0; try { m_GlobeControl.Globe.AddToEditHistroy(mlayer, mfeature, EnumEditType.Modify); dZAdded = Convert.ToDouble(textBoxAllZAdded.Value.ToString()); m_Geometry.MoveZ(dZAdded); // 这个比较慢先暂时不用 //UpdateNodeViewList(); for (int i = 0; i < listViewNodeList.Items.Count; i++) { ListViewItem item = listViewNodeList.Items[i]; item.SubItems[3].Text = (Double.Parse(item.SubItems[3].Text) + dZAdded).ToString(); } SelectItem(m_nCurSelected); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } catch (System.Exception exp) { Log.PublishTxt(exp); //MessageBox.Show(exp.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void btn_OK_Click(object sender, System.EventArgs e) { if (string.IsNullOrEmpty(this.textBox1.Text)) { errorProvider1.SetError(this.textBox1, "请输入升降高度"); return; } if (!double.TryParse(this.textBox1.Text, out double height)) { errorProvider1.SetError(this.textBox1, "输入高度不合法,请重新输入数字。"); return; } GSOFeatureLayer flayer = _layer as GSOFeatureLayer; //获得图层中的所有要素 GSOFeatures features = flayer.GetAllFeatures(); for (int i = 0; i < features.Length; i++) { //遍历所有要素 GSOFeature feature = features[i]; if (feature is GSOFeatureFolder) { MoveEachFeature(feature as GSOFeatureFolder, height); } else { GSOGeometry geometry = feature.Geometry; if (geometry != null) { //为了显示升降效果, //需要将ClampToGround模式修改为RelativeToGround模式 if (geometry.AltitudeMode == EnumAltitudeMode.ClampToGround) { geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround; } //将z轴移动height米 geometry.MoveZ(height); } } } _glbControl.Refresh(); }