Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

for shortest distance between two points along great circle
someone may already have done this...
or you can write a custom function to do the same thing..

Let ( [
R = 6372.8 ;
dLat = Radians ( laty - latx ) ;
dLon = Radians ( lony - lonx ) ;
lati = Radians ( latx ) ;
latj = Radians ( laty ) ;
a = Sin ( dLat / 2 ) * Sin ( dLat / 2 ) + Sin ( dLon / 2 ) * Sin ( dLon / 2 ) * Cos ( lati ) * Cos ( latj ) ;
c = 2 * Asin ( Sqrt ( a ) ) ; 
M = R * c * .621371192
] ;
Case ( IsEmpty ( units ) ; Int ( M ) & " mi " & Round ( ( M - Int ( M ) ) * 1760 ; 2 ) & " yds" ; Round ( R * c ; 3 ) & " km" )
)
// HaversineDistance ( latx ; lonx ; laty ; lony ; units )
// 15_02_03 JR
// v1.0
// returns shortest diatance by Haversine method
// if units then it is in KM else miles and yds

R = 6372.8d

lati = latx.toDouble()
loni = lonx.toDouble()
latj = laty.toDouble()
lonj = lony.toDouble()

dLat = Math.toRadians(latj - lati)
dLon = Math.toRadians(lonj - loni)
lati = Math.toRadians(lati)
latj = Math.toRadians(latj)
a = Math.sin(dLat / 2 ) * Math.sin (dLat / 2 ) + Math.sin(dLon / 2) * Math.sin(dLon / 2 ) * Math.cos(lati) * Math.cos(latj)
c = 2 * Math.asin(Math.sqrt( a ))
if ( units ){
	return (R * c).round(3) + ' km'
} else {
	M = ((R * c) * 0.621371192)
	return M.toInteger() + ' mi ' + ((M - M.toInteger()) * 1760).round(2) + ' yds'
} //end if

What's the benefit of doing this with ScriptMaster instead of as a custom function?

 

Presuming that the goal is to calculate distances between two points on the surface of the Earth (based on the radius being used), there's also a custom function using a different formula based on an ellipsoidal rather than spherical approximation, and so is more accurate (and more complicated).

  • Author

Nice CF JB...

I had written a ScriptMaster function to use a SOAP call to a site returning geo-location information, and adding this to the parsing of the JSON meant I could return the information they are really after in one step.

If you're sticking to ScriptMaster and accuracy is really important to you GeographicLib is the gold standard. It is, paradoxically, more accurate than the actual surface of the Earth.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.