/// <summary> /// 获取图层中的所有feature对象,包括featureFolder下面的feature对象 /// </summary> /// <param name="layer"></param> /// <returns></returns> public static GSOFeatures getRealFeaturesByLayer(GSOLayer layer) { GSOFeatures realFeatures = new GSOFeatures(); if (layer != null) { for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (feature != null) { if (feature.Type == EnumFeatureType.FeatureFolder) { GSOFeatureFolder featureFolder = feature as GSOFeatureFolder; getRealFeatureByFeatures(featureFolder.Features, ref realFeatures); } else { realFeatures.Add(feature); } } } } return(realFeatures); }
void GetRealFeature(GSOFeature feature, GSOFeatures realfeatures) { if (feature == null || realfeatures == null) { return; } if (feature.Type == EnumFeatureType.Feature) { realfeatures.Add(feature); } else if (feature.Type == EnumFeatureType.FeatureFolder) { GSOFeatureFolder featureFolder = (GSOFeatureFolder)feature; for (int i = 0; i < featureFolder.Features.Length; i++) { GetRealFeature(featureFolder.Features[i], realfeatures); } } }
public static GSOFeatures Table2Features(DataTable table, string currentQueryLayer, GeoScene.Globe.GSOGlobeControl globeControl1) { GSOFeatures features = new GSOFeatures(); for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; string featureName = row["编号"].ToString(); featureName = featureName.Trim(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(currentQueryLayer); GSOFeatures tempfeatures = layer.GetFeatureByName(featureName, false); if (tempfeatures.Length > 0) { features.Add(tempfeatures[0]); } } return(features); }
private void FrmPolygonToWater_Load(object sender, EventArgs e) { mFeatures = mLayer.GetAllFeatures(); mFeaturesOld = new GSOFeatures(); bool hasGeoWater = false; for (int i = 0; i < mFeatures.Length; i++) { if (mFeatures[i] != null) { mFeaturesOld.Add(mFeatures[i].Clone()); if (!hasGeoWater) { if (mFeatures[i].Geometry != null && mFeatures[i].Geometry.Type == EnumGeometryType.GeoWater) { GSOGeoWater geoWater = (GSOGeoWater)mFeatures[i].Geometry; // 水一般都是绝对高度模式 //geoWater.Altitude = EnumAltitudeMode.Absolute; textBoxWaveSpeedX.Text = geoWater.WaveSpeedX.ToString(); textBoxWaveSpeedY.Text = geoWater.WaveSpeedY.ToString(); textBoxWaveWidth.Text = geoWater.WaveWidth.ToString(); pictureBoxWaterColor.BackColor = geoWater.WaterColor; pictureBoxReflectColor.BackColor = geoWater.ReflectColor; textBoxNormalImage.Text = geoWater.WaveNormalImage; textBoxDuDvImage.Text = geoWater.WaveDuDvImage; checkboxReflectSky.Checked = geoWater.ReflectSky; checkBoxWaveLOD.Checked = geoWater.UseWaveLOD; hasGeoWater = true; } } } } if (!hasGeoWater) { textBoxWaveSpeedX.Text = "" + 0; textBoxWaveSpeedY.Text = "" + 0.00999999977648258; textBoxWaveWidth.Text = "" + 1; comboBoxLightType.SelectedIndex = 0; } }
private static void getRealFeatureByFeatures(GSOFeatures features, ref GSOFeatures realFeatures) { if (features == null) { return; } for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; if (feature != null) { if (feature.Type == EnumFeatureType.FeatureFolder) { GSOFeatureFolder featureFolder = feature as GSOFeatureFolder; getRealFeatureByFeatures(featureFolder.Features, ref realFeatures); } else { realFeatures.Add(feature); } } } }
private GSOFeatures getFeatures() { try { GSOFeatures feats = new GSOFeatures(); double min = double.Parse(textBox1.Text); double max = double.Parse(textBox2.Text); for (int i = 0; i < treeView1.Nodes.Count; i++) { if (treeView1.Nodes[i].Checked) { GSOLayer layer = treeView1.Nodes[i].Tag as GSOLayer; GSOFeatures fs = layer.GetAllFeatures(); for (int j = 0; j < fs.Length; j++) { GSOFeature f = fs[j]; double z = f.Geometry.GeoCenterPoint.Z; if (f != null && f.Geometry != null && f.Geometry.Type == EnumGeometryType.GeoModel) { GSOGeoModel model = f.Geometry as GSOGeoModel; z = model.PositionZ; } if (z >= min && z <= max) { feats.Add(f); } } } } return(feats); } catch (Exception exp) { exp.GetType(); } return(null); }
private GSOFeatures getFeatures() { try { GSOFeatures feats = new GSOFeatures(); double min = double.Parse(textBox1.Text); double max = double.Parse(textBox2.Text); for (int i = 0; i < treeView1.Nodes.Count; i++) { if (treeView1.Nodes[i].Checked) { GSOLayer layer = treeView1.Nodes[i].Tag as GSOLayer; GSOFeatures fs = layer.GetAllFeatures(); for (int j = 0; j < fs.Length; j++) { GSOFeature f = fs[j]; double z = f.Geometry.GeoCenterPoint.Z; if (f != null && f.Geometry != null && f.Geometry.Type == EnumGeometryType.GeoModel) { GSOGeoModel model = f.Geometry as GSOGeoModel; z = model.PositionZ; } if (z >= min && z <= max) { feats.Add(f); } } } } return feats; } catch (Exception exp) { exp.GetType(); } return null; }
void GetRealFeature(GSOFeature feature, GSOFeatures realfeatures) { if (feature == null || realfeatures == null) { return; } if (feature.Type == EnumFeatureType.Feature) { realfeatures.Add(feature); } else if (feature.Type == EnumFeatureType.FeatureFolder) { GSOFeatureFolder featureFolder = (GSOFeatureFolder)feature; for (int i = 0; i < featureFolder.Features.Length; i++) { GetRealFeature(featureFolder.Features[i],realfeatures); } } }
public static GSOFeatures Table2Features(DataTable table, string currentQueryLayer,GeoScene.Globe.GSOGlobeControl globeControl1) { GSOFeatures features = new GSOFeatures(); for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; string featureName = row["编号"].ToString(); featureName = featureName.Trim(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(currentQueryLayer); GSOFeatures tempfeatures = layer.GetFeatureByName(featureName, false); if (tempfeatures.Length > 0) { features.Add(tempfeatures[0]); } } return features; }
private bool apply() { double waveSpeedX = 0; if (!double.TryParse(textBoxWaveSpeedX.Text.Trim(), out waveSpeedX)) { MessageBox.Show("水波横向速度不符合要求"); return false ; } double waveSpeedY = 0; if (!double.TryParse(textBoxWaveSpeedY.Text.Trim(), out waveSpeedY)) { MessageBox.Show("水波纵向速度不符合要求"); return false; } double waveWidth = 0; if (!double.TryParse(textBoxWaveWidth.Text.Trim(), out waveWidth)) { MessageBox.Show("水波宽度不符合要求"); return false; } Color waterColor = pictureBoxWaterColor.BackColor; Color reflectorColor = Color.FromArgb(Convert.ToByte(upDownReflectOpaque.Value), pictureBoxReflectColor.BackColor); int intLightType = comboBoxLightType.SelectedIndex; string waveNormalImagePath = textBoxNormalImage.Text; string waveDuDvImagePath = textBoxDuDvImage.Text; GSOFeatures featuresAdded = new GSOFeatures(); GSOFeatures featuresNomal = new GSOFeatures(); for (int i = mFeatures.Length - 1; i >= 0 ; i--) { GSOFeature feature = mFeatures[i]; if (feature != null && feature.Geometry != null) { if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) { GSOGeoPolygon3D geoPolygon3d = (GSOGeoPolygon3D)feature.Geometry; GSOGeoWater geoWater = geoPolygon3d.ConvertToGeoWater(); // 水一般都是绝对高度模式 //geoWater.Altitude = EnumAltitudeMode.Absolute; geoWater.WaveSpeedX = waveSpeedX; geoWater.WaveSpeedY = waveSpeedY; geoWater.WaveWidth = waveWidth; geoWater.WaterColor = waterColor; geoWater.ReflectColor = reflectorColor; geoWater.WaveNormalImage = waveNormalImagePath; geoWater.WaveDuDvImage = waveDuDvImagePath; geoWater.ReflectSky = checkboxReflectSky.Checked; geoWater.UseWaveLOD = checkBoxWaveLOD.Checked; GSOFeature newFeature = feature.Clone(); geoWater.Play(); newFeature.Geometry = geoWater; featuresAdded.Add(newFeature); } else if (feature.Geometry.Type == EnumGeometryType.GeoWater) { GSOGeoWater geoWater = (GSOGeoWater)feature.Geometry; // 水一般都是绝对高度模式 //geoWater.Altitude = EnumAltitudeMode.Absolute; geoWater.WaveSpeedX = waveSpeedX; geoWater.WaveSpeedY = waveSpeedY; geoWater.WaveWidth = waveWidth; geoWater.WaterColor = waterColor; geoWater.ReflectColor = reflectorColor; geoWater.WaveNormalImage = waveNormalImagePath; geoWater.WaveDuDvImage = waveDuDvImagePath; geoWater.ReflectSky = checkboxReflectSky.Checked; geoWater.UseWaveLOD = checkBoxWaveLOD.Checked; GSOFeature newFeature = feature.Clone(); geoWater.Play(); newFeature.Geometry = geoWater; featuresAdded.Add(newFeature); } else { featuresNomal.Add(feature); } } } mLayer.RemoveAllFeature(); mLayer.AddFeatures(featuresAdded); mLayer.AddFeatures(featuresNomal); mGlobeControl.Refresh(); return true; }
private bool apply() { double waveSpeedX = 0; if (!double.TryParse(textBoxWaveSpeedX.Text.Trim(), out waveSpeedX)) { MessageBox.Show("水波横向速度不符合要求"); return(false); } double waveSpeedY = 0; if (!double.TryParse(textBoxWaveSpeedY.Text.Trim(), out waveSpeedY)) { MessageBox.Show("水波纵向速度不符合要求"); return(false); } double waveWidth = 0; if (!double.TryParse(textBoxWaveWidth.Text.Trim(), out waveWidth)) { MessageBox.Show("水波宽度不符合要求"); return(false); } Color waterColor = pictureBoxWaterColor.BackColor; Color reflectorColor = Color.FromArgb(Convert.ToByte(upDownReflectOpaque.Value), pictureBoxReflectColor.BackColor); int intLightType = comboBoxLightType.SelectedIndex; string waveNormalImagePath = textBoxNormalImage.Text; string waveDuDvImagePath = textBoxDuDvImage.Text; GSOFeatures featuresAdded = new GSOFeatures(); GSOFeatures featuresNomal = new GSOFeatures(); for (int i = mFeatures.Length - 1; i >= 0; i--) { GSOFeature feature = mFeatures[i]; if (feature != null && feature.Geometry != null) { if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) { GSOGeoPolygon3D geoPolygon3d = (GSOGeoPolygon3D)feature.Geometry; GSOGeoWater geoWater = geoPolygon3d.ConvertToGeoWater(); // 水一般都是绝对高度模式 //geoWater.Altitude = EnumAltitudeMode.Absolute; geoWater.WaveSpeedX = waveSpeedX; geoWater.WaveSpeedY = waveSpeedY; geoWater.WaveWidth = waveWidth; geoWater.WaterColor = waterColor; geoWater.ReflectColor = reflectorColor; geoWater.WaveNormalImage = waveNormalImagePath; geoWater.WaveDuDvImage = waveDuDvImagePath; geoWater.ReflectSky = checkboxReflectSky.Checked; geoWater.UseWaveLOD = checkBoxWaveLOD.Checked; GSOFeature newFeature = feature.Clone(); geoWater.Play(); newFeature.Geometry = geoWater; featuresAdded.Add(newFeature); } else if (feature.Geometry.Type == EnumGeometryType.GeoWater) { GSOGeoWater geoWater = (GSOGeoWater)feature.Geometry; // 水一般都是绝对高度模式 //geoWater.Altitude = EnumAltitudeMode.Absolute; geoWater.WaveSpeedX = waveSpeedX; geoWater.WaveSpeedY = waveSpeedY; geoWater.WaveWidth = waveWidth; geoWater.WaterColor = waterColor; geoWater.ReflectColor = reflectorColor; geoWater.WaveNormalImage = waveNormalImagePath; geoWater.WaveDuDvImage = waveDuDvImagePath; geoWater.ReflectSky = checkboxReflectSky.Checked; geoWater.UseWaveLOD = checkBoxWaveLOD.Checked; GSOFeature newFeature = feature.Clone(); geoWater.Play(); newFeature.Geometry = geoWater; featuresAdded.Add(newFeature); } else { featuresNomal.Add(feature); } } } mLayer.RemoveAllFeature(); mLayer.AddFeatures(featuresAdded); mLayer.AddFeatures(featuresNomal); mGlobeControl.Refresh(); return(true); }
//查询 private void buttonConditionSelect_Click(object sender, EventArgs e) { if (layer == null) { MessageBox.Show("请选择一个图层!"); return; } if (comboBoxConditionFieldName.Text == "" || comboBoxConditionFieldValue.Text == "" || comboBoxCondition.Text == "") { MessageBox.Show("请输入完整的查询条件!", "提示"); return; } GSOFeatureDataset featureDataset = layer.Dataset as GSOFeatureDataset; EnumFieldType currentFieldType = EnumFieldType.Text; if (featureDataset != null) { GSOFieldAttr field = featureDataset.GetField(comboBoxConditionFieldName.Text); if (field != null) { switch (field.Type) { case EnumFieldType.Double: case EnumFieldType.INT32: currentFieldType = EnumFieldType.Double; break; case EnumFieldType.Date: currentFieldType = EnumFieldType.Date; break; } } } try { switch (comboBoxCondition.Text) { case "=": for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (feature != null && feature.GetValue(comboBoxConditionFieldName.Text).ToString() == comboBoxConditionFieldValue.Text) { features.Add(feature); } } break; case ">=": for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (currentFieldType == EnumFieldType.Double) { if (feature != null && Double.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) >= Double.Parse(comboBoxConditionFieldValue.Text)) { features.Add(feature); } } else if (currentFieldType == EnumFieldType.Date) { if (feature != null && DateTime.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) >= DateTime.Parse(comboBoxConditionFieldValue.Text)) { features.Add(feature); } } } break; case "<=": for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (currentFieldType == EnumFieldType.Double) { if (feature != null && Double.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) <= Double.Parse(comboBoxConditionFieldValue.Text)) { features.Add(feature); } } else if (currentFieldType == EnumFieldType.Date) { if (feature != null && DateTime.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) <= DateTime.Parse(comboBoxConditionFieldValue.Text)) { features.Add(feature); } } } break; case ">": for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (currentFieldType == EnumFieldType.Double) { if (feature != null && Double.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) > Double.Parse(comboBoxConditionFieldValue.Text)) { features.Add(feature); } } else if (currentFieldType == EnumFieldType.Date) { if (feature != null && DateTime.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) > DateTime.Parse(comboBoxConditionFieldValue.Text)) { features.Add(feature); } } } break; case "<": for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (currentFieldType == EnumFieldType.Double) { if (feature != null && Double.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) < Double.Parse(comboBoxConditionFieldValue.Text)) { features.Add(feature); } } else if (currentFieldType == EnumFieldType.Date) { if (feature != null && DateTime.Parse(feature.GetFieldAsDataTime(comboBoxConditionFieldName.Text).ToString()) < DateTime.Parse(comboBoxConditionFieldValue.Text)) { features.Add(feature); } } } break; } if (features == null) { MessageBox.Show("请重新输入查询条件!", "提示"); return; } if (features.Length == 0) { MessageBox.Show("没有找到符合查询条件的对象!", "提示"); return; } SetDataTable(features); } catch (Exception ex) { Log.PublishTxt(ex); MessageBox.Show(ex.Message, "提示"); return; } }
//应用 private void buttonApply_Click(object sender, EventArgs e) { if (comboBoxLayerCaption.SelectedItem == null) { MessageBox.Show("请选择一个管线图层!", "提示"); return; } if (comboBoxLayerValveCaption.SelectedItem == null) { MessageBox.Show("请选择一个工井图层!", "提示"); return; } if (textBoxValueIndented.Text.Trim() == "") { MessageBox.Show("请输入缩进距离!", "提示"); return; } if (textBoxAllowance.Text.Trim() == "") { MessageBox.Show("请输入容限值!", "提示"); return; } double valueAllowance = 0.0; if (double.TryParse(textBoxAllowance.Text.Trim(), out valueAllowance) == false) { MessageBox.Show("请输入一个正确的容限值!", "提示"); return; } float valueIndented = 0.0f; if (float.TryParse(textBoxValueIndented.Text.Trim(), out valueIndented) == false) { MessageBox.Show("请输入一个正确的缩进值!", "提示"); return; } string layerCaption = comboBoxLayerCaption.SelectedItem.ToString().Trim(); string valveLayerCaption = comboBoxLayerValveCaption.SelectedItem.ToString().Trim(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerCaption); GSOLayer valveLayer = globeControl1.Globe.Layers.GetLayerByCaption(valveLayerCaption); if (layer != null && valveLayerCaption != null) { featuresIndented.RemoveAll(); cancelHighLight(layer.GetAllFeatures()); for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; double lineLenght = line.GetSpaceLength(false, 6378137.0); if (lineLenght <= valueIndented * 2) { continue; } featuresIndented.Add(feature);//缩进的管线集合 featuresInit.Add(feature.Clone()); //头缩进 GSOPoint3d headPoint = line[0][0]; GSOGeoPolyline3D newline = new GSOGeoPolyline3D(); GSOPoint3ds part = new GSOPoint3ds(); part.Add(headPoint); headPoint.X = headPoint.X - 0.0000000005; part.Add(headPoint); newline.AddPart(part); GSOGeoPolygon3D buffer = newline.CreateBuffer(valueAllowance, true, 5, true, false); GSOFeatures features = valveLayer.FindFeaturesInPolygon(buffer, false); if (features.Length > 0) { feature.HighLight = true; if (line.Style != null && line.Style is GSOPipeLineStyle3D) { GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D; style.HeadJointParam = new GSOPipeJointParam(); style.HeadJointParam.Extent = -valueIndented; } } //尾缩进 GSOPoint3d tailPoint = line[line.PartCount - 1][line[line.PartCount - 1].Count - 1]; newline = new GSOGeoPolyline3D(); part = new GSOPoint3ds(); part.Add(tailPoint); tailPoint.X = tailPoint.X - 0.0000000005; part.Add(tailPoint); newline.AddPart(part); buffer = newline.CreateBuffer(valueAllowance, true, 5, true, false); features = valveLayer.FindFeaturesInPolygon(buffer, false); if (features.Length > 0) { feature.HighLight = true; if (line.Style != null && line.Style is GSOPipeLineStyle3D) { GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D; style.TailJointParam = new GSOPipeJointParam(); style.TailJointParam.Extent = -valueIndented; } } } } } globeControl1.Globe.Refresh(); }