Select to view content in your preferred language

Precision Problem of "Intersect" from ITopologicalOperator

2595
3
01-29-2014 07:16 AM
DongliangPeng
Deactivated User
I tested "Intersect" from ITopologicalOperator, and found out that the result was not precision.

My test is very simple. I created two polylines, each of which had two vertices:
the first polyline: (0,0) and (1,1)
the second polyline: (0,1) and (1,0)
When I used the "intersect" function of ITopologicalOperator, I got an intersection, whose coordinates were 0.50000190734863281, 0.50000190734863281, which are not precision.

Does anybody know why? It's better to get a more precision result.

Thank you very much!


Below are my codes:

            object Missing = Type.Missing;

            IPointCollection pCol1 = new PolylineClass();
            IPoint ipt1 = new PointClass(); ipt1.PutCoords(0, 0);
            IPoint ipt2 = new PointClass(); ipt2.PutCoords(1, 1);
            pCol1.AddPoint(ipt1, ref Missing, ref Missing);
            pCol1.AddPoint(ipt2, ref Missing, ref Missing);
            IPolyline ipl1=pCol1 as IPolyline ;

            IPointCollection pCol2 = new PolylineClass();
            IPoint ipt3 = new PointClass(); ipt3.PutCoords(0, 1);
            IPoint ipt4 = new PointClass(); ipt4.PutCoords(1, 0);
            pCol2.AddPoint(ipt3, ref Missing, ref Missing);
            pCol2.AddPoint(ipt4, ref Missing, ref Missing);
            IPolyline ipl2=pCol2 as IPolyline ;

            ITopologicalOperator pTop = ipl1 as ITopologicalOperator;
            IGeometry pGeoIntersect = pTop.Intersect(ipl2, esriGeometryDimension.esriGeometry0Dimension);
            IPointCollection pColIntersect = pGeoIntersect as IPointCollection;

            for (int j = 0; j < pColIntersect.PointCount; j++)
            {
                double dblx = pColIntersect.get_Point(j).X;
                double dbly = pColIntersect.get_Point(j).Y;
            }
0 Kudos
3 Replies
NeilClemmons
Honored Contributor
Technically you should be assigning a spatial reference to your geometries so that the linear units are defined.  That spatial reference will also define the precision.

It's better to get a more precision result.


Up to a certain point, yes this is true.  However, I'm assuming your linear units are feet or meters since these are quite common.  If that's the case then the results are accurate out to about a millionth of a foot or meter.  You'd need an electron microscope to see that so does it really matter?
0 Kudos
DuncanHornby
MVP Notable Contributor
You can get desktop scanning electron microscopes now. Although I guess one would have to smash the monitor up and place bits of it into the scanner and then you'll be limited to the pixel resolution of the monitor...so.... your electron microscope idea won't work 😉
0 Kudos
DongliangPeng
Deactivated User
Technically you should be assigning a spatial reference to your geometries so that the linear units are defined.  That spatial reference will also define the precision.



Up to a certain point, yes this is true.  However, I'm assuming your linear units are feet or meters since these are quite common.  If that's the case then the results are accurate out to about a millionth of a foot or meter.  You'd need an electron microscope to see that so does it really matter?


Thank you very much for your reply.

Your answer is reasonable. For the vision purpose, the current precision is enough. However, I want to save the coordinates of the intersections as data, and later use the data for some other applications. In this case, some problems may occur. Therefore, it's better to get extrem precise intersections to avoid potential problems.

Is there anyway to see the codes of the "Intersect" function or how the "Intersect" function is implemented?
0 Kudos