<?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: Check intersection of two polyline features in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75370#M2019</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The problem is that you're casting from IFeature to IPolyline.&amp;nbsp; This is an invalid cast.&amp;nbsp; You need to be getting the Shape of the feature and casting that to IPolyline, not the feature object itself.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 May 2012 12:12:30 GMT</pubDate>
    <dc:creator>NeilClemmons</dc:creator>
    <dc:date>2012-05-17T12:12:30Z</dc:date>
    <item>
      <title>Check intersection of two polyline features</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75369#M2018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to get bool result of intersection of two polyline features. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;private bool CheckIntersection(IFeature feat1, IFeature feat2) { &amp;nbsp;&amp;nbsp;&amp;nbsp; IPolyline pLine1, pLine2; &amp;nbsp;&amp;nbsp;&amp;nbsp; pLine1 = feat1 as IPolyline; &amp;nbsp;&amp;nbsp;&amp;nbsp; pLine2 = feat2 as IPolyline; &amp;nbsp;&amp;nbsp;&amp;nbsp; ITopologicalOperator topoOp = pLine1 as ITopologicalOperator; &amp;nbsp;&amp;nbsp;&amp;nbsp; IGeometry pGeom = topoOp.Intersect(pLine2, esriGeometryDimension.esriGeometry0Dimension);&amp;nbsp; //Here I get this error: System.NullReferenceException:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Object reference not set to an instance of an object. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (pGeom == null) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else return true; }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone help me?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 08:52:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75369#M2018</guid>
      <dc:creator>AysberqTundra</dc:creator>
      <dc:date>2012-05-17T08:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Check intersection of two polyline features</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75370#M2019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The problem is that you're casting from IFeature to IPolyline.&amp;nbsp; This is an invalid cast.&amp;nbsp; You need to be getting the Shape of the feature and casting that to IPolyline, not the feature object itself.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 12:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75370#M2019</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2012-05-17T12:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Check intersection of two polyline features</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75371#M2020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The problem is that you're casting from IFeature to IPolyline.&amp;nbsp; This is an invalid cast.&amp;nbsp; You need to be getting the Shape of the feature and casting that to IPolyline, not the feature object itself.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello Neil. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I changed the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
private bool CheckIntersection(IFeature feat1, IFeature feat2)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; IPolyline pLine1, pLine2;
&amp;nbsp;&amp;nbsp;&amp;nbsp; pLine1 = feat1.Shape as IPolyline;
&amp;nbsp;&amp;nbsp;&amp;nbsp; pLine2 = feat2.Shape as IPolyline;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ITopologicalOperator topoOp = pLine1 as ITopologicalOperator;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeometry pGeom = topoOp.Intersect(pLine2, esriGeometryDimension.esriGeometry0Dimension);&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (pGeom == null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else return true;
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tested this function with different features. But the function returns only true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you help me solve this problem?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:55:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75371#M2020</guid>
      <dc:creator>AysberqTundra</dc:creator>
      <dc:date>2021-12-10T22:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Check intersection of two polyline features</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75372#M2021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The Intersect method returns a point collection when called using the 0-dimension flag.&amp;nbsp; Your code should check that this point collection is not null as well as check to make sure the point collection contains at least one point.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 12:55:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75372#M2021</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2012-05-17T12:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Check intersection of two polyline features</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75373#M2022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The Intersect method returns a point collection when called using the 0-dimension flag.&amp;nbsp; Your code should check that this point collection is not null as well as check to make sure the point collection contains at least one point.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I changed the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
private bool CheckIntersection(IFeature feat1, IFeature feat2)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; IPolyline pLine1, pLine2;
&amp;nbsp;&amp;nbsp;&amp;nbsp; pLine1 = feat1.Shape as IPolyline;
&amp;nbsp;&amp;nbsp;&amp;nbsp; pLine2 = feat2.Shape as IPolyline;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ITopologicalOperator topoOp = pLine1 as ITopologicalOperator;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeometry pGeom = topoOp.Intersect(pLine2, esriGeometryDimension.esriGeometry0Dimension);&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; IPointCollection pcol = pGeom as IPointCollection;
&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show(pcol.PointCount.ToString());
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (pcol.PointCount == 0)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else return true;
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But now MessageBox.Show(...) function returns only "0", CheckIntersection(...) function returns only false.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:55:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75373#M2022</guid>
      <dc:creator>AysberqTundra</dc:creator>
      <dc:date>2021-12-10T22:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Check intersection of two polyline features</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75374#M2023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If the point collection contains no points then the two geometries do not intersect in such a way that the intersection is defined as a point.&amp;nbsp; If your goal is simply to determine if two polylines share a spatial relationship with each other then you may be better served by calling IRelationalOperator.Disjoint.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2012 14:27:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75374#M2023</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2012-05-17T14:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Check intersection of two polyline features</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75375#M2024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If the point collection contains no points then the two geometries do not intersect in such a way that the intersection is defined as a point.&amp;nbsp; If your goal is simply to determine if two polylines share a spatial relationship with each other then you may be better served by calling IRelationalOperator.Disjoint.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Neil.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It worked. It is the best solution for my problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 May 2012 03:50:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/check-intersection-of-two-polyline-features/m-p/75375#M2024</guid>
      <dc:creator>AysberqTundra</dc:creator>
      <dc:date>2012-05-18T03:50:39Z</dc:date>
    </item>
  </channel>
</rss>

