exit;
}
+ function getParamBool($name, $default=false)
+ {
+ if (!isset($_GET[$name])) return $default;
+
+ return (bool) $_GET[$name];
+ }
function fail($sError, $sUserError = false)
{
function bySearchRank($a, $b)
{
if ($a['iSearchRank'] == $b['iSearchRank'])
- return strlen($a['sOperator']) + strlen($a['sHouseNumber']) - strlen($b['sOperator']) - strlen($b['sHouseNumber']);
+ return strlen($a['sOperator']) + strlen($a['sHouseNumber']) - strlen($b['sOperator']) - strlen($b['sHouseNumber']);
return ($a['iSearchRank'] < $b['iSearchRank']?-1:1);
}
return $aOrders;
}
+ function getResultDiameter($aResult)
+ {
+ $aClassType = getClassTypes();
+
+ $fDiameter = 0.0001;
- function javascript_renderData($xVal)
+ if (isset($aResult['class'])
+ && isset($aResult['type'])
+ && isset($aResult['admin_level'])
+ && isset($aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defdiameter'])
+ && $aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defdiameter'])
+ {
+ $fDiameter = $aClassType[$aResult['class'].':'.$aResult['type'].':'.$aResult['admin_level']]['defdiameter'];
+ }
+ elseif (isset($aResult['class'])
+ && isset($aResult['type'])
+ && isset($aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'])
+ && $aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'])
+ {
+ $fDiameter = $aClassType[$aResult['class'].':'.$aResult['type']]['defdiameter'];
+ }
+
+ return $fDiameter;
+ }
+
+
+ function javascript_renderData($xVal, $iOptions = 0)
{
header("Access-Control-Allow-Origin: *");
- $iOptions = 0;
if (defined('PHP_VERSION_ID') && PHP_VERSION_ID > 50400)
- $iOptions = JSON_UNESCAPED_UNICODE;
+ $iOptions |= JSON_UNESCAPED_UNICODE;
$jsonout = json_encode($xVal, $iOptions);
if( ! isset($_GET['json_callback']))
}
- function getAddressDetails(&$oDB, $sLanguagePrefArraySQL, $iPlaceID, $sCountryCode = false, $bRaw = false)
+ function getAddressDetails(&$oDB, $sLanguagePrefArraySQL, $iPlaceID, $sCountryCode = false, $housenumber =-1, $bRaw = false)
{
- $sSQL = "select *,get_name_by_language(name,$sLanguagePrefArraySQL) as localname from get_addressdata($iPlaceID)";
+ $sSQL = "select *,get_name_by_language(name,$sLanguagePrefArraySQL) as localname from get_addressdata($iPlaceID, $housenumber)";
if (!$bRaw) $sSQL .= " WHERE isaddress OR type = 'country_code'";
$sSQL .= " order by rank_address desc,isaddress desc";
}
// degrees decimal seconds
// N 40 26 46 W 79 58 56
- // N 40° 26′ 46″ W, 79° 58′ 56″
+ // N 40° 26′ 46″, W 79° 58′ 56″
// 1 2 3 4 5 6 7 8
elseif (preg_match('/\\b([NS])[ ]([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″"]*[, ]+([EW])[ ]([0-9]+)[° ]+([0-9]+)[′\' ]+([0-9]+)[″"]*\\b/', $sQuery, $aData))
{
return array('lat' => $fQueryLat, 'lon' => $fQueryLon, 'query' => $sQuery);
}
+
+
+ function geometryText2Points($geometry_as_text, $fRadius)
+ {
+ $aPolyPoints = NULL;
+ if (preg_match('#POLYGON\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch))
+ {
+ preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
+ }
+ elseif (preg_match('#LINESTRING\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch))
+ {
+ preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
+ }
+ elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch))
+ {
+ preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER);
+ }
+ elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#', $geometry_as_text, $aMatch))
+ {
+ $aPolyPoints = createPointsAroundCenter($aMatch[1], $aMatch[2], $fRadius);
+ }
+
+ if (isset($aPolyPoints))
+ {
+ $aResultPoints = array();
+ foreach($aPolyPoints as $aPoint)
+ {
+ $aResultPoints[] = array($aPoint[1], $aPoint[2]);
+ }
+ return $aResultPoints;
+ }
+
+ return;
+ }
+
+ function createPointsAroundCenter($fLon, $fLat, $fRadius)
+ {
+ $iSteps = max(8, min(100, ($fRadius * 40000)^2));
+ $fStepSize = (2*pi())/$iSteps;
+ $aPolyPoints = array();
+ for($f = 0; $f < 2*pi(); $f += $fStepSize)
+ {
+ $aPolyPoints[] = array('', $fLon+($fRadius*sin($f)), $fLat+($fRadius*cos($f)) );
+ }
+ return $aPolyPoints;
+ }