mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 13:24:07 +00:00
add admin_level to extratags for XML and details API endpoint
This commit is contained in:
@@ -19,6 +19,7 @@ from ..localization import Locales
|
|||||||
from ..result_formatting import FormatDispatcher
|
from ..result_formatting import FormatDispatcher
|
||||||
from .classtypes import ICONS
|
from .classtypes import ICONS
|
||||||
from . import format_json, format_xml
|
from . import format_json, format_xml
|
||||||
|
from .format_json import _add_admin_level
|
||||||
from .. import logging as loglib
|
from .. import logging as loglib
|
||||||
from ..server import content_types as ct
|
from ..server import content_types as ct
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ def _format_details_json(result: DetailedResult, options: Mapping[str, Any]) ->
|
|||||||
.keyval_not_none('indexed_date', result.indexed_date, lambda v: v.isoformat())\
|
.keyval_not_none('indexed_date', result.indexed_date, lambda v: v.isoformat())\
|
||||||
.keyval_not_none('importance', result.importance)\
|
.keyval_not_none('importance', result.importance)\
|
||||||
.keyval('calculated_importance', result.calculated_importance())\
|
.keyval('calculated_importance', result.calculated_importance())\
|
||||||
.keyval('extratags', result.extratags or {})\
|
.keyval('extratags', _add_admin_level(result) or {})\
|
||||||
.keyval_not_none('calculated_wikipedia', result.wikipedia)\
|
.keyval_not_none('calculated_wikipedia', result.wikipedia)\
|
||||||
.keyval('rank_address', result.rank_address)\
|
.keyval('rank_address', result.rank_address)\
|
||||||
.keyval('rank_search', result.rank_search)\
|
.keyval('rank_search', result.rank_search)\
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import xml.etree.ElementTree as ET
|
|||||||
from ..results import AddressLines, ReverseResult, ReverseResults, \
|
from ..results import AddressLines, ReverseResult, ReverseResults, \
|
||||||
SearchResult, SearchResults
|
SearchResult, SearchResults
|
||||||
from . import classtypes as cl
|
from . import classtypes as cl
|
||||||
|
from .format_json import _add_admin_level
|
||||||
from ..types import EntranceDetails
|
from ..types import EntranceDetails
|
||||||
|
|
||||||
|
|
||||||
@@ -125,8 +126,9 @@ def format_base_xml(results: Union[ReverseResults, SearchResults],
|
|||||||
|
|
||||||
if options.get('extratags', False):
|
if options.get('extratags', False):
|
||||||
eroot = ET.SubElement(root if simple else place, 'extratags')
|
eroot = ET.SubElement(root if simple else place, 'extratags')
|
||||||
if result.extratags:
|
tags = _add_admin_level(result)
|
||||||
for k, v in result.extratags.items():
|
if tags:
|
||||||
|
for k, v in tags.items():
|
||||||
ET.SubElement(eroot, 'tag', attrib={'key': k, 'value': v})
|
ET.SubElement(eroot, 'tag', attrib={'key': k, 'value': v})
|
||||||
|
|
||||||
if options.get('namedetails', False):
|
if options.get('namedetails', False):
|
||||||
|
|||||||
Reference in New Issue
Block a user