views:

493

answers:

1

Hi everyone,

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).

Thanks a lot !

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.

+1  A: 

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
James Schek
Very informative answer, thanks !
Decapsuleur