ooRexx logo usexhr.orx

-- Using the Google web api's without displaying the results on a web page with a Google Map
-- is against the usage terms Google has established, just so you do know the following is
-- not in line with Google requirements.
break = '' '-'~copies(118)
norm = '|' ' '~copies(117)'|'
say break
say norm~overlay('Reverse geocoding and elevation from Google(HTTP GET)',3)
say break
say norm
say norm~overlay('Geo Location: 51.941884,-9.808336',3)
xhr = .xhr~new('maps.googleapis.com',80)
-- Google uses chunked responses and returns a JSON object
-- replacing json with xml will return a xml string.
say norm~overlay(xhr~rspHeaders[1] '- Address.....:' .json~new()~fromJson(xhr~response)['results'][1]['formatted_address'],3)
say norm~overlay(xhr~rspHeaders[1] '- Elevation...:' .json~new()~fromJson(xhr~response)['results'][1]['elevation']~format(,0) 'meter',3)
say norm
say break
-- Reverse Geocoding from Openstreetmap
say norm~overlay('Reverse geocoding from Openstreetmap.org(HTTP GET), elevation from idenburg.net(HTTP POST)',3)
say break
say norm
say norm~overlay('Geo Location: 51.941884,-9.808336',3)
xhr = .xhr~new('nominatim.openstreetmap.org')
say norm~overlay(xhr~rspHeaders[1] '- Address.....:' .json~new()~fromJson(xhr~response)['display_name'],3)
-- Elevation (be it a little less precise(90mx90m)) is also available from
xhr = .xhr~new('www.idenburg.net') -- port 80 is default
say norm~overlay(xhr~rspHeaders[1] '- Elevation...:' xhr~response~substr(1,xhr~response~length-3) 'meter',3)  -- response ends in '200A20'x
say norm
say break
say norm~overlay('Fetching the first line from build.oorexx.org(HTTP GET)',3)
say break
say norm
-- RexxLA does not have these kind of restrictions so here it goes
xhr = .xhr~new('build.oorexx.org',80)
-- ooRexx uses Content-Length rsp header
say norm~overlay(xhr~rspHeaders[1] '-' xhr~response~substr(1,93),3)
say norm
say break

::requires 'xhr.cls'
::requires 'json.cls'
If you feel inclined to make corrections, suggestions etc., please mail me any.
All content © Ruurd Idenburg, 2007–2018, except where marked otherwise. All rights reserved. This page is primarily for non-commercial use only. The Idenburg website records no personal information and sets no ‘cookies’. This site is hosted on a VPS(Virtual Private System) rented from CloudVPS, a Dutch company, falling under Dutch (privacy) laws.

This page updated on Thu, 28 Apr 2016 14:59:56 +0200 by Ruurd Idenburg.