1 # SPDX-License-Identifier: GPL-3.0-or-later
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2023 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Helper function for parsing parameters and and outputting data
9 specifically for the v1 version of the API.
12 REVERSE_MAX_RANKS = [2, 2, 2, # 0-2 Continent/Sea
19 19, # 13 Village/Suburb
20 22, # 14 Hamlet/Neighbourhood
22 26, # 16 Major Streets
23 27, # 17 Minor Streets
28 def zoom_to_rank(zoom: int) -> int:
29 """ Convert a zoom parameter into a rank according to the v1 API spec.
31 return REVERSE_MAX_RANKS[max(0, min(18, zoom))]