mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-11-22 12:06:27 +03:00
Merge pull request #3458 from lonvia/python-package
Add support for installation via pip
This commit is contained in:
commit
c314a3092c
3
.github/ISSUE_TEMPLATE/config.yml
vendored
3
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -2,3 +2,6 @@ contact_links:
|
||||
- name: Nominatim Discussions
|
||||
url: https://github.com/osm-search/Nominatim/discussions
|
||||
about: Ask questions, get support, share ideas and discuss with community members.
|
||||
- name: Discussions about OpenStreetMap data
|
||||
url: https://community.openstreetmap.org/
|
||||
about: Ask questions about the data used by Nominatim and discuss with the OSM community.
|
||||
|
39
.github/workflows/ci-tests.yml
vendored
39
.github/workflows/ci-tests.yml
vendored
@ -105,12 +105,12 @@ jobs:
|
||||
|
||||
- name: Install latest pylint
|
||||
run: pip3 install -U pylint
|
||||
if: matrix.flavour != 'oldstuff'
|
||||
if: matrix.flavour == 'ubuntu-22'
|
||||
|
||||
- name: Python linting
|
||||
run: python3 -m pylint nominatim
|
||||
run: python3 -m pylint src
|
||||
working-directory: Nominatim
|
||||
if: matrix.flavour != 'oldstuff'
|
||||
if: matrix.flavour == 'ubuntu-22'
|
||||
|
||||
- name: Python unit tests
|
||||
run: python3 -m pytest test/python
|
||||
@ -126,7 +126,7 @@ jobs:
|
||||
if: matrix.flavour != 'oldstuff'
|
||||
|
||||
- name: Python static typechecking
|
||||
run: python3 -m mypy --strict nominatim
|
||||
run: python3 -m mypy --strict src
|
||||
working-directory: Nominatim
|
||||
if: matrix.flavour != 'oldstuff'
|
||||
|
||||
@ -227,16 +227,16 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
name: [Ubuntu-20, Ubuntu-22]
|
||||
name: [Ubuntu-22, Ubuntu-24]
|
||||
include:
|
||||
- name: Ubuntu-20
|
||||
image: "ubuntu:20.04"
|
||||
ubuntu: 20
|
||||
install_mode: install-apache
|
||||
- name: Ubuntu-22
|
||||
image: "ubuntu:22.04"
|
||||
ubuntu: 22
|
||||
install_mode: install-apache
|
||||
- name: Ubuntu-24
|
||||
image: "ubuntu:24.04"
|
||||
ubuntu: 24
|
||||
install_mode: install-apache
|
||||
|
||||
container:
|
||||
image: ${{ matrix.image }}
|
||||
@ -292,6 +292,16 @@ jobs:
|
||||
mkdir data-env-reverse
|
||||
working-directory: /home/nominatim
|
||||
|
||||
- name: Add nominatim to path
|
||||
run: |
|
||||
sudo ln -s /home/nominatim/nominatim-venv/bin/nominatim /usr/local/bin/nominatim
|
||||
if: matrix.ubuntu == 24
|
||||
|
||||
- name: Need lua binary
|
||||
run: |
|
||||
sudo apt-get install -y lua5.4 lua-dkjson
|
||||
if: matrix.ubuntu == 24
|
||||
|
||||
- name: Print version
|
||||
run: nominatim --version
|
||||
working-directory: /home/nominatim/nominatim-project
|
||||
@ -324,9 +334,18 @@ jobs:
|
||||
run: apt-get install -y python3-pip
|
||||
shell: bash
|
||||
|
||||
- name: Run update
|
||||
- name: Install osmium (Ubuntu 22)
|
||||
run: |
|
||||
pip3 install --user osmium
|
||||
if: matrix.ubuntu == 22
|
||||
|
||||
- name: Install osmium (Ubuntu 24)
|
||||
run: |
|
||||
/home/nominatim/nominatim-venv/bin/pip install osmium
|
||||
if: matrix.ubuntu == 24
|
||||
|
||||
- name: Run update
|
||||
run: |
|
||||
nominatim replication --init
|
||||
NOMINATIM_REPLICATION_MAX_DIFF=1 nominatim replication --once
|
||||
working-directory: /home/nominatim/nominatim-project
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,9 +1,12 @@
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
|
||||
docs/develop/*.png
|
||||
|
||||
build
|
||||
dist
|
||||
.coverage
|
||||
|
||||
.vagrant
|
||||
data/country_osm_grid.sql.gz
|
||||
|
@ -72,7 +72,7 @@ endif()
|
||||
# python (imports/updates only)
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
if (BUILD_IMPORTER)
|
||||
if (BUILD_IMPORTER OR BUILD_API)
|
||||
find_package(PythonInterp 3.7 REQUIRED)
|
||||
endif()
|
||||
|
||||
@ -221,20 +221,22 @@ if (BUILD_IMPORTER)
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
RENAME nominatim)
|
||||
|
||||
install(DIRECTORY nominatim
|
||||
DESTINATION ${NOMINATIM_LIBDIR}/lib-python
|
||||
FILES_MATCHING PATTERN "*.py"
|
||||
PATTERN "paths.py" EXCLUDE
|
||||
PATTERN __pycache__ EXCLUDE)
|
||||
|
||||
if (EXISTS ${PHP_BIN})
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/paths-py.tmpl paths-py.installed)
|
||||
else()
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/paths-py-no-php.tmpl paths-py.installed)
|
||||
endif()
|
||||
install(FILES ${PROJECT_BINARY_DIR}/paths-py.installed
|
||||
DESTINATION ${NOMINATIM_LIBDIR}/lib-python/nominatim
|
||||
RENAME paths.py)
|
||||
|
||||
foreach (submodule nominatim_db nominatim_api)
|
||||
install(DIRECTORY src/${submodule}
|
||||
DESTINATION ${NOMINATIM_LIBDIR}/lib-python
|
||||
FILES_MATCHING PATTERN "*.py"
|
||||
PATTERN "paths.py" EXCLUDE
|
||||
PATTERN __pycache__ EXCLUDE)
|
||||
install(FILES ${PROJECT_BINARY_DIR}/paths-py.installed
|
||||
DESTINATION ${NOMINATIM_LIBDIR}/lib-python/${submodule}
|
||||
RENAME paths.py)
|
||||
endforeach()
|
||||
|
||||
install(DIRECTORY lib-sql DESTINATION ${NOMINATIM_LIBDIR})
|
||||
|
||||
|
457
COPYING
457
COPYING
@ -1,339 +1,232 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
|
||||
Preamble
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
Preamble
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
0. Definitions.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
1. Source Code.
|
||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||
|
||||
NO WARRANTY
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||
|
||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
202
LICENSES/Apache-2.0.txt
Normal file
202
LICENSES/Apache-2.0.txt
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
339
LICENSES/GPL-2.0-only.txt
Normal file
339
LICENSES/GPL-2.0-only.txt
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
32
Makefile
Normal file
32
Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
all:
|
||||
|
||||
# Building of wheels
|
||||
|
||||
build: clean-build build-db build-api
|
||||
|
||||
clean-build:
|
||||
rm -f dist/*
|
||||
|
||||
build-db:
|
||||
python3 -m build packaging/nominatim-db --outdir dist/
|
||||
|
||||
build-api:
|
||||
python3 -m build packaging/nominatim-api --outdir dist/
|
||||
|
||||
# Tests
|
||||
|
||||
tests: mypy lint pytest bdd
|
||||
|
||||
mypy:
|
||||
mypy --strict src
|
||||
|
||||
pytest:
|
||||
pytest test/python
|
||||
|
||||
lint:
|
||||
pylint src
|
||||
|
||||
bdd:
|
||||
cd test/bdd; behave -DREMOVE_TEMPLATE=1
|
||||
|
||||
.PHONY: tests mypy pytest lint bdd build clean-build build-db build-api
|
26
README.md
26
README.md
@ -1,5 +1,4 @@
|
||||
[![Build Status](https://github.com/osm-search/Nominatim/workflows/CI%20Tests/badge.svg)](https://github.com/osm-search/Nominatim/actions?query=workflow%3A%22CI+Tests%22)
|
||||
[![codecov](https://codecov.io/gh/osm-search/Nominatim/branch/master/graph/badge.svg?token=8P1LXrhCMy)](https://codecov.io/gh/osm-search/Nominatim)
|
||||
|
||||
Nominatim
|
||||
=========
|
||||
@ -48,20 +47,31 @@ A quick summary of the necessary steps:
|
||||
License
|
||||
=======
|
||||
|
||||
The source code is available under a GPLv2 license.
|
||||
The Python source code is available under a GPL license version 3 or later.
|
||||
The Lua configuration files for osm2pgsql are released under the
|
||||
Apache License, Version 2.0. All other files are under a GPLv2 license.
|
||||
|
||||
|
||||
Contributing
|
||||
============
|
||||
|
||||
Contributions, bugreport and pull requests are welcome.
|
||||
For details see [contribution guide](CONTRIBUTING.md).
|
||||
Contributions, bug reports and pull requests are welcome. When reporting a
|
||||
bug, please use one of the
|
||||
[issue templates](https://github.com/osm-search/Nominatim/issues/new/choose)
|
||||
and make sure to provide all the information requested. If you are not
|
||||
sure if you have really found a bug, please ask for help in the forums
|
||||
first (see 'Questions' below).
|
||||
|
||||
For details on contributing, have a look at the
|
||||
[contribution guide](CONTRIBUTING.md).
|
||||
|
||||
|
||||
Questions and help
|
||||
==================
|
||||
|
||||
For questions, community help and discussions you can use the
|
||||
[Github discussions forum](https://github.com/osm-search/Nominatim/discussions)
|
||||
or join the
|
||||
[geocoding mailing list](https://lists.openstreetmap.org/listinfo/geocoding).
|
||||
If you have questions about search results and the OpenStreetMap data
|
||||
used in the search, use the [OSM Forum](https://community.openstreetmap.org/).
|
||||
|
||||
For questions, community help and discussions around the software and
|
||||
your own installation of Nominatim, use the
|
||||
[Github discussions forum](https://github.com/osm-search/Nominatim/discussions).
|
||||
|
18
Vagrantfile
vendored
18
Vagrantfile
vendored
@ -69,28 +69,28 @@ Vagrant.configure("2") do |config|
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu20" do |sub|
|
||||
sub.vm.box = "generic/ubuntu2004"
|
||||
config.vm.define "ubuntu24" do |sub|
|
||||
sub.vm.box = "bento/ubuntu-24.04"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||
s.path = "vagrant/Install-on-Ubuntu-24.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu20-apache" do |sub|
|
||||
sub.vm.box = "generic/ubuntu2004"
|
||||
config.vm.define "ubuntu24-apache" do |sub|
|
||||
sub.vm.box = "bento/ubuntu-24.04"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||
s.path = "vagrant/Install-on-Ubuntu-24.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout, "install-apache"]
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "ubuntu20-nginx" do |sub|
|
||||
sub.vm.box = "generic/ubuntu2004"
|
||||
config.vm.define "ubuntu24-nginx" do |sub|
|
||||
sub.vm.box = "bento/ubuntu-24.04"
|
||||
sub.vm.provision :shell do |s|
|
||||
s.path = "vagrant/Install-on-Ubuntu-20.sh"
|
||||
s.path = "vagrant/Install-on-Ubuntu-24.sh"
|
||||
s.privileged = false
|
||||
s.args = [checkout, "install-nginx"]
|
||||
end
|
||||
|
@ -4,8 +4,8 @@ import os
|
||||
|
||||
sys.path.insert(1, '@NOMINATIM_LIBDIR@/lib-python')
|
||||
|
||||
from nominatim import cli
|
||||
from nominatim import version
|
||||
from nominatim_db import cli
|
||||
from nominatim_db import version
|
||||
|
||||
version.GIT_COMMIT_HASH = '@GIT_HASH@'
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(1, '@CMAKE_SOURCE_DIR@')
|
||||
sys.path.insert(1, '@CMAKE_SOURCE_DIR@/src')
|
||||
|
||||
from nominatim import cli
|
||||
from nominatim import version
|
||||
from nominatim_db import cli
|
||||
from nominatim_db import version
|
||||
|
||||
version.GIT_COMMIT_HASH = '@GIT_HASH@'
|
||||
|
||||
|
@ -24,7 +24,7 @@ foreach (src ${DOC_SOURCES})
|
||||
endforeach()
|
||||
|
||||
ADD_CUSTOM_TARGET(doc
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-20.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-20.md
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-24.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-24.md
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-22.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-22.md
|
||||
COMMAND mkdocs build -d ${CMAKE_CURRENT_BINARY_DIR}/../site-html -f ${CMAKE_CURRENT_BINARY_DIR}/../mkdocs.yml
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Deploying the Nominatim Python frontend
|
||||
|
||||
The Nominatim can be run as a Python-based
|
||||
Nominatim can be run as a Python-based
|
||||
[ASGI web application](https://asgi.readthedocs.io/en/latest/). You have the
|
||||
choice between [Falcon](https://falcon.readthedocs.io/en/stable/)
|
||||
and [Starlette](https://www.starlette.io/) as the ASGI framework.
|
||||
@ -12,30 +12,39 @@ to configure it.
|
||||
|
||||
!!! Note
|
||||
Throughout this page, we assume your Nominatim project directory is
|
||||
located in `/srv/nominatim-project` and you have installed Nominatim
|
||||
using the default installation prefix `/usr/local`. If you have put it
|
||||
somewhere else, you need to adjust the commands and configuration
|
||||
accordingly.
|
||||
located in `/srv/nominatim-project`. If you have put it somewhere else,
|
||||
you need to adjust the commands and configuration accordingly.
|
||||
|
||||
We further assume that your web server runs as user `www-data`. Older
|
||||
versions of CentOS may still use the user name `apache`. You also need
|
||||
to adapt the instructions in this case.
|
||||
|
||||
### Installing the required packages
|
||||
|
||||
The Nominatim frontend is best run from its own virtual environment. If
|
||||
you have already created one for the database backend during
|
||||
[installation](Installation.md#Building-Nominatim), you can use that. Otherwise
|
||||
create one now with:
|
||||
|
||||
```sh
|
||||
sudo apt-get install virtualenv
|
||||
virtualenv /srv/nominatim-venv
|
||||
```
|
||||
|
||||
The Nominatim frontend is contained in the 'nominatim-api' package. To
|
||||
install directly from the source tree run:
|
||||
|
||||
```sh
|
||||
cd Nominatim
|
||||
/srv/nominatim-venv/bin/pip install packaging/nominatim-api
|
||||
```
|
||||
|
||||
The recommended way to deploy a Python ASGI application is to run
|
||||
the ASGI runner [uvicorn](https://uvicorn.org/)
|
||||
together with [gunicorn](https://gunicorn.org/) HTTP server. We use
|
||||
Falcon here as the web framework.
|
||||
|
||||
Create a virtual environment for the Python packages and install the necessary
|
||||
dependencies:
|
||||
Add the necessary packages to your virtual environment:
|
||||
|
||||
``` sh
|
||||
sudo apt install virtualenv
|
||||
virtualenv /srv/nominatim-venv
|
||||
/srv/nominatim-venv/bin/pip install SQLAlchemy PyICU psycopg[binary] \
|
||||
psycopg2-binary python-dotenv PyYAML falcon uvicorn gunicorn
|
||||
/srv/nominatim-venv/bin/pip install falcon uvicorn gunicorn
|
||||
```
|
||||
|
||||
### Setting up Nominatim as a systemd job
|
||||
@ -69,11 +78,10 @@ Requires=nominatim.socket
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment="PYTHONPATH=/usr/local/lib/nominatim/lib-python/"
|
||||
User=www-data
|
||||
Group=www-data
|
||||
WorkingDirectory=/srv/nominatim-project
|
||||
ExecStart=/srv/nominatim-venv/bin/gunicorn -b unix:/run/nominatim.sock -w 4 -k uvicorn.workers.UvicornWorker nominatim.server.falcon.server:run_wsgi
|
||||
ExecStart=/srv/nominatim-venv/bin/gunicorn -b unix:/run/nominatim.sock -w 4 -k uvicorn.workers.UvicornWorker nominatim_api.server.falcon.server:run_wsgi
|
||||
ExecReload=/bin/kill -s HUP $MAINPID
|
||||
StandardOutput=append:/var/log/gunicorn-nominatim.log
|
||||
StandardError=inherit
|
||||
|
@ -4,8 +4,8 @@ This page contains generic installation instructions for Nominatim and its
|
||||
prerequisites. There are also step-by-step instructions available for
|
||||
the following operating systems:
|
||||
|
||||
* [Ubuntu 24.04](../appendix/Install-on-Ubuntu-24.md)
|
||||
* [Ubuntu 22.04](../appendix/Install-on-Ubuntu-22.md)
|
||||
* [Ubuntu 20.04](../appendix/Install-on-Ubuntu-20.md)
|
||||
|
||||
These OS-specific instructions can also be found in executable form
|
||||
in the `vagrant/` directory.
|
||||
@ -27,7 +27,30 @@ and can't offer support.
|
||||
otherwise import and queries will be slow to the point of being unusable.
|
||||
Query performance has marked improvements with PostgreSQL 13+ and PostGIS 3.2+.
|
||||
|
||||
For compiling:
|
||||
For running Nominatim:
|
||||
|
||||
* [PostgreSQL](https://www.postgresql.org) (9.6+ will work, 11+ strongly recommended)
|
||||
* [PostGIS](https://postgis.net) (2.2+ will work, 3.0+ strongly recommended)
|
||||
* [osm2pgsql](https://osm2pgsql.org) (1.8+, optional when building with CMake)
|
||||
* [Python 3](https://www.python.org/) (3.7+)
|
||||
|
||||
Furthermore the following Python libraries are required:
|
||||
|
||||
* [Psycopg2](https://www.psycopg.org) (2.7+)
|
||||
* [Python Dotenv](https://github.com/theskumar/python-dotenv)
|
||||
* [psutil](https://github.com/giampaolo/psutil)
|
||||
* [Jinja2](https://palletsprojects.com/p/jinja/)
|
||||
* [SQLAlchemy](https://www.sqlalchemy.org/) (1.4.31+ with greenlet support)
|
||||
* one of
|
||||
* [psycopg3](https://www.psycopg.org)
|
||||
* [asyncpg](https://magicstack.github.io/asyncpg) (0.8+)
|
||||
* [PyICU](https://pypi.org/project/PyICU/)
|
||||
* [PyYaml](https://pyyaml.org/) (5.1+)
|
||||
* [datrie](https://github.com/pytries/datrie)
|
||||
|
||||
These will be installed automatically, when using pip installation.
|
||||
|
||||
When using legacy CMake-based installation:
|
||||
|
||||
* [cmake](https://cmake.org/)
|
||||
* [expat](https://libexpat.github.io/)
|
||||
@ -36,25 +59,10 @@ For compiling:
|
||||
* [zlib](https://www.zlib.net/)
|
||||
* [ICU](http://site.icu-project.org/)
|
||||
* [nlohmann/json](https://json.nlohmann.me/)
|
||||
* [Boost libraries](https://www.boost.org/), including system and filesystem
|
||||
* [Boost libraries](https://www.boost.org/), including system and file system
|
||||
* PostgreSQL client libraries
|
||||
* a recent C++ compiler (gcc 5+ or Clang 3.8+)
|
||||
|
||||
For running Nominatim:
|
||||
|
||||
* [PostgreSQL](https://www.postgresql.org) (9.6+ will work, 11+ strongly recommended)
|
||||
* [PostGIS](https://postgis.net) (2.2+ will work, 3.0+ strongly recommended)
|
||||
* [Python 3](https://www.python.org/) (3.7+)
|
||||
* [Psycopg2](https://www.psycopg.org) (2.7+)
|
||||
* [Python Dotenv](https://github.com/theskumar/python-dotenv)
|
||||
* [psutil](https://github.com/giampaolo/psutil)
|
||||
* [Jinja2](https://palletsprojects.com/p/jinja/)
|
||||
* [SQLAlchemy](https://www.sqlalchemy.org/) (1.4.31+ with greenlet support)
|
||||
* [asyncpg](https://magicstack.github.io/asyncpg) (0.8+)
|
||||
* [PyICU](https://pypi.org/project/PyICU/)
|
||||
* [PyYaml](https://pyyaml.org/) (5.1+)
|
||||
* [datrie](https://github.com/pytries/datrie)
|
||||
|
||||
For running continuous updates:
|
||||
|
||||
* [pyosmium](https://osmcode.org/pyosmium/)
|
||||
@ -87,7 +95,7 @@ Take into account that the OSM database is growing fast.
|
||||
Fast disks are essential. Using NVME disks is recommended.
|
||||
|
||||
Even on a well configured machine the import of a full planet takes
|
||||
around 2 days. When using traditional SSDs, 4-5 days are more realistic.
|
||||
around 2.5 days. When using traditional SSDs, 4-5 days are more realistic.
|
||||
|
||||
## Tuning the PostgreSQL database
|
||||
|
||||
@ -99,14 +107,16 @@ your `postgresql.conf` file.
|
||||
maintenance_work_mem = (10GB)
|
||||
autovacuum_work_mem = 2GB
|
||||
work_mem = (50MB)
|
||||
effective_cache_size = (24GB)
|
||||
synchronous_commit = off
|
||||
max_wal_size = 1GB
|
||||
checkpoint_timeout = 10min
|
||||
checkpoint_timeout = 60min
|
||||
checkpoint_completion_target = 0.9
|
||||
random_page_cost = 1.0
|
||||
wal_level = minimal
|
||||
max_wal_senders = 0
|
||||
|
||||
The numbers in brackets behind some parameters seem to work fine for
|
||||
64GB RAM machine. Adjust to your setup. A higher number for `max_wal_size`
|
||||
128GB RAM machine. Adjust to your setup. A higher number for `max_wal_size`
|
||||
means that PostgreSQL needs to run checkpoints less often but it does require
|
||||
the additional space on your disk.
|
||||
|
||||
@ -143,6 +153,23 @@ wget -O Nominatim/data/country_osm_grid.sql.gz https://nominatim.org/data/countr
|
||||
|
||||
### Building Nominatim
|
||||
|
||||
#### Building the latest development version with pip
|
||||
|
||||
Nominatim is easiest to run from its own virtual environment. To create one, run:
|
||||
|
||||
sudo apt-get install virtualenv
|
||||
virtualenv /srv/nominatim-venv
|
||||
|
||||
To install Nominatim directly from the source tree into the virtual environment, run:
|
||||
|
||||
/srv/nominatim-venv/bin/pip install packaging/nominatim-{db,api}
|
||||
|
||||
#### Building in legacy CMake mode
|
||||
|
||||
!!! warning
|
||||
Installing Nominatim through CMake is now deprecated. The infrastructure
|
||||
will be removed in Nominatim 5.0. Please switch to pip installation.
|
||||
|
||||
The code must be built in a separate directory. Create the directory and
|
||||
change into it.
|
||||
|
||||
|
@ -15,6 +15,22 @@ breaking changes. **Please read them before running the migration.**
|
||||
If you are migrating from a version <3.6, then you still have to follow
|
||||
the manual migration steps up to 3.6.
|
||||
|
||||
## 4.4.0 -> master
|
||||
|
||||
### New structure for Python packages
|
||||
|
||||
The nominatim Python package has been split into `nominatim-db` and `nominatim-api`.
|
||||
Any imports need to be adapted accordingly.
|
||||
|
||||
If you are running the Python frontend, change the server module from
|
||||
`nominatim.server.falcon.server` to `nominatim_api.server.falcon.server`.
|
||||
|
||||
If you are using the Nominatim library, all imports need to be changed
|
||||
from `nominatim.api.<module>` to `nominatim_api.<module>`.
|
||||
|
||||
If you have written custom tokenizers or sanitizers, the appropriate modules
|
||||
are now found in `nominatim_db`.
|
||||
|
||||
## 4.2.0 -> 4.3.0
|
||||
|
||||
### New indexes for reverse lookup
|
||||
|
@ -17,7 +17,7 @@ columns:
|
||||
|
||||
* **phrase**: the keyword to look for
|
||||
* **class**: key of the main tag of the place to find
|
||||
(see [principal tags in import style](../Import-Styles.md#set_main_tags-principal-tags)
|
||||
(see [principal tags in import style](Import-Styles.md#set_main_tags-principal-tags)
|
||||
* **type**: value of the main tag
|
||||
* **operator**: type of special phrase, may be one of:
|
||||
* *in*: place is within the place defined by the search term (e.g. "_Hotels in_ Berlin")
|
||||
|
@ -175,7 +175,7 @@ The following is a list of sanitizers that are shipped with Nominatim.
|
||||
|
||||
##### split-name-list
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.split_name_list
|
||||
::: nominatim_db.tokenizer.sanitizers.split_name_list
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
@ -183,7 +183,7 @@ The following is a list of sanitizers that are shipped with Nominatim.
|
||||
|
||||
##### strip-brace-terms
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.strip_brace_terms
|
||||
::: nominatim_db.tokenizer.sanitizers.strip_brace_terms
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
@ -191,7 +191,7 @@ The following is a list of sanitizers that are shipped with Nominatim.
|
||||
|
||||
##### tag-analyzer-by-language
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.tag_analyzer_by_language
|
||||
::: nominatim_db.tokenizer.sanitizers.tag_analyzer_by_language
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
@ -199,7 +199,7 @@ The following is a list of sanitizers that are shipped with Nominatim.
|
||||
|
||||
##### clean-housenumbers
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.clean_housenumbers
|
||||
::: nominatim_db.tokenizer.sanitizers.clean_housenumbers
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
@ -207,7 +207,7 @@ The following is a list of sanitizers that are shipped with Nominatim.
|
||||
|
||||
##### clean-postcodes
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.clean_postcodes
|
||||
::: nominatim_db.tokenizer.sanitizers.clean_postcodes
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
@ -215,7 +215,7 @@ The following is a list of sanitizers that are shipped with Nominatim.
|
||||
|
||||
##### clean-tiger-tags
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.clean_tiger_tags
|
||||
::: nominatim_db.tokenizer.sanitizers.clean_tiger_tags
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
@ -223,7 +223,7 @@ The following is a list of sanitizers that are shipped with Nominatim.
|
||||
|
||||
#### delete-tags
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.delete_tags
|
||||
::: nominatim_db.tokenizer.sanitizers.delete_tags
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
@ -231,7 +231,7 @@ The following is a list of sanitizers that are shipped with Nominatim.
|
||||
|
||||
#### tag-japanese
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.tag_japanese
|
||||
::: nominatim_db.tokenizer.sanitizers.tag_japanese
|
||||
options:
|
||||
members: False
|
||||
heading_level: 6
|
||||
|
@ -4,19 +4,19 @@ This chapter gives an overview how to set up Nominatim for development
|
||||
and how to run tests.
|
||||
|
||||
!!! Important
|
||||
This guide assumes that you develop under the latest version of Ubuntu. You
|
||||
can of course also use your favourite distribution. You just might have to
|
||||
adapt the commands below slightly, in particular the commands for installing
|
||||
additional software.
|
||||
This guide assumes you develop under the latest version of Debian/Ubuntu.
|
||||
You can of course also use your favourite distribution. You just might have
|
||||
to adapt the commands below slightly, in particular the commands for
|
||||
installing additional software.
|
||||
|
||||
## Installing Nominatim
|
||||
|
||||
The first step is to install Nominatim itself. Please follow the installation
|
||||
instructions in the [Admin section](../admin/Installation.md). You don't need
|
||||
to set up a webserver for development, the webserver that is included with PHP
|
||||
is sufficient.
|
||||
to set up a webserver for development, the webserver that can be started
|
||||
via `nominatim serve` is sufficient.
|
||||
|
||||
If you want to run Nominatim in a VM via Vagrant, use the default `ubuntu` setup.
|
||||
If you want to run Nominatim in a VM via Vagrant, use the default `ubuntu24` setup.
|
||||
Vagrant's libvirt provider runs out-of-the-box under Ubuntu. You also need to
|
||||
install an NFS daemon to enable directory sharing between host and guest. The
|
||||
following packages should get you started:
|
||||
@ -41,38 +41,45 @@ It has the following additional requirements:
|
||||
For testing the Python search frontend, you need to install extra dependencies
|
||||
depending on your choice of webserver framework:
|
||||
|
||||
* [httpx](https://www.python-httpx.org/) (starlette only)
|
||||
* [asgi-lifespan](https://github.com/florimondmanca/asgi-lifespan) (starlette only)
|
||||
* [httpx](https://www.python-httpx.org/) (Starlette only)
|
||||
* [asgi-lifespan](https://github.com/florimondmanca/asgi-lifespan) (Starlette only)
|
||||
|
||||
The documentation is built with mkdocs:
|
||||
|
||||
* [mkdocs](https://www.mkdocs.org/) >= 1.1.2
|
||||
* [mkdocstrings](https://mkdocstrings.github.io/) >= 0.18
|
||||
* [mkdocstrings-python](https://mkdocstrings.github.io/python/)
|
||||
* [mkdocstrings](https://mkdocstrings.github.io/) >= 0.25
|
||||
* [mkdocs-material](https://squidfunk.github.io/mkdocs-material/)
|
||||
|
||||
### Installing prerequisites on Ubuntu/Debian
|
||||
|
||||
Some of the Python packages require the newest version which is not yet
|
||||
available with the current distributions. Therefore it is recommended to
|
||||
install pip to get the newest versions.
|
||||
The Python tools should always be run with the most recent version.
|
||||
In particular, pylint tends to have a lot of breaking changes between versions.
|
||||
The easiest way, to handle these Python dependencies is to run your
|
||||
development from within a virtual environment.
|
||||
|
||||
To install all necessary packages run:
|
||||
To set up the virtual environment with all necessary packages run:
|
||||
|
||||
```sh
|
||||
sudo apt install php-cgi phpunit php-codesniffer \
|
||||
python3-pip python3-setuptools python3-dev
|
||||
|
||||
pip3 install --user behave mkdocs mkdocstrings pytest pytest-asyncio pylint \
|
||||
mypy types-PyYAML types-jinja2 types-psycopg2 types-psutil \
|
||||
types-ujson types-requests types-Pygments typing-extensions\
|
||||
httpx asgi-lifespan
|
||||
virtualenv ~/nominatim-dev-venv
|
||||
~/nominatim-dev-venv/bin/pip install\
|
||||
psycopg2-binary psutil psycopg[binary] PyICU SQLAlchemy \
|
||||
python-dotenv jinja2 pyYAML datree \
|
||||
behave mkdocs mkdocstrings pytest pytest-asyncio pylint \
|
||||
types-jinja2 types-markupsafe types-psutil types-psycopg2 \
|
||||
types-pygments types-pyyaml types-requests types-ujson \
|
||||
types-urllib3 typing-extensions unicorn falcon
|
||||
```
|
||||
|
||||
The `mkdocs` executable will be located in `.local/bin`. You may have to add
|
||||
this directory to your path, for example by running:
|
||||
Now enter the virtual environment whenever you want to develop:
|
||||
|
||||
```sh
|
||||
. ~/nominatim-dev-venv/bin/activate
|
||||
```
|
||||
echo 'export PATH=~/.local/bin:$PATH' > ~/.profile
|
||||
|
||||
For installing the PHP development tools, run:
|
||||
|
||||
```sh
|
||||
sudo apt install php-cgi phpunit php-codesniffer
|
||||
```
|
||||
|
||||
If your distribution does not have PHPUnit 7.3+, you can install it (as well
|
||||
@ -85,24 +92,47 @@ composer global require "phpunit/phpunit=8.*"
|
||||
```
|
||||
|
||||
The binaries are found in `.config/composer/vendor/bin`. You need to add this
|
||||
to your PATH as well:
|
||||
to your PATH:
|
||||
|
||||
```
|
||||
echo 'export PATH=~/.config/composer/vendor/bin:$PATH' > ~/.profile
|
||||
```
|
||||
|
||||
### Running Nominatim during development
|
||||
|
||||
The source code for Nominatim can be found in the `src` directory and can
|
||||
be run in-place. The source directory features a special script
|
||||
`nominatim-cli.py` which does the same as the installed 'nominatim' binary
|
||||
but executes against the code in the source tree. For example:
|
||||
|
||||
```
|
||||
me@machine:~$ cd Nominatim
|
||||
me@machine:~Nominatim$ ./nominatim-cli.py --version
|
||||
Nominatim version 4.4.99-1
|
||||
```
|
||||
|
||||
Make sure you have activated the virtual environment holding all
|
||||
necessary dependencies.
|
||||
|
||||
## Executing Tests
|
||||
|
||||
All tests are located in the `/test` directory.
|
||||
|
||||
To run all tests just go to the build directory and run make:
|
||||
To run all tests, run make from the source root:
|
||||
|
||||
```sh
|
||||
cd build
|
||||
make test
|
||||
make tests
|
||||
```
|
||||
|
||||
There are also make targets for executing only parts of the test suite.
|
||||
For example to run linting only use:
|
||||
|
||||
```sh
|
||||
make lint
|
||||
```
|
||||
|
||||
The possible testing targets are: mypy, lint, pytest, bdd.
|
||||
|
||||
For more information about the structure of the tests and how to change and
|
||||
extend the test suite, see the [Testing chapter](Testing.md).
|
||||
|
||||
|
@ -52,7 +52,7 @@ the function.
|
||||
|
||||
### Sanitizer configuration
|
||||
|
||||
::: nominatim.tokenizer.sanitizers.config.SanitizerConfig
|
||||
::: nominatim_db.tokenizer.sanitizers.config.SanitizerConfig
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
@ -73,14 +73,14 @@ adding extra attributes) or completely replace the list with a different one.
|
||||
|
||||
#### PlaceInfo - information about the place
|
||||
|
||||
::: nominatim.data.place_info.PlaceInfo
|
||||
::: nominatim_db.data.place_info.PlaceInfo
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
|
||||
#### PlaceName - extended naming information
|
||||
|
||||
::: nominatim.data.place_name.PlaceName
|
||||
::: nominatim_db.data.place_name.PlaceName
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
@ -139,12 +139,12 @@ They can be found in the directory
|
||||
|
||||
## Custom token analysis module
|
||||
|
||||
::: nominatim.tokenizer.token_analysis.base.AnalysisModule
|
||||
::: nominatim_db.tokenizer.token_analysis.base.AnalysisModule
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
|
||||
::: nominatim.tokenizer.token_analysis.base.Analyzer
|
||||
::: nominatim_db.tokenizer.token_analysis.base.Analyzer
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
|
@ -130,16 +130,16 @@ class as defined below.
|
||||
|
||||
### Python Tokenizer Class
|
||||
|
||||
All tokenizers must inherit from `nominatim.tokenizer.base.AbstractTokenizer`
|
||||
All tokenizers must inherit from `nominatim_db.tokenizer.base.AbstractTokenizer`
|
||||
and implement the abstract functions defined there.
|
||||
|
||||
::: nominatim.tokenizer.base.AbstractTokenizer
|
||||
::: nominatim_db.tokenizer.base.AbstractTokenizer
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
### Python Analyzer Class
|
||||
|
||||
::: nominatim.tokenizer.base.AbstractAnalyzer
|
||||
::: nominatim_db.tokenizer.base.AbstractAnalyzer
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
|
@ -20,7 +20,7 @@ configuration parameters, see the [Configuration page](../customize/Settings.md)
|
||||
|
||||
## `Configuration` class
|
||||
|
||||
::: nominatim.config.Configuration
|
||||
::: nominatim_api.Configuration
|
||||
options:
|
||||
members:
|
||||
- get_bool
|
||||
|
@ -12,22 +12,18 @@ in the database.
|
||||
The library interface is currently in an experimental stage. There might
|
||||
be some smaller adjustments to the public interface until the next version.
|
||||
|
||||
The library also misses a proper installation routine, so some manipulation
|
||||
of the PYTHONPATH is required. At the moment, use is only recommended for
|
||||
developers with some experience in Python.
|
||||
|
||||
## Installation
|
||||
|
||||
To use the Nominatim library, you need access to a local Nominatim database.
|
||||
Follow the [installation](../admin/Installation.md) and
|
||||
[import](../admin/Import.md) instructions to set up your database.
|
||||
|
||||
It is not yet possible to install it in the usual way via pip or inside a
|
||||
virtualenv. To get access to the library you need to set an appropriate
|
||||
`PYTHONPATH`. With the default installation, the python library can be found
|
||||
under `/usr/local/share/nominatim/lib-python`. If you have installed
|
||||
Nominatim under a different prefix, adapt the `/usr/local/` part accordingly.
|
||||
You can also point the `PYTHONPATH` to the Nominatim source code.
|
||||
The Nominatim frontend library is contained in the Python package `nominatim-api`.
|
||||
To install the package from the source tree directly, run:
|
||||
|
||||
pip install packaging/nominatim-api
|
||||
|
||||
Usually you would want to run this in a virtual environment.
|
||||
|
||||
### A simple search example
|
||||
|
||||
@ -43,7 +39,7 @@ This code snippet implements a simple search for the town of 'Brugge':
|
||||
from pathlib import Path
|
||||
import asyncio
|
||||
|
||||
import nominatim.api as napi
|
||||
import nominatim_api as napi
|
||||
|
||||
async def search(query):
|
||||
api = napi.NominatimAPIAsync(Path('.'))
|
||||
@ -61,7 +57,7 @@ This code snippet implements a simple search for the town of 'Brugge':
|
||||
``` python
|
||||
from pathlib import Path
|
||||
|
||||
import nominatim.api as napi
|
||||
import nominatim_api as napi
|
||||
|
||||
api = napi.NominatimAPI(Path('.'))
|
||||
|
||||
@ -116,7 +112,7 @@ standard 'nominatim' database:
|
||||
from pathlib import Path
|
||||
import asyncio
|
||||
|
||||
import nominatim.api as napi
|
||||
import nominatim_api as napi
|
||||
|
||||
config_params = {
|
||||
'NOMINATIM_DATABASE_DSN': 'pgsql:dbname=belgium'
|
||||
@ -134,7 +130,7 @@ standard 'nominatim' database:
|
||||
``` python
|
||||
from pathlib import Path
|
||||
|
||||
import nominatim.api as napi
|
||||
import nominatim_api as napi
|
||||
|
||||
config_params = {
|
||||
'NOMINATIM_DATABASE_DSN': 'pgsql:dbname=belgium'
|
||||
@ -161,7 +157,7 @@ Again searching for 'Brugge', this time with a nicely formatted result:
|
||||
from pathlib import Path
|
||||
import asyncio
|
||||
|
||||
import nominatim.api as napi
|
||||
import nominatim_api as napi
|
||||
|
||||
async def search(query):
|
||||
api = napi.NominatimAPIAsync(Path('.'))
|
||||
@ -180,7 +176,7 @@ Again searching for 'Brugge', this time with a nicely formatted result:
|
||||
``` python
|
||||
from pathlib import Path
|
||||
|
||||
import nominatim.api as napi
|
||||
import nominatim_api as napi
|
||||
|
||||
api = napi.NominatimAPI(Path('.'))
|
||||
|
||||
|
@ -5,26 +5,26 @@ in the query functions of the API object.
|
||||
|
||||
## Place identification
|
||||
|
||||
The [details](NominatimAPI.md#nominatim.api.core.NominatimAPI.details) and
|
||||
[lookup](NominatimAPI.md#nominatim.api.core.NominatimAPI.lookup) functions
|
||||
The [details](NominatimAPI.md#nominatim_api.core.NominatimAPI.details) and
|
||||
[lookup](NominatimAPI.md#nominatim_api.core.NominatimAPI.lookup) functions
|
||||
require references to places in the database. Below the possible
|
||||
types for place identification are listed. All types are dataclasses.
|
||||
|
||||
### PlaceID
|
||||
|
||||
::: nominatim.api.PlaceID
|
||||
::: nominatim_api.PlaceID
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
### OsmID
|
||||
|
||||
::: nominatim.api.OsmID
|
||||
::: nominatim_api.OsmID
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
## Geometry types
|
||||
|
||||
::: nominatim.api.GeometryFormat
|
||||
::: nominatim_api.GeometryFormat
|
||||
options:
|
||||
heading_level: 6
|
||||
members_order: source
|
||||
@ -33,14 +33,14 @@ types for place identification are listed. All types are dataclasses.
|
||||
|
||||
### Point
|
||||
|
||||
::: nominatim.api.Point
|
||||
::: nominatim_api.Point
|
||||
options:
|
||||
heading_level: 6
|
||||
show_signature_annotations: True
|
||||
|
||||
### Bbox
|
||||
|
||||
::: nominatim.api.Bbox
|
||||
::: nominatim_api.Bbox
|
||||
options:
|
||||
heading_level: 6
|
||||
show_signature_annotations: True
|
||||
@ -54,9 +54,7 @@ orthogonal to restriction by address ranks, which groups places by their
|
||||
geographic extent.
|
||||
|
||||
|
||||
::: nominatim.api.DataLayer
|
||||
::: nominatim_api.DataLayer
|
||||
options:
|
||||
heading_level: 6
|
||||
members_order: source
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ the placex table:
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
import sqlalchemy as sa
|
||||
from nominatim.api import NominatimAPIAsync
|
||||
from nominatim_api import NominatimAPIAsync
|
||||
|
||||
async def print_table_size():
|
||||
api = NominatimAPIAsync(Path('.'))
|
||||
@ -45,7 +45,7 @@ asyncio.run(print_table_size())
|
||||
|
||||
## SearchConnection class
|
||||
|
||||
::: nominatim.api.SearchConnection
|
||||
::: nominatim_api.SearchConnection
|
||||
options:
|
||||
members:
|
||||
- scalar
|
||||
|
@ -6,7 +6,7 @@ to instantiate a separate instance for each thread.
|
||||
|
||||
### NominatimAPI
|
||||
|
||||
::: nominatim.api.NominatimAPI
|
||||
::: nominatim_api.NominatimAPI
|
||||
options:
|
||||
members:
|
||||
- __init__
|
||||
@ -25,7 +25,7 @@ to instantiate a separate instance for each thread.
|
||||
|
||||
### NominatimAPIAsync
|
||||
|
||||
::: nominatim.api.NominatimAPIAsync
|
||||
::: nominatim_api.NominatimAPIAsync
|
||||
options:
|
||||
members:
|
||||
- __init__
|
||||
|
@ -12,7 +12,7 @@ functions that allow further processing of the results.
|
||||
Nominatim takes the result data from multiple sources. The `source_table` field
|
||||
in the result describes, from which source the result was retrieved.
|
||||
|
||||
::: nominatim.api.SourceTable
|
||||
::: nominatim_api.SourceTable
|
||||
options:
|
||||
heading_level: 6
|
||||
members_order: source
|
||||
@ -31,7 +31,7 @@ contains the result place itself and some artificial entries, for example,
|
||||
for the house number or the country code. This makes processing and creating
|
||||
a full address easier.
|
||||
|
||||
::: nominatim.api.AddressLine
|
||||
::: nominatim_api.AddressLine
|
||||
options:
|
||||
heading_level: 6
|
||||
members_order: source
|
||||
@ -43,7 +43,7 @@ may be used to find a place, when the `keywords` parameter is set. Search
|
||||
terms are split into terms for the name of the place and search terms for
|
||||
its address.
|
||||
|
||||
::: nominatim.api.WordInfo
|
||||
::: nominatim_api.WordInfo
|
||||
options:
|
||||
heading_level: 6
|
||||
|
||||
@ -53,6 +53,6 @@ Results are always returned with the full list of available names.
|
||||
|
||||
### Locale
|
||||
|
||||
::: nominatim.api.Locales
|
||||
::: nominatim_api.Locales
|
||||
options:
|
||||
heading_level: 6
|
||||
|
@ -58,8 +58,8 @@ nav:
|
||||
- 'Testing' : 'develop/Testing.md'
|
||||
- 'External Data Sources': 'develop/data-sources.md'
|
||||
- 'Appendix':
|
||||
- 'Installation on Ubuntu 20' : 'appendix/Install-on-Ubuntu-20.md'
|
||||
- 'Installation on Ubuntu 22' : 'appendix/Install-on-Ubuntu-22.md'
|
||||
- 'Installation on Ubuntu 24' : 'appendix/Install-on-Ubuntu-24.md'
|
||||
markdown_extensions:
|
||||
- codehilite
|
||||
- admonition
|
||||
@ -75,7 +75,7 @@ plugins:
|
||||
- mkdocstrings:
|
||||
handlers:
|
||||
python:
|
||||
paths: ["${PROJECT_SOURCE_DIR}"]
|
||||
paths: ["${PROJECT_SOURCE_DIR}/src"]
|
||||
options:
|
||||
show_source: False
|
||||
show_bases: False
|
||||
|
18
nominatim-cli.py
Executable file
18
nominatim-cli.py
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Helper script for development to run nominatim from the source directory.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
sys.path.insert(1, str((Path(__file__) / '..' / 'src').resolve()))
|
||||
|
||||
from nominatim_db import cli
|
||||
|
||||
exit(cli.nominatim(module_dir=None, osm2pgsql_path=None))
|
@ -1,28 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Subcommand definitions for the command-line tool.
|
||||
"""
|
||||
# mypy and pylint disagree about the style of explicit exports,
|
||||
# see https://github.com/PyCQA/pylint/issues/6006.
|
||||
# pylint: disable=useless-import-alias
|
||||
|
||||
from nominatim.clicmd.setup import SetupAll as SetupAll
|
||||
from nominatim.clicmd.replication import UpdateReplication as UpdateReplication
|
||||
from nominatim.clicmd.api import (APISearch as APISearch,
|
||||
APIReverse as APIReverse,
|
||||
APILookup as APILookup,
|
||||
APIDetails as APIDetails,
|
||||
APIStatus as APIStatus)
|
||||
from nominatim.clicmd.index import UpdateIndex as UpdateIndex
|
||||
from nominatim.clicmd.refresh import UpdateRefresh as UpdateRefresh
|
||||
from nominatim.clicmd.add_data import UpdateAddData as UpdateAddData
|
||||
from nominatim.clicmd.admin import AdminFuncs as AdminFuncs
|
||||
from nominatim.clicmd.freeze import SetupFreeze as SetupFreeze
|
||||
from nominatim.clicmd.special_phrases import ImportSpecialPhrases as ImportSpecialPhrases
|
||||
from nominatim.clicmd.export import QueryExport as QueryExport
|
||||
from nominatim.clicmd.convert import ConvertDB as ConvertDB
|
@ -1,15 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2022 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Path settings for extra data used by Nominatim.
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
PHPLIB_DIR = (Path(__file__) / '..' / '..' / 'lib-php').resolve()
|
||||
SQLLIB_DIR = (Path(__file__) / '..' / '..' / 'lib-sql').resolve()
|
||||
DATA_DIR = (Path(__file__) / '..' / '..' / 'data').resolve()
|
||||
CONFIG_DIR = (Path(__file__) / '..' / '..' / 'settings').resolve()
|
1
packaging/nominatim-api/COPYING
Symbolic link
1
packaging/nominatim-api/COPYING
Symbolic link
@ -0,0 +1 @@
|
||||
../../COPYING
|
38
packaging/nominatim-api/README.md
Normal file
38
packaging/nominatim-api/README.md
Normal file
@ -0,0 +1,38 @@
|
||||
# Nominatim - Frontend Library
|
||||
|
||||
Nominatim is a tool to search OpenStreetMap data
|
||||
by name and address (geocoding) and to generate synthetic addresses of
|
||||
OSM points (reverse geocoding).
|
||||
|
||||
This module implements the library for searching a Nominatim database
|
||||
imported with the [`nominatim-db`](https://pypi.org/project/nominatim-db/) package.
|
||||
|
||||
## Installation
|
||||
|
||||
To install the Nominatim API from pypi, run:
|
||||
|
||||
pip install nominatim-api
|
||||
|
||||
## Running a Nominatim server
|
||||
|
||||
You need Falcon or Starlette to run Nominatim as a service, as well as
|
||||
an ASGI-capable server like uvicorn. To install them from pypi run:
|
||||
|
||||
pip install falcon uvicorn
|
||||
|
||||
You need to have a Nominatim database imported with the 'nominatim-db'
|
||||
package. Go to the project directory, then run uvicorn as:
|
||||
|
||||
uvicorn --factory nominatim.server.falcon.server:run_wsgi
|
||||
|
||||
## Documentation
|
||||
|
||||
The full documentation for the Nominatim library can be found at:
|
||||
https://nominatim.org/release-docs/latest/library/Getting-Started/
|
||||
|
||||
The v1 API of the server is documented at:
|
||||
https://nominatim.org/release-docs/latest/api/Overview/
|
||||
|
||||
## License
|
||||
|
||||
The source code is available under a GPLv3 license.
|
15
packaging/nominatim-api/extra_src/paths.py
Normal file
15
packaging/nominatim-api/extra_src/paths.py
Normal file
@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Path settings for extra data used by Nominatim.
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
PHPLIB_DIR = None
|
||||
DATA_DIR = None
|
||||
SQLLIB_DIR = None
|
||||
CONFIG_DIR = (Path(__file__) / '..' / 'resources' / 'settings').resolve()
|
58
packaging/nominatim-api/pyproject.toml
Normal file
58
packaging/nominatim-api/pyproject.toml
Normal file
@ -0,0 +1,58 @@
|
||||
[project]
|
||||
name = "nominatim-api"
|
||||
description = "A tool for building a database of OpenStreetMap for geocoding and for searching the database. Search library."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.7"
|
||||
license = 'GPL-3.0-or-later'
|
||||
maintainers = [
|
||||
{ name = "Sarah Hoffmann", email = "lonvia@denofr.de" },
|
||||
{ name = "Marc Tobias", email = "mtmail-cpan@gmx.net" }
|
||||
]
|
||||
keywords = [ "geocoding", "OpenStreetMap", "search" ]
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: GNU General Public License (GPL)",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
dependencies = [
|
||||
"python-dotenv",
|
||||
"pyYAML>=5.1",
|
||||
"SQLAlchemy>=1.4.31",
|
||||
"psycopg",
|
||||
"PyICU"
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://nominatim.org"
|
||||
Documentation = "https://nominatim.org/release-docs/latest/"
|
||||
Issues = "https://github.com/osm-search/Nominatim/issues"
|
||||
Repository = "https://github.com/osm-search/Nominatim"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "src/nominatim_api/version.py"
|
||||
pattern = "NOMINATIM_API_VERSION = '(?P<version>[^']+)'"
|
||||
|
||||
[tool.hatch.build.targets.sdist]
|
||||
include = [
|
||||
"src/nominatim_api",
|
||||
"src/nominatim_db/config.py",
|
||||
"settings",
|
||||
"extra_src/paths.py"
|
||||
]
|
||||
|
||||
exclude = [
|
||||
"src/nominatim_api/config.py"
|
||||
]
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/nominatim_api"]
|
||||
|
||||
[tool.hatch.build.targets.wheel.force-include]
|
||||
"src/nominatim_db/config.py" = "nominatim_api/config.py"
|
||||
"extra_src/paths.py" = "nominatim_api/paths.py"
|
||||
"settings" = "nominatim_api/resources/settings"
|
1
packaging/nominatim-api/settings
Symbolic link
1
packaging/nominatim-api/settings
Symbolic link
@ -0,0 +1 @@
|
||||
../../settings/
|
1
packaging/nominatim-api/src
Symbolic link
1
packaging/nominatim-api/src
Symbolic link
@ -0,0 +1 @@
|
||||
../../src/
|
1
packaging/nominatim-db/COPYING
Symbolic link
1
packaging/nominatim-db/COPYING
Symbolic link
@ -0,0 +1 @@
|
||||
../../COPYING
|
54
packaging/nominatim-db/README.md
Normal file
54
packaging/nominatim-db/README.md
Normal file
@ -0,0 +1,54 @@
|
||||
# Nominatim - DB Backend
|
||||
|
||||
Nominatim is a tool to search OpenStreetMap data
|
||||
by name and address (geocoding) and to generate synthetic addresses of
|
||||
OSM points (reverse geocoding).
|
||||
|
||||
This module implements the database backend for Nominatim and the
|
||||
command-line tool for importing and maintaining the database.
|
||||
|
||||
## Installation
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Nominatim requires [osm2pgsql](https://osm2pgsql.org/) (>=1.8) for reading
|
||||
OSM data and [PostgreSQL](https://www.postgresql.org/) (>=9.6) to store the data.
|
||||
|
||||
On Ubuntu (>=23.04) and Debian (when using backports), you can install them with:
|
||||
|
||||
sudo apt-get install osm2pgsql postgresql-postgis
|
||||
|
||||
### Installation from pypi
|
||||
|
||||
To install Nominatim from pypi, run:
|
||||
|
||||
pip install nominatim-db
|
||||
|
||||
|
||||
## Quick start
|
||||
|
||||
First create a project directory for your new Nominatim database, which
|
||||
is the space for additional configuration and customization:
|
||||
|
||||
mkdir nominatim-project
|
||||
|
||||
Make sure you run all nominatim commands from within the project directory:
|
||||
|
||||
cd nominatim-project
|
||||
|
||||
Download an appropriate data extract, for example from
|
||||
[Geofabrik](https://download.geofabrik.de/) and import the file:
|
||||
|
||||
nominatim import --osm-file <downlaoded-osm-data.pbf>
|
||||
|
||||
You will need to install the [`nominatim-api`](https://pypi.org/project/nominatim-api/)
|
||||
package to query the database.
|
||||
|
||||
## Documentation
|
||||
|
||||
A HTML version of the documentation can be found at
|
||||
https://nominatim.org/release-docs/latest/ .
|
||||
|
||||
## License
|
||||
|
||||
The source code is available under a GPLv3 license.
|
1
packaging/nominatim-db/data
Symbolic link
1
packaging/nominatim-db/data
Symbolic link
@ -0,0 +1 @@
|
||||
../../data/
|
15
packaging/nominatim-db/extra_src/nominatim_db/paths.py
Normal file
15
packaging/nominatim-db/extra_src/nominatim_db/paths.py
Normal file
@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Path settings for extra data used by Nominatim.
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
PHPLIB_DIR = None
|
||||
DATA_DIR = (Path(__file__) / '..' / 'resources').resolve()
|
||||
SQLLIB_DIR = (DATA_DIR / 'lib-sql')
|
||||
CONFIG_DIR = (DATA_DIR / 'settings')
|
1
packaging/nominatim-db/lib-sql
Symbolic link
1
packaging/nominatim-db/lib-sql
Symbolic link
@ -0,0 +1 @@
|
||||
../../lib-sql/
|
71
packaging/nominatim-db/pyproject.toml
Normal file
71
packaging/nominatim-db/pyproject.toml
Normal file
@ -0,0 +1,71 @@
|
||||
[project]
|
||||
name = "nominatim-db"
|
||||
description = "A tool for building a database of OpenStreetMap for geocoding and for searching the database. Database backend."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.7"
|
||||
license = 'GPL-3.0-or-later'
|
||||
maintainers = [
|
||||
{ name = "Sarah Hoffmann", email = "lonvia@denofr.de" },
|
||||
{ name = "Marc Tobias", email = "mtmail-cpan@gmx.net" }
|
||||
]
|
||||
keywords = [ "geocoding", "OpenStreetMap", "search" ]
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: GNU General Public License (GPL)",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
dependencies = [
|
||||
"psycopg2-binary",
|
||||
"python-dotenv",
|
||||
"jinja2",
|
||||
"pyYAML>=5.1",
|
||||
"datrie",
|
||||
"psutil",
|
||||
"PyICU"
|
||||
]
|
||||
dynamic = ["version"]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://nominatim.org"
|
||||
Documentation = "https://nominatim.org/release-docs/latest/"
|
||||
Issues = "https://github.com/osm-search/Nominatim/issues"
|
||||
Repository = "https://github.com/osm-search/Nominatim"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "src/nominatim_db/version.py"
|
||||
pattern = "NOMINATIM_VERSION = parse_version.'(?P<version>[^-]+)"
|
||||
|
||||
[tool.hatch.build.targets.sdist]
|
||||
include = [
|
||||
"src/nominatim_db",
|
||||
"scripts",
|
||||
"lib-sql/**/*.sql",
|
||||
"settings",
|
||||
"data/words.sql",
|
||||
"extra_src/nominatim_db/paths.py"
|
||||
]
|
||||
|
||||
artifacts = [
|
||||
"data/country_osm_grid.sql.gz"
|
||||
]
|
||||
|
||||
exclude = [
|
||||
"src/nominatim_db/paths.py"
|
||||
]
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/nominatim_db"]
|
||||
|
||||
[tool.hatch.build.targets.wheel.shared-scripts]
|
||||
"scripts" = "/"
|
||||
|
||||
[tool.hatch.build.targets.wheel.force-include]
|
||||
"lib-sql" = "nominatim_db/resources/lib-sql"
|
||||
"settings" = "nominatim_db/resources/settings"
|
||||
"data/country_osm_grid.sql.gz" = "nominatim_db/resources/country_osm_grid.sql.gz"
|
||||
"data/words.sql" = "nominatim_db/resources/words.sql"
|
||||
"extra_src/nominatim_db/paths.py" = "nominatim_db/paths.py"
|
5
packaging/nominatim-db/scripts/nominatim
Executable file
5
packaging/nominatim-db/scripts/nominatim
Executable file
@ -0,0 +1,5 @@
|
||||
#!python3
|
||||
|
||||
from nominatim_db import cli
|
||||
|
||||
exit(cli.nominatim(module_dir=None, osm2pgsql_path=None))
|
1
packaging/nominatim-db/settings
Symbolic link
1
packaging/nominatim-db/settings
Symbolic link
@ -0,0 +1 @@
|
||||
../../settings/
|
1
packaging/nominatim-db/src
Symbolic link
1
packaging/nominatim-db/src
Symbolic link
@ -0,0 +1 @@
|
||||
../../src
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
The public interface of the Nominatim library.
|
||||
@ -14,6 +14,9 @@ import from this file, not from the source files directly.
|
||||
# See also https://github.com/PyCQA/pylint/issues/6006
|
||||
# pylint: disable=useless-import-alias
|
||||
|
||||
from .errors import (UsageError as UsageError)
|
||||
from .config import (Configuration as Configuration)
|
||||
|
||||
from .core import (NominatimAPI as NominatimAPI,
|
||||
NominatimAPIAsync as NominatimAPIAsync)
|
||||
from .connection import (SearchConnection as SearchConnection)
|
||||
@ -36,3 +39,5 @@ from .results import (SourceTable as SourceTable,
|
||||
SearchResult as SearchResult,
|
||||
SearchResults as SearchResults)
|
||||
from .localization import (Locales as Locales)
|
||||
|
||||
from .version import NOMINATIM_API_VERSION as __version__
|
12
src/nominatim_api/config.py
Normal file
12
src/nominatim_api/config.py
Normal file
@ -0,0 +1,12 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
|
||||
# This file is just a placeholder to make the config module available
|
||||
# during development. It will be replaced by nominatim_db/config.py on
|
||||
# installation.
|
||||
# pylint: skip-file
|
||||
from nominatim_db.config import *
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Extended SQLAlchemy connection class that also includes access to the schema.
|
||||
@ -14,16 +14,16 @@ import asyncio
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.ext.asyncio import AsyncConnection
|
||||
|
||||
from nominatim.typing import SaFromClause
|
||||
from nominatim.db.sqlalchemy_schema import SearchTables
|
||||
from nominatim.db.sqlalchemy_types import Geometry
|
||||
from nominatim.api.logging import log
|
||||
from .typing import SaFromClause
|
||||
from .sql.sqlalchemy_schema import SearchTables
|
||||
from .sql.sqlalchemy_types import Geometry
|
||||
from .logging import log
|
||||
|
||||
T = TypeVar('T')
|
||||
|
||||
class SearchConnection:
|
||||
""" An extended SQLAlchemy connection class, that also contains
|
||||
then table definitions. The underlying asynchronous SQLAlchemy
|
||||
the table definitions. The underlying asynchronous SQLAlchemy
|
||||
connection can be accessed with the 'connection' property.
|
||||
The 't' property is the collection of Nominatim tables.
|
||||
"""
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Implementation of classes for API access via libraries.
|
||||
@ -16,18 +16,18 @@ from pathlib import Path
|
||||
import sqlalchemy as sa
|
||||
import sqlalchemy.ext.asyncio as sa_asyncio
|
||||
|
||||
from nominatim.errors import UsageError
|
||||
from nominatim.db.sqlalchemy_schema import SearchTables
|
||||
from nominatim.db.async_core_library import PGCORE_LIB, PGCORE_ERROR
|
||||
import nominatim.db.sqlite_functions
|
||||
from nominatim.config import Configuration
|
||||
from nominatim.api.connection import SearchConnection
|
||||
from nominatim.api.status import get_status, StatusResult
|
||||
from nominatim.api.lookup import get_detailed_place, get_simple_place
|
||||
from nominatim.api.reverse import ReverseGeocoder
|
||||
from nominatim.api.search import ForwardGeocoder, Phrase, PhraseType, make_query_analyzer
|
||||
import nominatim.api.types as ntyp
|
||||
from nominatim.api.results import DetailedResult, ReverseResult, SearchResults
|
||||
from .errors import UsageError
|
||||
from .sql.sqlalchemy_schema import SearchTables
|
||||
from .sql.async_core_library import PGCORE_LIB, PGCORE_ERROR
|
||||
from .config import Configuration
|
||||
from .sql import sqlite_functions, sqlalchemy_functions #pylint: disable=unused-import
|
||||
from .connection import SearchConnection
|
||||
from .status import get_status, StatusResult
|
||||
from .lookup import get_detailed_place, get_simple_place
|
||||
from .reverse import ReverseGeocoder
|
||||
from .search import ForwardGeocoder, Phrase, PhraseType, make_query_analyzer
|
||||
from . import types as ntyp
|
||||
from .results import DetailedResult, ReverseResult, SearchResults
|
||||
|
||||
|
||||
class NominatimAPIAsync: #pylint: disable=too-many-instance-attributes
|
||||
@ -127,7 +127,7 @@ class NominatimAPIAsync: #pylint: disable=too-many-instance-attributes
|
||||
@sa.event.listens_for(engine.sync_engine, "connect")
|
||||
def _on_sqlite_connect(dbapi_con: Any, _: Any) -> None:
|
||||
dbapi_con.run_async(lambda conn: conn.enable_load_extension(True))
|
||||
nominatim.db.sqlite_functions.install_custom_functions(dbapi_con)
|
||||
sqlite_functions.install_custom_functions(dbapi_con)
|
||||
cursor = dbapi_con.cursor()
|
||||
cursor.execute("SELECT load_extension('mod_spatialite')")
|
||||
cursor.execute('SELECT SetDecimalPrecision(7)')
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2022 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Custom exception and error classes for Nominatim.
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Helper functions for localizing names of results.
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Functions for specialised logging with HTML output.
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Implementation of place lookup by ID.
|
||||
@ -12,18 +12,17 @@ import datetime as dt
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from nominatim.typing import SaColumn, SaRow, SaSelect
|
||||
from nominatim.api.connection import SearchConnection
|
||||
import nominatim.api.types as ntyp
|
||||
import nominatim.api.results as nres
|
||||
from nominatim.api.logging import log
|
||||
from .typing import SaColumn, SaRow, SaSelect
|
||||
from .connection import SearchConnection
|
||||
from .logging import log
|
||||
from . import types as ntyp
|
||||
from . import results as nres
|
||||
|
||||
RowFunc = Callable[[Optional[SaRow], Type[nres.BaseResultT]], Optional[nres.BaseResultT]]
|
||||
|
||||
GeomFunc = Callable[[SaSelect, SaColumn], SaSelect]
|
||||
|
||||
|
||||
|
||||
async def find_in_placex(conn: SearchConnection, place: ntyp.PlaceRef,
|
||||
add_geometries: GeomFunc) -> Optional[SaRow]:
|
||||
""" Search for the given place in the placex table and return the
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Helper classes and functions for formatting results into API responses.
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Dataclasses for search results and helper functions to fill them.
|
||||
@ -18,12 +18,12 @@ import datetime as dt
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from nominatim.typing import SaSelect, SaRow
|
||||
from nominatim.db.sqlalchemy_types import Geometry
|
||||
from nominatim.api.types import Point, Bbox, LookupDetails
|
||||
from nominatim.api.connection import SearchConnection
|
||||
from nominatim.api.logging import log
|
||||
from nominatim.api.localization import Locales
|
||||
from .typing import SaSelect, SaRow
|
||||
from .sql.sqlalchemy_types import Geometry
|
||||
from .types import Point, Bbox, LookupDetails
|
||||
from .connection import SearchConnection
|
||||
from .logging import log
|
||||
from .localization import Locales
|
||||
|
||||
# This file defines complex result data classes.
|
||||
# pylint: disable=too-many-instance-attributes
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Implementation of reverse geocoding.
|
||||
@ -12,13 +12,13 @@ import functools
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from nominatim.typing import SaColumn, SaSelect, SaFromClause, SaLabel, SaRow,\
|
||||
SaBind, SaLambdaSelect
|
||||
from nominatim.api.connection import SearchConnection
|
||||
import nominatim.api.results as nres
|
||||
from nominatim.api.logging import log
|
||||
from nominatim.api.types import AnyPoint, DataLayer, ReverseDetails, GeometryFormat, Bbox
|
||||
from nominatim.db.sqlalchemy_types import Geometry
|
||||
from .typing import SaColumn, SaSelect, SaFromClause, SaLabel, SaRow,\
|
||||
SaBind, SaLambdaSelect
|
||||
from .sql.sqlalchemy_types import Geometry
|
||||
from .connection import SearchConnection
|
||||
from . import results as nres
|
||||
from .logging import log
|
||||
from .types import AnyPoint, DataLayer, ReverseDetails, GeometryFormat, Bbox
|
||||
|
||||
# In SQLAlchemy expression which compare with NULL need to be expressed with
|
||||
# the equal sign.
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Module for forward search.
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Conversion from token assignment to an abstract DB search.
|
||||
@ -10,12 +10,12 @@ Conversion from token assignment to an abstract DB search.
|
||||
from typing import Optional, List, Tuple, Iterator, Dict
|
||||
import heapq
|
||||
|
||||
from nominatim.api.types import SearchDetails, DataLayer
|
||||
from nominatim.api.search.query import QueryStruct, Token, TokenType, TokenRange, BreakType
|
||||
from nominatim.api.search.token_assignment import TokenAssignment
|
||||
import nominatim.api.search.db_search_fields as dbf
|
||||
import nominatim.api.search.db_searches as dbs
|
||||
import nominatim.api.search.db_search_lookups as lookups
|
||||
from ..types import SearchDetails, DataLayer
|
||||
from .query import QueryStruct, Token, TokenType, TokenRange, BreakType
|
||||
from .token_assignment import TokenAssignment
|
||||
from . import db_search_fields as dbf
|
||||
from . import db_searches as dbs
|
||||
from . import db_search_lookups as lookups
|
||||
|
||||
|
||||
def wrap_near_search(categories: List[Tuple[str, str]],
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Data structures for more complex fields in abstract search descriptions.
|
||||
@ -12,10 +12,10 @@ import dataclasses
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from nominatim.typing import SaFromClause, SaColumn, SaExpression
|
||||
from nominatim.api.search.query import Token
|
||||
import nominatim.api.search.db_search_lookups as lookups
|
||||
from nominatim.utils.json_writer import JsonWriter
|
||||
from ..typing import SaFromClause, SaColumn, SaExpression
|
||||
from ..utils.json_writer import JsonWriter
|
||||
from .query import Token
|
||||
from . import db_search_lookups as lookups
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Implementation of lookup functions for the search_name table.
|
||||
@ -12,8 +12,8 @@ from typing import List, Any
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.ext.compiler import compiles
|
||||
|
||||
from nominatim.typing import SaFromClause
|
||||
from nominatim.db.sqlalchemy_types import IntArray
|
||||
from ..typing import SaFromClause
|
||||
from ..sql.sqlalchemy_types import IntArray
|
||||
|
||||
# pylint: disable=consider-using-f-string
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Implementation of the actual database accesses for forward search.
|
||||
@ -12,13 +12,13 @@ import abc
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from nominatim.typing import SaFromClause, SaScalarSelect, SaColumn, \
|
||||
SaExpression, SaSelect, SaLambdaSelect, SaRow, SaBind
|
||||
from nominatim.api.connection import SearchConnection
|
||||
from nominatim.api.types import SearchDetails, DataLayer, GeometryFormat, Bbox
|
||||
import nominatim.api.results as nres
|
||||
from nominatim.api.search.db_search_fields import SearchData, WeightedCategories
|
||||
from nominatim.db.sqlalchemy_types import Geometry, IntArray
|
||||
from ..typing import SaFromClause, SaScalarSelect, SaColumn, \
|
||||
SaExpression, SaSelect, SaLambdaSelect, SaRow, SaBind
|
||||
from ..sql.sqlalchemy_types import Geometry, IntArray
|
||||
from ..connection import SearchConnection
|
||||
from ..types import SearchDetails, DataLayer, GeometryFormat, Bbox
|
||||
from .. import results as nres
|
||||
from .db_search_fields import SearchData, WeightedCategories
|
||||
|
||||
#pylint: disable=singleton-comparison,not-callable
|
||||
#pylint: disable=too-many-branches,too-many-arguments,too-many-locals,too-many-statements
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Public interface to the search code.
|
||||
@ -13,15 +13,15 @@ import re
|
||||
import datetime as dt
|
||||
import difflib
|
||||
|
||||
from nominatim.api.connection import SearchConnection
|
||||
from nominatim.api.types import SearchDetails
|
||||
from nominatim.api.results import SearchResult, SearchResults, add_result_details
|
||||
from nominatim.api.search.token_assignment import yield_token_assignments
|
||||
from nominatim.api.search.db_search_builder import SearchBuilder, build_poi_search, wrap_near_search
|
||||
from nominatim.api.search.db_searches import AbstractSearch
|
||||
from nominatim.api.search.query_analyzer_factory import make_query_analyzer, AbstractQueryAnalyzer
|
||||
from nominatim.api.search.query import Phrase, QueryStruct
|
||||
from nominatim.api.logging import log
|
||||
from ..connection import SearchConnection
|
||||
from ..types import SearchDetails
|
||||
from ..results import SearchResult, SearchResults, add_result_details
|
||||
from ..logging import log
|
||||
from .token_assignment import yield_token_assignments
|
||||
from .db_search_builder import SearchBuilder, build_poi_search, wrap_near_search
|
||||
from .db_searches import AbstractSearch
|
||||
from .query_analyzer_factory import make_query_analyzer, AbstractQueryAnalyzer
|
||||
from .query import Phrase, QueryStruct
|
||||
|
||||
class ForwardGeocoder:
|
||||
""" Main class responsible for place search.
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Implementation of query analysis for the ICU tokenizer.
|
||||
@ -16,12 +16,12 @@ from icu import Transliterator
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from nominatim.typing import SaRow
|
||||
from nominatim.api.connection import SearchConnection
|
||||
from nominatim.api.logging import log
|
||||
from nominatim.api.search import query as qmod
|
||||
from nominatim.api.search.query_analyzer_factory import AbstractQueryAnalyzer
|
||||
from nominatim.db.sqlalchemy_types import Json
|
||||
from ..typing import SaRow
|
||||
from ..sql.sqlalchemy_types import Json
|
||||
from ..connection import SearchConnection
|
||||
from ..logging import log
|
||||
from ..search import query as qmod
|
||||
from ..search.query_analyzer_factory import AbstractQueryAnalyzer
|
||||
|
||||
|
||||
DB_TO_TOKEN_TYPE = {
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Implementation of query analysis for the legacy tokenizer.
|
||||
@ -14,11 +14,11 @@ import dataclasses
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from nominatim.typing import SaRow
|
||||
from nominatim.api.connection import SearchConnection
|
||||
from nominatim.api.logging import log
|
||||
from nominatim.api.search import query as qmod
|
||||
from nominatim.api.search.query_analyzer_factory import AbstractQueryAnalyzer
|
||||
from ..typing import SaRow
|
||||
from ..connection import SearchConnection
|
||||
from ..logging import log
|
||||
from . import query as qmod
|
||||
from .query_analyzer_factory import AbstractQueryAnalyzer
|
||||
|
||||
def yield_words(terms: List[str], start: int) -> Iterator[Tuple[str, qmod.TokenRange]]:
|
||||
""" Return all combinations of words in the terms list after the
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Datastructures for a tokenized query.
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Factory for creating a query analyzer for the configured tokenizer.
|
||||
@ -12,11 +12,11 @@ from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
import importlib
|
||||
|
||||
from nominatim.api.logging import log
|
||||
from nominatim.api.connection import SearchConnection
|
||||
from ..logging import log
|
||||
from ..connection import SearchConnection
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from nominatim.api.search.query import Phrase, QueryStruct
|
||||
from .query import Phrase, QueryStruct
|
||||
|
||||
class AbstractQueryAnalyzer(ABC):
|
||||
""" Class for analysing incoming queries.
|
||||
@ -49,6 +49,6 @@ async def make_query_analyzer(conn: SearchConnection) -> AbstractQueryAnalyzer:
|
||||
log().comment(f"No tokenizer named '{name}' available. Database not set up properly.")
|
||||
raise RuntimeError('Tokenizer not found')
|
||||
|
||||
module = importlib.import_module(f'nominatim.api.search.{name}_tokenizer')
|
||||
module = importlib.import_module(f'nominatim_api.search.{name}_tokenizer')
|
||||
|
||||
return cast(AbstractQueryAnalyzer, await module.create_query_analyzer(conn))
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Create query interpretations where each vertice in the query is assigned
|
||||
@ -11,8 +11,8 @@ a specific function (expressed as a token type).
|
||||
from typing import Optional, List, Iterator
|
||||
import dataclasses
|
||||
|
||||
import nominatim.api.search.query as qmod
|
||||
from nominatim.api.logging import log
|
||||
from ..logging import log
|
||||
from . import query as qmod
|
||||
|
||||
# pylint: disable=too-many-return-statements,too-many-branches
|
||||
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Server implementation using the falcon webserver framework.
|
||||
@ -14,10 +14,10 @@ import asyncio
|
||||
|
||||
from falcon.asgi import App, Request, Response
|
||||
|
||||
from nominatim.api import NominatimAPIAsync
|
||||
import nominatim.api.v1 as api_impl
|
||||
import nominatim.api.logging as loglib
|
||||
from nominatim.config import Configuration
|
||||
from ...config import Configuration
|
||||
from ...core import NominatimAPIAsync
|
||||
from ... import v1 as api_impl
|
||||
from ... import logging as loglib
|
||||
|
||||
class HTTPNominatimError(Exception):
|
||||
""" A special exception class for errors raised during processing.
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Server implementation using the starlette webserver framework.
|
||||
@ -21,10 +21,10 @@ from starlette.middleware import Middleware
|
||||
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
|
||||
from nominatim.api import NominatimAPIAsync
|
||||
import nominatim.api.v1 as api_impl
|
||||
import nominatim.api.logging as loglib
|
||||
from nominatim.config import Configuration
|
||||
from ...config import Configuration
|
||||
from ...core import NominatimAPIAsync
|
||||
from ... import v1 as api_impl
|
||||
from ... import logging as loglib
|
||||
|
||||
class ParamWrapper(api_impl.ASGIAdaptor):
|
||||
""" Adaptor class for server glue to Starlette framework.
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Import the base library to use with asynchronous SQLAlchemy.
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Custom functions and expressions for SQLAlchemy.
|
||||
@ -13,7 +13,7 @@ from typing import Any
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.ext.compiler import compiles
|
||||
|
||||
from nominatim.typing import SaColumn
|
||||
from ..typing import SaColumn
|
||||
|
||||
# pylint: disable=all
|
||||
|
@ -2,15 +2,14 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
SQLAlchemy definitions for all tables used by the frontend.
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
import nominatim.db.sqlalchemy_functions #pylint: disable=unused-import
|
||||
from nominatim.db.sqlalchemy_types import Geometry, KeyValueStore, IntArray
|
||||
from .sqlalchemy_types import Geometry, KeyValueStore, IntArray
|
||||
|
||||
#pylint: disable=too-many-instance-attributes
|
||||
class SearchTables:
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Module with custom types for SQLAlchemy
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Custom types for SQLAlchemy.
|
||||
@ -15,7 +15,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.ext.compiler import compiles
|
||||
from sqlalchemy import types
|
||||
|
||||
from nominatim.typing import SaColumn, SaBind
|
||||
from ...typing import SaColumn, SaBind
|
||||
|
||||
#pylint: disable=all
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Custom type for an array of integers.
|
||||
@ -13,7 +13,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.ext.compiler import compiles
|
||||
from sqlalchemy.dialects.postgresql import ARRAY
|
||||
|
||||
from nominatim.typing import SaDialect, SaColumn
|
||||
from ...typing import SaDialect, SaColumn
|
||||
|
||||
# pylint: disable=all
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Common json type for different dialects.
|
||||
@ -13,7 +13,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.dialects.sqlite import JSON as sqlite_json
|
||||
|
||||
from nominatim.typing import SaDialect
|
||||
from ...typing import SaDialect
|
||||
|
||||
# pylint: disable=all
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
A custom type that implements a simple key-value store of strings.
|
||||
@ -14,7 +14,7 @@ from sqlalchemy.ext.compiler import compiles
|
||||
from sqlalchemy.dialects.postgresql import HSTORE
|
||||
from sqlalchemy.dialects.sqlite import JSON as sqlite_json
|
||||
|
||||
from nominatim.typing import SaDialect, SaColumn
|
||||
from ...typing import SaDialect, SaColumn
|
||||
|
||||
# pylint: disable=all
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Custom functions for SQLite.
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Classes and function related to status call.
|
||||
@ -13,8 +13,8 @@ import dataclasses
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from nominatim.api.connection import SearchConnection
|
||||
from nominatim import version
|
||||
from .connection import SearchConnection
|
||||
from .version import NOMINATIM_API_VERSION
|
||||
|
||||
@dataclasses.dataclass
|
||||
class StatusResult:
|
||||
@ -22,9 +22,9 @@ class StatusResult:
|
||||
"""
|
||||
status: int
|
||||
message: str
|
||||
software_version = version.NOMINATIM_VERSION
|
||||
software_version = NOMINATIM_API_VERSION
|
||||
data_updated: Optional[dt.datetime] = None
|
||||
database_version: Optional[version.NominatimVersion] = None
|
||||
database_version: Optional[str] = None
|
||||
|
||||
|
||||
async def get_status(conn: SearchConnection) -> StatusResult:
|
||||
@ -44,8 +44,7 @@ async def get_status(conn: SearchConnection) -> StatusResult:
|
||||
|
||||
# Database version
|
||||
try:
|
||||
verstr = await conn.get_property('database_version')
|
||||
status.database_version = version.parse_version(verstr)
|
||||
status.database_version = await conn.get_property('database_version')
|
||||
except ValueError:
|
||||
pass
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Complex datatypes used by the Nominatim API.
|
||||
@ -16,8 +16,8 @@ import math
|
||||
from struct import unpack
|
||||
from binascii import unhexlify
|
||||
|
||||
from nominatim.errors import UsageError
|
||||
from nominatim.api.localization import Locales
|
||||
from .errors import UsageError
|
||||
from .localization import Locales
|
||||
|
||||
# pylint: disable=no-member,too-many-boolean-expressions,too-many-instance-attributes
|
||||
|
40
src/nominatim_api/typing.py
Normal file
40
src/nominatim_api/typing.py
Normal file
@ -0,0 +1,40 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Type definitions for typing annotations.
|
||||
|
||||
Complex type definitions are moved here, to keep the source files readable.
|
||||
"""
|
||||
from typing import Union, TYPE_CHECKING
|
||||
|
||||
# pylint: disable=missing-class-docstring,useless-import-alias
|
||||
|
||||
# SQLAlchemy introduced generic types in version 2.0 making typing
|
||||
# incompatible with older versions. Add wrappers here so we don't have
|
||||
# to litter the code with bare-string types.
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
import sqlalchemy as sa
|
||||
import os
|
||||
from typing_extensions import (TypeAlias as TypeAlias)
|
||||
else:
|
||||
TypeAlias = str
|
||||
|
||||
StrPath = Union[str, 'os.PathLike[str]']
|
||||
|
||||
SaLambdaSelect: TypeAlias = 'Union[sa.Select[Any], sa.StatementLambdaElement]'
|
||||
SaSelect: TypeAlias = 'sa.Select[Any]'
|
||||
SaScalarSelect: TypeAlias = 'sa.ScalarSelect[Any]'
|
||||
SaRow: TypeAlias = 'sa.Row[Any]'
|
||||
SaColumn: TypeAlias = 'sa.ColumnElement[Any]'
|
||||
SaExpression: TypeAlias = 'sa.ColumnElement[bool]'
|
||||
SaLabel: TypeAlias = 'sa.Label[Any]'
|
||||
SaFromClause: TypeAlias = 'sa.FromClause'
|
||||
SaSelectable: TypeAlias = 'sa.Selectable'
|
||||
SaBind: TypeAlias = 'sa.BindParameter[Any]'
|
||||
SaDialect: TypeAlias = 'sa.Dialect'
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Streaming JSON encoder.
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Implementation of API version v1 (aka the legacy version).
|
||||
@ -10,11 +10,11 @@ Implementation of API version v1 (aka the legacy version).
|
||||
|
||||
#pylint: disable=useless-import-alias
|
||||
|
||||
from nominatim.api.v1.server_glue import (ASGIAdaptor as ASGIAdaptor,
|
||||
EndpointFunc as EndpointFunc,
|
||||
ROUTES as ROUTES)
|
||||
from .server_glue import (ASGIAdaptor as ASGIAdaptor,
|
||||
EndpointFunc as EndpointFunc,
|
||||
ROUTES as ROUTES)
|
||||
|
||||
import nominatim.api.v1.format as _format
|
||||
from . import format as _format
|
||||
|
||||
list_formats = _format.dispatch.list_formats
|
||||
supports_format = _format.dispatch.supports_format
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Hard-coded information about tag categories.
|
||||
@ -12,7 +12,8 @@ version a more flexible formatting is required.
|
||||
"""
|
||||
from typing import Tuple, Optional, Mapping, Union
|
||||
|
||||
import nominatim.api as napi
|
||||
from ..results import ReverseResult, SearchResult
|
||||
from ..types import Bbox
|
||||
|
||||
def get_label_tag(category: Tuple[str, str], extratags: Optional[Mapping[str, str]],
|
||||
rank: int, country: Optional[str]) -> str:
|
||||
@ -41,7 +42,7 @@ def get_label_tag(category: Tuple[str, str], extratags: Optional[Mapping[str, st
|
||||
return label.lower().replace(' ', '_')
|
||||
|
||||
|
||||
def bbox_from_result(result: Union[napi.ReverseResult, napi.SearchResult]) -> napi.Bbox:
|
||||
def bbox_from_result(result: Union[ReverseResult, SearchResult]) -> Bbox:
|
||||
""" Compute a bounding box for the result. For ways and relations
|
||||
a given boundingbox is used. For all other object, a box is computed
|
||||
around the centroid according to dimensions derived from the
|
||||
@ -49,7 +50,7 @@ def bbox_from_result(result: Union[napi.ReverseResult, napi.SearchResult]) -> na
|
||||
"""
|
||||
if (result.osm_object and result.osm_object[0] == 'N') or result.bbox is None:
|
||||
extent = NODE_EXTENT.get(result.category, 0.00005)
|
||||
return napi.Bbox.from_point(result.centroid, extent)
|
||||
return Bbox.from_point(result.centroid, extent)
|
||||
|
||||
return result.bbox
|
||||
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Output formatters for API version v1.
|
||||
@ -11,11 +11,14 @@ from typing import List, Dict, Mapping, Any
|
||||
import collections
|
||||
import datetime as dt
|
||||
|
||||
import nominatim.api as napi
|
||||
from nominatim.api.result_formatting import FormatDispatcher
|
||||
from nominatim.api.v1.classtypes import ICONS
|
||||
from nominatim.api.v1 import format_json, format_xml
|
||||
from nominatim.utils.json_writer import JsonWriter
|
||||
from ..utils.json_writer import JsonWriter
|
||||
from ..status import StatusResult
|
||||
from ..results import DetailedResult, ReverseResults, SearchResults, \
|
||||
AddressLines, AddressLine
|
||||
from ..localization import Locales
|
||||
from ..result_formatting import FormatDispatcher
|
||||
from .classtypes import ICONS
|
||||
from . import format_json, format_xml
|
||||
|
||||
class RawDataList(List[Dict[str, Any]]):
|
||||
""" Data type for formatting raw data lists 'as is' in json.
|
||||
@ -23,16 +26,16 @@ class RawDataList(List[Dict[str, Any]]):
|
||||
|
||||
dispatch = FormatDispatcher()
|
||||
|
||||
@dispatch.format_func(napi.StatusResult, 'text')
|
||||
def _format_status_text(result: napi.StatusResult, _: Mapping[str, Any]) -> str:
|
||||
@dispatch.format_func(StatusResult, 'text')
|
||||
def _format_status_text(result: StatusResult, _: Mapping[str, Any]) -> str:
|
||||
if result.status:
|
||||
return f"ERROR: {result.message}"
|
||||
|
||||
return 'OK'
|
||||
|
||||
|
||||
@dispatch.format_func(napi.StatusResult, 'json')
|
||||
def _format_status_json(result: napi.StatusResult, _: Mapping[str, Any]) -> str:
|
||||
@dispatch.format_func(StatusResult, 'json')
|
||||
def _format_status_json(result: StatusResult, _: Mapping[str, Any]) -> str:
|
||||
out = JsonWriter()
|
||||
|
||||
out.start_object()\
|
||||
@ -47,8 +50,8 @@ def _format_status_json(result: napi.StatusResult, _: Mapping[str, Any]) -> str:
|
||||
return out()
|
||||
|
||||
|
||||
def _add_address_row(writer: JsonWriter, row: napi.AddressLine,
|
||||
locales: napi.Locales) -> None:
|
||||
def _add_address_row(writer: JsonWriter, row: AddressLine,
|
||||
locales: Locales) -> None:
|
||||
writer.start_object()\
|
||||
.keyval('localname', locales.display_name(row.names))\
|
||||
.keyval_not_none('place_id', row.place_id)
|
||||
@ -69,8 +72,8 @@ def _add_address_row(writer: JsonWriter, row: napi.AddressLine,
|
||||
.end_object()
|
||||
|
||||
|
||||
def _add_address_rows(writer: JsonWriter, section: str, rows: napi.AddressLines,
|
||||
locales: napi.Locales) -> None:
|
||||
def _add_address_rows(writer: JsonWriter, section: str, rows: AddressLines,
|
||||
locales: Locales) -> None:
|
||||
writer.key(section).start_array()
|
||||
for row in rows:
|
||||
_add_address_row(writer, row, locales)
|
||||
@ -78,8 +81,8 @@ def _add_address_rows(writer: JsonWriter, section: str, rows: napi.AddressLines,
|
||||
writer.end_array().next()
|
||||
|
||||
|
||||
def _add_parent_rows_grouped(writer: JsonWriter, rows: napi.AddressLines,
|
||||
locales: napi.Locales) -> None:
|
||||
def _add_parent_rows_grouped(writer: JsonWriter, rows: AddressLines,
|
||||
locales: Locales) -> None:
|
||||
# group by category type
|
||||
data = collections.defaultdict(list)
|
||||
for row in rows:
|
||||
@ -98,9 +101,9 @@ def _add_parent_rows_grouped(writer: JsonWriter, rows: napi.AddressLines,
|
||||
writer.end_object().next()
|
||||
|
||||
|
||||
@dispatch.format_func(napi.DetailedResult, 'json')
|
||||
def _format_details_json(result: napi.DetailedResult, options: Mapping[str, Any]) -> str:
|
||||
locales = options.get('locales', napi.Locales())
|
||||
@dispatch.format_func(DetailedResult, 'json')
|
||||
def _format_details_json(result: DetailedResult, options: Mapping[str, Any]) -> str:
|
||||
locales = options.get('locales', Locales())
|
||||
geom = result.geometry.get('geojson')
|
||||
centroid = result.centroid.to_geojson()
|
||||
|
||||
@ -169,41 +172,41 @@ def _format_details_json(result: napi.DetailedResult, options: Mapping[str, Any]
|
||||
return out()
|
||||
|
||||
|
||||
@dispatch.format_func(napi.ReverseResults, 'xml')
|
||||
def _format_reverse_xml(results: napi.ReverseResults, options: Mapping[str, Any]) -> str:
|
||||
@dispatch.format_func(ReverseResults, 'xml')
|
||||
def _format_reverse_xml(results: ReverseResults, options: Mapping[str, Any]) -> str:
|
||||
return format_xml.format_base_xml(results,
|
||||
options, True, 'reversegeocode',
|
||||
{'querystring': options.get('query', '')})
|
||||
|
||||
|
||||
@dispatch.format_func(napi.ReverseResults, 'geojson')
|
||||
def _format_reverse_geojson(results: napi.ReverseResults,
|
||||
@dispatch.format_func(ReverseResults, 'geojson')
|
||||
def _format_reverse_geojson(results: ReverseResults,
|
||||
options: Mapping[str, Any]) -> str:
|
||||
return format_json.format_base_geojson(results, options, True)
|
||||
|
||||
|
||||
@dispatch.format_func(napi.ReverseResults, 'geocodejson')
|
||||
def _format_reverse_geocodejson(results: napi.ReverseResults,
|
||||
@dispatch.format_func(ReverseResults, 'geocodejson')
|
||||
def _format_reverse_geocodejson(results: ReverseResults,
|
||||
options: Mapping[str, Any]) -> str:
|
||||
return format_json.format_base_geocodejson(results, options, True)
|
||||
|
||||
|
||||
@dispatch.format_func(napi.ReverseResults, 'json')
|
||||
def _format_reverse_json(results: napi.ReverseResults,
|
||||
@dispatch.format_func(ReverseResults, 'json')
|
||||
def _format_reverse_json(results: ReverseResults,
|
||||
options: Mapping[str, Any]) -> str:
|
||||
return format_json.format_base_json(results, options, True,
|
||||
class_label='class')
|
||||
|
||||
|
||||
@dispatch.format_func(napi.ReverseResults, 'jsonv2')
|
||||
def _format_reverse_jsonv2(results: napi.ReverseResults,
|
||||
@dispatch.format_func(ReverseResults, 'jsonv2')
|
||||
def _format_reverse_jsonv2(results: ReverseResults,
|
||||
options: Mapping[str, Any]) -> str:
|
||||
return format_json.format_base_json(results, options, True,
|
||||
class_label='category')
|
||||
|
||||
|
||||
@dispatch.format_func(napi.SearchResults, 'xml')
|
||||
def _format_search_xml(results: napi.SearchResults, options: Mapping[str, Any]) -> str:
|
||||
@dispatch.format_func(SearchResults, 'xml')
|
||||
def _format_search_xml(results: SearchResults, options: Mapping[str, Any]) -> str:
|
||||
extra = {'querystring': options.get('query', '')}
|
||||
for attr in ('more_url', 'exclude_place_ids', 'viewbox'):
|
||||
if options.get(attr):
|
||||
@ -213,27 +216,27 @@ def _format_search_xml(results: napi.SearchResults, options: Mapping[str, Any])
|
||||
|
||||
|
||||
|
||||
@dispatch.format_func(napi.SearchResults, 'geojson')
|
||||
def _format_search_geojson(results: napi.SearchResults,
|
||||
@dispatch.format_func(SearchResults, 'geojson')
|
||||
def _format_search_geojson(results: SearchResults,
|
||||
options: Mapping[str, Any]) -> str:
|
||||
return format_json.format_base_geojson(results, options, False)
|
||||
|
||||
|
||||
@dispatch.format_func(napi.SearchResults, 'geocodejson')
|
||||
def _format_search_geocodejson(results: napi.SearchResults,
|
||||
@dispatch.format_func(SearchResults, 'geocodejson')
|
||||
def _format_search_geocodejson(results: SearchResults,
|
||||
options: Mapping[str, Any]) -> str:
|
||||
return format_json.format_base_geocodejson(results, options, False)
|
||||
|
||||
|
||||
@dispatch.format_func(napi.SearchResults, 'json')
|
||||
def _format_search_json(results: napi.SearchResults,
|
||||
@dispatch.format_func(SearchResults, 'json')
|
||||
def _format_search_json(results: SearchResults,
|
||||
options: Mapping[str, Any]) -> str:
|
||||
return format_json.format_base_json(results, options, False,
|
||||
class_label='class')
|
||||
|
||||
|
||||
@dispatch.format_func(napi.SearchResults, 'jsonv2')
|
||||
def _format_search_jsonv2(results: napi.SearchResults,
|
||||
@dispatch.format_func(SearchResults, 'jsonv2')
|
||||
def _format_search_jsonv2(results: SearchResults,
|
||||
options: Mapping[str, Any]) -> str:
|
||||
return format_json.format_base_json(results, options, False,
|
||||
class_label='category')
|
@ -2,16 +2,16 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Helper functions for output of results in json formats.
|
||||
"""
|
||||
from typing import Mapping, Any, Optional, Tuple, Union
|
||||
|
||||
import nominatim.api as napi
|
||||
import nominatim.api.v1.classtypes as cl
|
||||
from nominatim.utils.json_writer import JsonWriter
|
||||
from ..utils.json_writer import JsonWriter
|
||||
from ..results import AddressLines, ReverseResults, SearchResults
|
||||
from . import classtypes as cl
|
||||
|
||||
#pylint: disable=too-many-branches
|
||||
|
||||
@ -21,7 +21,7 @@ def _write_osm_id(out: JsonWriter, osm_object: Optional[Tuple[str, int]]) -> Non
|
||||
.keyval('osm_id', osm_object[1])
|
||||
|
||||
|
||||
def _write_typed_address(out: JsonWriter, address: Optional[napi.AddressLines],
|
||||
def _write_typed_address(out: JsonWriter, address: Optional[AddressLines],
|
||||
country_code: Optional[str]) -> None:
|
||||
parts = {}
|
||||
for line in (address or []):
|
||||
@ -42,7 +42,7 @@ def _write_typed_address(out: JsonWriter, address: Optional[napi.AddressLines],
|
||||
|
||||
|
||||
def _write_geocodejson_address(out: JsonWriter,
|
||||
address: Optional[napi.AddressLines],
|
||||
address: Optional[AddressLines],
|
||||
obj_place_id: Optional[int],
|
||||
country_code: Optional[str]) -> None:
|
||||
extra = {}
|
||||
@ -66,7 +66,7 @@ def _write_geocodejson_address(out: JsonWriter,
|
||||
out.keyval('country_code', country_code)
|
||||
|
||||
|
||||
def format_base_json(results: Union[napi.ReverseResults, napi.SearchResults],
|
||||
def format_base_json(results: Union[ReverseResults, SearchResults],
|
||||
options: Mapping[str, Any], simple: bool,
|
||||
class_label: str) -> str:
|
||||
""" Return the result list as a simple json string in custom Nominatim format.
|
||||
@ -142,7 +142,7 @@ def format_base_json(results: Union[napi.ReverseResults, napi.SearchResults],
|
||||
return out()
|
||||
|
||||
|
||||
def format_base_geojson(results: Union[napi.ReverseResults, napi.SearchResults],
|
||||
def format_base_geojson(results: Union[ReverseResults, SearchResults],
|
||||
options: Mapping[str, Any],
|
||||
simple: bool) -> str:
|
||||
""" Return the result list as a geojson string.
|
||||
@ -204,7 +204,7 @@ def format_base_geojson(results: Union[napi.ReverseResults, napi.SearchResults],
|
||||
return out()
|
||||
|
||||
|
||||
def format_base_geocodejson(results: Union[napi.ReverseResults, napi.SearchResults],
|
||||
def format_base_geocodejson(results: Union[ReverseResults, SearchResults],
|
||||
options: Mapping[str, Any], simple: bool) -> str:
|
||||
""" Return the result list as a geocodejson string.
|
||||
"""
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Helper functions for output of results in XML format.
|
||||
@ -11,12 +11,13 @@ from typing import Mapping, Any, Optional, Union
|
||||
import datetime as dt
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import nominatim.api as napi
|
||||
import nominatim.api.v1.classtypes as cl
|
||||
from ..results import AddressLines, ReverseResult, ReverseResults, \
|
||||
SearchResult, SearchResults
|
||||
from . import classtypes as cl
|
||||
|
||||
#pylint: disable=too-many-branches
|
||||
|
||||
def _write_xml_address(root: ET.Element, address: napi.AddressLines,
|
||||
def _write_xml_address(root: ET.Element, address: AddressLines,
|
||||
country_code: Optional[str]) -> None:
|
||||
parts = {}
|
||||
for line in address:
|
||||
@ -36,7 +37,7 @@ def _write_xml_address(root: ET.Element, address: napi.AddressLines,
|
||||
ET.SubElement(root, 'country_code').text = country_code
|
||||
|
||||
|
||||
def _create_base_entry(result: Union[napi.ReverseResult, napi.SearchResult],
|
||||
def _create_base_entry(result: Union[ReverseResult, SearchResult],
|
||||
root: ET.Element, simple: bool) -> ET.Element:
|
||||
place = ET.SubElement(root, 'result' if simple else 'place')
|
||||
if result.place_id is not None:
|
||||
@ -82,7 +83,7 @@ def _create_base_entry(result: Union[napi.ReverseResult, napi.SearchResult],
|
||||
return place
|
||||
|
||||
|
||||
def format_base_xml(results: Union[napi.ReverseResults, napi.SearchResults],
|
||||
def format_base_xml(results: Union[ReverseResults, SearchResults],
|
||||
options: Mapping[str, Any],
|
||||
simple: bool, xml_root_tag: str,
|
||||
xml_extra_info: Mapping[str, str]) -> str:
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Helper function for parsing parameters and and outputting data
|
||||
@ -12,8 +12,8 @@ from typing import Tuple, Optional, Any, Dict, Iterable
|
||||
from itertools import chain
|
||||
import re
|
||||
|
||||
from nominatim.api.results import SearchResult, SearchResults, SourceTable
|
||||
from nominatim.api.types import SearchDetails, GeometryFormat
|
||||
from ..results import SearchResult, SearchResults, SourceTable
|
||||
from ..types import SearchDetails, GeometryFormat
|
||||
|
||||
REVERSE_MAX_RANKS = [2, 2, 2, # 0-2 Continent/Sea
|
||||
4, 4, # 3-4 Country
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Generic part of the server implementation of the v1 API.
|
||||
@ -17,13 +17,17 @@ from urllib.parse import urlencode
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from nominatim.errors import UsageError
|
||||
from nominatim.config import Configuration
|
||||
import nominatim.api as napi
|
||||
import nominatim.api.logging as loglib
|
||||
from nominatim.api.v1.format import dispatch as formatting
|
||||
from nominatim.api.v1.format import RawDataList
|
||||
from nominatim.api.v1 import helpers
|
||||
from ..errors import UsageError
|
||||
from ..config import Configuration
|
||||
from .. import logging as loglib
|
||||
from ..core import NominatimAPIAsync
|
||||
from .format import dispatch as formatting
|
||||
from .format import RawDataList
|
||||
from ..types import DataLayer, GeometryFormat, PlaceRef, PlaceID, OsmID, Point
|
||||
from ..status import StatusResult
|
||||
from ..results import DetailedResult, ReverseResults, SearchResult, SearchResults
|
||||
from ..localization import Locales
|
||||
from . import helpers
|
||||
|
||||
CONTENT_TEXT = 'text/plain; charset=utf-8'
|
||||
CONTENT_XML = 'text/xml; charset=utf-8'
|
||||
@ -211,16 +215,16 @@ class ASGIAdaptor(abc.ABC):
|
||||
return False
|
||||
|
||||
|
||||
def get_layers(self) -> Optional[napi.DataLayer]:
|
||||
def get_layers(self) -> Optional[DataLayer]:
|
||||
""" Return a parsed version of the layer parameter.
|
||||
"""
|
||||
param = self.get('layer', None)
|
||||
if param is None:
|
||||
return None
|
||||
|
||||
return cast(napi.DataLayer,
|
||||
reduce(napi.DataLayer.__or__,
|
||||
(getattr(napi.DataLayer, s.upper()) for s in param.split(','))))
|
||||
return cast(DataLayer,
|
||||
reduce(DataLayer.__or__,
|
||||
(getattr(DataLayer, s.upper()) for s in param.split(','))))
|
||||
|
||||
|
||||
def parse_format(self, result_type: Type[Any], default: str) -> str:
|
||||
@ -243,19 +247,19 @@ class ASGIAdaptor(abc.ABC):
|
||||
""" Create details structure from the supplied geometry parameters.
|
||||
"""
|
||||
numgeoms = 0
|
||||
output = napi.GeometryFormat.NONE
|
||||
output = GeometryFormat.NONE
|
||||
if self.get_bool('polygon_geojson', False):
|
||||
output |= napi.GeometryFormat.GEOJSON
|
||||
output |= GeometryFormat.GEOJSON
|
||||
numgeoms += 1
|
||||
if fmt not in ('geojson', 'geocodejson'):
|
||||
if self.get_bool('polygon_text', False):
|
||||
output |= napi.GeometryFormat.TEXT
|
||||
output |= GeometryFormat.TEXT
|
||||
numgeoms += 1
|
||||
if self.get_bool('polygon_kml', False):
|
||||
output |= napi.GeometryFormat.KML
|
||||
output |= GeometryFormat.KML
|
||||
numgeoms += 1
|
||||
if self.get_bool('polygon_svg', False):
|
||||
output |= napi.GeometryFormat.SVG
|
||||
output |= GeometryFormat.SVG
|
||||
numgeoms += 1
|
||||
|
||||
if numgeoms > self.config().get_int('POLYGON_OUTPUT_MAX_TYPES'):
|
||||
@ -267,12 +271,12 @@ class ASGIAdaptor(abc.ABC):
|
||||
}
|
||||
|
||||
|
||||
async def status_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
async def status_endpoint(api: NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
""" Server glue for /status endpoint. See API docs for details.
|
||||
"""
|
||||
result = await api.status()
|
||||
|
||||
fmt = params.parse_format(napi.StatusResult, 'text')
|
||||
fmt = params.parse_format(StatusResult, 'text')
|
||||
|
||||
if fmt == 'text' and result.status:
|
||||
status_code = 500
|
||||
@ -283,32 +287,32 @@ async def status_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> A
|
||||
status=status_code)
|
||||
|
||||
|
||||
async def details_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
async def details_endpoint(api: NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
""" Server glue for /details endpoint. See API docs for details.
|
||||
"""
|
||||
fmt = params.parse_format(napi.DetailedResult, 'json')
|
||||
fmt = params.parse_format(DetailedResult, 'json')
|
||||
place_id = params.get_int('place_id', 0)
|
||||
place: napi.PlaceRef
|
||||
place: PlaceRef
|
||||
if place_id:
|
||||
place = napi.PlaceID(place_id)
|
||||
place = PlaceID(place_id)
|
||||
else:
|
||||
osmtype = params.get('osmtype')
|
||||
if osmtype is None:
|
||||
params.raise_error("Missing ID parameter 'place_id' or 'osmtype'.")
|
||||
place = napi.OsmID(osmtype, params.get_int('osmid'), params.get('class'))
|
||||
place = OsmID(osmtype, params.get_int('osmid'), params.get('class'))
|
||||
|
||||
debug = params.setup_debugging()
|
||||
|
||||
locales = napi.Locales.from_accept_languages(params.get_accepted_languages())
|
||||
locales = Locales.from_accept_languages(params.get_accepted_languages())
|
||||
|
||||
result = await api.details(place,
|
||||
address_details=params.get_bool('addressdetails', False),
|
||||
linked_places=params.get_bool('linkedplaces', True),
|
||||
parented_places=params.get_bool('hierarchy', False),
|
||||
keywords=params.get_bool('keywords', False),
|
||||
geometry_output = napi.GeometryFormat.GEOJSON
|
||||
geometry_output = GeometryFormat.GEOJSON
|
||||
if params.get_bool('polygon_geojson', False)
|
||||
else napi.GeometryFormat.NONE,
|
||||
else GeometryFormat.NONE,
|
||||
locales=locales
|
||||
)
|
||||
|
||||
@ -326,17 +330,17 @@ async def details_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) ->
|
||||
return params.build_response(output, num_results=1)
|
||||
|
||||
|
||||
async def reverse_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
async def reverse_endpoint(api: NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
""" Server glue for /reverse endpoint. See API docs for details.
|
||||
"""
|
||||
fmt = params.parse_format(napi.ReverseResults, 'xml')
|
||||
fmt = params.parse_format(ReverseResults, 'xml')
|
||||
debug = params.setup_debugging()
|
||||
coord = napi.Point(params.get_float('lon'), params.get_float('lat'))
|
||||
coord = Point(params.get_float('lon'), params.get_float('lat'))
|
||||
|
||||
details = params.parse_geometry_details(fmt)
|
||||
details['max_rank'] = helpers.zoom_to_rank(params.get_int('zoom', 18))
|
||||
details['layers'] = params.get_layers()
|
||||
details['locales'] = napi.Locales.from_accept_languages(params.get_accepted_languages())
|
||||
details['locales'] = Locales.from_accept_languages(params.get_accepted_languages())
|
||||
|
||||
result = await api.reverse(coord, **details)
|
||||
|
||||
@ -357,25 +361,25 @@ async def reverse_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) ->
|
||||
'namedetails': params.get_bool('namedetails', False),
|
||||
'addressdetails': params.get_bool('addressdetails', True)}
|
||||
|
||||
output = formatting.format_result(napi.ReverseResults([result] if result else []),
|
||||
output = formatting.format_result(ReverseResults([result] if result else []),
|
||||
fmt, fmt_options)
|
||||
|
||||
return params.build_response(output, num_results=1 if result else 0)
|
||||
|
||||
|
||||
async def lookup_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
async def lookup_endpoint(api: NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
""" Server glue for /lookup endpoint. See API docs for details.
|
||||
"""
|
||||
fmt = params.parse_format(napi.SearchResults, 'xml')
|
||||
fmt = params.parse_format(SearchResults, 'xml')
|
||||
debug = params.setup_debugging()
|
||||
details = params.parse_geometry_details(fmt)
|
||||
details['locales'] = napi.Locales.from_accept_languages(params.get_accepted_languages())
|
||||
details['locales'] = Locales.from_accept_languages(params.get_accepted_languages())
|
||||
|
||||
places = []
|
||||
for oid in (params.get('osm_ids') or '').split(','):
|
||||
oid = oid.strip()
|
||||
if len(oid) > 1 and oid[0] in 'RNWrnw' and oid[1:].isdigit():
|
||||
places.append(napi.OsmID(oid[0].upper(), int(oid[1:])))
|
||||
places.append(OsmID(oid[0].upper(), int(oid[1:])))
|
||||
|
||||
if len(places) > params.config().get_int('LOOKUP_MAX_COUNT'):
|
||||
params.raise_error('Too many object IDs.')
|
||||
@ -383,7 +387,7 @@ async def lookup_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> A
|
||||
if places:
|
||||
results = await api.lookup(places, **details)
|
||||
else:
|
||||
results = napi.SearchResults()
|
||||
results = SearchResults()
|
||||
|
||||
if debug:
|
||||
return params.build_response(loglib.get_and_disable(), num_results=len(results))
|
||||
@ -397,28 +401,28 @@ async def lookup_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> A
|
||||
return params.build_response(output, num_results=len(results))
|
||||
|
||||
|
||||
async def _unstructured_search(query: str, api: napi.NominatimAPIAsync,
|
||||
details: Dict[str, Any]) -> napi.SearchResults:
|
||||
async def _unstructured_search(query: str, api: NominatimAPIAsync,
|
||||
details: Dict[str, Any]) -> SearchResults:
|
||||
if not query:
|
||||
return napi.SearchResults()
|
||||
return SearchResults()
|
||||
|
||||
# Extract special format for coordinates from query.
|
||||
query, x, y = helpers.extract_coords_from_query(query)
|
||||
if x is not None:
|
||||
assert y is not None
|
||||
details['near'] = napi.Point(x, y)
|
||||
details['near'] = Point(x, y)
|
||||
details['near_radius'] = 0.1
|
||||
|
||||
# If no query is left, revert to reverse search.
|
||||
if x is not None and not query:
|
||||
result = await api.reverse(details['near'], **details)
|
||||
if not result:
|
||||
return napi.SearchResults()
|
||||
return SearchResults()
|
||||
|
||||
return napi.SearchResults(
|
||||
[napi.SearchResult(**{f.name: getattr(result, f.name)
|
||||
for f in dataclasses.fields(napi.SearchResult)
|
||||
if hasattr(result, f.name)})])
|
||||
return SearchResults(
|
||||
[SearchResult(**{f.name: getattr(result, f.name)
|
||||
for f in dataclasses.fields(SearchResult)
|
||||
if hasattr(result, f.name)})])
|
||||
|
||||
query, cls, typ = helpers.extract_category_from_query(query)
|
||||
if cls is not None:
|
||||
@ -428,10 +432,10 @@ async def _unstructured_search(query: str, api: napi.NominatimAPIAsync,
|
||||
return await api.search(query, **details)
|
||||
|
||||
|
||||
async def search_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
async def search_endpoint(api: NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
""" Server glue for /search endpoint. See API docs for details.
|
||||
"""
|
||||
fmt = params.parse_format(napi.SearchResults, 'jsonv2')
|
||||
fmt = params.parse_format(SearchResults, 'jsonv2')
|
||||
debug = params.setup_debugging()
|
||||
details = params.parse_geometry_details(fmt)
|
||||
|
||||
@ -448,11 +452,11 @@ async def search_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> A
|
||||
details['min_rank'], details['max_rank'] = \
|
||||
helpers.feature_type_to_rank(params.get('featureType', ''))
|
||||
if params.get('featureType', None) is not None:
|
||||
details['layers'] = napi.DataLayer.ADDRESS
|
||||
details['layers'] = DataLayer.ADDRESS
|
||||
else:
|
||||
details['layers'] = params.get_layers()
|
||||
|
||||
details['locales'] = napi.Locales.from_accept_languages(params.get_accepted_languages())
|
||||
details['locales'] = Locales.from_accept_languages(params.get_accepted_languages())
|
||||
|
||||
# unstructured query parameters
|
||||
query = params.get('q', None)
|
||||
@ -508,7 +512,7 @@ async def search_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> A
|
||||
return params.build_response(output, num_results=len(results))
|
||||
|
||||
|
||||
async def deletable_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
async def deletable_endpoint(api: NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
""" Server glue for /deletable endpoint.
|
||||
This is a special endpoint that shows polygons that have been
|
||||
deleted or are broken in the OSM data but are kept in the
|
||||
@ -528,7 +532,7 @@ async def deletable_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -
|
||||
return params.build_response(formatting.format_result(results, fmt, {}))
|
||||
|
||||
|
||||
async def polygons_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
async def polygons_endpoint(api: NominatimAPIAsync, params: ASGIAdaptor) -> Any:
|
||||
""" Server glue for /polygons endpoint.
|
||||
This is a special endpoint that shows polygons that have changed
|
||||
their size but are kept in the Nominatim database with their
|
||||
@ -560,7 +564,7 @@ async def polygons_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) ->
|
||||
return params.build_response(formatting.format_result(results, fmt, {}))
|
||||
|
||||
|
||||
EndpointFunc = Callable[[napi.NominatimAPIAsync, ASGIAdaptor], Any]
|
||||
EndpointFunc = Callable[[NominatimAPIAsync, ASGIAdaptor], Any]
|
||||
|
||||
ROUTES = [
|
||||
('status', status_endpoint),
|
11
src/nominatim_api/version.py
Normal file
11
src/nominatim_api/version.py
Normal file
@ -0,0 +1,11 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Version information for the Nominatim API.
|
||||
"""
|
||||
|
||||
NOMINATIM_API_VERSION = '4.4.99'
|
@ -1,8 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# Copyright (C) 2024 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Command-line interface to the Nominatim functions for import, update,
|
||||
@ -16,12 +16,12 @@ import sys
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
from nominatim.config import Configuration
|
||||
from nominatim.tools.exec_utils import run_php_server
|
||||
from nominatim.errors import UsageError
|
||||
from nominatim import clicmd
|
||||
from nominatim import version
|
||||
from nominatim.clicmd.args import NominatimArgs, Subcommand
|
||||
from .config import Configuration
|
||||
from .errors import UsageError
|
||||
from .tools.exec_utils import run_php_server
|
||||
from . import clicmd
|
||||
from . import version
|
||||
from .clicmd.args import NominatimArgs, Subcommand
|
||||
|
||||
LOG = logging.getLogger()
|
||||
|
||||
@ -180,7 +180,7 @@ class AdminServe:
|
||||
else:
|
||||
port = 8088
|
||||
|
||||
server_module = importlib.import_module(f'nominatim.server.{args.engine}.server')
|
||||
server_module = importlib.import_module(f'nominatim_api.server.{args.engine}.server')
|
||||
|
||||
app = server_module.get_application(args.project_dir)
|
||||
uvicorn.run(app, host=host, port=port)
|
||||
@ -207,15 +207,29 @@ def get_set_parser() -> CommandlineParser:
|
||||
|
||||
parser.add_subcommand('admin', clicmd.AdminFuncs())
|
||||
|
||||
parser.add_subcommand('export', clicmd.QueryExport())
|
||||
parser.add_subcommand('convert', clicmd.ConvertDB())
|
||||
parser.add_subcommand('serve', AdminServe())
|
||||
try:
|
||||
exportcmd = importlib.import_module('nominatim_db.clicmd.export')
|
||||
apicmd = importlib.import_module('nominatim_db.clicmd.api')
|
||||
convertcmd = importlib.import_module('nominatim_db.clicmd.convert')
|
||||
|
||||
parser.add_subcommand('export', exportcmd.QueryExport())
|
||||
parser.add_subcommand('convert', convertcmd.ConvertDB())
|
||||
parser.add_subcommand('serve', AdminServe())
|
||||
|
||||
parser.add_subcommand('search', apicmd.APISearch())
|
||||
parser.add_subcommand('reverse', apicmd.APIReverse())
|
||||
parser.add_subcommand('lookup', apicmd.APILookup())
|
||||
parser.add_subcommand('details', apicmd.APIDetails())
|
||||
parser.add_subcommand('status', apicmd.APIStatus())
|
||||
except ModuleNotFoundError as ex:
|
||||
if not ex.name or 'nominatim_api' not in ex.name: # pylint: disable=E1135
|
||||
raise ex
|
||||
|
||||
parser.parser.epilog = \
|
||||
'\n\nNominatim API package not found. The following commands are not available:'\
|
||||
'\n export, convert, serve, search, reverse, lookup, details, status'\
|
||||
"\n\nRun 'pip install nominatim-api' to install the package."
|
||||
|
||||
parser.add_subcommand('search', clicmd.APISearch())
|
||||
parser.add_subcommand('reverse', clicmd.APIReverse())
|
||||
parser.add_subcommand('lookup', clicmd.APILookup())
|
||||
parser.add_subcommand('details', clicmd.APIDetails())
|
||||
parser.add_subcommand('status', clicmd.APIStatus())
|
||||
|
||||
return parser
|
||||
|
21
src/nominatim_db/clicmd/__init__.py
Normal file
21
src/nominatim_db/clicmd/__init__.py
Normal file
@ -0,0 +1,21 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2023 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Subcommand definitions for the command-line tool.
|
||||
"""
|
||||
# mypy and pylint disagree about the style of explicit exports,
|
||||
# see https://github.com/PyCQA/pylint/issues/6006.
|
||||
# pylint: disable=useless-import-alias
|
||||
|
||||
from .setup import SetupAll as SetupAll
|
||||
from .replication import UpdateReplication as UpdateReplication
|
||||
from .index import UpdateIndex as UpdateIndex
|
||||
from .refresh import UpdateRefresh as UpdateRefresh
|
||||
from .add_data import UpdateAddData as UpdateAddData
|
||||
from .admin import AdminFuncs as AdminFuncs
|
||||
from .freeze import SetupFreeze as SetupFreeze
|
||||
from .special_phrases import ImportSpecialPhrases as ImportSpecialPhrases
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user