<?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: Calculate distance from IRing behaves inconsistant to IProximityOperator in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/calculate-distance-from-iring-behaves-inconsistant/m-p/542003#M14672</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This sounds like a precision issue. Although you have supplied a sample of your data as Shapefiles is this in fact the storage format you are using? Are you actually using a geodatabase and the XY resolution of the datasets are different? If they are Shapefiles try importing them into a geodatabase with a default XY resolution, then try your code?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Feb 2014 19:55:21 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2014-02-27T19:55:21Z</dc:date>
    <item>
      <title>Calculate distance from IRing behaves inconsistant to IProximityOperator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/calculate-distance-from-iring-behaves-inconsistant/m-p/542002#M14671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey around,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a two featureClasses of type Polygon where the slave-class depends on the master-class. Having said this I want to reshape some portions of the slave-class (I call them Candidates within my code) by the appropriate paths within the master-class. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I start up querying the slaves that belong to a given master-features by using a spatial query (intersect). Now I loop every point within the slave and compare them to the points within the master. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume the following condition for my candidate:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The from-point and the to-point of the Candidate coincide the master-geometry. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I calculate the distance of the points within the slave-geometry to the master-geometry using the IProximityOperator-interface (with master-geom as proxy). A distance of 0 indicates that the point is on the master-geometry. So I build up the candidates as ICurve-members by adding all the points that do NOT coincide the master-geometry and finally append the from- and to-point (which DO coincide). Now I have a set of candidates that represent ICurve-members. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following code retrieves the candidates: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
IPointCollection4 points = (IPointCollection4)slave.Feature.Shape; // the points of the slave-feature

IPoint fromPoint = null;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // fromPoint of the candidate
IPoint toPoint = null;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // toPoint of the candidate

IPolyline curve = new PolylineClass();&amp;nbsp;&amp;nbsp; // the geometry of the candidate to add to the result-list
IPointCollection curvePoints = (IPointCollection)curve;


for (int j = 19; j &amp;lt; 22; j++)&amp;nbsp;&amp;nbsp;&amp;nbsp; // consider only these three points
{ 
 // iterate through the points of the slave-geometry

 IPoint point = points.get_Point(j);
 double distance = proxy.ReturnDistance(point); // distance from every point within the slave to the master-geometry

 if (distance &amp;gt; TestClass.Tolerance) // point is totally outside
 {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; // does not happen in our test-case
&amp;nbsp; // ...
 }
 else if (distance &amp;lt; TestClass.Tolerance &amp;amp;&amp;amp; distance &amp;gt; 0) // point is within the tolerance so it might be a candidate
 {&amp;nbsp; 
&amp;nbsp; curvePoints.AddPoint(point);
 }
 else
 {

&amp;nbsp; // point touches the outline of the feature. These touching points form the borders of the correction

&amp;nbsp; if (fromPoint == null) fromPoint = point; // set the fromPoint if not exists
&amp;nbsp; toPoint = point;&amp;nbsp;&amp;nbsp;&amp;nbsp; // set the toPoint

&amp;nbsp; // terminate the candidate and append it to the result

&amp;nbsp; IRelationalOperator relOp = (IRelationalOperator)fromPoint;
&amp;nbsp; if (!relOp.Equals(toPoint))
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; // terminate the current curve

&amp;nbsp;&amp;nbsp; // add the fromPoint to the curve
&amp;nbsp;&amp;nbsp; object before = (object)0;
&amp;nbsp;&amp;nbsp; object after = Type.Missing;
&amp;nbsp;&amp;nbsp; curvePoints.AddPoint(fromPoint, ref before, ref after);
&amp;nbsp;&amp;nbsp; // add the toPoint to the curve
&amp;nbsp;&amp;nbsp; curvePoints.AddPoint(toPoint);

&amp;nbsp;&amp;nbsp; fromPoint = point;&amp;nbsp; // make the current toPoint the next fromPoint
&amp;nbsp;&amp;nbsp; toPoint = null;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; Candidate candidate = new Candidate(curve);// build a new (temporary) candidate from the curve
&amp;nbsp;&amp;nbsp; result.Add(candidate);
&amp;nbsp; }
 }

} 
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I do next is getting the actual reshaper-geometry from the master-feature. Therefor I extract the portion of the master-geometry that fits from- and to-point of my candidate using this code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
IPoint fromPoint = this.Geometry.FromPoint; // "this" is the candidate we retrieved in the previos code
IPoint toPoint = this.Geometry.ToPoint;
double fromDistance = 0, toDistance = 0;&amp;nbsp;&amp;nbsp; // distances along the curve
// if these variables are not equal 0 the given point does not belong to the curve
double fromAcrossDistance = 0, toAcrossDistance = 0; // distances across the curve

// get the ring that forms the masterGeometry in order to access the methods for querying near points
IRing ring = new RingClass();
((ISegmentCollection) ring).AddSegmentCollection((ISegmentCollection) masterGeometry);

// calculate the distance of the fromPoint to the master-geometries along its curve
ring.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, fromPoint, false, null, ref fromDistance, ref fromAcrossDistance, false);
// calculate the distance of the toPoint to the master-geometries along its curve
ring.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, toPoint, false, null, ref toDistance, ref toAcrossDistance, false);
// when either the from- or the toPoint does not coincide with the geometry we return an empty curve
&amp;nbsp;&amp;nbsp; 
// obviously here is the problem
// although we got the from- and toPoints of the candidate (this) by checking if their distance to the masterGeometry is 0 we get some (quite small) 
// difference to 0 in the distances accross the curve
if (fromAcrossDistance &amp;gt; 0 || toAcrossDistance &amp;gt; 0) return (ICurve) new Path();
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is strange in here is that for the same candidate (whose from- and to-point are on the master-geometry, compare condition) we get from/toAcrossDistances that are not exactly 0 but sth. around 0.0000009 or so. why do IRing#QueryPointAndDistance and IProximityOperator#ReturnDistance behave so different and how can I avoid this? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope that you can follow my thoughts and help me finding out the issue behind. I append two shape-files with the mentioned features also.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bye&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 09:56:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/calculate-distance-from-iring-behaves-inconsistant/m-p/542002#M14671</guid>
      <dc:creator>CarstenSchumann</dc:creator>
      <dc:date>2014-02-21T09:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate distance from IRing behaves inconsistant to IProximityOperator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/calculate-distance-from-iring-behaves-inconsistant/m-p/542003#M14672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This sounds like a precision issue. Although you have supplied a sample of your data as Shapefiles is this in fact the storage format you are using? Are you actually using a geodatabase and the XY resolution of the datasets are different? If they are Shapefiles try importing them into a geodatabase with a default XY resolution, then try your code?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Feb 2014 19:55:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/calculate-distance-from-iring-behaves-inconsistant/m-p/542003#M14672</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2014-02-27T19:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate distance from IRing behaves inconsistant to IProximityOperator</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/calculate-distance-from-iring-behaves-inconsistant/m-p/542004#M14673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The featureClasses are indeed in different datasets, but their tolerance is the same (predefined in our database-schema). Actually this tolerance is much greater then the obtained error, while the former is set to 0.0001m (for the whole SDE) the latter is around 0.0000000009 as mentioned before, so I wonder why the engine recognizes this difference anyway...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Both FCs are stored within an SDE.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 06:27:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/calculate-distance-from-iring-behaves-inconsistant/m-p/542004#M14673</guid>
      <dc:creator>CarstenSchumann</dc:creator>
      <dc:date>2014-03-03T06:27:35Z</dc:date>
    </item>
  </channel>
</rss>

