zoukankan      html  css  js  c++  java
  • 利用IFeatureIndex2 和 IIndexQuery2提高空间查询效率

                StringBuilder tSB = new StringBuilder();

                IFeatureClass tFeatureClass = (IFeatureClass)this._InDataset;

               

                IGeoDataset tGeodataset=(IGeoDataset)this._InDataset;

     

                IFeatureIndex2 tFeatureIndex = new FeatureIndexClass();

                ESRI.ArcGIS.esriSystem.ITrackCancel tTrackCancel=new CancelTracker();

                IIndexQuery tIndexQuery = tFeatureIndex as IIndexQuery;

                IIndexQuery2 tIndexQuery2 = (IIndexQuery2)tIndexQuery;

                tFeatureIndex.FeatureClass = tFeatureClass;

                tFeatureIndex.set_OutputSpatialReference(tFeatureClass.OIDFieldName, tGeodataset.SpatialReference);

                tFeatureIndex.Index(tTrackCancel, tGeodataset.Extent);//tGeodataset.Extent

     

                int iDex = tFeatureClass.FindField(this._FieldName);

                for (int i = 0; i < _Rows; i++)

                {

                    for (int j = 0; j < _Cols; j++)

                    {

                        double[] pX = null;

                        double[] pY = null;

                        getPolygon(i, j, ref pX, ref pY);

                        IPoint tPoint = new PointClass();

                        tPoint.X = pX[0] + (pX[3] - pX[0]) / 2;

                        tPoint.Y = pY[0] + (pY[0] - pY[3]) / 2;

                        

                        int oid= tIndexQuery2.WithinFeature(tPoint);

                        if (oid>-1)

                        {

                            IFeature tFeature = tFeatureClass.GetFeature(oid);

                            object o = tFeature.get_Value(iDex);

                            if (o != null && o.ToString().Trim() != "")

                            {

                                tSB.Append(o.ToString() + "  ");

                            }

                            else

                            {

                                tSB.Append("-9999" + "  ");

                            }

                        }

                        else

                        {

                            tSB.Append("-9999" + "  ");

                        }

                       

                    }

                }

             

                return tSB;

            }

     

     

    利用IFeatureIndex2 和 IIndexQuery2来作空间检索,比用IFeatureCursor tFeatureCursor= tFeatureClass.Search(null, true);然后遍历IFeature快一些。

  • 相关阅读:
    [AGC001F] Wide Swap
    [SCOI2016]幸运数字
    [POI2014]HOTHotels 加强版
    [JSOI2008]球形空间产生器
    JZOJ 3167.查税
    0linux简介
    vmware15pro安装ubuntu18.10时出现显示不全问题
    02目录
    linux系统的基础优化
    1安装操作系统
  • 原文地址:https://www.cnblogs.com/cglNet/p/2391645.html
Copyright © 2011-2022 走看看