
1. Re: Compute Distance based on Lon/Lat
Adam Crahen Mar 26, 2016 7:30 PM (in response to Bas Groothedde)Hi Bas
Have a look at this and see if it helps get you closer.
I mapped out your paths and facility locations on a dual axis. I used path order on size so you could see the direction of travel. I didn't use the custom sql for the distance calc.
Distance
IF ISnull(ACOS((SIN(RADIANS(LOOKUP(AVG([Lat]), First())))
* SIN(RADIANS(AVG([Lat]))) + COS(RADIANS(LOOKUP(AVG([Lat]), First()))) * COS(RADIANS(AVG([Lat]))) *
COS(RADIANS(AVG([Lon]))  RADIANS(LOOKUP(AVG([Lon]), First()))) ))*[Units])
THEN 0
ELSE
ACOS((SIN(RADIANS(LOOKUP(AVG([Lat]), First())))
* SIN(RADIANS(AVG([Lat]))) + COS(RADIANS(LOOKUP(AVG([Lat]), First()))) * COS(RADIANS(AVG([Lat]))) *
COS(RADIANS(AVG([Lon]))  RADIANS(LOOKUP(AVG([Lon]), First()))) ))*[Units]
END
You can select the units via a parameter. i figure you are after km.
Check the compute on the distance calc:
A couple notes:
1) When you hover over point order 1, it will say zero for the distance because it is calculating the distance from itself.
2) This is not the driving distance which can vary greatly from the direct path.
I didn't know what version you have, so I did this in 9.0.

Bas.twbx 146.1 KB


2. Re: Compute Distance based on Lon/Lat
Bas Groothedde Mar 29, 2016 1:15 AM (in response to Adam Crahen)Adam, this is great!
Thanks for taking the time answering my question!

3. Re: Compute Distance based on Lon/Lat
Bas Groothedde Mar 31, 2016 1:26 AM (in response to Adam Crahen)Hey Adam,
After you have helped me impressively, I wonder whether you could help me with the following problem as well. It deals with flows in paths:
MappingAdding Flow Details in PathKind regards!