Select to view content in your preferred language

Runtime geoprocessing troubles (geometric network tracing)

2693
4
Jump to solution
08-10-2012 10:39 AM
Labels (1)
MarkCederholm
Frequent Contributor
My goal is to create a Runtime app that works with a file geodatabase on disk outside of a GPK or MPK.  I can create and use the referenced MPK just fine, but I'm having problems with the GPK.

The GPK is supposed to perform tracing on a geometric network.  Following the Network Analyst example, I created a model with flags and barriers set up as feature set model parameters, and set the geometric network as a model parameter.  When I run the model in ArcMap, it works fine.

From there, I created a GPK using the "Package schema only" and "Support ArcGIS Runtime" options.  But when I create a LocalGeoprocessingService with the GPK, the REST services URL comes up blank in the browser while the app is running.

What am I doing wrong?
0 Kudos
1 Solution

Accepted Solutions
MarkCederholm
Frequent Contributor
Here's why I couldn't see the REST service pages:  the corporate standard browser at work is IE7, which doesn't support the JSON.stringify function that ArcGIS Runtime uses.  I installed IE8 on my test box and the problem went away.  Apparently that's not an issue with ArcGIS Server 10.1 because I can see it just fine with IE7. 😛

View solution in original post

0 Kudos
4 Replies
MarkCederholm
Frequent Contributor
I created a simple Buffer GPK and see the same issue.  So it may not be related to the tracing model.
0 Kudos
MarkCederholm
Frequent Contributor
It turns out the service works.  I just can't view the REST endpoint the way the documentation describes.  Weird.  :confused:
0 Kudos
MarkCederholm
Frequent Contributor
I never figured out why the REST services page refuses to appear, but at least I finally figured out how to get the geometric network trace service working.

It turned out that creating a model was NOT the way to go, because the service would not expose the network parameter, and would try to use the exported schema as the geometric network.  Instead, I created a script tool with the network path as a string parameter.

I ran into another problem in that the edge features contain curves, which will cause the service to bomb.  Because Densify_edit is not supported in Runtime (BOO! :mad:), I had to work around it by exporting results to a temporary shapefile.

import arcpy
import os
# Script arguments and variables
sNetwork = arcpy.GetParameterAsText(0)
Flags = arcpy.GetParameterAsText(1)
Barriers = arcpy.GetParameterAsText(2)
Trace_Results = Flags
LayerList = ["gas_main", "service_line", "service_point"]
EdgeList = [True, True, False]
iOutParameter = 3
try:
    arcpy.env.workspace = "in_memory"
    sScratchWS = arcpy.env.scratchFolder
    # Perform trace
    arcpy.AddMessage("Tracing...")
    arcpy.TraceGeometricNetwork_management(
        sNetwork, Trace_Results, Flags, "FIND_CONNECTED", Barriers)
    # Extract feature sets from group layer
    for i in range(len(LayerList)):
        sLayer = LayerList
        bEdge = EdgeList
        arcpy.AddMessage("Processing results (" + sLayer + ")...")
        SelectResults = arcpy.SelectData_management(Trace_Results, sLayer)
        SelectLayer = SelectResults.getOutput(0)
        TempName = arcpy.CreateUniqueName(sLayer)
        if bEdge:
            # Densify_edit (to remove curves) is not supported in Runtime
            # Workaround: export features to shapefile
            TempShpName = arcpy.CreateUniqueName(sLayer + ".shp", sScratchWS)
            arcpy.AddMessage("TempShpName = " + TempShpName)
            arcpy.CopyFeatures_management(SelectLayer, TempShpName)
            arcpy.CopyFeatures_management(TempShpName, TempName)
            arcpy.Delete_management(TempShpName)
        else:            
            arcpy.Select_analysis(SelectLayer, TempName, None)
        OutFeatureSet = arcpy.FeatureSet()
        OutFeatureSet.load(TempName)
        arcpy.SetParameter(iOutParameter, OutFeatureSet)
        iOutParameter += 1
except Exception, ErrorDesc:
    sErr = "ERROR:\n" + str(ErrorDesc)
    arcpy.AddError(sErr)
0 Kudos
MarkCederholm
Frequent Contributor
Here's why I couldn't see the REST service pages:  the corporate standard browser at work is IE7, which doesn't support the JSON.stringify function that ArcGIS Runtime uses.  I installed IE8 on my test box and the problem went away.  Apparently that's not an issue with ArcGIS Server 10.1 because I can see it just fine with IE7. 😛
0 Kudos