<?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 Re: How to get a segment of a polyline at a certain location? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579921#M15663</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is a code snippet to illustrate the basics of walking through the ISegmentCollection interface to modify the FromPoint of the segment end (VB.Net):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;SegCount = pSegColl.SegmentCount
For j = 0 To SegCount - 1
&amp;nbsp; pSegment = pSegColl.Segment(j)
&amp;nbsp; pInPoint = New Point&amp;nbsp; 'If you needed to modify the segment points do the next steps
&amp;nbsp; pInPoint.SpatialReference = pSpatialRef
&amp;nbsp; pInPoint = pSegment.FromPoint
&amp;nbsp; ' Do something with the segment point
&amp;nbsp; pSegment.FromPoint = pInPoint
&amp;nbsp; pSegColl.SegmentsChanged()&amp;nbsp; ' Send out Segment Changed Message event
&amp;nbsp; pInPoint = Nothing ' Clean up Point Object
Next j&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are only reading the segments you can just examine the pSegment.FromPoint.X,.Y,.M, or .Z values directly instead of assigning them to a new point to modify them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:56:22 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2021-12-12T00:56:22Z</dc:date>
    <item>
      <title>How to get a segment of a polyline at a certain location?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579918#M15660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everybody:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Given a polyline and a point on it, how can I find the segment of that polyline on that point? I checked the ISegmentCollection interface but couldn't find a way to do it. How can I do it? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;***********************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason I want to find the polyline segment for a given point&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;***********************************************&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to write a function to decide whether a given 3D point feature is on a given 3D polyline feature. After making sure the point is exactly contained by the polyline, I want to allow some Z-coordinate tolerance, which is decided according to the segment length of the polyline at that location:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-- The segment is long, which means the distance between polyline vertices is large, then allow a larger tolerance&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-- The segment is short, indicating closer distance between polyline vertices, then allow smaller tolerance&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there alternative way different from finding the segment? I want to find the local vertex density instead of an overall one for a long polyline (which can be calculated by length divided by number of vertices).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jan 2014 22:57:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579918#M15660</guid>
      <dc:creator>SuiHuang</dc:creator>
      <dc:date>2014-01-28T22:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a segment of a polyline at a certain location?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579919#M15661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A simple idea I have now is to enumerate through all the segments, but that doesn't seem to be efficient...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jan 2014 22:59:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579919#M15661</guid>
      <dc:creator>SuiHuang</dc:creator>
      <dc:date>2014-01-28T22:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a segment of a polyline at a certain location?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579920#M15662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If these were Routes you could get the measure of the point and find the segment that bounded that measure from the segment end point M values.&amp;nbsp; You would have to decide what rule you want to follow if the measure was on a vertex.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You also might be interested in my Add-On tool that can generate 3D route measures on a projected Polyline MZ feature class linked in &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/98525-Add-In-for-Assigning-measures-based-on-XYZ-coordinates-in-a-Projected-layer" rel="nofollow noopener noreferrer" target="_blank"&gt;this thread&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp; Just convert your lines to a new Polyline M Z feature class and the tool can assign the measures for you.&amp;nbsp; The Locate Features Along a Route tool can then create a measure event table from your points that would report the 3D distance traveled along the line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My tool just walks through the ISegmentCollection interface to examine each segment's FromPoint or ToPoint (pSegment.FromPoint.X,.Y,.Z or pSegment.ToPoint.X,.Y,.Z) to derive and set the M values (pSegment.FromPoint.M or pSegment.ToPoint.M).&amp;nbsp; That is the interface I would use to find the segment the point fell on based on the M value of the point on the line and the M values at each segment end.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The ICurve.QueryPointAndDistance may also prove useful to get the 2D distance along the curve of the point and its interpolated M and Z values on the line.&amp;nbsp; The IMSegmentation interface may also be useful (GetMsAtDistance) if you go with this option.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If for some reason you ever need to set one of the coordinates on a segment follow this typical code snippet (you cannot set the coordinate directly to the segment without a temporary point object):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp; pInPoint = New Point&amp;nbsp; ' Create a new point
&amp;nbsp; pInPoint.SpatialReference = pSpatialRef&amp;nbsp; ' Previously obtained Spatial Reference from input lines
&amp;nbsp; pInPoint = pSegment.ToPoint '&amp;nbsp; Set the new point to the point of interest from the segment
&amp;nbsp; pInPoint.M = distAlong&amp;nbsp; ' in other parts of my code distAlong keeps track of accumulated 3D distances along the line
&amp;nbsp; pSegment.ToPoint = pInPoint&amp;nbsp; ' replace the point of interest with the modified M coordinate&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:56:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579920#M15662</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-12T00:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a segment of a polyline at a certain location?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579921#M15663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is a code snippet to illustrate the basics of walking through the ISegmentCollection interface to modify the FromPoint of the segment end (VB.Net):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;SegCount = pSegColl.SegmentCount
For j = 0 To SegCount - 1
&amp;nbsp; pSegment = pSegColl.Segment(j)
&amp;nbsp; pInPoint = New Point&amp;nbsp; 'If you needed to modify the segment points do the next steps
&amp;nbsp; pInPoint.SpatialReference = pSpatialRef
&amp;nbsp; pInPoint = pSegment.FromPoint
&amp;nbsp; ' Do something with the segment point
&amp;nbsp; pSegment.FromPoint = pInPoint
&amp;nbsp; pSegColl.SegmentsChanged()&amp;nbsp; ' Send out Segment Changed Message event
&amp;nbsp; pInPoint = Nothing ' Clean up Point Object
Next j&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are only reading the segments you can just examine the pSegment.FromPoint.X,.Y,.M, or .Z values directly instead of assigning them to a new point to modify them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:56:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579921#M15663</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-12T00:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a segment of a polyline at a certain location?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579922#M15664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Take a look at the IHitTest interface.&amp;nbsp; It can tell you if a point is on the line as well as the segment index of the segment in the line's segment collection.&amp;nbsp; If the line is multi-part, it will also tell you the part index in the line's geometry collection.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jan 2014 14:47:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579922#M15664</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2014-01-29T14:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a segment of a polyline at a certain location?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579923#M15665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you! IHitTest interface works and I used it to find the segment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Take a look at the IHitTest interface.&amp;nbsp; It can tell you if a point is on the line as well as the segment index of the segment in the line's segment collection.&amp;nbsp; If the line is multi-part, it will also tell you the part index in the line's geometry collection.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 21:42:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-get-a-segment-of-a-polyline-at-a-certain/m-p/579923#M15665</guid>
      <dc:creator>SuiHuang</dc:creator>
      <dc:date>2014-01-30T21:42:58Z</dc:date>
    </item>
  </channel>
</rss>

