private void MoveEachFeature(GSOFeatureFolder folder, double daltX, double daltY) { GSOFeatures features = folder.Features; for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; if (feature is GSOFeatureFolder) { MoveEachFeature(feature as GSOFeatureFolder, daltX, daltY); } else { GSOGeometry g = feature.Geometry; if (g != null) { g.MoveXY(daltX, daltY); } //GSOGeoModel model = feature.Geometry as GSOGeoModel; //if (model!=null) //{ // GSOPoint3d pt = model.Position; // pt.X += daltX; // pt.Y += daltY; // model.Position = pt; //} } } }
private void btnMove_Click(object sender, EventArgs e) { GSOLayer layer = ctl.Globe.Layers[cmbLayers.SelectedIndex]; if (layer != null) { if (layer.Type != EnumLayerType.FeatureLayer) { MessageBox.Show("当前选中的图层不是模型图层!", "提示"); return; } if (txtOldLat.Text == "") { MessageBox.Show("请选择起点"); } else if (txtNewLat.Text == "") { MessageBox.Show("请选择目标点"); } else { double daltX = Convert.ToDouble(txtNewLon.Text) - Convert.ToDouble(txtOldLon.Text); double daltY = Convert.ToDouble(txtNewLat.Text) - Convert.ToDouble(txtOldLat.Text); 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, daltX, daltY); } else { GSOGeometry g = feature.Geometry; if (g != null) { g.MoveXY(daltX, daltY); } // switch (feature.Geometry.Type) // { // case EnumGeometryType.GeoPolyline3D: // GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; // for (int m = 0; m < line.PartCount; m++) // { // for (int j = 0; j < line[m].Count; j++) // { // GSOPoint3d line0 = line[m][j]; // line0.X += daltX; // line0.Y += daltY; // line[m][j] = line0; // } // } // break; // case EnumGeometryType.GeoPolygon3D: // GSOGeoPolygon3D polygon = feature.Geometry as GSOGeoPolygon3D; // if (polygon != null) // { // polygon.MoveXY(daltX, daltY); // } // break; // case EnumGeometryType.GeoModel: // GSOGeoModel model = feature.Geometry as GSOGeoModel; // if (model != null) // { // GSOPoint3d pt = model.Position; // pt.X += daltX; // pt.Y += daltY; // model.Position = pt; // } // break; // case EnumGeometryType.GeoFrameAnimation: // GSOGeoFrameAnimation frameAnimation = feature.Geometry as GSOGeoFrameAnimation; // if (frameAnimation != null) // { // GSOPoint3d pt = frameAnimation.Position; // pt.X += daltX; // pt.Y += daltY; // frameAnimation.Position = pt; // } // break; // default: // GSOGeometry g = feature.Geometry; // if (g != null) // { // g.MoveXY(daltX, daltY); // } // break; // } } } if (startFeat != null) { startFeat.Delete(); } if (endFeat != null) { endFeat.Delete(); } ctl.Refresh(); //this.Close(); } } else { MessageBox.Show("请选择图层"); } }