zoukankan      html  css  js  c++  java
  • 线性参考

    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);
      }
    }
  • 相关阅读:
    已安装 SQL Server 2005 Express 工具。若要继续,请删除 SQL Server 2005 Express 工具
    超时时间已到。超时时间已到,但是尚未从池中获取连接。出现这种情况可能是因为所有池连接均在使用,并且达到了最大池大小。
    C#微信公众号开发 -- (七)自定义菜单事件之VIEW及网页(OAuth2.0)授权
    C#微信公众号开发 -- (六)自定义菜单事件之CLICK
    C#微信公众号开发 -- (五)自定义菜单创建
    C#微信公众号开发 -- (四)获取API调用所需的全局唯一票据access_token
    C#微信公众号开发 -- (三)用户关注之后自动回复
    C#微信公众号开发 -- (二)验证成为开发者
    linux下删除大量文件提示参数过长解决办法
    Linux 远程连接sftp与ftp
  • 原文地址:https://www.cnblogs.com/zuiyirenjian/p/1947078.html
Copyright © 2011-2022 走看看