在 ArcGIS 中进行线性参考的编程方法

发布于 2024-08-01 17:49:29 字数 1972 浏览 5 评论 0原文

我正在开发一个自定义 ArcGIS Desktop 工具项目,我想在其中实现自动线性参考功能。 长话短说,我想显示路线上有问题的路段,并使用颜色代码(例如绿色、黄色、红色等)显示严重性。 我知道这是一个非常常见的场景,并且已经了解到完成此任务的“正确方法”是创建一个线性事件表,该表将允许我为某些路线段分配不同的代码。 我的一些同事知道如何手动执行此操作,但我似乎找不到任何方法以编程方式复制此操作。

当前的工具是用 C# 编写的,并且已经执行了所有需要的计算来确定有问题的区域。 问题主要是我不知道从哪里开始,因为我对ArcObjects了解不多。 欢迎任何代码示例或建议(C# 是首选,但 C++、VB 和其他语言肯定会对我有帮助)。

编辑:

我正在尝试使用 MakeRouteEventLayer 工具,但似乎无法满足不同的先决条件。 这些路由托管在 SDE 服务器上。 到目前为止,我正在以这种方式建立连接:

ESRI.ArcGIS.esriSystem.IPropertySet pConnectionProperties = new ESRI.ArcGIS.esriSystem.PropertySet();
ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pWorkspaceFactory;
ESRI.ArcGIS.Geodatabase.IWorkspace pWorkspace;
ESRI.ArcGIS.Location.ILocatorManager pLocatorManager;
ESRI.ArcGIS.Location.IDatabaseLocatorWorkspace pDatabaseLocatorWorkspace;

pConnectionProperties.SetProperty("server", "xxxx");
pConnectionProperties.SetProperty("instance", "yyyy");
pConnectionProperties.SetProperty("database", "zzzz");
pConnectionProperties.SetProperty("AUTHENTICATION_MODE", "OSA");
pConnectionProperties.SetProperty("version", "dbo.DEFAULT");

pWorkspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory();
pWorkspace = pWorkspaceFactory.Open(pConnectionProperties, 0);
pLocatorManager = new ESRI.ArcGIS.Location.LocatorManager();
pDatabaseLocatorWorkspace = (ESRI.ArcGIS.Location.IDatabaseLocatorWorkspace)pLocatorManager.GetLocatorWorkspace(pWorkspace);

现在我一直在尝试为 MakeRouteEventLayer 的 构造函数。 我似乎找不到如何让功能层作为输入路由功能传递。 另外,我不明白如何正确创建事件表。 除了 这个 我不明白,因为它没有记录/注释,并且没有提及数据类型。

I am working on a custom ArcGIS Desktop tool project and I would like to implement an automated linear referencing feature in it. To make a long story short, I would like to display problematic segments along a route and show the severity by using a color code (say green, yellow, red, etc.). I know this is a pretty common scenario and have come to understand that the "right way" of accomplishing this task is to create a linear event table which will allow me to assign different codes to certain route segments. Some of my colleagues know how to do it manually but I can't seem to find any way to replicate this programaticaly.

The current tool is written in C# and already performs all the needed calculations to determine the problematic areas. The problem mainly is that I don't know where to start since I don't know a lot about ArcObjects. Any code sample or suggestion is welcome (C# is preferred but C++, VB and others will surely help me anyway).

EDIT :

I'm trying to use the MakeRouteEventLayer tool but can't seem to get the different pre-conditions met. The routes are hosted on an SDE server. So far, I am establishing a connection this way :

ESRI.ArcGIS.esriSystem.IPropertySet pConnectionProperties = new ESRI.ArcGIS.esriSystem.PropertySet();
ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pWorkspaceFactory;
ESRI.ArcGIS.Geodatabase.IWorkspace pWorkspace;
ESRI.ArcGIS.Location.ILocatorManager pLocatorManager;
ESRI.ArcGIS.Location.IDatabaseLocatorWorkspace pDatabaseLocatorWorkspace;

pConnectionProperties.SetProperty("server", "xxxx");
pConnectionProperties.SetProperty("instance", "yyyy");
pConnectionProperties.SetProperty("database", "zzzz");
pConnectionProperties.SetProperty("AUTHENTICATION_MODE", "OSA");
pConnectionProperties.SetProperty("version", "dbo.DEFAULT");

pWorkspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory();
pWorkspace = pWorkspaceFactory.Open(pConnectionProperties, 0);
pLocatorManager = new ESRI.ArcGIS.Location.LocatorManager();
pDatabaseLocatorWorkspace = (ESRI.ArcGIS.Location.IDatabaseLocatorWorkspace)pLocatorManager.GetLocatorWorkspace(pWorkspace);

Now I am stuck trying to prepare everything for MakeRouteEventLayer's constructor. I can't seem to find how i'm supposed to get the Feature Layer to pass as the Input Route Features. Also, I don't understand how to create an event table properly. I can't seem to find any exemple relating to what I am trying to accomplish aside from this one which I don't understand since it isn't documented/commented and the datatypes are not mentionned.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百合的盛世恋 2024-08-08 17:49:29

我不完全确定你想做什么。 如果您想要获取线性参考值或直接在已定义线性参考的要素类中操作它们,这非常简单。

IFeatureClass fc = ....;
IFeature 特征 = fc.GetFeature(...);
IMSegmentation3 seg = (IMSegmentation3)feature;
...等等...

如果您需要创建具有线性参考的要素类,您应该从ArcToolbox 中的“地理处理”工具开始。 如果开箱即用的工具可以完成您需要的大部分工作,这将最大限度地减少您的编码。

强烈建议尽可能弄清楚您需要使用 ArcMap 做什么...然后退出 ArcObjects。

  1. 线性参考 API
  2. 线性参考工具箱
  3. 了解线性参考

I'm not entirely certain what it is you want to do. If you want to get Linear Referencing values or manipulate them directly in a feature class that already has linear referencing defined, that's pretty straight forward.

IFeatureClass fc = ....;
IFeature feature = fc.GetFeature(...);
IMSegmentation3 seg = (IMSegmentation3)feature;
... blah ...

If you need to create a Feature class with linear referencing, you should start witht he "Geoprocessing" tools in the ArcToolbox. If the out-of-the-box tools can do most of what you need, this will minimize your coding.

I would strongly recommend trying to figure what you need to do with ArcMap if at all possible... then backing out the ArcObjects.

  1. Linear Referencing API
  2. Linear Referencing Toolbox
  3. Understanding Linear Referencing
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文