summaryrefslogtreecommitdiff
path: root/widgets/weather/GetLatLangFromCity.php
diff options
context:
space:
mode:
authorMartin Schirrmacher <vdr.skinflatplus@schirrmacher.eu>2014-11-16 12:43:30 +0100
committerMartin Schirrmacher <vdr.skinflatplus@schirrmacher.eu>2014-11-16 12:43:30 +0100
commitefdb12a81dd96d913651b8b2bd5bbcbd8b135cbb (patch)
tree1c8b26612abe39c49fd494c32ea33554bcbaff55 /widgets/weather/GetLatLangFromCity.php
parentff62c44e6cfdf5b015d04256341e950de76c6b92 (diff)
downloadskin-flatplus-efdb12a81dd96d913651b8b2bd5bbcbd8b135cbb.tar.gz
skin-flatplus-efdb12a81dd96d913651b8b2bd5bbcbd8b135cbb.tar.bz2
update widgets
Diffstat (limited to 'widgets/weather/GetLatLangFromCity.php')
-rw-r--r--widgets/weather/GetLatLangFromCity.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/widgets/weather/GetLatLangFromCity.php b/widgets/weather/GetLatLangFromCity.php
new file mode 100644
index 00000000..e05c1bc8
--- /dev/null
+++ b/widgets/weather/GetLatLangFromCity.php
@@ -0,0 +1,25 @@
+<?php
+
+$handle = fopen ("php://stdin","r");
+echo "Country (like DE for Germany): ";
+$country = fgets($handle);
+echo "City (like Berlin): ";
+$city = fgets($handle);
+
+// get lat & long from google maps
+$MAPSURL = "http://maps.googleapis.com/maps/api/geocode/json?address=".$city.",".$country."&sensor=false";
+$json = file_get_contents($MAPSURL);
+$data = json_decode($json, true);
+
+if( !isset($data['results'][0]) ) {
+ echo "no latitude and longitude find for: ".$city.",".$country." !\n";
+ exit;
+}
+$latitude = $data['results'][0]['geometry']['location']['lat'];
+$longitude = $data['results'][0]['geometry']['location']['lng'];
+
+echo "latitude: ".$latitude."\n";
+echo "longitude: ".$longitude."\n";
+echo "put these values in update_weather.config\n";
+
+?>