]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/nominatim.c
small typos and wording in the API docs
[nominatim.git] / nominatim / nominatim.c
index 72604bb6ad06707f485f52c0631a77ab691585c8..1771be2e2ced6df8a18bdb11d8ff31390768c034 100644 (file)
@@ -75,6 +75,8 @@ static void long_usage(char *arg0)
     fprintf(stderr, "   -i|--index\t\tIndex the database.\n");
     fprintf(stderr, "   -e|--export\t\tGenerate a structured file.\n");
     fprintf(stderr, "   -I|--import\t\tImport a structured file.\n");
+    fprintf(stderr, "   -r|--minrank\t\tMinimum / starting rank. (default: 0))\n");
+    fprintf(stderr, "   -R|--maxrank\t\tMaximum / finishing rank. (default: 30)\n");
     fprintf(stderr, "   -t|--threads\t\tNumber of threads to create for indexing.\n");
     fprintf(stderr, "   -F|--file\t\tfile to use (either to import or export).\n");
     fprintf(stderr, "   -T|--tagfile\t\tfile containing 'special' tag pairs\n");
@@ -83,7 +85,8 @@ static void long_usage(char *arg0)
     fprintf(stderr, "   -v|--verbose\t\tVerbose output.\n");
     fprintf(stderr, "\n");
 
-    if (sizeof(int*) == 4) {
+    if (sizeof(int*) == 4)
+    {
         fprintf(stderr, "\n\nYou are running this on 32bit system - this will not work\n");
     }
 }
@@ -101,6 +104,8 @@ int main(int argc, char *argv[])
     int index = 0;
     int export = 0;
     int import = 0;
+    int minrank = 0;
+    int maxrank = 30;
     int threads = 1;
     const char *file = NULL;
     const char *tagsfile = "partitionedtags.def";
@@ -110,19 +115,13 @@ int main(int argc, char *argv[])
 
     PGconn *conn;
 
-    fprintf(stderr, "nominatim SVN version %s\n\n", VERSION);
-
-    if (sizeof(int*) == 4) {
-        fprintf(stderr, "\n!! You are running this on 32bit system, so at most\n");
-        fprintf(stderr, "!! 3GB of RAM can be used. If you encounter unexpected\n");
-        fprintf(stderr, "!! exceptions during import, you should try running in slim\n");
-        fprintf(stderr, "!! mode using parameter -s.\n");
-        exit(EXIT_FAILURE);
-    }
+    fprintf(stderr, "nominatim version %s\n\n", NOMINATIM_VERSION);
 
-    while (1) {
+    while (1)
+    {
         int c, option_index = 0;
-        static struct option long_options[] = {
+        static struct option long_options[] =
+        {
             {"help",     0, 0, 'h'},
 
             {"verbose",  0, 0, 'v'},
@@ -140,63 +139,104 @@ int main(int argc, char *argv[])
             {"file",  1, 0, 'F'},
             {"tagsfile",  1, 0, 'T'},
 
+            {"minrank",  1, 0, 'r'},
+            {"maxrank",  1, 0, 'R'},
+
+
 
             {0, 0, 0, 0}
         };
 
-        c = getopt_long(argc, argv, "vhd:U:WH:P:ieIt:F:T:", long_options, &option_index);
+        c = getopt_long(argc, argv, "vhd:U:WH:P:ieIt:F:T:r:R:", long_options, &option_index);
         if (c == -1)
             break;
 
-        switch (c) {
-            case 'v': verbose=1;  break;
-            case 'd': db=optarg;  break;
-            case 'U': username=optarg; break;
-            case 'W': pass_prompt=1; break;
-            case 'H': host=optarg; break;
-            case 'P': port=optarg; break;
-            case 'h': long_usage_bool=1; break;
-            case 'i': index=1; break;
-            case 'e': export=1; break;
-            case 'I': import=1; break;
-            case 't': threads=atoi(optarg); break;
-            case 'F': file=optarg; break;
-            case 'T': tagsfile=optarg; break;
-            case '?':
-            default:
-                short_usage(argv[0]);
-                exit(EXIT_FAILURE);
+        switch (c)
+        {
+        case 'v':
+            verbose=1;
+            break;
+        case 'd':
+            db=optarg;
+            break;
+        case 'U':
+            username=optarg;
+            break;
+        case 'W':
+            pass_prompt=1;
+            break;
+        case 'H':
+            host=optarg;
+            break;
+        case 'P':
+            port=optarg;
+            break;
+        case 'h':
+            long_usage_bool=1;
+            break;
+        case 'i':
+            index=1;
+            break;
+        case 'e':
+            export=1;
+            break;
+        case 'I':
+            import=1;
+            break;
+        case 't':
+            threads=atoi(optarg);
+            break;
+        case 'r':
+            minrank=atoi(optarg);
+            break;
+        case 'R':
+            maxrank=atoi(optarg);
+            break;
+        case 'F':
+            file=optarg;
+            break;
+        case 'T':
+            tagsfile=optarg;
+            break;
+        case '?':
+        default:
+            short_usage(argv[0]);
+            exit(EXIT_FAILURE);
         }
     }
 
-    if (long_usage_bool) {
+    if (long_usage_bool)
+    {
         long_usage(argv[0]);
         exit(EXIT_FAILURE);
     }
 
     if (threads < 1) threads = 1;
 
-/*
-    if (argc == optind) {  // No non-switch arguments
-        short_usage(argv[0]);
-        exit(EXIT_FAILURE);
-    }
-*/
-    if (index && import) {
+    /*
+        if (argc == optind) {  // No non-switch arguments
+            short_usage(argv[0]);
+            exit(EXIT_FAILURE);
+        }
+    */
+    if (index && import)
+    {
         fprintf(stderr, "Error: --index and --import options can not be used on the same database!\n");
         exit(EXIT_FAILURE);
     }
 
     if (pass_prompt)
         password = simple_prompt("Password:", 100, 0);
-    else {
+    else
+    {
         password = getenv("PGPASS");
     }
 
     // Test the database connection
     conninfo = build_conninfo(db, username, password, host, port);
     conn = PQconnectdb(conninfo);
-    if (PQstatus(conn) != CONNECTION_OK) {
+    if (PQstatus(conn) != CONNECTION_OK)
+    {
         fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(conn));
         exit(EXIT_FAILURE);
     }
@@ -204,11 +244,11 @@ int main(int argc, char *argv[])
 
     if (!index && !export && !import)
     {
-       fprintf(stderr, "Please select index, export or import.\n");
+        fprintf(stderr, "Please select index, export or import.\n");
         exit(EXIT_FAILURE);
     }
-    if (index) nominatim_index(0, 30, threads, conninfo, file);
-    if (export) nominatim_export(0, 30, conninfo, file);
+    if (index) nominatim_index(minrank, maxrank, threads, conninfo, file);
+    if (export) nominatim_export(minrank, maxrank, conninfo, file);
     if (import) nominatim_import(conninfo, tagsfile, file);
 
     return 0;