Tuesday, 21 July 2015

arcgis 10.0 - How to return shapes from geo service?


I have a geo service that seems to finally be working. I have the service setup with a list of Polylines as the returned object. This is what I'm trying to implement but it doesn't work:


 IPointCollection points = new MultipointClass();
points.AddPoint(station);
points.AddPoint(targets[index]);
messages.AddMessage(string.Format("Computing distance from origin to target {0}", index));
Polyline result = distanceComputer.CostPathAsPolyline(points,

hydrographyRasterDataset,
hydrographyRasterDataset) as Polyline;
IGeometry feature = result as IGeometry;
messages.AddMessage("Getting new row for output.");
IFeatureBuffer buffer = outputClass.CreateFeatureBuffer();
IFeature polyline = (IFeature) buffer;
messages.AddMessage("adding shape");
polyline.Shape = feature;
messages.AddMessage("adding object");
polyline.set_Value(polyline.Fields.FindField("SHAPE"), result);

messages.AddMessage("adding length");
polyline.set_Value(polyline.Fields.FindField("SHAPE_Length"), ((IPolyline)result).Length);
messages.AddMessage("Commiting to output");
outputCursor.InsertFeature(buffer);

When I try setting the value for "SHAPE" I get an exception and the message is:


This spatial reference object cannot be defined from the available information

So how exactly to I set the polyline in the return object (basically adding rows of Polylines to the OutputFeatureSet) so that it does not blow up?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...