Index: src/webservice/htdocs/SiWeather/Webservice/IpGeoLocator.php
===================================================================
--- src/webservice/htdocs/SiWeather/Webservice/IpGeoLocator.php	(revision 851179ec808ab3b445c3f5707e15a26c0d28693b)
+++ src/webservice/htdocs/SiWeather/Webservice/IpGeoLocator.php	(revision 851179ec808ab3b445c3f5707e15a26c0d28693b)
@@ -0,0 +1,90 @@
+<?php
+/*
+    Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301  USA.
+*/
+
+namespace SiWeather\Webservice;
+
+/**
+  * @brief Translates an IP Address into City, Country, Region, Zipcode, Latitude, Longitude, Time/Zone
+  *
+  * Returns null if someting failed.
+  */
+class IpGeoLocator
+{
+	public static function locate($ip, &$errorMessage){
+		if(!$ip || empty($ip)){
+			$errorMessage = "IpGeoLocator: No ip given";
+			return null;
+		}
+	
+		$config = new WebserviceConfig();
+		$baseUrl = $config->getConfig("geoipservice");
+		if(!$baseUrl || empty($baseUrl)){
+			$errorMessage = "IpGeoLocator: No geo ip service base url set (see config \"geoipservice\")";
+			error_log($errorMessage);
+			return null;
+		}
+	
+		$client = new \GuzzleHttp\Client
+		(
+			[
+				"base_uri" => $baseUrl,
+				"timeout" => 5.0,
+				"http_errors" => false,
+			]
+		);
+		$response = $client->get("/json/". $ip);
+		if(is_null($response)){
+			$errorMessage = "IpGeoLocator: Failed to fetch ip";
+			return null;
+		}
+		if($response->getStatusCode() != 200){
+			if($response->getStatusCode() == 403){
+				$errorMessage = "IpGeoLocator: Probably too many ". $baseUrl ." requests (>10000/hour). Reason:". $response->getReasonPhrase();
+			}
+			else{
+				$errorMessage = "IpGeoLocator: Request failed with code ". $response->getStatusCode() ." and reason ". $response->getReasonPhrase();
+			}
+			error_log($errorMessage);
+			return null;
+		}
+
+		$body = $response->getBody();
+		if(empty($body)){
+			$errorMessage = "IpGeoLocator: Returned empty body";
+			error_log($errorMessage);
+			return null;
+		}
+		$json = json_decode($body, TRUE);
+		if(is_null($json) || !$json || !is_array($json)){
+			$errorMessage = "IpGeoLocator: Could not convert answer into json data\n". $body;
+			error_log($errorMessage);
+			return null;
+		}
+		
+		$location = new Location($json["city"], $json["zip_code"],
+								 $json["region_name"], $json["region_code"],
+								 $json["country_name"], $json["country_code"],
+								 $json["latitude"], $json["longitude"],
+								 $json["time_zone"]);
+		return $location;
+	}
+}
+
+?>
Index: src/webservice/htdocs/SiWeather/Webservice/Location.php
===================================================================
--- src/webservice/htdocs/SiWeather/Webservice/Location.php	(revision 851179ec808ab3b445c3f5707e15a26c0d28693b)
+++ src/webservice/htdocs/SiWeather/Webservice/Location.php	(revision 851179ec808ab3b445c3f5707e15a26c0d28693b)
@@ -0,0 +1,150 @@
+<?php
+/*
+    Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301  USA.
+*/
+
+namespace SiWeather\Webservice;
+
+/**
+  * @brief Describes a city in a region and a country.
+  *
+  * The codes (region and country) are Alpha 2 codes from ISO 3166-1 (country) and ISO 3166-2 (subdivision).
+  *
+  */
+class Location
+{
+	public function __construct($city, $zipCode = "",
+								$regionName = "", $regionCode = "",
+								$countryName = "", $countryCode = "",
+								$latitude = "", $longitude = "", 
+								$timeZone = ""){
+
+		$this->_city = "";
+		$this->_zipCode = "";
+		$this->_regionName = "";
+		$this->_regionCode = "";
+		$this->_countryName = "";
+		$this->_countryCode = "";
+		$this->_longitude = 0;
+		$this->_latitude = 0;
+		$this->_timeZone = "";
+
+
+		$this->setCity($city);
+		$this->setZipCode($zipCode);
+		$this->setRegion($regionName, $regionCode);
+		$this->setCountry($countryName, $countryCode);
+		$this->setLocation($longitude, $latitude);
+		$this->setTimezone($timeZone);
+	}
+
+	public function setCity($name){
+		$this->_city = $name;
+	}
+	
+	public function city(){
+		return $this->_city;
+	}
+	
+	public function setZipCode($code){
+		$this->_zipCode = $code;
+	}
+	
+	public function zipCode(){
+		return $this->_zipCode;
+	}
+	
+	public function setRegion($name, $code){
+		$this->_regionName = $name;
+		if(strlen($code) == 2)
+			$this->_regionCode = $code;
+	}
+	
+	public function regionName(){
+		return $this->_regionName;
+	}
+	
+	public function regionCode(){
+		return $this->_regionCode;
+	}
+
+	public function setCountry($name, $code){
+		$this->_countryName = $name;
+		if(strlen($code) == 2)
+			$this->_countryCode = $code;
+	}
+	
+	public function countryName(){
+		return $this->_countryName;
+	}
+	
+	public function countryCode(){
+		return $this->_countryCode;
+	}
+	
+	/**
+	  * @brief Sets the location to @p $latitude and @p $longitude
+	  *
+	  * @note Please note that this functions arguments are in the typical order of 
+	  *       city coordinates, whereas the WKT format turned around those values
+	  *       (WKT(Longitude Latitude)).
+	  *
+	  * @see latitude()
+	  * @see longitude()
+	  * @see locationWkt()
+	  */
+	public function setLocation($latitude, $longitude){
+		if(is_numeric($latitude) && ($latitude > -90.0 && $latitude < 90.0))
+			$this->_latitude = $latitude;
+		if(is_numeric($longitude) && ($longitude > -180.0 && $longitude < 180.0))
+			$this->_longitude = $longitude;
+	}
+	
+	public function latitude(){
+		return $this->_latitude;
+	}
+	
+	public function longitude(){
+		return $this->_longitude;
+	}
+	
+	public function locationWkt(){
+		return $this->longitude() ." ". $this->latitude();
+	}
+	
+	public function setTimeZone($zone){
+		if(preg_match("/^[\D]+\/[\D]+$/", $zone) > 0)
+			$this->_timeZone = $zone;
+	}
+	
+	public function timeZone(){
+		return $this->_timeZone;
+	}
+
+	private $_countryCode;
+	private $_countryName;
+	private $_regionCode;
+	private $_regionName;
+	private $_city;
+	private $_zipCode;
+	private $_timeZone;
+	private $_latitude;
+	private $_longitude;
+}
+
+?>
