Select to view content in your preferred language

IPolyline.QueryPoint(...) and Snap

1258
6
08-27-2010 12:11 PM
JianLiu
Occasional Contributor
According to the developer's help, IPolyline.QueryPoint(...) returns the Point at a given distance along the curve or extended curve. I expected that point was exactly ON the curve (or its extension), however it turns out there is always a small offset from the polyline itself (in other words, the queried point doesn't touch the line).

Is this a bug or by design? Anybody knows? Is the snapEnvironment the only way to fix it? I would prefer something without starting editing. Please advise. Any comments will be appreciated, thanks in advance!
0 Kudos
6 Replies
JeffMatson
Frequent Contributor
Is your data frame, curve geometry and return point geometry all in the same coordinate system?
0 Kudos
JianLiu
Occasional Contributor
I just checked, they (data frame, curve file and interpolated point file) are all in the same system. I use intermediate pointClass() in the program, do I need to set their spatial reference as well? If that is not set, could that cause the problem?


I've also tested using the SnapEnvironment to snap the point to the curve, but even after reported successfully snapped, the points are not moved/snapped at all.

Could this have anything to do with tolerance?
0 Kudos
JeffMatson
Frequent Contributor
Yes, I would first try projecting your intermediate point to match the curve geometry, and see if that helps.  Also, is any of your data Z aware?

Regarding snapping, most likely the point is within the tolerance and that is why it is not moving.

If nothing is helping, perhaps you could zip up a small amount of data and your code and someone can take a look...
0 Kudos
JianLiu
Occasional Contributor
Yes, I would first try projecting your intermediate point to match the curve geometry, and see if that helps. Also, is any of your data Z aware? 
  
Regarding snapping, most likely the point is within the tolerance and that is why it is not moving. 
  
If nothing is helping, perhaps you could zip up a small amount of data and your code and someone can take a look...




Thanks Jeff. This is the code for a single feature:

//create a new intermediate point
IPoint tempPoint = new PointClass();
tempPoint.SpatialReference = segment.SpatialReference;

//does the interpolation and assign it to tempPoint. It turns out tempPoint is NOT ON the curve
segment.QueryPoint(esriSegmentExtension.esriNoExtension, ((double)houseNumber - (double)from) / ((double)to - (double)from), true, tempPoint);

//tried IProximityOperator to move the point, to no avail
IProximityOperator proxOp = segment as IProximityOperator;
interpolatedPoint = proxOp.ReturnNearestPoint(tempPoint, esriSegmentExtension.esriNoExtension);

//also tried SnapEnvironment to move the point, to no avail.

Any advice will be appreciated. Thanks!
0 Kudos
JeffMatson
Frequent Contributor
Does your data contain true curves, or was it converted to shapefile from a dataset that did contain true curves?  If so you might be seeing a "display error" when zoomed in to a very large scale. 

One thing you might try is to split the curve at your query point using , and then compare the X and Y values of the vertex from the polyline, and the point.  If they are equal then it might be the display issue, but if the values are not the same then there may be something else going on.
0 Kudos
JianLiu
Occasional Contributor
I've just realized that this may be due to "coordinate precision". See:

http://www.ian-ko.com/resources/Topology_Problems_2.htm

for a good explanation.

Knowing how this happened and not wanting to creating an vertex on the original curve (which will slightly nudge the curve due to coordinate grid), I am wondering if and how I may apply some kind of "tolerance" to the spatial relationships? For example, I want anything falling within the tiny tolerance (the coordinate precision in my case) to be recognized as "touch", instead of "intersect" or "disconnect"... Please advise..Thanks!
0 Kudos