× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Here's one that we use to get miles from google. Just need to fill in
your api key.


D origin s 32a
D destination s 32a
d xorigin s like(origin)
d xdestination s like(destination)
d url s 2000a
d httphdr s 256a
d estatus s 10a
d status s 32a
d value s 7s 0
d miles s 7s 0
d ok s 10a inz('OK ')
d apikey s 39a inz('put your api key here')
C *entry plist
C origin parm origin parm1 32
C destination parm destination parm2 32
C parm miles parm3 15 5
C
C*

miles = 0;

exec sql
set :origin = compress(:origin),
:destination = compress(:destination);

exec sql
select coalesce(miles,0) into :miles
from googmiles
where upper(:origin) = upper(orig) and
upper(:destination) = upper(dest)
fetch first row only;

if miles <> 0;
return;
endif;


xorigin = origin;
xdestination = destination;
httphdr = '<httpHeader connectTimeout="1500"></httpHeader>';
value = 0;

exec sql
set :origin = systools.urlencode(trim(:origin),'UTF-8');
exec sql
set :destination = systools.urlencode(trim(:destination),'UTF-8');

url = 'https://maps.googleapis.com/maps/api/distancematrix/xml' +
'?origins=' + %trim(origin) + '&destinations=' + %trim(destination) +

'&units=imperial' + '&key=' + apikey;

exec sql
select coalesce(origin,' '), coalesce(destination,' '),
coalesce(estatus, ' '), coalesce(distance_value,0), status
into :origin, :destination, :estatus, :value, :status
from
xmltable('/DistanceMatrixResponse'
passing(xmlparse(document
systools.httpgetblob(:url, :httphdr)))
Columns
status char(32) path 'status',
origin char(32) path 'origin_address',
destination char(32) path 'destination_address',
estatus char(10) path 'row/element/status',
duration_text char(20) path 'row/element/duration/text',
duration_value decimal(7,0) path 'row/element/duration/value',
distance_text char(20) path 'row/element/distance/text',
distance_value decimal(7,0) path 'row/element/distance/value'
) as a;

if estatus = ok;
miles =%dech(value/1609.34:7:0);

exec sql
insert into googmiles(orig, dest, miles)
values(upper(:xorigin), upper(:xdestination), :miles);

else;
miles = 0;
endif;

return;




From: "mlazarus" <mlazarus@xxxxxxxxxxxx>
To: "Midrange Systems Technical Discussion"
<midrange-l@xxxxxxxxxxxxxxxxxx>
Date: 12/02/2022 08:08 AM
Subject: Re: Web service call to determine distance between 2 zip
codes



Alan,

I don't have code, but check out the Google geolocation APIs. You
need to set up an account and you'll get a key to use for your
requests. Under a certain number of uses per month it's free.

-mark

On 12/2/2022 8:11 AM, Alan Shore via MIDRANGE-L wrote:
Hi everyone
We are on V7r3
I have been given a task to extract data concerning packages that have
shipped
Part of that data is to determine the distance between the origin zip
code and the destination zip code
Does anyone have code (and is willing to share it) for a web service
call to obtain this information?
As always - all answers gratefully accepted

Alan Shore
Solutions Architect
IT Supply Chain Execution

[cid:image001.png@01D90625.BD2AB6B0]

60 Orville Drive
Bohemia, NY 11716
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
E-mail : ASHORE@xxxxxxxxxxxxxxxxxxxx

'If you're going through hell, keep going.'
Winston Churchill



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.