mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 05:14:07 +00:00
add _add_admin_level helper function to helpers.py
This commit is contained in:
@@ -12,10 +12,20 @@ from typing import Tuple, Optional, Any, Dict, Iterable
|
||||
from itertools import chain
|
||||
import re
|
||||
|
||||
from ..results import SearchResults, SourceTable
|
||||
from ..results import SearchResults, SourceTable, BaseResult
|
||||
from ..types import SearchDetails, GeometryFormat
|
||||
|
||||
|
||||
def _add_admin_level(result: BaseResult) -> Optional[Dict[str, str]]:
|
||||
""" Inject admin_level into extratags for boundary=administrative results.
|
||||
"""
|
||||
tags = result.extratags
|
||||
if result.category == ('boundary', 'administrative') and result.admin_level < 15:
|
||||
tags = dict(tags) if tags else {}
|
||||
tags['admin_level'] = str(result.admin_level)
|
||||
return tags
|
||||
|
||||
|
||||
REVERSE_MAX_RANKS = [2, 2, 2, # 0-2 Continent/Sea
|
||||
4, 4, # 3-4 Country
|
||||
8, # 5 State
|
||||
|
||||
Reference in New Issue
Block a user