]> git.openstreetmap.org Git - nominatim.git/blobdiff - website/lookup.php
factor out parameter parsing into its own class
[nominatim.git] / website / lookup.php
index 9d0cea4cc3602d4dd22b840c53cb79b2f621821a..0129f21748a4f03d0dd55e58c638d96d611e28b1 100755 (executable)
@@ -6,27 +6,17 @@
        require_once(CONST_BasePath.'/lib/log.php');
        require_once(CONST_BasePath.'/lib/PlaceLookup.php');
        require_once(CONST_BasePath.'/lib/output.php');
        require_once(CONST_BasePath.'/lib/log.php');
        require_once(CONST_BasePath.'/lib/PlaceLookup.php');
        require_once(CONST_BasePath.'/lib/output.php');
-
-       if (strpos(CONST_BulkUserIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false)
-       {
-               $fLoadAvg = getLoadAverage();
-               if ($fLoadAvg > 2) sleep(60);
-               if ($fLoadAvg > 4) sleep(120);
-               if ($fLoadAvg > 6)
-               {
-                       userError("Bulk User: Temporary block due to high server load");
-                       exit;
-               }
-       }
-
-       $oDB =& getDB();
        ini_set('memory_limit', '200M');
 
        ini_set('memory_limit', '200M');
 
+       $oParams = new ParameterParser();
+
        // Format for output
        // Format for output
-       $sOutputFormat = getParamSet('format', array('xml', 'json'), 'xml');
+       $sOutputFormat = $oParams->getSet('format', array('xml', 'json'), 'xml');
 
        // Preferred language
 
        // Preferred language
-       $aLangPrefOrder = getPreferredLanguages();
+       $aLangPrefOrder = $oParams->getPreferredLanguages();
+
+       $oDB =& getDB();
 
        $hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
 
 
        $hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
 
 
        $oPlaceLookup = new PlaceLookup($oDB);
        $oPlaceLookup->setLanguagePreference($aLangPrefOrder);
 
        $oPlaceLookup = new PlaceLookup($oDB);
        $oPlaceLookup->setLanguagePreference($aLangPrefOrder);
-       $oPlaceLookup->setIncludeAddressDetails(getParamBool('addressdetails', true));
-       $oPlaceLookup->setIncludeExtraTags(getParamBool('extratags', false));
-       $oPlaceLookup->setIncludeNameDetails(getParamBool('namedetails', false));
+       $oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', true));
+       $oPlaceLookup->setIncludeExtraTags($oParams->getBool('extratags', false));
+       $oPlaceLookup->setIncludeNameDetails($oParams->getBool('namedetails', false));
 
 
-       $aOsmIds = explode(',', getParamString('osm_ids', ''));
+       $aOsmIds = explode(',', $oParams->getString('osm_ids', ''));
 
        if (count($aOsmIds) > CONST_Places_Max_ID_count)
        {
 
        if (count($aOsmIds) > CONST_Places_Max_ID_count)
        {
@@ -56,8 +46,7 @@
                if ( $iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R') )
                {
                        $aCleanedQueryParts[] = $sType . $iId;
                if ( $iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R') )
                {
                        $aCleanedQueryParts[] = $sType . $iId;
-                       $oPlaceLookup->setOSMID($sType, $iId);
-                       $oPlace = $oPlaceLookup->lookup();
+                       $oPlace = $oPlaceLookup->lookupOSMID($sType, $iId);
                        if ($oPlace){
                                // we want to use the search-* output templates, so we need to fill
                                // $aSearchResults and slightly change the (reverse search) oPlace
                        if ($oPlace){
                                // we want to use the search-* output templates, so we need to fill
                                // $aSearchResults and slightly change the (reverse search) oPlace