|
echo $fn ?>
|
|
../code/usexhr.orx/var/www/html/ooRexx/wip
#!usr/bin/rexx
-- 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)
xhr~get('/maps/api/geocode/json?latlng=51.941884,-9.808336&sensor=false')
-- 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)
xhr~get('/maps/api/elevation/json?locations=51.941884,-9.808336&sensor=false')
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')
xhr~get('/reverse?format=json&lat=51.941884&lon=-9.808336&zoom=18&addressdetails=1')
say norm~overlay(xhr~rspHeaders[1] '- Address.....:' .json~new()~fromJson(xhr~response)['display_name'],3)
/* idenburg.net is not available anymore
-- Elevation (be it a little less precise(90mx90m)) is also available from
xhr = .xhr~new('www.idenburg.net') -- port 80 is default
xhr~post('/cycling/getSRTMElevationDemo.php','lat=51.941884&lon=-9.808336')
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)
xhr~get('/')
-- ooRexx uses Content-Length rsp header
say norm~overlay(xhr~rspHeaders[1] '-' xhr~response~substr(1,93),3)
say norm
say break
return
::requires 'xhr.cls'
::requires 'json.cls'
If you feel inclined to make corrections, suggestions etc.,
please mail me any.
| |
All content © Ruurd Idenburg, 2007– echo date('Y');?>,
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 Transip.nl, a Dutch company, falling under Dutch (privacy) laws (I think).
This page updated on echo date("r", filemtime("./index.php"));?> by Ruurd Idenburg.
|
|