This project is read-only.


Aug 26, 2009 at 8:41 AM

Please could somebody post some code to calculate the distance between 2 'Position' objects.

I am sure it's a method somewhere in the framework but I just can't find it!


Aug 26, 2009 at 7:56 PM

Check out the DistanceTo method of the Position class.  This can be found in the GeoFramework 2.0 project here at CodePlex.

Aug 26, 2009 at 8:14 PM

Thanks, but how do I get the result into feet as an integer?

Distance dis = e.Position.DistanceTo(oldposition);

"dis.ToFeet" returns another distance structure.



Aug 26, 2009 at 8:22 PM

That's right, every distance measurement is always associated with a unit to prevent mix-ups of units.  Same for the Speed and Area structures.  You can access the Value property to get the value as a Double, then convert to an Int32:

int dis = (int)e.Position.DistanceTo(oldposition).ToFeet().Value;


Aug 26, 2009 at 8:37 PM

Thanks Jon ... got there in the end.