Ejemplo n.º 1
0
$oDB =& getDB();
ini_set('memory_limit', '200M');
// Format for output
$sOutputFormat = 'xml';
if (isset($_GET['format']) && ($_GET['format'] == 'html' || $_GET['format'] == 'xml' || $_GET['format'] == 'json' || $_GET['format'] == 'jsonv2')) {
    $sOutputFormat = $_GET['format'];
}
// Preferred language
$aLangPrefOrder = getPreferredLanguages();
$hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
if (isset($_GET['osm_type']) && isset($_GET['osm_id']) && (int) $_GET['osm_id'] && ($_GET['osm_type'] == 'N' || $_GET['osm_type'] == 'W' || $_GET['osm_type'] == 'R')) {
    $aLookup = array('osm_type' => $_GET['osm_type'], 'osm_id' => $_GET['osm_id']);
} else {
    if (isset($_GET['lat']) && isset($_GET['lon']) && preg_match('/^[+-]?[0-9]*\\.?[0-9]+$/', $_GET['lat']) && preg_match('/^[+-]?[0-9]*\\.?[0-9]+$/', $_GET['lon'])) {
        $oReverseGeocode = new ReverseGeocode($oDB);
        $oReverseGeocode->setLanguagePreference($aLangPrefOrder);
        $oReverseGeocode->setLatLon($_GET['lat'], $_GET['lon']);
        $oReverseGeocode->setZoom(@$_GET['zoom']);
        $aLookup = $oReverseGeocode->lookup();
        if (CONST_Debug) {
            var_dump($aLookup);
        }
    } else {
        $aLookup = null;
    }
}
if ($aLookup) {
    $oPlaceLookup = new PlaceLookup($oDB);
    $oPlaceLookup->setLanguagePreference($aLangPrefOrder);
    $oPlaceLookup->setIncludeAddressDetails(getParamBool('addressdetails', true));
    $oPlaceLookup->setIncludeExtraTags(getParamBool('extratags', false));
Ejemplo n.º 2
0
$oDB =& getDB();
$bVerbose = $aResult['verbose'];
if (!$aResult['search-only']) {
    $oReverseGeocode = new ReverseGeocode($oDB);
    $oReverseGeocode->setIncludeAddressDetails(true);
    echo "Warm reverse: ";
    if ($bVerbose) {
        echo "\n";
    }
    for ($i = 0; $i < 1000; $i++) {
        $fLat = rand(-9000, 9000) / 100;
        $fLon = rand(-18000, 18000) / 100;
        if ($bVerbose) {
            echo "{$fLat}, {$fLon} = ";
        }
        $oReverseGeocode->setLanguagePreference(array('en'));
        $oReverseGeocode->setLatLon($fLat, $fLon);
        $oReverseGeocode->setZoom(20);
        $aDetails = $oReverseGeocode->lookup();
        if ($bVerbose) {
            echo $aDetails['langaddress'] . "\n";
        } else {
            echo ".";
        }
    }
    echo "\n";
}
if (!$aResult['reverse-only']) {
    $oGeocode =& new Geocode($oDB);
    echo "Warm search: ";
    if ($bVerbose) {