Community of VE/MapPoint Users and Developers
This is a discussion on calculate straight line distance within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi to all, i'd like to know a method to calculate straight line distance between two points. To add a ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| calculate straight line distance i'd like to know a method to calculate straight line distance between two points. To add a line i do map.Shapes.addLine(location1,location2) and distance? Thank you for any suggestion, Francesco |
| |||
| Re: calculate straight line distance
Think this works in VB6 when you haven't calculated a route oMap.Shapes.AddLine location1, location2 Distance# = oMap.Distance(location1, location2) There's a good example on MapPoint help under 'Distance Method' using both VB6 and C# Rgds, David |
| |||
| Re: calculate straight line distance
Hi Francesco, In addition to the reply of David, if you have to do it with only latitude / longitude you can use this formula: Code: public static int CalcDistance(double lat1, double lon1, double lat2, double lon2, out int heading)
{
double lat = lat2 - lat1;
double lon = (lon2 - lon1) * Math.Cos(Tools.deg2rad((int)((lat1 + lat2) / 2)));
double dist = Math.Sqrt(lat * lat + lon * lon);
heading = Tools.rad2deg(Math.Acos(lat / dist));
if (lon < 0) // Western direction
heading = 360 - heading;
return (int)(dist * 60 * 1852);
}
private static double deg2rad(int degree)
{
return degree * Math.PI / 180;
}
private static int rad2deg(double rad)
{
return (int)(rad * 180 / Math.PI);
}
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| calculate, distance, line, straight |
| ||||
| Posted By | For | Type | Date | |
| Discovering MapPoint Map Printing Capabilities - MapPoint Articles - MP2K Magazine | This thread | Refback | 12-19-2006 09:15 AM | |
| Pushpin Tool Add-in - MP2K Magazine | This thread | Refback | 12-13-2006 08:38 AM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Points in a straight line | Dazzer | MapPoint 2006/2009 Discussion | 6 | 05-25-2004 11:27 AM |
| [VB6 + MP2K] How to calculate distance between... | Vincent BENNER | MapPoint 2006/2009 Discussion | 1 | 11-19-2003 11:59 AM |
| how to calculate distance between 2 towns | Anonymous | MapPoint 2006/2009 Discussion | 3 | 06-06-2003 02:51 PM |
| So how do i get it to calculate teh distance betwe.... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 12-19-2001 07:42 AM |
| I would like to calculate the distance from multip.... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 10-31-2001 03:39 AM |
French Ski Holidays
French ski holidays will suit all skiers and most taste buds too. There is a huge range of accommodation from self-catered or catered chalets to all-inclusive luxury hotels.
Spain Weather
Check Spain Weather before you travel. We provide information on Spain including weather, flights and accommodation.
Holidays Italy
Book your holidays in Italy. Italy has a great climate and the beaches to go with it. Book a great deal for great value online at dealchecker.co.uk.
Antigua Holidays
We have the most popular Antigua holidays at highly competitive prices at The Holiday Place. Book a break in sunny Antigua today.
Tunisia
Tunisia enjoys excellent weather, golden beaches and a beautiful blue sea. Moving away from the beach you will find a country that has a rich and varied past. Discover the secrets of history yourself by exploring all the ruins.
Inclusive package holidays
Choose one of the many inclusive package holidays at Travel.co.uk and save a lot of trouble and money too!
Holidays to Sharm el Sheikh
Want to visit the Sinai peninsula? We can help. Info on holidays to Sharm el Sheikh, only at On The Beach.