]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #416 from lonvia/dead-code-removal
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 30 Mar 2016 18:33:54 +0000 (20:33 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 30 Mar 2016 18:33:54 +0000 (20:33 +0200)
Remove unused and/or unmaintained php code

NEWS [deleted file]
lib/lib.php
settings/partitionedtags.def [deleted file]
sql/tables-minimal.sql [deleted file]
sql/update_bigint.sql [deleted file]
utils/setup.php
utils/update.php

diff --git a/NEWS b/NEWS
deleted file mode 100644 (file)
index e69de29..0000000
index fccda314e52904458396953d8f00d858fb7d8516..75e72b4ce6b741d053d0241d6bf71ed3872d90ac 100644 (file)
        }
 
 
-       function getBlockingProcesses()
-       {
-               $sStats = file_get_contents('/proc/stat');
-               if (preg_match('/procs_blocked ([0-9]+)/i', $sStats, $aMatches))
-               {
-                       return (int)$aMatches[1];
-               }
-               return 0;
-       }
-
-
        function getLoadAverage()
        {
                $sLoadAverage = file_get_contents('/proc/loadavg');
        {
                if ($a['importance'] != $b['importance'])
                        return ($a['importance'] > $b['importance']?-1:1);
-               /*
-                  if ($a['aPointPolygon']['numfeatures'] != $b['aPointPolygon']['numfeatures'])
-                  return ($a['aPointPolygon']['numfeatures'] > $b['aPointPolygon']['numfeatures']?-1:1);
-                  if ($a['aPointPolygon']['area'] != $b['aPointPolygon']['area'])
-                  return ($a['aPointPolygon']['area'] > $b['aPointPolygon']['area']?-1:1);
-               //      if ($a['levenshtein'] != $b['levenshtein'])
-               //          return ($a['levenshtein'] < $b['levenshtein']?-1:1);
-               if ($a['rank_search'] != $b['rank_search'])
-               return ($a['rank_search'] < $b['rank_search']?-1:1);
-                */
+
                return ($a['foundorder'] < $b['foundorder']?-1:1);
        }
 
                        {
                                $aTokens[' '.$sWord] = ' '.$sWord;
                                $aTokens[$sWord] = $sWord;
-                               //if (!strpos($sWord,' ')) $aTokens[$sWord] = $sWord;
                        }
                }
                return $aTokens;
           GB Postcode functions
         */
 
-       function gbPostcodeAlphaDifference($s1, $s2)
-       {
-               $aValues = array(
-                               'A'=>0,
-                               'B'=>1,
-                               'D'=>2,
-                               'E'=>3,
-                               'F'=>4,
-                               'G'=>5,
-                               'H'=>6,
-                               'J'=>7,
-                               'L'=>8,
-                               'N'=>9,
-                               'O'=>10,
-                               'P'=>11,
-                               'Q'=>12,
-                               'R'=>13,
-                               'S'=>14,
-                               'T'=>15,
-                               'U'=>16,
-                               'W'=>17,
-                               'X'=>18,
-                               'Y'=>19,
-                               'Z'=>20);
-               return abs(($aValues[$s1[0]]*21+$aValues[$s1[1]]) - ($aValues[$s2[0]]*21+$aValues[$s2[1]]));
-       }
-
-
        function gbPostcodeCalculate($sPostcode, $sPostcodeSector, $sPostcodeEnd, &$oDB)
        {
                // Try an exact match on the gb_postcode table
        }
 
 
-       function usPostcodeCalculate($sPostcode, &$oDB)
-       {
-               $iZipcode = (int)$sPostcode;
-
-               // Try an exact match on the us_zippostcode table
-               $sSQL = 'select zipcode, ST_X(ST_Centroid(geometry)) as lon,ST_Y(ST_Centroid(geometry)) as lat from us_zipcode where zipcode = '.$iZipcode;
-               $aNearPostcodes = $oDB->getAll($sSQL);
-               if (PEAR::IsError($aNearPostcodes))
-               {
-                       var_dump($sSQL, $aNearPostcodes);
-                       exit;
-               }
-
-               if (!sizeof($aNearPostcodes))
-               {
-                       $sSQL = 'select zipcode,ST_X(ST_Centroid(geometry)) as lon,ST_Y(ST_Centroid(geometry)) as lat from us_zipcode where zipcode between '.($iZipcode-100).' and '.($iZipcode+100).' order by abs(zipcode - '.$iZipcode.') asc limit 5';
-                       $aNearPostcodes = $oDB->getAll($sSQL);
-                       if (PEAR::IsError($aNearPostcodes))
-                       {
-                               var_dump($sSQL, $aNearPostcodes);
-                               exit;
-                       }
-               }
-
-               if (!sizeof($aNearPostcodes))
-               {
-                       return false;
-               }
-
-               $fTotalLat = 0;
-               $fTotalLon = 0;
-               $fTotalFac = 0;
-               foreach($aNearPostcodes as $aPostcode)
-               {
-                       $iDiff = abs($aPostcode['zipcode'] - $iZipcode) + 1;
-                       if ($iDiff == 0)
-                               $fFac = 1;
-                       else
-                               $fFac = 1/($iDiff*$iDiff);
-
-                       $fTotalFac += $fFac;
-                       $fTotalLat += $aPostcode['lat'] * $fFac;
-                       $fTotalLon += $aPostcode['lon'] * $fFac;
-               }
-               if ($fTotalFac)
-               {
-                       $fLat = $fTotalLat / $fTotalFac;
-                       $fLon = $fTotalLon / $fTotalFac;
-                       return array(array('lat' => $fLat, 'lon' => $fLon, 'radius' => 0.2));
-               }
-               return false;
-
-               /*
-                  $fTotalFac is a surprisingly good indicator of accuracy
-                  $iZoom = 18 + round(log($fTotalFac,32));
-                  $iZoom = max(13,min(18,$iZoom));
-                */
-       }
-
-
        function getClassTypes()
        {
                return array(
diff --git a/settings/partitionedtags.def b/settings/partitionedtags.def
deleted file mode 100644 (file)
index ef4caf5..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-amenity airport
-amenity arts_centre
-amenity atm
-amenity auditorium
-amenity bank
-amenity bar
-amenity bench
-amenity bicycle_parking
-amenity bicycle_rental
-amenity brothel
-amenity bureau_de_change
-amenity bus_station
-amenity cafe
-amenity car_rental
-amenity car_wash
-amenity casino
-amenity cinema
-amenity clinic
-amenity club
-amenity college
-amenity community_centre
-amenity courthouse
-amenity crematorium
-amenity dentist
-amenity doctors
-amenity dormitory
-amenity drinking_water
-amenity driving_school
-amenity embassy
-amenity emergency_phone
-amenity fast_food
-amenity ferry_terminal
-amenity fire_hydrant
-amenity fire_station
-amenity fountain
-amenity fuel
-amenity grave_yard
-amenity hall
-amenity health_centre
-amenity hospital
-amenity hotel
-amenity hunting_stand
-amenity ice_cream
-amenity kindergarten
-amenity library
-amenity market
-amenity marketplace
-amenity nightclub
-amenity nursery
-amenity nursing_home
-amenity office
-amenity park
-amenity parking
-amenity pharmacy
-amenity place_of_worship
-amenity police
-amenity post_box
-amenity post_office
-amenity preschool
-amenity prison
-amenity pub
-amenity public_building
-amenity public_market
-amenity reception_area
-amenity restaurant
-amenity retirement_home
-amenity sauna
-amenity school
-amenity shelter
-amenity shop
-amenity shopping
-amenity social_club
-amenity studio
-amenity supermarket
-amenity taxi
-amenity telephone
-amenity theatre
-amenity toilets
-amenity townhall
-amenity university
-amenity veterinary
-amenity waste_basket
-amenity wifi
-amenity youth_centre
-boundary administrative
-building apartments
-building block
-building bunker
-building chapel
-building church
-building commercial
-building dormitory
-building entrance
-building faculty
-building farm
-building flats
-building garage
-building hospital
-building hotel
-building house
-building industrial
-building office
-building public
-building residential
-building retail
-building school
-building shop
-building stadium
-building store
-building terrace
-building tower
-building train_station
-building university
-highway bridleway
-highway bus_stop
-highway construction
-highway cycleway
-highway distance_marker
-highway emergency_access_point
-highway footway
-highway gate
-highway motorway_junction
-highway path
-highway pedestrian
-highway platform
-highway primary
-highway primary_link
-highway raceway
-highway road
-highway secondary
-highway secondary_link
-highway services
-highway steps
-highway tertiary
-highway track
-highway trail
-highway trunk
-highway trunk_link
-highway unsurfaced
-historic archaeological_site
-historic battlefield
-historic building
-historic castle
-historic church
-historic house
-historic icon
-historic manor
-historic memorial
-historic mine
-historic monument
-historic museum
-historic ruins
-historic tower
-historic wayside_cross
-historic wayside_shrine
-historic wreck
-landuse cemetery
-landuse commercial
-landuse construction
-landuse farm
-landuse farmland
-landuse farmyard
-landuse forest
-landuse grass
-landuse industrial
diff --git a/sql/tables-minimal.sql b/sql/tables-minimal.sql
deleted file mode 100644 (file)
index d7a2863..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-drop table import_npi_log;
-CREATE TABLE import_npi_log (
-  npiid integer,
-  batchend timestamp,
-  batchsize integer,
-  starttime timestamp,
-  endtime timestamp,
-  event text
-  );
-
-drop table IF EXISTS word;
-CREATE TABLE word (
-  word_id INTEGER,
-  word_token text,
-  word_trigram text,
-  word text,
-  class text,
-  type text,
-  country_code varchar(2),
-  search_name_count INTEGER,
-  operator TEXT
-  );
-SELECT AddGeometryColumn('word', 'location', 4326, 'GEOMETRY', 2);
-CREATE INDEX idx_word_word_id on word USING BTREE (word_id);
-CREATE INDEX idx_word_word_token on word USING BTREE (word_token);
-GRANT SELECT ON word TO "www-data" ;
-DROP SEQUENCE seq_word;
-CREATE SEQUENCE seq_word start 1;
-
-drop table IF EXISTS location_property CASCADE;
-CREATE TABLE location_property (
-  place_id BIGINT,
-  partition integer,
-  parent_place_id BIGINT,
-  housenumber TEXT,
-  postcode TEXT
-  );
-SELECT AddGeometryColumn('location_property', 'centroid', 4326, 'POINT', 2);
-
-CREATE TABLE location_property_aux () INHERITS (location_property);
-CREATE INDEX idx_location_property_aux_place_id ON location_property_aux USING BTREE (place_id);
-CREATE INDEX idx_location_property_aux_parent_place_id ON location_property_aux USING BTREE (parent_place_id);
-CREATE INDEX idx_location_property_aux_housenumber_parent_place_id ON location_property_aux USING BTREE (parent_place_id, housenumber);
-
-CREATE TABLE location_property_tiger () INHERITS (location_property);
-CREATE INDEX idx_location_property_tiger_place_id ON location_property_tiger USING BTREE (place_id);
-CREATE INDEX idx_location_property_tiger_parent_place_id ON location_property_tiger USING BTREE (parent_place_id);
-CREATE INDEX idx_location_property_tiger_housenumber_parent_place_id ON location_property_tiger USING BTREE (parent_place_id, housenumber);
-
-drop table IF EXISTS search_name_blank CASCADE;
-CREATE TABLE search_name_blank (
-  place_id BIGINT,
-  search_rank integer,
-  address_rank integer,
-  importance FLOAT,
-  country_code varchar(2),
-  name_vector integer[],
-  nameaddress_vector integer[]
-  );
-SELECT AddGeometryColumn('search_name_blank', 'centroid', 4326, 'GEOMETRY', 2);
-
-drop table IF EXISTS search_name;
-CREATE TABLE search_name () INHERITS (search_name_blank);
-CREATE INDEX search_name_name_vector_idx ON search_name USING GIN (name_vector gin__int_ops) WITH (fastupdate = off);
-CREATE INDEX searchnameplacesearch_search_nameaddress_vector_idx ON search_name USING GIN (nameaddress_vector gin__int_ops) WITH (fastupdate = off);
-CREATE INDEX idx_search_name_centroid ON search_name USING GIST (centroid);
-CREATE INDEX idx_search_name_place_id ON search_name USING BTREE (place_id);
-
-drop table IF EXISTS place_addressline;
-CREATE TABLE place_addressline (
-  place_id BIGINT,
-  address_place_id BIGINT,
-  fromarea boolean,
-  isaddress boolean,
-  distance float,
-  cached_rank_address integer
-  );
-CREATE INDEX idx_place_addressline_place_id on place_addressline USING BTREE (place_id);
-CREATE INDEX idx_place_addressline_address_place_id on place_addressline USING BTREE (address_place_id);
-
-drop table IF EXISTS place_boundingbox CASCADE;
-CREATE TABLE place_boundingbox (
-  place_id BIGINT,
-  minlat float,
-  maxlat float,
-  minlon float,
-  maxlon float,
-  numfeatures integer,
-  area float
-  );
-CREATE INDEX idx_place_boundingbox_place_id on place_boundingbox USING BTREE (place_id);
-SELECT AddGeometryColumn('place_boundingbox', 'outline', 4326, 'GEOMETRY', 2);
-CREATE INDEX idx_place_boundingbox_outline ON place_boundingbox USING GIST (outline);
-GRANT SELECT on place_boundingbox to "www-data" ;
-GRANT INSERT on place_boundingbox to "www-data" ;
-
-drop table country;
-CREATE TABLE country (
-  country_code varchar(2),
-  country_name hstore,
-  country_default_language_code varchar(2)
-  );
-SELECT AddGeometryColumn('country', 'geometry', 4326, 'POLYGON', 2);
-insert into country select iso3166::varchar(2), 'name:en'->cntry_name, null, 
-  ST_Transform(geometryn(the_geom, generate_series(1, numgeometries(the_geom))), 4326) from worldboundaries;
-CREATE INDEX idx_country_country_code ON country USING BTREE (country_code);
-CREATE INDEX idx_country_geometry ON country USING GIST (geometry);
-
-drop table placex;
-CREATE TABLE placex (
-  place_id BIGINT NOT NULL,
-  partition integer,
-  osm_type char(1),
-  osm_id INTEGER,
-  class TEXT NOT NULL,
-  type TEXT NOT NULL,
-  name HSTORE,
-  admin_level INTEGER,
-  housenumber TEXT,
-  street TEXT,
-  isin TEXT,
-  postcode TEXT,
-  country_code varchar(2),
-  extratags HSTORE,
-  parent_place_id BIGINT,
-  linked_place_id BIGINT,
-  rank_address INTEGER,
-  rank_search INTEGER,
-  importance FLOAT,
-  indexed_status INTEGER,
-  indexed_date TIMESTAMP,
-  geometry_sector INTEGER
-  );
-SELECT AddGeometryColumn('placex', 'geometry', 4326, 'GEOMETRY', 2);
-CREATE UNIQUE INDEX idx_place_id ON placex USING BTREE (place_id);
-CREATE INDEX idx_placex_osmid ON placex USING BTREE (osm_type, osm_id);
-CREATE INDEX idx_placex_rank_search ON placex USING BTREE (rank_search);
-CREATE INDEX idx_placex_rank_address ON placex USING BTREE (rank_address);
-CREATE INDEX idx_placex_geometry ON placex USING GIST (geometry);
-CREATE INDEX idx_placex_parent_place_id ON placex USING BTREE (parent_place_id) where parent_place_id IS NOT NULL;
-
-DROP SEQUENCE seq_place;
-CREATE SEQUENCE seq_place start 1;
-GRANT SELECT on placex to "www-data" ;
-GRANT UPDATE ON placex to "www-data" ;
-GRANT SELECT ON search_name to "www-data" ;
-GRANT DELETE on search_name to "www-data" ;
-GRANT INSERT on search_name to "www-data" ;
-GRANT SELECT on place_addressline to "www-data" ;
-GRANT INSERT ON place_addressline to "www-data" ;
-GRANT DELETE on place_addressline to "www-data" ;
-GRANT SELECT ON seq_word to "www-data" ;
-GRANT UPDATE ON seq_word to "www-data" ;
-GRANT INSERT ON word to "www-data" ;
-GRANT SELECT on country to "www-data" ;
diff --git a/sql/update_bigint.sql b/sql/update_bigint.sql
deleted file mode 100644 (file)
index 9cc0fff..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-\a
-\t
-\o /tmp/bigintupdate.sql
-select 'alter table "'||relname||'" alter '||attname||' type bigint;' from pg_attribute join pg_class on 
-(attrelid = oid) where attname like '%place_id%' and attnum > 0 and relkind = 'r'::"char" and atttypid = 23 
-and not relname::text ~ '^.*_[0-9]+$' order by 'alter table "'||relname||'" alter '||attname||' type 
-bigint;';
-\o
-\i /tmp/bigintupdate.sql
index a363fab35142757fef707e491c25a7dfa0504909..8c343e34a893f107cf0719cd660e684aefd4e212 100755 (executable)
@@ -24,7 +24,6 @@
                array('enable-diff-updates', '', 0, 1, 0, 0, 'bool', 'Turn on the code required to make diff updates work'),
                array('enable-debug-statements', '', 0, 1, 0, 0, 'bool', 'Include debug warning statements in pgsql commands'),
                array('ignore-errors', '', 0, 1, 0, 0, 'bool', 'Continue import even when errors in SQL are present (EXPERT)'),
-               array('create-minimal-tables', '', 0, 1, 0, 0, 'bool', 'Create minimal main tables'),
                array('create-tables', '', 0, 1, 0, 0, 'bool', 'Create main tables'),
                array('create-partition-tables', '', 0, 1, 0, 0, 'bool', 'Create required partition tables'),
                array('create-partition-functions', '', 0, 1, 0, 0, 'bool', 'Create required partition triggers'),
@@ -37,7 +36,6 @@
                array('osmosis-init', '', 0, 1, 0, 0, 'bool', 'Generate default osmosis configuration'),
                array('index', '', 0, 1, 0, 0, 'bool', 'Index the data'),
                array('index-noanalyse', '', 0, 1, 0, 0, 'bool', 'Do not perform analyse operations during index (EXPERT)'),
-               array('index-output', '', 0, 1, 1, 1, 'string', 'File to dump index information to'),
                array('create-search-indices', '', 0, 1, 0, 0, 'bool', 'Create additional indices required for search and update'),
                array('create-website', '', 0, 1, 1, 1, 'realpath', 'Create symlinks to setup web directory'),
                array('drop', '', 0, 1, 0, 0, 'bool', 'Drop tables needed for updates, making the database readonly (EXPERIMENTAL)'),
                pgsqlRunScript($sTemplate);
        }
 
-       if ($aCMDResult['create-minimal-tables'])
-       {
-               echo "Minimal Tables\n";
-               $bDidSomething = true;
-               pgsqlRunScriptFile(CONST_BasePath.'/sql/tables-minimal.sql');
-
-               $sScript = '';
-
-               // Backstop the import process - easliest possible import id
-               $sScript .= "insert into import_npi_log values (18022);\n";
-
-               $hFile = @fopen(CONST_BasePath.'/settings/partitionedtags.def', "r");
-               if (!$hFile) fail('unable to open list of partitions: '.CONST_BasePath.'/settings/partitionedtags.def');
-
-               while (($sLine = fgets($hFile, 4096)) !== false && $sLine && substr($sLine,0,1) !='#')
-               {
-                       list($sClass, $sType) = explode(' ', trim($sLine));
-                       $sScript .= "create table place_classtype_".$sClass."_".$sType." as ";
-                       $sScript .= "select place_id as place_id,geometry as centroid from placex limit 0;\n";
-
-                       $sScript .= "CREATE INDEX idx_place_classtype_".$sClass."_".$sType."_centroid ";
-                       $sScript .= "ON place_classtype_".$sClass."_".$sType." USING GIST (centroid);\n";
-
-                       $sScript .= "CREATE INDEX idx_place_classtype_".$sClass."_".$sType."_place_id ";
-                       $sScript .= "ON place_classtype_".$sClass."_".$sType." USING btree(place_id);\n";
-               }
-               fclose($hFile);
-               pgsqlRunScript($sScript);
-       }
-
        if ($aCMDResult['create-tables'] || $aCMDResult['all'])
        {
                $bDidSomething = true;
        {
                $bDidSomething = true;
                $sOutputFile = '';
-               if (isset($aCMDResult['index-output'])) $sOutputFile = ' -F '.$aCMDResult['index-output'];
                $sBaseCmd = CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$iInstances.$sOutputFile;
                passthruCheckReturn($sBaseCmd.' -R 4');
                if (!$aCMDResult['index-noanalyse']) pgsqlRunScript('ANALYSE');
index d9667ccf021afbd088d524fb6ff15bb61a64dcfa..f5dec537baca2d035669be3384b9a6b33a9de8b5 100755 (executable)
                array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
                array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
 
-               array('max-load', '', 0, 1, 1, 1, 'float', 'Maximum load average - indexing is paused if this is exceeded'),
-               array('max-blocking', '', 0, 1, 1, 1, 'int', 'Maximum blocking processes - indexing is aborted / paused if this is exceeded'),
-
                array('import-osmosis', '', 0, 1, 0, 0, 'bool', 'Import using osmosis'),
                array('import-osmosis-all', '', 0, 1, 0, 0, 'bool', 'Import using osmosis forever'),
-               array('no-npi', '', 0, 1, 0, 0, 'bool', 'Do not write npi index files'),
+               array('no-npi', '', 0, 1, 0, 0, 'bool', '(obsolate)'),
                array('no-index', '', 0, 1, 0, 0, 'bool', 'Do not index the new data'),
 
-               array('import-npi-all', '', 0, 1, 0, 0, 'bool', 'Import npi pre-indexed files'),
-
-               array('import-hourly', '', 0, 1, 0, 0, 'bool', 'Import hourly diffs'),
-               array('import-daily', '', 0, 1, 0, 0, 'bool', 'Import daily diffs'),
                array('import-all', '', 0, 1, 0, 0, 'bool', 'Import all available files'),
 
                array('import-file', '', 0, 1, 1, 1, 'realpath', 'Re-import data from an OSM file'),
                array('index', '', 0, 1, 0, 0, 'bool', 'Index'),
                array('index-rank', '', 0, 1, 1, 1, 'int', 'Rank to start indexing from'),
                array('index-instances', '', 0, 1, 1, 1, 'int', 'Number of indexing instances (threads)'),
-               array('index-estrate', '', 0, 1, 1, 1, 'int', 'Estimated indexed items per second (def:30)'),
 
                array('deduplicate', '', 0, 1, 0, 0, 'bool', 'Deduplicate tokens'),
        );
        getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
 
-       if ($aResult['import-hourly'] + $aResult['import-daily'] + isset($aResult['import-diff']) > 1)
-       {
-               showUsage($aCMDOptions, true, 'Select either import of hourly or daily');
-       }
-
        if (!isset($aResult['index-instances'])) $aResult['index-instances'] = 1;
        if (!isset($aResult['index-rank'])) $aResult['index-rank'] = 0;
 
-/*
-       // Lock to prevent multiple copies running
-       if (exec('/bin/ps uww | grep '.basename(__FILE__).' | grep -v /dev/null | grep -v grep -c', $aOutput2, $iResult) > 1)
-       {
-               fail("Copy already running\n");
-       }
-       if (!isset($aResult['max-load'])) $aResult['max-load'] = 1.9;
-       if (!isset($aResult['max-blocking'])) $aResult['max-blocking'] = 3;
-       if (getBlockingProcesses() > $aResult['max-blocking'])
-       {
-               fail("Too many blocking processes for import\n");
-       }
-*/
-
        date_default_timezone_set('Etc/UTC');
 
        $oDB =& getDB();
        }
 
 
-       $bFirst = true;
-       $bContinue = $aResult['import-all'];
-       while ($bContinue || $bFirst)
+       if (isset($aResult['import-diff']))
        {
-               $bFirst = false;
-
-               if ($aResult['import-hourly'])
+               // import diff directly (e.g. from osmosis --rri)
+               $sNextFile = $aResult['import-diff'];
+               if (!file_exists($sNextFile))
                {
-                       // Mirror the hourly diffs
-                       exec('wget --quiet --mirror -l 1 -P '.$sMirrorDir.' http://planet.openstreetmap.org/hourly');
-                       $sNextFile = $oDB->getOne('select TO_CHAR(lastimportdate,\'YYYYMMDDHH24\')||\'-\'||TO_CHAR(lastimportdate+\'1 hour\'::interval,\'YYYYMMDDHH24\')||\'.osc.gz\' from import_status');
-                       $sNextFile = $sMirrorDir.'planet.openstreetmap.org/hourly/'.$sNextFile;
-                       $sUpdateSQL = 'update import_status set lastimportdate = lastimportdate+\'1 hour\'::interval';
+                       fail("Cannot open $sNextFile\n");
                }
 
-               if ($aResult['import-daily'])
-               {
-                       // Mirror the daily diffs
-                       exec('wget --quiet --mirror -l 1 -P '.$sMirrorDir.' http://planet.openstreetmap.org/daily');
-                       $sNextFile = $oDB->getOne('select TO_CHAR(lastimportdate,\'YYYYMMDD\')||\'-\'||TO_CHAR(lastimportdate+\'1 day\'::interval,\'YYYYMMDD\')||\'.osc.gz\' from import_status');
-                       $sNextFile = $sMirrorDir.'planet.openstreetmap.org/daily/'.$sNextFile;
-                       $sUpdateSQL = 'update import_status set lastimportdate = lastimportdate::date + 1';
-               }
-               
-               if (isset($aResult['import-diff']))
+               // Import the file
+               $sCMD = $sOsm2pgsqlCmd.' '.$sNextFile;
+               echo $sCMD."\n";
+               exec($sCMD, $sJunk, $iErrorLevel);
+
+               if ($iErrorLevel)
                {
-                       // import diff directly (e.g. from osmosis --rri)
-                       $sNextFile = $aResult['import-diff'];
-                       if (!file_exists($sNextFile))
-                       {
-                               fail("Cannot open $sNextFile\n");
-                       }
-                       // Don't update the import status - we don't know what this file contains
-                       $sUpdateSQL = 'update import_status set lastimportdate = now() where false';
+                       fail("Error from osm2pgsql, $iErrorLevel\n");
                }
 
-               // Missing file is not an error - it might not be created yet
-               if (($aResult['import-hourly'] || $aResult['import-daily'] || isset($aResult['import-diff'])) && file_exists($sNextFile))
-               {
-                       // Import the file
-                       $sCMD = $sOsm2pgsqlCmd.' '.$sNextFile;
-                       echo $sCMD."\n";
-                       exec($sCMD, $sJunk, $iErrorLevel);
+               // Don't update the import status - we don't know what this file contains
+       }
 
-                       if ($iErrorLevel)
-                       {
-                               fail("Error from osm2pgsql, $iErrorLevel\n");
-                       }
-       
-                       // Move the date onwards
-                       $oDB->query($sUpdateSQL);
-               }
-               else
+       $sTemporaryFile = CONST_BasePath.'/data/osmosischange.osc';
+       $bHaveDiff = false;
+       if (isset($aResult['import-file']) && $aResult['import-file'])
+       {
+               $bHaveDiff = true;
+               $sCMD = CONST_Osmosis_Binary.' --read-xml \''.$aResult['import-file'].'\' --read-empty --derive-change --write-xml-change '.$sTemporaryFile;
+               echo $sCMD."\n";
+               exec($sCMD, $sJunk, $iErrorLevel);
+               if ($iErrorLevel)
                {
-                       $bContinue = false;
+                       fail("Error converting osm to osc, osmosis returned: $iErrorLevel\n");
                }
        }
 
-       $bModifyXML = false;
-       $sModifyXMLstr = '';
        $bUseOSMApi = isset($aResult['import-from-main-api']) && $aResult['import-from-main-api'];
-       if (isset($aResult['import-file']) && $aResult['import-file'])
-       {
-               $bModifyXML = true;
-       }
+       $sContentURL = '';
        if (isset($aResult['import-node']) && $aResult['import-node'])
        {
-               $bModifyXML = true;
                if ($bUseOSMApi)
                {
-                       $sModifyXMLstr = file_get_contents('http://www.openstreetmap.org/api/0.6/node/'.$aResult['import-node']);
+                       $sContentURL = 'http://www.openstreetmap.org/api/0.6/node/'.$aResult['import-node'];
                }
                else
                {
-                       $sModifyXMLstr = file_get_contents('http://overpass-api.de/api/interpreter?data=node('.$aResult['import-node'].');out%20meta;');
+                       $sContentURL = 'http://overpass-api.de/api/interpreter?data=node('.$aResult['import-node'].');out%20meta;';
                }
        }
        if (isset($aResult['import-way']) && $aResult['import-way'])
        {
-               $bModifyXML = true;
                if ($bUseOSMApi)
                {
-                       $sCmd = 'http://www.openstreetmap.org/api/0.6/way/'.$aResult['import-way'].'/full';
+                       $sContentURL = 'http://www.openstreetmap.org/api/0.6/way/'.$aResult['import-way'].'/full';
                }
                else
                {
-                       $sCmd = 'http://overpass-api.de/api/interpreter?data=(way('.$aResult['import-way'].');node(w););out%20meta;';
+                       $sContentURL = 'http://overpass-api.de/api/interpreter?data=(way('.$aResult['import-way'].');node(w););out%20meta;';
                }
-               $sModifyXMLstr = file_get_contents($sCmd);
        }
        if (isset($aResult['import-relation']) && $aResult['import-relation'])
        {
-               $bModifyXML = true;
                if ($bUseOSMApi)
                {
-                       $sModifyXMLstr = file_get_contents('http://www.openstreetmap.org/api/0.6/relation/'.$aResult['import-relation'].'/full');
+                       $sContentURLsModifyXMLstr = 'http://www.openstreetmap.org/api/0.6/relation/'.$aResult['import-relation'].'/full';
                }
                else
                {
-                       $sModifyXMLstr = file_get_contents('http://overpass-api.de/api/interpreter?data=((rel('.$aResult['import-relation'].');way(r);node(w));node(r));out%20meta;');
+                       $sContentURL = 'http://overpass-api.de/api/interpreter?data=((rel('.$aResult['import-relation'].');way(r);node(w));node(r));out%20meta;';
                }
        }
-       if ($bModifyXML)
+       if ($sContentURL)
        {
-               // derive change from normal osm file with osmosis
-               $sTemporaryFile = CONST_BasePath.'/data/osmosischange.osc';
-               if (isset($aResult['import-file']) && $aResult['import-file'])
+               $sModifyXMLstr = file_get_contents($sContentURL);
+               $bHaveDiff = true;
+
+               $aSpec = array(
+                       0 => array("pipe", "r"),  // stdin
+                       1 => array("pipe", "w"),  // stdout
+                       2 => array("pipe", "w") // stderr
+               );
+               $sCMD = CONST_Osmosis_Binary.' --read-xml - --read-empty --derive-change --write-xml-change '.$sTemporaryFile;
+               echo $sCMD."\n";
+               $hProc = proc_open($sCMD, $aSpec, $aPipes);
+               if (!is_resource($hProc))
                {
-                       $sCMD = CONST_Osmosis_Binary.' --read-xml \''.$aResult['import-file'].'\' --read-empty --derive-change --write-xml-change '.$sTemporaryFile;
-                       echo $sCMD."\n";
-                       exec($sCMD, $sJunk, $iErrorLevel);
-                       if ($iErrorLevel)
-                       {
-                               fail("Error converting osm to osc, osmosis returned: $iErrorLevel\n");
-                       }
+                       fail("Error converting osm to osc, osmosis failed\n");
                }
-               else
+               fwrite($aPipes[0], $sModifyXMLstr);
+               fclose($aPipes[0]);
+               $sOut = stream_get_contents($aPipes[1]);
+               if ($aResult['verbose']) echo $sOut;
+               fclose($aPipes[1]);
+               $sErrors = stream_get_contents($aPipes[2]);
+               if ($aResult['verbose']) echo $sErrors;
+               fclose($aPipes[2]);
+               if ($iError = proc_close($hProc))
                {
-                       $aSpec = array(
-                               0 => array("pipe", "r"),  // stdin
-                               1 => array("pipe", "w"),  // stdout
-                               2 => array("pipe", "w") // stderr
-                       );
-                       $sCMD = CONST_Osmosis_Binary.' --read-xml - --read-empty --derive-change --write-xml-change '.$sTemporaryFile;
-                       echo $sCMD."\n";
-                       $hProc = proc_open($sCMD, $aSpec, $aPipes);
-                       if (!is_resource($hProc))
-                       {
-                               fail("Error converting osm to osc, osmosis failed\n");
-                       }
-                       fwrite($aPipes[0], $sModifyXMLstr);
-                       fclose($aPipes[0]);
-                       $sOut = stream_get_contents($aPipes[1]);
-                       if ($aResult['verbose']) echo $sOut;
-                       fclose($aPipes[1]);
-                       $sErrors = stream_get_contents($aPipes[2]);
-                       if ($aResult['verbose']) echo $sErrors;
-                       fclose($aPipes[2]);
-                       if ($iError = proc_close($hProc))
-                       {
-                               echo "Error converting osm to osc, osmosis returned: $iError\n";
-                               echo $sOut;
-                               echo $sErrors;
-                               exit(-1);
-                       }
+                       echo $sOut;
+                       echo $sErrors;
+                       fail("Error converting osm to osc, osmosis returned: $iError\n");
                }
+       }
 
+       if ($bHaveDiff)
+       {
                // import generated change file
                $sCMD = $sOsm2pgsqlCmd.' '.$sTemporaryFile;
                echo $sCMD."\n";
        {
 
                $pgver = (float) CONST_Postgresql_Version;
-                if ($pgver < 9.3) {
+               if ($pgver < 9.3) {
                        fail("ERROR: deduplicate is only currently supported in postgresql 9.3");
                }
 
-                $oDB =& getDB();
-                $sSQL = 'select partition from country_name order by country_code';
-                $aPartitions = $oDB->getCol($sSQL);
-                if (PEAR::isError($aPartitions))
-                {
-                        fail($aPartitions->getMessage());
-                }
-                $aPartitions[] = 0;
+               $oDB =& getDB();
+               $sSQL = 'select partition from country_name order by country_code';
+               $aPartitions = $oDB->getCol($sSQL);
+               if (PEAR::isError($aPartitions))
+               {
+                       fail($aPartitions->getMessage());
+               }
+               $aPartitions[] = 0;
 
                $sSQL = "select word_token,count(*) from word where substr(word_token, 1, 1) = ' ' and class is null and type is null and country_code is null group by word_token having count(*) > 1 order by word_token";
                $aDuplicateTokens = $oDB->getAll($sSQL);
                                        exit(1);
                                }
                        }
-
                }
        }
 
                }
 
                $sImportFile = CONST_BasePath.'/data/osmosischange.osc';
-               $sOsmosisCMD = CONST_Osmosis_Binary;
                $sOsmosisConfigDirectory = CONST_InstallPath.'/settings';
-               $sCMDDownload = $sOsmosisCMD.' --read-replication-interval workingDirectory='.$sOsmosisConfigDirectory.' --simplify-change --write-xml-change '.$sImportFile;
-               $sCMDCheckReplicationLag = $sOsmosisCMD.' -q --read-replication-lag workingDirectory='.$sOsmosisConfigDirectory;
+               $sCMDDownload = CONST_Osmosis_Binary.' --read-replication-interval workingDirectory='.$sOsmosisConfigDirectory.' --simplify-change --write-xml-change '.$sImportFile;
+               $sCMDCheckReplicationLag = CONST_Osmosis_Binary.' -q --read-replication-lag workingDirectory='.$sOsmosisConfigDirectory;
                $sCMDImport = $sOsm2pgsqlCmd.' '.$sImportFile;
                $sCMDIndex = CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'];
-               if (!$aResult['no-npi']) {
-                       $sCMDIndex .= '-F ';
-               }
+
                while(true)
                {
                        $fStartTime = time();
                        $iFileSize = 1001;
 
-                       // Logic behind this is that osm2pgsql locks the database quite a bit
-                       // So it is better to import lots of small files
-                       // But indexing works most efficiently on large amounts of data
-                       // So do lots of small imports and a BIG index
-
-//                     while($aResult['import-osmosis-all'] && $iFileSize > 1000)
-//                     {
-                               if (!file_exists($sImportFile))
+                       if (!file_exists($sImportFile))
+                       {
+                               // First check if there are new updates published (except for minutelies - there's always new diffs to process)
+                               if ( CONST_Replication_Update_Interval > 60 )
                                {
-                                       // First check if there are new updates published (except for minutelies - there's always new diffs to process)
-                                       if ( CONST_Replication_Update_Interval > 60 )
-                                       {
 
-                                               unset($aReplicationLag);
-                                               exec($sCMDCheckReplicationLag, $aReplicationLag, $iErrorLevel); 
-                                               while ($iErrorLevel > 0 || $aReplicationLag[0] < 1)
+                                       unset($aReplicationLag);
+                                       exec($sCMDCheckReplicationLag, $aReplicationLag, $iErrorLevel); 
+                                       while ($iErrorLevel > 0 || $aReplicationLag[0] < 1)
+                                       {
+                                               if ($iErrorLevel)
                                                {
-                                                       if ($iErrorLevel)
-                                                       {
-                                                               echo "Error: $iErrorLevel. ";
-                                                               echo "Re-trying: ".$sCMDCheckReplicationLag." in ".CONST_Replication_Recheck_Interval." secs\n";
-                                                       }
-                                                       else
-                                                       {
-                                                               echo ".";
-                                                       }
-                                                       sleep(CONST_Replication_Recheck_Interval);
-                                                       unset($aReplicationLag);
-                                                       exec($sCMDCheckReplicationLag, $aReplicationLag, $iErrorLevel); 
+                                                       echo "Error: $iErrorLevel. ";
+                                                       echo "Re-trying: ".$sCMDCheckReplicationLag." in ".CONST_Replication_Recheck_Interval." secs\n";
                                                }
-                                               // There are new replication files - use osmosis to download the file
-                                               echo "\n".date('Y-m-d H:i:s')." Replication Delay is ".$aReplicationLag[0]."\n";
-                                       }
-                                       $fStartTime = time();
-                                       $fCMDStartTime = time();
-                                       echo $sCMDDownload."\n";
-                                       exec($sCMDDownload, $sJunk, $iErrorLevel);
-                                       while ($iErrorLevel > 0)
-                                       {
-                                               echo "Error: $iErrorLevel\n";
-                                               sleep(60);
-                                               echo 'Re-trying: '.$sCMDDownload."\n";
-                                               exec($sCMDDownload, $sJunk, $iErrorLevel);
+                                               else
+                                               {
+                                                       echo ".";
+                                               }
+                                               sleep(CONST_Replication_Recheck_Interval);
+                                               unset($aReplicationLag);
+                                               exec($sCMDCheckReplicationLag, $aReplicationLag, $iErrorLevel); 
                                        }
-                                       $iFileSize = filesize($sImportFile);
-                                       $sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory);
-                                       $sSQL = "INSERT INTO import_osmosis_log values ('$sBatchEnd',$iFileSize,'".date('Y-m-d H:i:s',$fCMDStartTime)."','".date('Y-m-d H:i:s')."','osmosis')";
-                                       var_Dump($sSQL);
-                                       $oDB->query($sSQL);
-                                       echo date('Y-m-d H:i:s')." Completed osmosis step for $sBatchEnd in ".round((time()-$fCMDStartTime)/60,2)." minutes\n";
+                                       // There are new replication files - use osmosis to download the file
+                                       echo "\n".date('Y-m-d H:i:s')." Replication Delay is ".$aReplicationLag[0]."\n";
                                }
-
-                               $iFileSize = filesize($sImportFile);
-                               $sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory);
-               
-                               // Import the file
+                               $fStartTime = time();
                                $fCMDStartTime = time();
-                               echo $sCMDImport."\n";
-                               exec($sCMDImport, $sJunk, $iErrorLevel);
-                               if ($iErrorLevel)
+                               echo $sCMDDownload."\n";
+                               exec($sCMDDownload, $sJunk, $iErrorLevel);
+                               while ($iErrorLevel > 0)
                                {
                                        echo "Error: $iErrorLevel\n";
-                                       exit($iErrorLevel);
+                                       sleep(60);
+                                       echo 'Re-trying: '.$sCMDDownload."\n";
+                                       exec($sCMDDownload, $sJunk, $iErrorLevel);
                                }
-                               $sSQL = "INSERT INTO import_osmosis_log values ('$sBatchEnd',$iFileSize,'".date('Y-m-d H:i:s',$fCMDStartTime)."','".date('Y-m-d H:i:s')."','osm2pgsql')";
+                               $iFileSize = filesize($sImportFile);
+                               $sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory);
+                               $sSQL = "INSERT INTO import_osmosis_log values ('$sBatchEnd',$iFileSize,'".date('Y-m-d H:i:s',$fCMDStartTime)."','".date('Y-m-d H:i:s')."','osmosis')";
                                var_Dump($sSQL);
                                $oDB->query($sSQL);
-                               echo date('Y-m-d H:i:s')." Completed osm2pgsql step for $sBatchEnd in ".round((time()-$fCMDStartTime)/60,2)." minutes\n";
+                               echo date('Y-m-d H:i:s')." Completed osmosis step for $sBatchEnd in ".round((time()-$fCMDStartTime)/60,2)." minutes\n";
+                       }
 
-                               // Archive for debug?
-                               unlink($sImportFile);
-//                     }
+                       $iFileSize = filesize($sImportFile);
+                       $sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory);
+       
+                       // Import the file
+                       $fCMDStartTime = time();
+                       echo $sCMDImport."\n";
+                       exec($sCMDImport, $sJunk, $iErrorLevel);
+                       if ($iErrorLevel)
+                       {
+                               echo "Error: $iErrorLevel\n";
+                               exit($iErrorLevel);
+                       }
+                       $sSQL = "INSERT INTO import_osmosis_log values ('$sBatchEnd',$iFileSize,'".date('Y-m-d H:i:s',$fCMDStartTime)."','".date('Y-m-d H:i:s')."','osm2pgsql')";
+                       var_Dump($sSQL);
+                       $oDB->query($sSQL);
+                       echo date('Y-m-d H:i:s')." Completed osm2pgsql step for $sBatchEnd in ".round((time()-$fCMDStartTime)/60,2)." minutes\n";
+
+                       // Archive for debug?
+                       unlink($sImportFile);
 
                        $sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory);
 
                        $sThisIndexCmd = $sCMDIndex;
                        $fCMDStartTime = time();
 
-                       if (!$aResult['no-npi'])
-                       {
-                               $iFileID = $oDB->getOne('select nextval(\'file\')');
-                               if (PEAR::isError($iFileID))
-                               {
-                                       echo $iFileID->getMessage()."\n";
-                                       exit(-1);
-                               } 
-                               $sFileDir = CONST_BasePath.'/export/diff/';
-                               $sFileDir .= str_pad(floor($iFileID/1000000), 3, '0', STR_PAD_LEFT);
-                               $sFileDir .= '/'.str_pad(floor($iFileID/1000) % 1000, 3, '0', STR_PAD_LEFT);
-
-                               if (!is_dir($sFileDir)) mkdir($sFileDir, 0777, true);
-                               $sThisIndexCmd .= $sFileDir;
-                               $sThisIndexCmd .= '/'.str_pad($iFileID % 1000, 3, '0', STR_PAD_LEFT);
-                               $sThisIndexCmd .= ".npi.out";
-
-                               preg_match('#^([0-9]{4})-([0-9]{2})-([0-9]{2})#', $sBatchEnd, $aBatchMatch);
-                               $sFileDir = CONST_BasePath.'/export/index/';
-                               $sFileDir .= $aBatchMatch[1].'/'.$aBatchMatch[2];
-
-                               if (!is_dir($sFileDir)) mkdir($sFileDir, 0777, true);
-                               file_put_contents($sFileDir.'/'.$aBatchMatch[3].'.idx', "$sBatchEnd\t$iFileID\n", FILE_APPEND);
-                       }
-
                        if (!$aResult['no-index'])
                        {
                                echo "$sThisIndexCmd\n";
                                        echo "Error: $iErrorLevel\n";
                                        exit($iErrorLevel);
                                }
-
-                               if (!$aResult['no-npi'])
-                               {
-                                       $sFileDir = CONST_BasePath.'/export/diff/';
-                                       $sFileDir .= str_pad(floor($iFileID/1000000), 3, '0', STR_PAD_LEFT);
-                                       $sFileDir .= '/'.str_pad(floor($iFileID/1000) % 1000, 3, '0', STR_PAD_LEFT);
-
-                                       $sThisIndexCmd = 'bzip2 -z9 '.$sFileDir.'/'.str_pad($iFileID % 1000, 3, '0', STR_PAD_LEFT).".npi.out";
-                                       echo "$sThisIndexCmd\n";
-                                       exec($sThisIndexCmd, $sJunk, $iErrorLevel);
-                                       if ($iErrorLevel)
-                                       {
-                                               echo "Error: $iErrorLevel\n";
-                                               exit($iErrorLevel);
-                                       }
-
-                                       rename($sFileDir.'/'.str_pad($iFileID % 1000, 3, '0', STR_PAD_LEFT).".npi.out.bz2",
-                                               $sFileDir.'/'.str_pad($iFileID % 1000, 3, '0', STR_PAD_LEFT).".npi.bz2");
-                               }
                        }
 
                        $sSQL = "INSERT INTO import_osmosis_log values ('$sBatchEnd',$iFileSize,'".date('Y-m-d H:i:s',$fCMDStartTime)."','".date('Y-m-d H:i:s')."','index')";
                        echo date('Y-m-d H:i:s')." Sleeping $iSleep seconds\n";
                        sleep($iSleep);
                }
-
-       }
-
-       if ($aResult['import-npi-all'])
-       {
-               $iNPIID = $oDB->getOne('select max(npiid) from import_npi_log');
-               if (PEAR::isError($iNPIID))
-               {
-                       var_dump($iNPIID);
-                       exit(1);
-               }
-               $sConfigDirectory = CONST_InstallPath.'/settings';
-               $sCMDImportTemplate = CONST_InstallPath.'/nominatim/nominatim -d gazetteer -P 5433 -I -T '.CONST_BasePath.'/settings/partitionedtags.def -F ';
-               while(true)
-               {
-                       $fStartTime = time();
-
-                       $iNPIID++;
-
-                       $sImportFile = CONST_BasePath.'/export/diff/';
-                       $sImportFile .= str_pad(floor($iNPIID/1000000), 3, '0', STR_PAD_LEFT);
-                       $sImportFile .= '/'.str_pad(floor($iNPIID/1000) % 1000, 3, '0', STR_PAD_LEFT);
-                       $sImportFile .= '/'.str_pad($iNPIID % 1000, 3, '0', STR_PAD_LEFT);
-                       $sImportFile .= ".npi";
-                       while(!file_exists($sImportFile) && !file_exists($sImportFile.'.bz2'))
-                       {
-                               echo "sleep (waiting for $sImportFile)\n";
-                               sleep(10);
-                       }
-                       if (file_exists($sImportFile.'.bz2')) $sImportFile .= '.bz2';
-
-                       $iFileSize = filesize($sImportFile);
-               
-                       // Import the file
-                       $fCMDStartTime = time();
-                       $sCMDImport = $sCMDImportTemplate . $sImportFile;
-                       echo $sCMDImport."\n";
-                       exec($sCMDImport, $sJunk, $iErrorLevel);
-                       if ($iErrorLevel)
-                       {
-                               fail("Error: $iErrorLevel\n");
-                       }
-                       $sBatchEnd = $iNPIID;
-                       echo "Completed for $sBatchEnd in ".round((time()-$fCMDStartTime)/60,2)." minutes\n";
-                       $sSQL = "INSERT INTO import_npi_log values ($iNPIID, null, $iFileSize,'".date('Y-m-d H:i:s',$fCMDStartTime)."','".date('Y-m-d H:i:s')."','import')";
-                       var_Dump($sSQL);
-                       $oDB->query($sSQL);
-               }
-               
        }
 
        function getosmosistimestamp($sOsmosisConfigDirectory)