|
Actually it is to be used to determine 'exclusive' territories.... example... a particular customer has exclusive rights to products within a 200 mile radius... well, since we have a trucking company we know each customer's longitude and latitude. So the problem becomes how do I do that.... if a customer calls in to place an order for an item, and that item is exclusive to another customer for the 200 mile radius... can the customer purchase? Is he inside or outside exclusive territory? And the data I have to determine this is longitude and latitude... And if he is within the exclusive area, the user would get an error stating, 'exclusive'... otherwise, the order would be allowed to go thru... lol... programming can get complicated at times, but I have been doing it for 22 years, and can honestly say, I still love it! Karen Brasier I.T. Department - Software Analyst Standard Furniture Manufacturing Co. Bay Minette, Alabama 36507 (251) 937-6741 ext 8848 There are 10 kinds of people in the world, those that understand binary and those that do not. -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of jstevens@xxxxxxxxxxxxxx Sent: Wednesday, January 12, 2005 1:44 PM To: RPG programming on the AS400 / iSeries Subject: Re: longitude / latitude distance calculations Karen, I did an application just like this about 12 years ago. I had the database of cities and their lat/lon location, and needed the miles between them. I actually did it in RPG II back then. If I remember, the hardest part was writing my own sin, cos, sqrt, tan, and arc-tan functions with only +/-*. I would assume that those functions are available in the C binding library now. Is this for a transportation application? Are you really trying to get to highway miles, or is straight line, surface miles good enough? Jeff Stevens Mize, Houser & Co. P.A. 913 451 1882 JStevens@xxxxxxxxxxxxxx "Karen Brasier" <karen.brasier@xxxxxxxxx> Sent by: rpg400-l-bounces@xxxxxxxxxxxx 01/12/2005 01:23 PM Please respond to RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx> To "'RPG programming on the AS400 / iSeries'" <rpg400-l@xxxxxxxxxxxx> cc Subject longitude / latitude distance calculations Working on a project and need to know the distance in miles between two locations. The information that I have in the file to use to do this is the longitude and latitude. I have seen the code in PC jargon, but have not been able to find anything about how to accomplish this in RPG. Any suggestions would be appreciated... I am cutting/pasting the calc to accomplish this below... as I look at this, I am lost! (or worse, lol) surely, there is an easier way, but in searching the archives, I found nothing on this... const pi = 3.14159265358979323846 Function distance(lat1, lon1, lat2, lon2, unit) Dim theta, dist theta = lon1 - lon2 dist = sin(deg2rad(lat1)) * sin(deg2rad(lat2)) + cos(deg2rad(lat1)) * cos(deg2rad(lat2)) * cos(deg2rad(theta)) response.write "dist = " & dist & "<br>" dist = acos(dist) dist = rad2deg(dist) response.write "dist = " & dist & "<br>" distance = dist * 60 * 1.1515 Select Case ucase(unit) Case "k" distance = distance * 1.609344 Case "n" distance = distance * 0.8684 End Select End Function ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::: this function get the arccos function using arctan function ::: ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Function acos(rad) If abs(rad) <> 1 Then acos = pi/2 - atn(rad / sqr(1 - rad * rad)) ElseIf rad = -1 Then acos = pi End If End function ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::: this function converts decimal degrees to radians ::: ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Function deg2rad(deg) deg2rad = cdbl(deg * pi / 180) End Function ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: '::: this function converts radians to decimal degrees ::: ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Function rad2deg(rad) rad2deg = cdbl(rad * 180 / pi) End Function msgbox(distance(32.9697, -96.80322, 29.46786, -98.53506, "m") & " miles<br>") msgbox(distance(32.9697, -96.80322, 29.46786, -98.53506, "k") & " kilometers<br>") msgbox(distance(32.9697, -96.80322, 29.46786, -98.53506, "n") & " nautical miles<br>") Karen Brasier I.T. Department - Software Analyst Standard Furniture Manufacturing Co. Bay Minette, Alabama 36507 (251) 937-6741 ext 8848 There are 10 kinds of people in the world, those that understand binary and those that do not. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.