finish #102
This commit is contained in:
@@ -23,7 +23,12 @@ class SpsApi extends Api {
|
||||
* Route string for the domain paramter
|
||||
* @var string
|
||||
*/
|
||||
public static $routeParameterDomain = "/domain/:domain";
|
||||
public static $routeParameterDomain = "(/domain/:domain)";
|
||||
/**
|
||||
* Route string for the range paramter
|
||||
* @var string
|
||||
*/
|
||||
public static $routeParameterRange = "(/range/:range)";
|
||||
|
||||
/**
|
||||
* Route string for the Longitude paramter
|
||||
@@ -67,6 +72,12 @@ class SpsApi extends Api {
|
||||
*/
|
||||
public static $keyLat = "latitude";
|
||||
|
||||
/**
|
||||
* Keyword for range arguments
|
||||
* @var string
|
||||
*/
|
||||
public static $keyRange = "range";
|
||||
|
||||
/*
|
||||
* Varible for the range of the searchpolygon
|
||||
* @var float
|
||||
@@ -141,8 +152,8 @@ class SpsApi extends Api {
|
||||
* @return querry result as xml
|
||||
*/
|
||||
public function sendSpsCoordinateQuery($queryArgs) {
|
||||
|
||||
// check arguments of the query
|
||||
|
||||
// check arguments of the query
|
||||
if (!array_key_exists(self::$keyLong, $queryArgs) || !array_key_exists(self::$keyLat, $queryArgs)) {
|
||||
return null;
|
||||
}
|
||||
@@ -154,6 +165,14 @@ class SpsApi extends Api {
|
||||
}
|
||||
|
||||
// build a request polygon
|
||||
if (array_key_exists(self::$keyRange, $queryArgs)) {
|
||||
$newRange = $queryArgs[self::$keyRange];
|
||||
if ($this->validRange($newRange)) {
|
||||
self::$range = $newRange;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$queryArgs[self::$keyPoly] = $this->createPolygon($latitude, $longitude, self::$range);
|
||||
|
||||
// send querry
|
||||
@@ -161,6 +180,19 @@ class SpsApi extends Api {
|
||||
return $this->serialManager->arrayToSps($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method check if a string is a valid Longitude
|
||||
* @param string $string
|
||||
* @return bool
|
||||
*/
|
||||
private function validRange($string) {
|
||||
$digit = str_replace(".", "", $string);
|
||||
if (ctype_digit($digit)) {
|
||||
return TRUE;
|
||||
};
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method check if a string is a valid Longitude
|
||||
* @param string $string
|
||||
|
||||
Reference in New Issue
Block a user