• 线性参考


    public AddLineEvent
    {
      try
      {
        // Get the event table.  It is called 'pavement'.
        IMxDocument pMxDoc;
        ITableCollection pTblColl;
        ITable pEventTable = null;            
        IMap pMap;
        IDataset pDS;

        pMxDoc = (IMxDocument) m_app.Document;
        pMap = (IMap) pMxDoc.FocusMap;
        pTblColl = (ITableCollection) pMap;
        for (int i = 0; i < pTblColl.TableCount; i++)
        {
          pDS = (IDataset) pTblColl.get_Table(i);
          if (pDS.BrowseName.ToLower() == "pavement")
          {
            pEventTable = (ITable) pDS;
            break;
          }
        }
        if (pEventTable == null)
        {
          MessageBox.Show("Could not find the event table", "AddLineEventLayer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
          return;
        }

        // Get the route feature class.  It is called 'roads_route_hwy'
        ILayer pLayer;
        IFeatureLayer pFLayer;
        IFeatureClass pRouteFc = null;
        for (int i = 0; i < pMap.LayerCount; i++)
        {
          pLayer = pMap.get_Layer(i);
          if (pLayer.Name.ToLower() == "roads_route_hwy")
          {
            pFLayer = pLayer as IFeatureLayer;
            if (pFLayer != null)
            {
              pRouteFc = (IFeatureClass) pFLayer.FeatureClass;
            }
          }
        }
        if (pRouteFc == null)
        {
          MessageBox.Show("Could not find the route feature class", "AddLineEventLayer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
          return;
        }

        // Create the route event source...

        //The route locator
        IName pName;
        IRouteLocatorName pRMLName = new RouteMeasureLocatorNameClass();

        pDS = (IDataset) pRouteFc;
        pName = (IName) pDS.FullName;
        pRMLName.RouteFeatureClassName = pName;
        pRMLName.RouteIDFieldName = "rkey";
        pRMLName.RouteIDIsUnique = true;
        pRMLName.RouteMeasureUnit = 0;   // esriUnknownUnit type
        pRMLName.RouteWhereClause = "";

        // Create the route event properties
        //   We will be using IRouteEventProperties2 to take advantage of adding an error field
        IRouteEventProperties2 pRtProp = new RouteMeasureLinePropertiesClass();
        IRouteMeasureLineProperties pRMLnProp;

        pRtProp.EventMeasureUnit = 0;   // esriUnknownUnit type
        pRtProp.EventRouteIDFieldName = "rkey";
        pRtProp.LateralOffsetFieldName = "offset";
        pRtProp.AddErrorField = true;  // add field for locating errors
        pRtProp.ErrorFieldName = "LOC_ERRORS";   // specify name for the locating errors field

        pRMLnProp = (IRouteMeasureLineProperties) pRtProp;
        pRMLnProp.FromMeasureFieldName = "fmp";
        pRMLnProp.ToMeasureFieldName = "tmp";

        pDS = (IDataset) pEventTable;
        pName = (IName) pDS.FullName;

        IRouteEventSourceName pRESN = new RouteEventSourceNameClass();
        pRESN.EventTableName = pName;
        pRESN.EventProperties = (IRouteEventProperties) pRMLnProp;
        pRESN.RouteLocatorName = pRMLName;

        // By opening a route event source name object, you have a 'dynamic' feature class ...
        IFeatureClass pEventFC;
        pName = (IName) pRESN;
        pEventFC = (IFeatureClass) pName.Open();

        // Create the layer and add it to the current map
        IActiveView pActive;
        pFLayer = new FeatureLayerClass();
        pFLayer.FeatureClass = pEventFC;
        pFLayer.Name = pDS.BrowseName + "_Events";   // "Pavement_Events"

        pMap.AddLayer(pFLayer);

        pActive = (IActiveView) pMxDoc.ActiveView;
        pActive.Refresh();
      }
      catch (COMException COMEx)
      {
        MessageBox.Show(COMEx.Message,"COM Error: " + COMEx.ErrorCode.ToString(),MessageBoxButtons.OK,MessageBoxIcon.Warning);
      }
      catch (System.Exception SysEx)
      {
        MessageBox.Show(SysEx.Message,".NET Error: ",MessageBoxButtons.OK,MessageBoxIcon.Warning);
      }
    }
  • 相关阅读:
    奇葩的Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
    dubbo的本地存根
    已知w是一个大于10但不大于1000000的无符号整数,若w是n(n≥2)位的整数,则求出w的后n-1位的数。
    数字字符串转换成与其面值相同的长整形整数
    PHP实现MySQL的主键id自动重新自增排序
    四叶玫瑰数
    PHP动态实现从数据库中访问链接到标签a的herf中
    Proteus8.0的main.asm源代码使用
    Office 2010 安装和激活出错解决办法
    PHP实现文件读写中英文数据分割插入数组代码
  • 原文地址:https://www.cnblogs.com/zuiyirenjian/p/1947078.html
Copyright © 2020-2023  润新知