Sample - Convert Trace to KML

Version 2

    Versions: 9.3.1 - current

    Product Availability: ArcFM Server

     

    This developer sample converts an IMMEidSearchResults object into a KML format which may be viewed using Google Earth. To implement this sample, you will need to perform an operation that returns an IMMEidSearchResults object. This operation may call the TraceResultsToKML class in the developer sample (Miner.ConvertTraceToKML.ConvertTraceResultsToKML.TraceResultsToKML) in order to export results to KML and display them in Google Earth.

     

    The TraceResultsToKML class has four input parameters:

    • traceResults: This is the IMMEidSearchResults object that contains the search results.
    • pointFeatureClassesToInclude: This is a hashtable that includes the point feature classes you wish to convert to KML.
    • lineFeatureClassesToInclude: This is a hashtable that includes the linear feature classes you wish to convert to KML.
    • showGoogleEarth: This is a boolean value that determines whether Google Earth is opened automatically.


    How to Implement:

    1. Open ConvertTraceToKML.csproj and connect any broken references.
    2. Open SampleTraceConsole.csproj and connect any broken references.
    3. In ConvertTraceResultsToKML.cs, locate the following: C:\Program Files (x86)\Google\Google Earth\client\googleearth.exe
    4. Change this location path to match the location of your stored GoogleEarth.exe.
    5. In Program.cs, locate the following:

    // location and name of file geodatabase
    IWorkspace wksp = FileGDBWorkspace(@"D:\Program Files (x86)\Telvent\", @"MINERVILLE.gdb");

    // location and name of electric network
    IGeometricNetwork geometricNetwork = Network(wksp, @"ElectricDataset", @"ElecGeomNetwork");

    1. Change the FileGDBWorkspace location to point to your geodatabase.
      Note: If you are pointing to a geodatabase other than MINERVILLE, ensure your dataset, network, and feature classes are appropriate for your geodatabase.
    2. Build the solution.
    3. When the conversion is complete, the KML files are saved to the system temp directory or build location (e.g., C:\Documents and Settings\[current user]\Local Settings\Temp). This path may be modified in the developer sample. The files saved are named: junctions.kml and edges.kml.
    4. In the Bin\Debug folder, run the SampleTraceConsole.exe to do the trace, perform the conversion and open those results in Google Earth.


    Requires:

    All of the files shown below are required for the project to compile successfully.

     

    FileDescription
    ConvertTraceToKML.csprojC# project containing the code to convert trace results to KML
    SampleTraceConsole.csprojC# project containing the sample trace results to convert
    ConvertTraceResultsToKML.csThe class module to convert trace results to KML.
    Program.csThe sample console window class module to create trace results. Program.cs could be used to create a command line program to perform different kinds of operations and send them to Google Earth.
    AssemblyInfo.csAssembly metadata
    CheckOutLicenses.csSample code for license checkout in standalone environments
    LicenseInitializer.csSample code for license checkout in standalong environments