<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Points to Polyline - How to the spatial reference? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/points-to-polyline-how-to-the-spatial-reference/m-p/623904#M16784</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In a project, I created a polyline through a collection of points. The related code is below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; // Create and add segments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ISegmentCollection path = new ESRI.ArcGIS.Geometry.PathClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; object obj = Type.Missing;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; for (int i = 1; i &amp;lt; pointsCollection.Count; i++) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ILine pLine = CreateLine(pointsCollection[i - 1], pointsCollection&lt;I&gt;);&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; path.AddSegment((ISegment)pLine, ref obj, ref obj);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; // Get the Polyline&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ESRI.ArcGIS.Geometry.IPolyline pSegPoly = new ESRI.ArcGIS.Geometry.PolylineClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ESRI.ArcGIS.Geometry.IGeometryCollection pGeoColl = pSegPoly as IGeometryCollection;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pGeoColl.AddGeometry((IGeometry)path, ref obj, ref obj);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pGeoColl.GeometriesChanged();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; // Get json results&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; JsonObject onSegment = Conversion.ToJsonObject((IPolyline)pGeoColl);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; List&amp;lt;JsonObject&amp;gt; jsonGeometry = new List&amp;lt;JsonObject&amp;gt;();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; jsonGeometry.Add(onSegment);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; JsonObject resultJsonObject = new JsonObject();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; resultJsonObject.AddArray("Geometry", jsonGeometry.ToArray());&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; // Get byte array of json and return results, which will be the output of ArcGIS Server SOE service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; byte[] result = Encoding.UTF8.GetBytes(resultJsonObject.ToJson());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return result;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The data from my ArcGIS Server's service call looks like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{ "Geometry": [ {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; "paths": [ [ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [-8575118.2321458999,4707114.1745275566], ... [-8575820.374931246,4707389.1788524361] ] ]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; } ] }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideally, after the { } block, there should be &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"spatialReference":{"wkid":102100}}, which is the same as that of the points in the point collection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can the SR information be added to the polyline?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jan 2014 16:10:59 GMT</pubDate>
    <dc:creator>ShaningYu</dc:creator>
    <dc:date>2014-01-16T16:10:59Z</dc:date>
    <item>
      <title>Points to Polyline - How to the spatial reference?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/points-to-polyline-how-to-the-spatial-reference/m-p/623904#M16784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In a project, I created a polyline through a collection of points. The related code is below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; // Create and add segments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ISegmentCollection path = new ESRI.ArcGIS.Geometry.PathClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; object obj = Type.Missing;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; for (int i = 1; i &amp;lt; pointsCollection.Count; i++) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ILine pLine = CreateLine(pointsCollection[i - 1], pointsCollection&lt;I&gt;);&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; path.AddSegment((ISegment)pLine, ref obj, ref obj);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; // Get the Polyline&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ESRI.ArcGIS.Geometry.IPolyline pSegPoly = new ESRI.ArcGIS.Geometry.PolylineClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ESRI.ArcGIS.Geometry.IGeometryCollection pGeoColl = pSegPoly as IGeometryCollection;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pGeoColl.AddGeometry((IGeometry)path, ref obj, ref obj);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pGeoColl.GeometriesChanged();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; // Get json results&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; JsonObject onSegment = Conversion.ToJsonObject((IPolyline)pGeoColl);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; List&amp;lt;JsonObject&amp;gt; jsonGeometry = new List&amp;lt;JsonObject&amp;gt;();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; jsonGeometry.Add(onSegment);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; JsonObject resultJsonObject = new JsonObject();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; resultJsonObject.AddArray("Geometry", jsonGeometry.ToArray());&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; // Get byte array of json and return results, which will be the output of ArcGIS Server SOE service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; byte[] result = Encoding.UTF8.GetBytes(resultJsonObject.ToJson());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return result;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The data from my ArcGIS Server's service call looks like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{ "Geometry": [ {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; "paths": [ [ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [-8575118.2321458999,4707114.1745275566], ... [-8575820.374931246,4707389.1788524361] ] ]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; } ] }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideally, after the { } block, there should be &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"spatialReference":{"wkid":102100}}, which is the same as that of the points in the point collection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can the SR information be added to the polyline?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 16:10:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/points-to-polyline-how-to-the-spatial-reference/m-p/623904#M16784</guid>
      <dc:creator>ShaningYu</dc:creator>
      <dc:date>2014-01-16T16:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Points to Polyline - How to the spatial reference? - Solved</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/points-to-polyline-how-to-the-spatial-reference/m-p/623905#M16785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Found to be very simple, just add&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; pSegPoly.SpatialReference = point.SpatialReference;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then, the result from ArcGIS Server's SOE service contains the SR as needed.&amp;nbsp; Thread is to be closed.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 16:16:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/points-to-polyline-how-to-the-spatial-reference/m-p/623905#M16785</guid>
      <dc:creator>ShaningYu</dc:creator>
      <dc:date>2014-01-16T16:16:41Z</dc:date>
    </item>
  </channel>
</rss>

