在ArcGlobe三维环境中进行数据查询2(模型定位显示)
2014-01-03 15:18
405 查看
代码如下:
void dataGridView1_CellClick(object sender,DataGridViewCellEventArgs e)
{
//取查询条件
StringstrCode = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
if (strCode== String.Empty)
{
return;
}
//取查询图层名称
StringLayerName = this.comboBox1.SelectedItem.ToString();
//获得当前视图
IScene scene= this.axGlobe.Globe.GlobeDisplay.Scene;
IQueryFilter pQueryFilter = new QueryFilterClass();
IActiveViewpActiveView;
pActiveView= (IActiveView)scene;
//清空上一次选择
scene.ClearSelection();
IFeatureLayer pFeatureLayer;
pFeatureLayer= (IFeatureLayer)scene.get_Layer(GetLayerId(LayerName, scene));
pQueryFilter.WhereClause = “NAME=”" + strCode + “”";
IFeatureCursor pFeatureCursor;
pFeatureCursor = pFeatureLayer.FeatureClass.Search(pQueryFilter, false);
IFeaturepFeature;
pFeature =pFeatureCursor.NextFeature();
while(pFeature != null)
{
scene.SelectFeature(pFeatureLayer, pFeature);
pFeature = pFeatureCursor.NextFeature();
}
ESRI.ArcGIS.Carto.ILayer layer =(ESRI.ArcGIS.Carto.ILayer)scene.get_Layer(GetLayerId(LayerName, scene));
// Get theline feature selected in the layer
ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)layer;
ESRI.ArcGIS.Carto.IFeatureSelection featureSelection =(ESRI.ArcGIS.Carto.IFeatureSelection)layer;
ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet =featureSelection.SelectionSet;
ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass;
stringshapeField = featureClass.ShapeFieldName;
ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilterCls = newESRI.ArcGIS.Geodatabase.SpatialFilterClass();
ESRI.ArcGIS.Geometry.ISpatialReference spatialReference =scene.SpatialReference;
spatialFilterCls.GeometryField = shapeField;
spatialFilterCls.set_OutputSpatialReference(shapeField, spatialReference);
ESRI.ArcGIS.Geodatabase.ICursor cursor;
selectionSet.Search(spatialFilterCls, true, out cursor);
ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor =(ESRI.ArcGIS.Geodatabase.IFeatureCursor)cursor;
ESRI.ArcGIS.Geodatabase.IFeature SFeature;
SFeature =featureCursor.NextFeature();
ESRI.ArcGIS.Geometry.IEnvelope envelope = SFeature.Shape.Envelope;
ESRI.ArcGIS.Analyst3D.ICamera camera =this.axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera;
ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera =(ESRI.ArcGIS.GlobeCore.IGlobeCamera)camera;
ESRI.ArcGIS.Analyst3D.ISceneViewer sceneViewer =this.axGlobe.Globe.GlobeDisplay.ActiveViewer;
globeCamera.OrientationMode =esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal;
IPointtarget = new PointClass();
target.PutCoords(0, 0);
target.Z =0;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.Target = target;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.ViewingDistance = 1.5;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.ViewFieldAngle = 8.5;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.RollAngle = 0.0;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.RecalcUp();
//定位
globeCamera.SetToZoomToExtents(envelope, this.axGlobe.Globe, sceneViewer);
//显示比例调整
double vfa =this.axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.ViewFieldAngle;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.ViewFieldAngle = vfa * 6;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Redraw(false);
}
void dataGridView1_CellClick(object sender,DataGridViewCellEventArgs e)
{
//取查询条件
StringstrCode = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
if (strCode== String.Empty)
{
return;
}
//取查询图层名称
StringLayerName = this.comboBox1.SelectedItem.ToString();
//获得当前视图
IScene scene= this.axGlobe.Globe.GlobeDisplay.Scene;
IQueryFilter pQueryFilter = new QueryFilterClass();
IActiveViewpActiveView;
pActiveView= (IActiveView)scene;
//清空上一次选择
scene.ClearSelection();
IFeatureLayer pFeatureLayer;
pFeatureLayer= (IFeatureLayer)scene.get_Layer(GetLayerId(LayerName, scene));
pQueryFilter.WhereClause = “NAME=”" + strCode + “”";
IFeatureCursor pFeatureCursor;
pFeatureCursor = pFeatureLayer.FeatureClass.Search(pQueryFilter, false);
IFeaturepFeature;
pFeature =pFeatureCursor.NextFeature();
while(pFeature != null)
{
scene.SelectFeature(pFeatureLayer, pFeature);
pFeature = pFeatureCursor.NextFeature();
}
ESRI.ArcGIS.Carto.ILayer layer =(ESRI.ArcGIS.Carto.ILayer)scene.get_Layer(GetLayerId(LayerName, scene));
// Get theline feature selected in the layer
ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)layer;
ESRI.ArcGIS.Carto.IFeatureSelection featureSelection =(ESRI.ArcGIS.Carto.IFeatureSelection)layer;
ESRI.ArcGIS.Geodatabase.ISelectionSet selectionSet =featureSelection.SelectionSet;
ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass;
stringshapeField = featureClass.ShapeFieldName;
ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilterCls = newESRI.ArcGIS.Geodatabase.SpatialFilterClass();
ESRI.ArcGIS.Geometry.ISpatialReference spatialReference =scene.SpatialReference;
spatialFilterCls.GeometryField = shapeField;
spatialFilterCls.set_OutputSpatialReference(shapeField, spatialReference);
ESRI.ArcGIS.Geodatabase.ICursor cursor;
selectionSet.Search(spatialFilterCls, true, out cursor);
ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor =(ESRI.ArcGIS.Geodatabase.IFeatureCursor)cursor;
ESRI.ArcGIS.Geodatabase.IFeature SFeature;
SFeature =featureCursor.NextFeature();
ESRI.ArcGIS.Geometry.IEnvelope envelope = SFeature.Shape.Envelope;
ESRI.ArcGIS.Analyst3D.ICamera camera =this.axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera;
ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera =(ESRI.ArcGIS.GlobeCore.IGlobeCamera)camera;
ESRI.ArcGIS.Analyst3D.ISceneViewer sceneViewer =this.axGlobe.Globe.GlobeDisplay.ActiveViewer;
globeCamera.OrientationMode =esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal;
IPointtarget = new PointClass();
target.PutCoords(0, 0);
target.Z =0;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.Target = target;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.ViewingDistance = 1.5;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.ViewFieldAngle = 8.5;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.RollAngle = 0.0;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.RecalcUp();
//定位
globeCamera.SetToZoomToExtents(envelope, this.axGlobe.Globe, sceneViewer);
//显示比例调整
double vfa =this.axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.ViewFieldAngle;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Camera.ViewFieldAngle = vfa * 6;
axGlobe.Globe.GlobeDisplay.ActiveViewer.Redraw(false);
}
相关文章推荐
- 在ArcGlobe三维环境中进行数据查询2(模型定位显示)
- 在ArcGlobe三维环境中进行数据查询(.net)
- 在ArcGlobe三维环境中进行数据查询(.net)
- SharePoint服务器端对象模型 之 使用CAML进行数据查询(Part 2)
- SharePoint服务器端对象模型 之 使用CAML进行数据查询
- Flex调用WebService进行数据查询和显示(调整)
- thinkphp的M方法可以直接使用模型类进行查询,而模型类名字要与数据表对应,模型类中字段不需要写
- SharePoint服务器端对象模型 之 使用CAML进行数据查询(Part 3)
- C#中对DataGridView列表中的数据进行查询并定位
- Qt环境下利用OpenGL显示三维模型
- 使用CHtml::encode直接使用模型的数据进行显示
- SharePoint服务器端对象模型 之 使用CAML进行数据查询(Part 4)
- 一起看代码来玩玩QT之18 database(five 用lineEidt 对database 进行高级别的查询,使QTableView显示所需的数据)
- 使用谷歌地球高程数据显示三维模型
- Swing编程中用于显示数据库查询结果的数据模型
- 使用数据挖掘模型进行查询
- EMAP开发时创建页面模型后,根据模型中查询动作生成页面模板,没有数据显示
- 分页(对查询出的数据进行分页显示)
- easyui-datagrid行编辑,后台以主表为基表关联从表进行查询数据后,在前台行编辑字段内容的显示