Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So it appears that creating a parameter requires that a Schema be defined in the database. I have Simple_Point and Simple_Polyline defined there already. My parameters are as follows:

   Parameter A   Direction=Input  Data = Esri.ArcGISExplorer.Geometry.Point
   Parameter B   Direction=Input  Data = Array of Esri.ArcGISExplorer.Geometry.Point
   Parameter C   Direction=Output Data = Array of Esri.ArcGISExplorer.Geometry.Polyline

I have googled until my eyes are watering and cannot find examples of passing an array of points. If I find something, the documentation is old and the objects mentioned do not exist in the 10.1 namespace.

I hope someone here knows how to do this! Thanks in advance.


With existing code, we create parameters by calling GPUtilities.CreatePointRecordsetParameterEdit("name", "description", "schema", direction, parameterType (input, output, derived), new GPFeatureRecordSetLayer());

That method then creates the IGPParameterEdit3 parameter like so:

        IFeatureWorkspace pFeatWksp = GPDatabase.GetRMWWorkspace();
        IFeatureClass pFC = pFeatWksp.OpenFeatureClass(schemaName);

        IRecordSetInit recordset = new RecordSetClass();
        recordset.SetSourceTable((ITable)pFC, null);
        IGPRecordSet gpRS = new GPRecordSetClass();
        gpRS.RecordSet = (IRecordSet)recordset;
        IGPRecordSet gpR = new GPFeatureRecordSetLayerClass();
        gpR.RecordSet = (IRecordSet)recordset;
        IGPFeatureRecordSetLayer gpFRSL = (IGPFeatureRecordSetLayer)gpR;

        IGPFeatureSchema fgs = new GPFeatureSchemaClass();
        fgs.GeometryType = esriGeometryType.esriGeometryPoint;
        IGPSchema gpSchema = (IGPSchema)fgs;

        IGPFeatureClassDomain geomTypeDomain = new GPFeatureClassDomainClass();

        IGPParameterEdit3 parameterEdit = new GPParameterClass
            IGPParameterEdit_Name = name,
            IGPParameterEdit_DisplayName = displayName,
            IGPParameterEdit_DataType = gpDataType,
            IGPParameterEdit_Value = (IGPValue)gpFRSL,
            IGPParameterEdit3_Schema = gpSchema,
            IGPParameterEdit3_Domain = (IGPDomain)geomTypeDomain,
            IGPParameterEdit_ParameterType = paramType,
            IGPParameterEdit_Direction = paramDirection,
            IGPParameterEdit_Enabled = true

        return parameterEdit;

Now I have a schema defined for a simple Point and a simple Polyline. If I want to do a PointArray as the second parameter do I need a different schema? Or is does ESRI just use the base object type of a collection as the schema?

Likewise for the return object. That would be a PolylineCollection which again either is fine because the schema for Simple_Polyline already exists in the database or I need a schema for the PolylineCollection. The resulting definition of my service call ParameterInfo is defined as this:

        public IArray ParameterInfo
            IArray parameters = new ArrayClass();

            IGPParameterEdit3 inputPoint = 
                GPUtilities.CreatePointRecordsetParameterEdit("StationPoint", "Station Point", "Simple_Point", 
                    esriGPParameterType.esriGPParameterTypeRequired, new GPFeatureRecordSetLayerTypeClass(), true);
            IGPParameterEdit3 targetPoints = 
                GPUtilities.CreatePointRecordsetParameterEdit("TargetPoints", "Target Points", "Simple_Point", 
                    esriGPParameterType.esriGPParameterTypeRequired, new GPFeatureRecordSetLayerTypeClass(), true);
            IGPParameterEdit3 outputPoints =
                GPUtilities.CreatePolylineRecordsetParameterEdit("OutputLine", "Output Line", "Simple_Polyline",
                    esriGPParameterType.esriGPParameterTypeDerived, new GPFeatureRecordSetLayerTypeClass(), true);

            return parameters;

Does this help refine what I'm asking at all?

share|improve this question
up vote 1 down vote accepted

So what I found was that I set the schema for the Standard_Point. And I can add multiple points with that schema to the input parameter.

Likewise it is a matter of having the output parameter defined with the schema of Standard_Polyline and add multiple Polyline objects to the returned parameter.

I will edit this with the code once I have that figured out!

So here is the code that handles the array of standard points:

            IFeatureClass stationClass;
        IQueryFilter filter;
        _gputilities.DecodeFeatureLayer(GPUtilities.GetParameterValueByName(parameterValues, "StationPoint"),
            out stationClass, out filter);
        if (stationClass == null)
            message.AddError(2, "Could not open Station input dataset.");

        IFeatureClass targetClass;
        _gputilities.DecodeFeatureLayer(GPUtilities.GetParameterValueByName(parameterValues, "TargetPoint"),
            out targetClass, out filter);
        if (targetClass == null)
            message.AddError(2, "Could not open Target input dataset.");

        IFeatureClass outputFeatureClass;
        _gputilities.DecodeFeatureLayer(GPUtilities.GetParameterValueByName(parameterValues, "OutputLine"),
            out outputFeatureClass, out filter);
        if (outputFeatureClass == null)
            message.AddError(2, "Could not open output dataset.");

        // First get the origin point for computing distances
        Point origin = (stationClass.Search(null, false)).NextFeature().Shape as Point;

        // Then get the list of all targets
        List<Point> targets = new List<Point>();
        IFeatureCursor cursor = targetClass.Search(null, false);
        IFeature nextTarget = cursor.NextFeature();
        while (nextTarget != null)
            Point targetObject = nextTarget.Shape as Point;
            if (targetObject != null)
            nextTarget = cursor.NextFeature();

        // finally fix the 10.1 bug leaving behind last computation
        cursor = outputFeatureClass.Search(null, false);
        nextTarget = cursor.NextFeature();
        while (nextTarget != null)
            nextTarget = cursor.NextFeature();
        message.AddMessage(string.Format("There are a total of {0} targets passed for computation", targets.Count));
share|improve this answer

I assume that you are attempting to pass an array of points to create a polyline. According to this documentation, it seems you can pass points individually through polyline.AddPoint(). The documentation also notes that you can get an IEnumerable from a group of points and pass that instead. Since Array implements IEnumerable, perhaps you will be able to get to and pass your array in this fashion.

share|improve this answer
I am passing the origin point, and the array of points, to compute the distance between the origin and each individual point by computing the Polyline between the two points using Cost Distance. – SASS_Shooter Oct 15 '13 at 15:36
I am also looking for coding examples with hopefully some explanation of why things are done so I can better understand this stuff. I also am looking for the answer to passing back an array of PolyLines. – SASS_Shooter Oct 15 '13 at 15:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.