Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Distance Calculation by Latitude/Longitude

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Distance Calculation by Latitude/Longitude
 Login/Join
 
Member
posted
I was trying to calculate distance by using latitude and longtitude. Does anyone has the formula or ways to do so? I'd really appreciated.
 
Posts: 6 | Location: Memphis | Registered: April 30, 2007Report This Post
Virtuoso
posted Hide Post
quote:
calculate distance by using latitude and longtitude



how about google

distance

gives you

Haversine formula:
 R = earth’s radius (mean radius = 6,371km)
Δlat = lat2− lat1
Δlong = long2− long1
a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2)
c = 2.atan2(√a, √(1−a))
d = R.c 

(Note that angles need to be in radians to pass to trig functions).
 
JavaScript: var R = 6371; 
var dLat = (lat2-lat1).toRad();
var dLon = (lon2-lon1).toRad(); 
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
        Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) * 
        Math.sin(dLon/2) * Math.sin(dLon/2); 
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
var d = R * c; 
  


and

meridian

I'm not sure if you will be able to do this in WF, but you might be able to do this.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
http://www.mathforum.com/library/drmath/view/51711.html

The above gives a discussion of the issue, Of course how to calculate sines and cosines to do the formula should be interesting.


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
Adong,

See the discussion on this subject from February this year.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Guru
posted Hide Post
Here's what I came up with after much discussion in February and a little help from some college math professors.

-SET &PI = 3.1415926535897932384626433832795;
-* Earth's mean radius in km 6371
-* Earth's mean radius in mi 3956
-SET &Earth_R = 3956;

DEFINE FUNCTION F_SIN(angle/I3)
Rads/D33.12 = angle / 180 * &PI ;
F_SIN/D20.12 = Rads - ((Rads ** 3)/(1*2*3))
+ ((Rads ** 5)/(1*2*3*4*5)) - ((Rads ** 7)/(1*2*3*4*5*6*7))
+ ((Rads ** 9)/(1*2*3*4*5*6*7*8*9)) + ((Rads ** 11)/(1*2*3*4*5*6*7*8*9*10*11))
+ ((Rads ** 13)/(1*2*3*4*5*6*7*8*9*10*11*12*13));
END
-*
-RUN
-*
DEFINE FUNCTION F_COS(angle/I3)
Rads/D33.12 = angle / 180 * &PI ;
F_COS/D20.12 = 1 - ((Rads ** 2)/(1*2))
+ ((Rads ** 4)/(1*2*3*4)) - ((Rads ** 6)/(1*2*3*4*5*6))
+ ((Rads ** 8)/(1*2*3*4*5*6*7*8)) - ((Rads ** 10)/(1*2*3*4*5*6*7*8*9*10))
+ ((Rads ** 12)/(1*2*3*4*5*6*7*8*9*10*11*12));
END
-*
-RUN
-*
DEFINE FUNCTION F_DIST(Lat1/D16.6, Long1/D16.6, Lat2/D16.6, Long2/D16.6)
Earth_R/D8 = 3956;
dLat/D20.6 = Lat2 - Lat1;
dLong/D20.6 = Long2 - Long1;
F_DIST/D20.4 = SQRT(dLat * dLat + dLong * dLong) * 1/(F_COS(dLat / 2)) / 360 * (2 * &PI * Earth_R);
END
-*
-RUN
-*
TABLE FILE CAR
SUM
-**************SIN COS COT********************************
-**************DISTANCE CALCULATOR************************
COMPUTE LON1/D20.8 = 94.9202;
COMPUTE LON2/D20.8 = 94.9741;
COMPUTE LAT1/D20.8 = 29.3969;
COMPUTE LAT2/D20.8 = 29.3676;
COMPUTE DLON/D20.8 = LON2-LON1;
COMPUTE DLAT/D20.8 = LAT2-LAT1;
COMPUTE DIST/D20.8 = F_DIST(LAT1, LON1, LAT2, LON2);
BY COUNTRY NOPRINT
WHERE RECORDLIMIT EQ 1
END

Hope this helps

Glenda


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
Expert
posted Hide Post
Adong, i think we would all agree that it depends on how much accuracy you need.
Do you need to correct for the curvature of the earth, or not?
If not, then plain old Pythagoras should be good enough, after xlating your latlongs into radians. If your distances are all within your country (you don't say what country you're in), you can decide just how much agony you need to go thru. If your distances are crossing continents, then Tony and Glenda have done your heavy lifting for you. (looks like a great first entry for the new wf wikipedia!)




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Virtuoso
posted Hide Post
Did you mean to say
quote:
- ((Rads ** 11)/
?
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Member
posted Hide Post
Glenda,

Thank you very much for your post. It works perfect. I really appreciate your help.

Maggie
 
Posts: 6 | Location: Memphis | Registered: April 30, 2007Report This Post
Guru
posted Hide Post
Maggie,

Glad I was able to help.

Glenda.


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
Expert
posted Hide Post
Hi Glenda,

I think that this topic is one worthy for writing an article about for the FOCUS on Developers area. I'm sure Kathleen would agree as it is bound to come up time and again. What do you reckon?

T (currently in Vegas!!Smiler)



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Guru
posted Hide Post
Tony,

I'm just a puzzle solver. The more challenging the better. When a COBOL programmer said WeBFOCUS code was too limited to perform distance calculations, it was like waving a red flag in front of a bull (or a stubborn Irish gal).

I don't know the first thing about writing an article. If you want to help me or write it yourself, I won't mind. It sure would save others from what I had to go through to find the information.

And don't rub it in! I couldn't make Las Vegas this year and I so wanted to meet you and the others.
Glenda


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
Virtuoso
posted Hide Post
I discussed this issue (more in general) with some people from IBI in Vegas.
It is indeed not easy to use recursive programming within webfocus and create formulas for several mathematic or financial functions like IRR and FV etc.
But I'm sure that they will see it as a challange to forfill our wishes on this point if we ask them




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Expert
posted Hide Post
Hi Glenda,

I agree totally, just tell me that "it can't be done" and I will try to find a way. Just as when Susannah said that trig functions are not possible in Feb in answer to the original question.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Guru
posted Hide Post
Tony,

You've got me pegged!

Glenda


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
Expert
posted Hide Post
T and Glenda... i see a really great Summit presentation on this subject for the 2 of you to do together for 2008...
and there's a chance, i hear, that Summit might be in Dallas... close enough for "Red" to get there.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Guru
posted Hide Post
Susannah,

YOu are so perceptive. I never said a thing about being a redhead. But yes, that's where the stubborn streak comes from. I like your idea. I'm game if Tony is.


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Distance Calculation by Latitude/Longitude

Copyright © 1996-2020 Information Builders