mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
consolidate cli interface to single tool
This commit is contained in:
@@ -112,17 +112,8 @@ if (BUILD_IMPORTER)
|
|||||||
${PROJECT_BINARY_DIR}/utils/${script_source})
|
${PROJECT_BINARY_DIR}/utils/${script_source})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set(NOMINATIM_TOOLS
|
configure_file(${PROJECT_SOURCE_DIR}/cmake/tool.tmpl
|
||||||
setup
|
${PROJECT_BINARY_DIR}/nominatim)
|
||||||
update
|
|
||||||
admin
|
|
||||||
query
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach (tool_name ${NOMINATIM_TOOLS})
|
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/tool.tmpl
|
|
||||||
${PROJECT_BINARY_DIR}/nominatim-${tool_name})
|
|
||||||
endforeach()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import sys
|
|||||||
|
|
||||||
sys.path.insert(1, '@CMAKE_SOURCE_DIR@')
|
sys.path.insert(1, '@CMAKE_SOURCE_DIR@')
|
||||||
|
|
||||||
from nominatim import tools
|
from nominatim import cli
|
||||||
|
|
||||||
tools.@tool_name@(module_dir='@CMAKE_BINARY_DIR@/module',
|
cli.nominatim(module_dir='@CMAKE_BINARY_DIR@/module',
|
||||||
osm2pgsql_path='@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql',
|
osm2pgsql_path='@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql',
|
||||||
phplib_dir='@CMAKE_SOURCE_DIR@/lib',
|
phplib_dir='@CMAKE_SOURCE_DIR@/lib',
|
||||||
data_dir='@CMAKE_SOURCE_DIR@')
|
data_dir='@CMAKE_SOURCE_DIR@')
|
||||||
|
|||||||
@@ -66,14 +66,18 @@ class CommandlineParser:
|
|||||||
|
|
||||||
class SetupAll:
|
class SetupAll:
|
||||||
"""\
|
"""\
|
||||||
Create a new database and import data from an OSM file.
|
Create a new Nominatim database from an OSM file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_args(parser):
|
def add_args(parser):
|
||||||
group = parser.add_argument_group('Required arguments')
|
group_name = parser.add_argument_group('Required arguments')
|
||||||
group.add_argument('--osm-file', required=True,
|
group = group_name.add_mutually_exclusive_group(required=True)
|
||||||
|
group.add_argument('--osm-file',
|
||||||
help='OSM file to be imported.')
|
help='OSM file to be imported.')
|
||||||
|
group.add_argument('--continue', nargs=1,
|
||||||
|
choices=['load-data', 'indexing', 'db-postprocess'],
|
||||||
|
help='Continue an import that was interrupted')
|
||||||
group = parser.add_argument_group('Optional arguments')
|
group = parser.add_argument_group('Optional arguments')
|
||||||
group.add_argument('--osm2pgsql-cache', metavar='SIZE', type=int,
|
group.add_argument('--osm2pgsql-cache', metavar='SIZE', type=int,
|
||||||
help='Size of cache to be used by osm2pgsql (in MB)')
|
help='Size of cache to be used by osm2pgsql (in MB)')
|
||||||
@@ -98,28 +102,12 @@ class SetupAll:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run(args):
|
def run(args):
|
||||||
print("TODO: setup all", args)
|
print("TODO: ./utils/setup.php", args)
|
||||||
|
|
||||||
|
|
||||||
class SetupContinue:
|
class SetupFreeze:
|
||||||
"""\
|
"""\
|
||||||
Continue an import previously started with the `all` command.
|
Make database read-only.
|
||||||
"""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def add_args(parser):
|
|
||||||
group = parser.add_argument_group('Required aruments')
|
|
||||||
group.add_argument('pickup-point', nargs=1,
|
|
||||||
choices=['load-data', 'indexing', 'db-postprocess'],
|
|
||||||
help='Position where to continue the import')
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def run(args):
|
|
||||||
print("TODO: setup continue", args)
|
|
||||||
|
|
||||||
class SetupDrop:
|
|
||||||
"""\
|
|
||||||
Remove all tables only needed for keeping data up-to-date.
|
|
||||||
|
|
||||||
About half of data in the Nominatim database is kept only to be able to
|
About half of data in the Nominatim database is kept only to be able to
|
||||||
keep the data up-to-date with new changes made in OpenStreetMap. This
|
keep the data up-to-date with new changes made in OpenStreetMap. This
|
||||||
@@ -137,27 +125,10 @@ class SetupDrop:
|
|||||||
def run(args):
|
def run(args):
|
||||||
print("TODO: setup drop", args)
|
print("TODO: setup drop", args)
|
||||||
|
|
||||||
class SetupAddExternal:
|
|
||||||
"""\
|
|
||||||
Add additional external data to the Nominatim database.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def add_args(parser):
|
|
||||||
group = parser.add_argument_group('Data sources')
|
|
||||||
group.add_argument('--tiger-data', metavar='DIR',
|
|
||||||
help='Add housenumbers from the US TIGER census database.')
|
|
||||||
group.add_argument('--wiki-data',
|
|
||||||
help='Add or update Wikipedia/data importance numbers.')
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def run(args):
|
|
||||||
print("TODO: setup extern", args)
|
|
||||||
|
|
||||||
|
|
||||||
class SetupSpecialPhrases:
|
class SetupSpecialPhrases:
|
||||||
"""\
|
"""\
|
||||||
Create special phrases.
|
Maintain special phrases.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -176,23 +147,6 @@ class SetupSpecialPhrases:
|
|||||||
print("./utils/specialphrases.php --from-wiki", args)
|
print("./utils/specialphrases.php --from-wiki", args)
|
||||||
|
|
||||||
|
|
||||||
class UpdateStatus:
|
|
||||||
"""\
|
|
||||||
Check for the status of the data.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def add_args(parser):
|
|
||||||
group = parser.add_argument_group('Additional arguments')
|
|
||||||
group.add_argument('--check-for-updates', action='store_true',
|
|
||||||
help='Check if new updates are available')
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def run(args):
|
|
||||||
print('./utils/update.php --check-for-updates', args)
|
|
||||||
|
|
||||||
|
|
||||||
class UpdateReplication:
|
class UpdateReplication:
|
||||||
"""\
|
"""\
|
||||||
Update the database using an online replication service.
|
Update the database using an online replication service.
|
||||||
@@ -208,6 +162,8 @@ class UpdateReplication:
|
|||||||
help="""Do not update the trigger function to
|
help="""Do not update the trigger function to
|
||||||
support differential updates.""")
|
support differential updates.""")
|
||||||
group = parser.add_argument_group('Arguments for updates')
|
group = parser.add_argument_group('Arguments for updates')
|
||||||
|
group.add_argument('--check-for-updates', action='store_true',
|
||||||
|
help='Check if new updates are available and exit')
|
||||||
group.add_argument('--once', action='store_true',
|
group.add_argument('--once', action='store_true',
|
||||||
help="""Download and apply updates only once. When
|
help="""Download and apply updates only once. When
|
||||||
not set, updates are continuously applied""")
|
not set, updates are continuously applied""")
|
||||||
@@ -223,7 +179,7 @@ class UpdateReplication:
|
|||||||
print('./utils/update.php --import-osmosis(-all)', args)
|
print('./utils/update.php --import-osmosis(-all)', args)
|
||||||
|
|
||||||
|
|
||||||
class UpdateImport:
|
class UpdateAddData:
|
||||||
"""\
|
"""\
|
||||||
Add additional data from a file or an online source.
|
Add additional data from a file or an online source.
|
||||||
|
|
||||||
@@ -245,6 +201,8 @@ class UpdateImport:
|
|||||||
help='Import a single way from the API')
|
help='Import a single way from the API')
|
||||||
group.add_argument('--relation', metavar='ID', type=int,
|
group.add_argument('--relation', metavar='ID', type=int,
|
||||||
help='Import a single relation from the API')
|
help='Import a single relation from the API')
|
||||||
|
group.add_argument('--tiger-data', metavar='DIR',
|
||||||
|
help='Add housenumbers from the US TIGER census database.')
|
||||||
group = parser.add_argument_group('Extra arguments')
|
group = parser.add_argument_group('Extra arguments')
|
||||||
group.add_argument('--use-main-api', action='store_true',
|
group.add_argument('--use-main-api', action='store_true',
|
||||||
help='Use OSM API instead of Overpass to download objects')
|
help='Use OSM API instead of Overpass to download objects')
|
||||||
@@ -286,49 +244,24 @@ class UpdateRefresh:
|
|||||||
help='Reimport address level configuration')
|
help='Reimport address level configuration')
|
||||||
group.add_argument('--importance', action='store_true',
|
group.add_argument('--importance', action='store_true',
|
||||||
help='Recompute place importances')
|
help='Recompute place importances')
|
||||||
|
group.add_argument('--functions', action='store_true',
|
||||||
|
help='Update the PL/pgSQL functions in the database')
|
||||||
|
group.add_argument('--wiki-data',
|
||||||
|
help='Update Wikipedia/data importance numbers.')
|
||||||
|
group.add_argument('--website', action='store_true',
|
||||||
|
help='Refresh the directory that serves the scripts for the web API')
|
||||||
|
group = parser.add_argument_group('Arguments for function refresh')
|
||||||
|
group.add_argument('--no-diff-updates', action='store_false', dest='diffs',
|
||||||
|
help='Do not enable code for propagating updates')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run(args):
|
def run(args):
|
||||||
print('./utils/update.php', args)
|
print('./utils/update.php', args)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AdminCreateFunctions:
|
|
||||||
"""\
|
|
||||||
Update the PL/pgSQL functions in the database.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def add_args(parser):
|
|
||||||
group = parser.add_argument_group('Expert arguments')
|
|
||||||
group.add_argument('--no-diff-updates', action='store_false', dest='diffs',
|
|
||||||
help='Do not enable code for propagating updates')
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def run(args):
|
|
||||||
print("TODO: ./utils/setup.php --create-functions --enable-diff-updates "
|
|
||||||
"--create-partition-functions", args)
|
|
||||||
|
|
||||||
|
|
||||||
class AdminSetupWebsite:
|
|
||||||
"""\
|
|
||||||
Setup the directory that serves the scripts for the web API.
|
|
||||||
|
|
||||||
The directory is created under `/website` in the project directory.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def add_args(parser):
|
|
||||||
pass # No options
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def run(args):
|
|
||||||
print("TODO: ./utils/setup.php --setup-website", args)
|
|
||||||
|
|
||||||
|
|
||||||
class AdminCheckDatabase:
|
class AdminCheckDatabase:
|
||||||
"""\
|
"""\
|
||||||
Check that the Nominatim database is complete and operational.
|
Check that the database is complete and operational.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -342,7 +275,7 @@ class AdminCheckDatabase:
|
|||||||
|
|
||||||
class AdminWarm:
|
class AdminWarm:
|
||||||
"""\
|
"""\
|
||||||
Pre-warm caches of the database for search and reverse queries.
|
Warm database caches for search and reverse queries.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -360,9 +293,9 @@ class AdminWarm:
|
|||||||
print("TODO: ./utils/warm.php", args)
|
print("TODO: ./utils/warm.php", args)
|
||||||
|
|
||||||
|
|
||||||
class AdminExport:
|
class QueryExport:
|
||||||
"""\
|
"""\
|
||||||
Export addresses as CSV file from a Nominatim database
|
Export addresses as CSV file from a Nominatim database.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -399,53 +332,44 @@ class AdminExport:
|
|||||||
def run(args):
|
def run(args):
|
||||||
print("TODO: ./utils/export.php", args)
|
print("TODO: ./utils/export.php", args)
|
||||||
|
|
||||||
def setup(**kwargs):
|
|
||||||
|
class QueryTodo:
|
||||||
"""\
|
"""\
|
||||||
Commands for creating a Nominatim database and importing data.
|
Todo
|
||||||
"""
|
"""
|
||||||
parser = CommandlineParser('nominatim-setup', setup.__doc__)
|
@staticmethod
|
||||||
|
def add_args(parser):
|
||||||
|
pass
|
||||||
|
|
||||||
parser.add_subcommand('all', SetupAll)
|
def run(args):
|
||||||
parser.add_subcommand('continue', SetupContinue())
|
print("TODO: searching")
|
||||||
parser.add_subcommand('drop', SetupDrop())
|
|
||||||
parser.add_subcommand('add-external', SetupAddExternal())
|
|
||||||
parser.add_subcommand('special-phrases', SetupSpecialPhrases())
|
|
||||||
parser.run()
|
|
||||||
|
|
||||||
def update(**kwargs):
|
|
||||||
|
def nominatim(**kwargs):
|
||||||
"""\
|
"""\
|
||||||
Commands for updating data inside a Nominatim database.
|
Command-line tools for importing, updating, administrating and
|
||||||
|
querying the Nominatim database.
|
||||||
"""
|
"""
|
||||||
parser = CommandlineParser('nominatim-update', update.__doc__)
|
parser = CommandlineParser('nominatim', nominatim.__doc__)
|
||||||
|
|
||||||
parser.add_subcommand('status', UpdateStatus())
|
parser.add_subcommand('import', SetupAll)
|
||||||
parser.add_subcommand('replication', UpdateReplication())
|
parser.add_subcommand('freeze', SetupFreeze)
|
||||||
parser.add_subcommand('import', UpdateImport())
|
parser.add_subcommand('replication', UpdateReplication)
|
||||||
parser.add_subcommand('index', UpdateIndex())
|
|
||||||
parser.add_subcommand('refresh', UpdateRefresh())
|
parser.add_subcommand('check-database', AdminCheckDatabase)
|
||||||
|
parser.add_subcommand('warm', AdminWarm)
|
||||||
parser.run()
|
|
||||||
|
parser.add_subcommand('special-phrases', SetupSpecialPhrases)
|
||||||
def admin(**kwargs):
|
|
||||||
"""\
|
parser.add_subcommand('add-data', UpdateAddData)
|
||||||
Commands for inspecting and maintaining a Nomiantim database.
|
parser.add_subcommand('index', UpdateIndex)
|
||||||
"""
|
parser.add_subcommand('refresh', UpdateRefresh)
|
||||||
parser = CommandlineParser('nominatim-admin', admin.__doc__)
|
|
||||||
|
parser.add_subcommand('export', QueryExport)
|
||||||
parser.add_subcommand('create-functions', AdminCreateFunctions())
|
parser.add_subcommand('search', QueryTodo)
|
||||||
parser.add_subcommand('setup-website', AdminSetupWebsite())
|
parser.add_subcommand('reverse', QueryTodo)
|
||||||
parser.add_subcommand('check-database', AdminCheckDatabase())
|
parser.add_subcommand('lookup', QueryTodo)
|
||||||
parser.add_subcommand('warm', AdminWarm())
|
parser.add_subcommand('details', QueryTodo)
|
||||||
parser.add_subcommand('export', AdminExport())
|
parser.add_subcommand('status', QueryTodo)
|
||||||
|
|
||||||
parser.run()
|
|
||||||
|
|
||||||
def query(**kwargs):
|
|
||||||
"""\
|
|
||||||
Query the database.
|
|
||||||
|
|
||||||
This provides a command-line query interface to Nominatim's API.
|
|
||||||
"""
|
|
||||||
parser = CommandlineParser('nominatim-query', query.__doc__)
|
|
||||||
|
|
||||||
parser.run()
|
parser.run()
|
||||||
Reference in New Issue
Block a user