In a project, I created a polyline through a collection of points. The related code is below: // Create and add segments ISegmentCollection path = new ESRI.ArcGIS.Geometry.PathClass(); object obj = Type.Missing; for (int i = 1; i < pointsCollection.Count; i++) { ILine pLine = CreateLine(pointsCollection[i - 1], pointsCollection); path.AddSegment((ISegment)pLine, ref obj, ref obj); }
// Get the Polyline ESRI.ArcGIS.Geometry.IPolyline pSegPoly = new ESRI.ArcGIS.Geometry.PolylineClass(); ESRI.ArcGIS.Geometry.IGeometryCollection pGeoColl = pSegPoly as IGeometryCollection; pGeoColl.AddGeometry((IGeometry)path, ref obj, ref obj); pGeoColl.GeometriesChanged();
// Get json results JsonObject onSegment = Conversion.ToJsonObject((IPolyline)pGeoColl); List<JsonObject> jsonGeometry = new List<JsonObject>(); jsonGeometry.Add(onSegment); JsonObject resultJsonObject = new JsonObject(); resultJsonObject.AddArray("Geometry", jsonGeometry.ToArray());
// Get byte array of json and return results, which will be the output of ArcGIS Server SOE service byte[] result = Encoding.UTF8.GetBytes(resultJsonObject.ToJson()); return result;
The data from my ArcGIS Server's service call looks like: { "Geometry": [ { "paths": [ [ [-8575118.2321458999,4707114.1745275566], ... [-8575820.374931246,4707389.1788524361] ] ] } ] } Ideally, after the { } block, there should be "spatialReference":{"wkid":102100}}, which is the same as that of the points in the point collection.
How can the SR information be added to the polyline?
Found to be very simple, just add pSegPoly.SpatialReference = point.SpatialReference; Then, the result from ArcGIS Server's SOE service contains the SR as needed. Thread is to be closed.
Found to be very simple, just add pSegPoly.SpatialReference = point.SpatialReference; Then, the result from ArcGIS Server's SOE service contains the SR as needed. Thread is to be closed.