]> git.openstreetmap.org Git - nominatim.git/commitdiff
default path fixes
authorBrian Quinion <openstreetmap@brian.quinion.co.uk>
Mon, 25 Oct 2010 12:22:22 +0000 (12:22 +0000)
committerBrian Quinion <openstreetmap@brian.quinion.co.uk>
Mon, 25 Oct 2010 12:22:22 +0000 (12:22 +0000)
lib/lib.php
nominatim/postgresql.h
utils/setup.php

index e384949e7bcb8d503be6f27831730e951ab61b32..8a1fb902cbbdba574010f5f6a6d8bb069ec4ca2d 100644 (file)
@@ -4,7 +4,7 @@
        {
                if (!$sUserError) $sUserError = $sError;
                log('ERROR:'.$sError);
-               echo $sUserError;
+               echo $sUserError."\n";
                exit;
        }
 
index ebece6106c065ef391284a96604cd2ed739bcdd6..6a14e94e6ea56d33e2fd038979b677b0be601e04 100644 (file)
@@ -7,6 +7,8 @@
 #define PG_OID_INT8                    20
 #define PG_OID_INT4                    23
 
+#include <byteswap.h>
+
 #if __BYTE_ORDER == __BIG_ENDIAN
 #define PGint16(x)     (x)
 #define PGint32(x)     (x)
index 397eaa1b1fb981e0cb4ae1f661b3a158dbc5c4bc..26179d04bc51666c1bd26e5057f6a5e2605145c9 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php -Cq
 <?php
 
-       require_once('../lib/init-cmd.php');
+       require_once(dirname(dirname(__FILE__)).'/lib/init-cmd.php');
        ini_set('memory_limit', '800M');
 
        $aCMDOptions = array(
                array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
                array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
 
+               array('create-db', '', 0, 1, 0, 0, 'bool', 'Build a blank nominatim db'),
+               array('load-data', '', 0, 1, 0, 0, 'realpath', 'Import a osm file'),
                array('create-partitions', '', 0, 1, 0, 0, 'bool', 'Create required partition tables and triggers'),
        );
        getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
 
+       if ($aCMDResult['create-db'])
+       {
+               // TODO: path detection, detection memory, etc.
+               passthru('createdb nominatim');
+               passthru('createlang plpgsql nominatim');
+               passthru('psql -f /mqdata/mapquest/postgres-9.0.1-server/share/contrib/_int.sql nominatim');
+               passthru('psql -f /mqdata/mapquest/postgres-9.0.1-server/share/contrib/hstore.sql nominatim');
+               passthru('psql -f /mqdata/mapquest/postgres-9.0.1-server/share/contrib/postgis-1.5/postgis.sql nominatim');
+               passthru('psql -f /mqdata/mapquest/postgres-9.0.1-server/share/contrib/postgis-1.5/spatial_ref_sys.sql nominatim');
+       }
+
+       if ($aCMDResult['load-data'])
+       {
+               passthru(CONST_BasePath.'/osm2pgsql -lsc -O gazetteer -C 10000 --hstore -d nominatim '.$aCMDResult['load-data']);
+       }
+
        if ($aCMDResult['create-partitions'])
        {
                $sSQL = 'select distinct country_code from country_name order by country_code';
                $aPartitions = $oDB->getCol($sSQL);
+               if (PEAR::isError($aPartitions))
+               {
+                       fail($aPartitions->getMessage());
+               }
                $aPartitions[] = 'none';
 
                $sTemplate = file_get_contents(CONST_BasePath.'/sql/partitions.src.sql');
@@ -32,6 +54,7 @@
                        $sTemplate = str_replace($aMatch[0], $sResult, $sTemplate);
                }
                echo $sTemplate;
+               exit;
        }
 
        showUsage($aCMDOptions, true);