Following on from the 3D plots of the Earth globes in comments to an earlier post, here's some hacky code to grab longtitude and latitude.

(nb. This code attempts to send the IP address of your primary DNS to www.geobytes.com so don't run it if you don't want that action.)

if kernelopts(platform)="windows" then
   res:=ssystem("ipconfig /all"): res:=res[2];
   StringTools:-Search("Primary Dns Suffix",res);
   ans:=StringTools:-Split(res[%+36..%+70])[1];
else
   ans:=ssystem("hostname -y"): ans:=ans[2];
end if:
full:=HTTP:-Get(cat("http://www.geobytes.com/IpLocator.htm?GetLocation&IpAddress=",ans))[2]:
sloc:=StringTools:-Search("GLatLng(",full):
latitude,longitude:=parse(full[sloc+8..sloc+24]);

                  latitude, longitude := -41.4569, 147.1793

This could be used to put an arrow or disk marking "you are here" on the plotted globe.

The code to get an IP is very hacky. On Unix/Linux it is assuming use of yp. The dicing up by StringTools is very crude. I ran it on ubuntu 64 and Windows 7 in Maple 15.01 and 16.01 (but the initial IP extraction failed on 14.01). Thus the first part may not work for most people. But once the IP is obtained (in some revised way) then it can be used for `ans` in the HTTP-Get() call.

acer


Please Wait...