예제 #1
0
        public static void GetCurrentSurfaceMax(ILayer ilayer_0, out double double_0, out double double_1)
        {
            ISurface surfaceFromLayer = SurfaceInfo.GetSurfaceFromLayer(ilayer_0);

            if (surfaceFromLayer != null)
            {
                if (surfaceFromLayer is ITinAdvanced)
                {
                    ITinAdvanced tinAdvanced = surfaceFromLayer as ITinAdvanced;
                    IEnvelope    extent      = tinAdvanced.Extent;
                    double_0 = ((extent.Width > extent.Height) ? extent.Width : extent.Height);
                    double_1 = extent.ZMax;
                }
                else
                {
                    IRasterSurface rasterSurface = surfaceFromLayer as IRasterSurface;
                    IRasterProps   rasterProps   = rasterSurface.Raster as IRasterProps;
                    IEnvelope      extent        = rasterProps.Extent;
                    double_0 = ((extent.Width > extent.Height) ? extent.Width : extent.Height);
                    IRasterBandCollection rasterBandCollection = rasterProps as IRasterBandCollection;
                    IRasterBand           rasterBand           = rasterBandCollection.Item(0);
                    IRasterStatistics     statistics           = rasterBand.Statistics;
                    double_1 = statistics.Maximum;
                }
            }
            else
            {
                double_0 = 0.0;
                double_1 = 0.0;
            }
        }
예제 #2
0
 /// <summary>
 /// 获取分析图层及Surfer
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void comboBoxOpen_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxOpen.Items.Count > 0)
     {
         string LayerName = comboBoxOpen.SelectedItem.ToString();
         m_Layer = GetLayerByName(ref LayerName);
         if (m_Layer is IRasterLayer)//读取Raster数据的ISurface
         {
             IRasterLayer   pRasterLayer   = m_Layer as IRasterLayer;
             IRasterSurface pRasterSurface = new RasterSurfaceClass();
             pRasterSurface.PutRaster(pRasterLayer.Raster, 0);
             m_Surface = pRasterSurface as ISurface;
         }
         else if (m_Layer is ITinLayer)//读取TIN数据的ISurface
         {
             ITinLayer pTinLayer = m_Layer as ITinLayer;
             m_Surface = pTinLayer.Dataset as ISurface;
         }
         if (m_Surface == null)
         {
             MessageBox.Show("请选择需要进行分析的DEM数据", "提示!");
             return;
         }
         pTool3DLineOfSight.m_Layer   = m_Layer;   //将当前选中的图层传给通视分析工具
         pTool3DLineOfSight.m_SurFace = m_Surface; //将当前获取的Surface传给通视分析工具
         //下面是根据获取的Surface来自动判断是否应用曲率和折射校正
         bool bCurvEnabled;
         bCurvEnabled = false;
         ISurface    pSurface = m_Surface;
         IGeoDataset pGeoDataset;
         if (pSurface is ITin)
         {
             pGeoDataset = pSurface as IGeoDataset;
         }
         else
         {
             IRasterSurface pRasterSurf = pSurface as IRasterSurface;
             pGeoDataset = pRasterSurf.RasterBand.RasterDataset as IGeoDataset;
         }
         ISpatialReference pSpatialReference = pGeoDataset.SpatialReference;
         ILinearUnit       pLinearUnit       = pSpatialReference.ZCoordinateUnit;
         if (pLinearUnit != null)
         {
             if (pSpatialReference is IProjectedCoordinateSystem)//当投影ProjectedCoordinateSystem时使用应用曲率和折射校正
             {
                 bCurvEnabled = true;
             }
         }
         checkBoxCurv.Checked = bCurvEnabled;
     }
 }
예제 #3
0
        public IRasterSurface GetSurfFormLayer(IRasterLayer pRLayer)
        {
            I3DProperties p3DProp = Get3DPropsFromLayer((pRLayer));
            //获取图层的基准面
            IRasterSurface pRSurf = (IRasterSurface)p3DProp.BaseSurface;

            //如果空 则取栅格的第一个波段
            if (pRSurf == null)
            {
                //MessageBox.Show("null");
                pRSurf = new RasterSurfaceClass();
                IRasterBandCollection bands = (IRasterBandCollection)pRLayer.Raster;
                pRSurf.RasterBand = bands.Item(0);
            }
            return(pRSurf);
        }
예제 #4
0
        public void SetlayerSurface(IRasterLayer pRlayer, int ZFactor)
        {
            //获取3DProp
            I3DProperties p3DProp = Get3DPropsFromLayer((ILayer)pRlayer);

            p3DProp.BaseOption = esriBaseOption.esriBaseSurface;

            //设置基准高
            IRasterSurface pRSurf = GetSurfFormLayer(pRlayer);

            p3DProp.BaseSurface = (IFunctionalSurface)pRSurf;

            //设置Z因子
            p3DProp.ZFactor = ZFactor;

            //图层渲染优先级,越小优先级越大;
            p3DProp.DepthPriorityValue = 0;

            p3DProp.Apply3DProperties(pRlayer);//I3DProperties中唯一的一个方法,用来执行变更后的属性。
        }
예제 #5
0
 public override void OnClick()
 {
     _plugin.CurrentTool = this;
     if (this.isurface_0 != null)
     {
         IGeoDataset geoDataset;
         if (this.isurface_0 is ITin)
         {
             geoDataset = (this.isurface_0 as IGeoDataset);
         }
         else
         {
             IRasterSurface rasterSurface = this.isurface_0 as IRasterSurface;
             geoDataset = (rasterSurface.RasterBand.RasterDataset as IGeoDataset);
         }
         ISpatialReference spatialReference = geoDataset.SpatialReference;
         ILinearUnit       zCoordinateUnit  = spatialReference.ZCoordinateUnit;
         if (zCoordinateUnit != null && spatialReference is IProjectedCoordinateSystem)
         {
             ToolSceneLineOfSight.bCurvEnabled = true;
         }
     }
 }
예제 #6
0
        /// <summary>
        /// 获取分析图层及Surfer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboBoxOpen_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxOpen.Items.Count > 0)
                {
                    label.Text = "";
                    Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, sRefPlaneName);
                    Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, ContourName);
                    m_pCurrentSceneControl.SceneGraph.RefreshViewers();
                    m_ScenePoly         = null;
                    m_StaPolygon        = null;
                    m_SurFace           = null;
                    txtArea2DSel.Text   = "";
                    txtAreaAbove.Text   = "";
                    txtAreaBelow.Text   = "";
                    txtPara.Text        = "";
                    txtPlaneHeight.Text = "";
                    txtVolumeAbove.Text = "";
                    txtVolumeBelow.Text = "";

                    DrawGeo.Enabled        = false;
                    sldPlaneHeight.Enabled = false;
                    btncount.Enabled       = false;
                    string LayerName = comboBoxOpen.SelectedItem.ToString();
                    ILayer pLayer    = GetLayerByName(ref LayerName);

                    if (pLayer is IRasterLayer)//读取Raster数据的ISurface
                    {
                        IRasterLayer      pRasterLayer = pLayer as IRasterLayer;
                        IGeoDataset       pDataset     = pRasterLayer as IGeoDataset;
                        ISpatialReference psr          = pDataset.SpatialReference;

                        if (!(psr is IProjectedCoordinateSystem))
                        {
                            label.Text = "该数据为地理坐标,计算结果无效仅供参考!";
                        }

                        IRasterSurface pRasterSurface = new RasterSurfaceClass();
                        pRasterSurface.PutRaster(pRasterLayer.Raster, 0);
                        m_SurFace       = pRasterSurface as ISurface;
                        DrawGeo.Enabled = false;
                        m_IsTin         = false;
                    }
                    else if (pLayer is ITinLayer)//读取TIN数据的ISurface
                    {
                        ITinLayer         pTinLayer = pLayer as ITinLayer;
                        IGeoDataset       pDataset  = pTinLayer as IGeoDataset;
                        ISpatialReference psr       = pDataset.SpatialReference;

                        if (!(psr is IProjectedCoordinateSystem))
                        {
                            label.Text = "该数据为地理坐标,计算结果无效仅供参考!";
                        }

                        m_SurFace       = pTinLayer.Dataset as ISurface;
                        m_IsTin         = true;
                        DrawGeo.Enabled = true;
                    }
                    if (m_SurFace == null)
                    {
                        MessageBox.Show("请选择需要进行分析的DEM数据", "提示!");
                        return;
                    }
                    if (m_StaPolygon == null)
                    {
                        if (m_SurFace is ITin)
                        {
                            ITin pTin = m_SurFace as ITin;
                            sldPlaneHeight.Maximum = Convert.ToInt32(pTin.Extent.ZMax);
                            sldPlaneHeight.Minimum = Convert.ToInt32(pTin.Extent.ZMin);
                        }
                        else
                        {
                            IRasterSurface    pRasterSurface   = m_SurFace as IRasterSurface;
                            IRasterStatistics pRasterStatistic = pRasterSurface.RasterBand.Statistics;
                            sldPlaneHeight.Maximum = Convert.ToInt32(pRasterStatistic.Maximum);
                            sldPlaneHeight.Minimum = Convert.ToInt32(pRasterStatistic.Minimum);
                        }
                        double Vale = sldPlaneHeight.Maximum + sldPlaneHeight.Minimum;
                        Vale = Vale / 2;
                        txtPlaneHeight.Text = Vale.ToString();
                        Vale = Convert.ToDouble(txtPlaneHeight.Text);
                        sldPlaneHeight.Value = Convert.ToInt32(Vale);
                    }
                    else
                    {
                        double zrange;
                        zrange = m_StaPolygon.Envelope.ZMax - m_StaPolygon.Envelope.ZMin;
                        sldPlaneHeight.Maximum = Convert.ToInt32(m_StaPolygon.Envelope.ZMax + zrange);
                        sldPlaneHeight.Minimum = Convert.ToInt32(m_StaPolygon.Envelope.ZMin);
                        sldPlaneHeight.Value   = Convert.ToInt32(Math.Round(m_StaPolygon.Envelope.ZMin + (zrange * 0.5)));
                        txtPlaneHeight.Text    = sldPlaneHeight.Value.ToString();
                    }
                    sldPlaneHeight.Enabled = true;
                    btncount.Enabled       = true;
                }
            }
            catch
            {
                return;
            }
        }
        private ISurface GetSurfaceFromLayer(ILayer player)
        {
            try
            {
                IRasterLayer     pRLayer;
                I3DProperties    p3DProp = null;
                ILayerExtensions pLE;
                IRasterSurface   pSurface = null;;
                ITinLayer        pTLayer;



                if (player is IRasterLayer)
                {
                    pRLayer = player as IRasterLayer;
                    pLE     = player as ILayerExtensions;

                    for (int i = 0; i <= pLE.ExtensionCount - 1; i++)
                    {
                        if (pLE.get_Extension(i) is I3DProperties)
                        {
                            p3DProp = pLE.get_Extension(i) as I3DProperties;
                            break;
                        }
                    }



                    if (p3DProp == null)
                    {
                        IRasterBandCollection pBands;
                        if (pRLayer.Raster != null)
                        {
                            pSurface            = new RasterSurfaceClass();
                            pBands              = pRLayer.Raster as IRasterBandCollection;
                            pSurface.RasterBand = pBands.Item(0);
                        }
                        return(pSurface as ISurface);
                    }
                    else
                    {
                        pSurface = p3DProp.BaseSurface as IRasterSurface;
                    }
                    return(pSurface as ISurface);
                }

                else
                {
                    if (player is ITinLayer)
                    {
                        pTLayer = player as ITinLayer;
                        return(pTLayer.Dataset as ISurface);
                    }
                }
                return(null);
            }

            catch (Exception ex)
            {
                string g = ex.Message;
                return(null);
            }
        }