This commit is contained in:
stubbfel
2013-07-01 18:54:59 +02:00
parent aa03fdcd1b
commit 7851ee7e3b
15 changed files with 177 additions and 97 deletions

View File

@@ -71,46 +71,47 @@ class SpsApi extends Api {
* Varible for the range of the searchpolygon
* @var float
*/
private $range = 1;
private static $range = 1;
/*
* Varible for the fist chars of the string for a Polygon
* @var string
*/
private $polyStartStr = "GeomFromText('Polygon((";
private static $polyStartStr = "GeomFromText('Polygon((";
/*
* Varible for the last chars of the string for a Polygon
* @var string
*/
private $polyEndStr = "))'";
private static $polyEndStr = "))'";
/**
* maximum value of latitude
* @var float
*/
private $maxLat = 180;
private static $maxLat = 180;
/**
* minimum value of latitude
* @var float
*/
private $minLat = -180;
private static $minLat = -180;
/**
* maximum value of longitude
* @var float
*/
private $maxLong = 180;
private static $maxLong = 180;
/**
* minimum value of longitude
* @var float
*/
private $minLong = -180;
private static $minLong = -180;
/**
* Default-Constructor
* Constructor
* @param array[assoc] $headers - RequestHeader
*/
public function __construct($headers = array()) {
$this->sqlManager = new \database\SpsSqlManager();
@@ -142,18 +143,18 @@ class SpsApi extends Api {
public function sendSpsCoordinateQuery($queryArgs) {
// check arguments of the query
if (!array_key_exists(SpsApi::$keyLong, $queryArgs) || !array_key_exists(SpsApi::$keyLat, $queryArgs)) {
if (!array_key_exists(self::$keyLong, $queryArgs) || !array_key_exists(self::$keyLat, $queryArgs)) {
return null;
}
$latitude = $queryArgs[SpsApi::$keyLat];
$longitude = $queryArgs[SpsApi::$keyLong];
$latitude = $queryArgs[self::$keyLat];
$longitude = $queryArgs[self::$keyLong];
if (!$this->validLatitude($latitude) || !$this->validLongitude($longitude)) {
return null;
}
// build a request polygon
$queryArgs[SpsApi::$keyPoly] = $this->createPolygon($latitude, $longitude, $this->range);
$queryArgs[self::$keyPoly] = $this->createPolygon($latitude, $longitude, self::$range);
// send querry
$result = $this->sqlManager->sendSpsCoordinateQuery($queryArgs);
@@ -169,7 +170,7 @@ class SpsApi extends Api {
$digitLessPoint = str_replace(".", "", $string);
$digit = str_replace("-", "", $digitLessPoint);
if (ctype_digit($digit)) {
if ($string <= $this->maxLong && $string >= $this->minLong) {
if ($string <= self::$maxLong && $string >= self::$minLong) {
return TRUE;
}
};
@@ -185,7 +186,7 @@ class SpsApi extends Api {
$digitLessPoint = str_replace(".", "", $string);
$digit = str_replace("-", "", $digitLessPoint);
if (ctype_digit($digit)) {
if ($string <= $this->maxLat && $string >= $this->minLat) {
if ($string <= self::$maxLat && $string >= self::$minLat) {
return TRUE;
}
};
@@ -204,7 +205,7 @@ class SpsApi extends Api {
$minLong = $longitude - $range;
$maxLat = $latitude + $range;
$maxLong = $longitude + $range;
return $this->polyStartStr . "$minLat $minLong,$minLat $maxLong,$maxLat $maxLong,$maxLat $minLong,$minLat $minLong" . $this->polyEndStr;
return self::$polyStartStr . "$minLat $minLong,$minLat $maxLong,$maxLat $maxLong,$maxLat $minLong,$minLat $minLong" . self::$polyEndStr;
}
}