|
POST
|
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 more
09-06-2012
10:18 AM
|
0
|
0
|
993
|
|
POST
|
This works fine if I define param1 as "Feature Class":
def execute(self, parameters, messages):
try:
arcpy.env.workspace = "in_memory"
# Get parameters
Input_Features = parameters[0].valueAsText
Buffers = arcpy.CreateUniqueName("Buffer")
# Perform buffer
arcpy.Buffer_analysis(Input_Features, Buffers,
"100 Feet", "FULL", "ROUND", "NONE", "")
# OutFeatureSet = arcpy.FeatureSet()
# OutFeatureSet.load(Buffers)
parameters[1].value = Buffers
except Exception, ErrorDesc:
sErr = "ERROR:\n" + str(ErrorDesc)
messages.addErrorMessage(sErr)
return
Perhaps, unlike a regular toolbox, a Python toolbox cannot understand "Feature Set" as an output type.
... View more
08-22-2012
02:41 PM
|
0
|
0
|
6264
|
|
POST
|
How do you set an output parameter (e.g. a feature set) in the execute method of a tool in a Python toolbox? I've tried setting parameters = output and arcpy.SetParameter(n, output) and neither work. For example, the following script works fine in a regular toolbox:
import arcpy
try:
arcpy.env.workspace = "in_memory"
# Get parameters
Input_Features = arcpy.GetParameterAsText(0)
Buffers = arcpy.CreateUniqueName("Buffer")
# Perform buffer
arcpy.Buffer_analysis(Input_Features, Buffers,
"100 Feet", "FULL", "ROUND", "NONE", "")
OutFeatureSet = arcpy.FeatureSet()
OutFeatureSet.load(Buffers)
arcpy.SetParameter(1, OutFeatureSet)
except Exception, ErrorDesc:
sErr = "ERROR:\n" + str(ErrorDesc)
arcpy.AddError(sErr)
But I can't get the output to work in a Python toolbox:
import arcpy
import os
class Toolbox(object):
def __init__(self):
self.label = "Runtime Tools"
self.alias = ""
# List of tool classes associated with this toolbox
self.tools = [BufferTest]
class BufferTest(object):
def __init__(self):
self.label = "Buffer Test"
self.description = "Create buffers"
self.canRunInBackground = False
def getParameterInfo(self):
params = []
param0 = arcpy.Parameter(
displayName = "Input Features",
name = "inputFeatures",
datatype = "Feature Set",
parameterType = "Required",
direction = "Input")
param0.value = os.path.join(os.path.dirname(__file__),
"FC_Templates.gdb\PointTemplate")
params.append(param0)
param1 = arcpy.Parameter(
displayName = "Buffers",
name = "buffers",
datatype = "Feature Set",
parameterType = "Derived",
direction = "Output")
params.append(param1)
return params
def execute(self, parameters, messages):
try:
arcpy.env.workspace = "in_memory"
# Get parameters
Input_Features = parameters[0].valueAsText
Buffers = arcpy.CreateUniqueName("Buffer")
# Perform buffer
arcpy.Buffer_analysis(Input_Features, Buffers,
"100 Feet", "FULL", "ROUND", "NONE", "")
OutFeatureSet = arcpy.FeatureSet()
OutFeatureSet.load(Buffers)
# parameters[1] = OutFeatureSet
arcpy.SetParameter(1, OutFeatureSet)
except Exception, ErrorDesc:
sErr = "ERROR:\n" + str(ErrorDesc)
messages.addErrorMessage(sErr)
return
What am I doing wrong? Thanks!
... View more
08-21-2012
09:03 AM
|
1
|
7
|
18137
|
|
POST
|
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)
... View more
08-17-2012
02:40 PM
|
0
|
0
|
993
|
|
POST
|
It turns out the service works. I just can't view the REST endpoint the way the documentation describes. Weird. :confused:
... View more
08-13-2012
12:27 PM
|
0
|
0
|
993
|
|
POST
|
I created a simple Buffer GPK and see the same issue. So it may not be related to the tracing model.
... View more
08-10-2012
12:45 PM
|
0
|
0
|
993
|
|
POST
|
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?
... View more
08-10-2012
10:39 AM
|
0
|
4
|
3095
|
|
POST
|
Yeah, I guess I've gotten too used to working with COM objects, which have a life of their own.
... View more
05-02-2012
06:17 AM
|
0
|
0
|
693
|
|
POST
|
I've noticed that row objects tend not to like to travel outside the scope of a search loop, even if the unique option is set. For example, this code works OK: foreach (Row r in tab.Search("*", "", RowInstance.Unique))
{
this.Manipulate(r);
tab.Update(r);
break;
} Whereas this can crash with a protected memory violation: Row row = null;
foreach (Row r in tab.Search("*", "", RowInstance.Unique))
{
row = r;
break;
}
if (row != null)
{
this.Manipulate(row);
tab.Update(row);
} This seems to go against common programming sense, but obviously code design can accommodate this.
... View more
05-01-2012
12:23 PM
|
0
|
3
|
2108
|
|
POST
|
I figured out what was going on. The file geodatabase in question was upgraded from v9. I copied the schema into a feshly created one and the problem went away. Yet more proof that the geodatabase upgrade tool is messed up.
... View more
04-30-2012
06:26 AM
|
0
|
0
|
604
|
|
POST
|
I have an empty point feature class and I add a feature using the following code: tab = gdb.OpenTable("\\" + sClassName);
row = tab.CreateRowObject();
row.SetString("TITLE", "Hwy 69/access road");
row.SetString("DETAIL", "there is no valve here");
pt = new Point(1239977, 12558523);
pb = new PointShapeBuffer();
pb.Setup(ShapeType.Point);
pb.point = pt;
row.SetGeometry(pb);
tab.Insert(row);
tab.Close(); I can read the feature just fine using the following code: tab = gdb.OpenTable("\\" + sClassName);
foreach (Row r in tab.Search("*", "1 = 1", RowInstance.Recycle))
{
pb = r.GetGeometry();
pt = pb.point;
Console.WriteLine("x=" + pt.x.ToString() + ",y=" + pt.y.ToString());
string s = r.GetString("TITLE");
Console.WriteLine("TITLE=" + s);
s = r.GetString("DETAIL");
Console.WriteLine("DETAIL=" + s);
}
tab.Close(); But when I try to preview the feature class in ArcCatalog or open it in ArcMap (10.0SP4), I get "Error opening feature class, General function failure". Any idea what I might be doing wrong? (I'm using API 1.2)
... View more
04-26-2012
10:53 AM
|
0
|
1
|
3036
|
|
POST
|
Trying to set MinimumResolution in Map.xml explicity doesn't work - I think the baselayer overrides it. Setting it from an add-in works.
... View more
02-14-2012
06:35 AM
|
0
|
0
|
451
|
|
POST
|
Is there a way to change the maximum map scale so that you can zoom in closer?
... View more
02-10-2012
10:53 AM
|
0
|
1
|
2270
|
|
POST
|
I saw the problem with custom code. I'm not aware of any out-of-the-box tool in ArcMap that goes through the exact motions necessary to cause the problem: a spatial query must be made against a feature class, and for every feature returned, its shape is used to spatially query another feature class. If both feature classes use ST_GEOMETRY storage, the error occurs; if both use SDELOB, it does not. I have not tried a mixed case.
... View more
01-04-2012
10:29 AM
|
0
|
0
|
736
|
|
POST
|
I'd like to see da support spatial queries (i.e. using a geometry class, since not all geodatabases support spatial SQL).
... View more
01-04-2012
06:42 AM
|
1
|
6
|
7156
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-04-2012 06:42 AM | |
| 1 | 09-23-2021 10:42 AM | |
| 2 | 09-28-2021 07:07 AM | |
| 1 | 04-07-2021 10:31 PM | |
| 3 | 03-21-2021 01:14 PM |
| Online Status |
Offline
|
| Date Last Visited |
01-07-2022
08:31 AM
|