How to define an Output Feature when the data is double

12-06-2013 08:11 AM
Occasional Contributor
I had logic in place that returned a collection of PolyLines as the output feature. However the call we make is returning multiple polylines for a single set of points. I'm changing it now so that it sums the results and returns only a length of type double for each set of points. (which actually makes returning place holders for failed calls easier)

When I go to establish my output cursor I get a null object exception. So the way I defined it is wrong. Here is how I'm defining it:

        IArray parameters = new ArrayClass();

        IGPParameterEdit3 inputPoint =
          GPUtilities.CreatePointRecordsetParameterEdit("StationPoint", "Station Point", "Standard_Point",
          esriGPParameterType.esriGPParameterTypeRequired, new GPFeatureRecordSetLayerTypeClass(), true);
        IGPParameterEdit3 targetPoints =
        GPUtilities.CreatePointRecordsetParameterEdit("TargetList", "Target List", "Standard_Point",
          esriGPParameterType.esriGPParameterTypeRequired, new GPFeatureRecordSetLayerTypeClass(), true);
        //    The original output parameter setting code
        //IGPParameterEdit3 outputPoints =
        //    GPUtilities.CreatePolylineRecordsetParameterEdit("OutputList", "Output List", "Standard_Polyline",
        //        esriGPParameterDirection.esriGPParameterDirectionOutput,
        //        esriGPParameterType.esriGPParameterTypeDerived, new GPFeatureRecordSetLayerTypeClass(), true);
        IGPParameterEdit3 outputValues = new GPParameterClass();
        outputValues.DataType = new GPFeatureRecordSetLayerTypeClass();
        outputValues.Value = new DEFeatureClassClass();
        outputValues.Direction = esriGPParameterDirection.esriGPParameterDirectionOutput;
        outputValues.DisplayName = "Output Lengths";
        outputValues.Name = "OutputLengths";
        outputValues.ParameterType = esriGPParameterType.esriGPParameterTypeDerived;
        IGPFeatureSchema outputSchema = new GPFeatureSchemaClass();
        IGPSchema schema = (IGPSchema)outputSchema;
        schema.CloneDependency = true;
        outputValues.Schema = outputSchema as IGPSchema;
        return parameters;

I'm also not sure if I'm setting the buffer correctly either. Here is how I'm handling the accumulation and setting of the return values:

            double distanceCompute = 0;
            for (int subindex = 0; subindex < result.GeometryCount; subindex++)
                 Polyline data = (Polyline) result.Geometry[subindex];
                 IPolyline idata = (IPolyline) data;
                 distanceCompute += idata.Length;
            messages.AddMessage(String.Format("Saving distance of {0} as new feature for target {1}.", distanceCompute, index));
            IFeatureBuffer featureBuffer = outputClass.CreateFeatureBuffer();
            IFeatureCursor cursor = outputClass.Insert(true);
            featureBuffer.set_Value(0, distanceCompute);

The sooner I can get this fixed the better. 🙂

Thanks a ton everyone.
0 Kudos
0 Replies