2 import { fetch_from_api, update_html_title } from '../lib/api_utils.js';
3 import { page } from '../lib/stores.js';
6 osmLink, wikipediaLink, coverageType, isAdminBoundary,
7 formatAddressRank, formatKeywordToken
8 } from '../lib/helpers.js';
9 import Header from '../components/Header.svelte';
10 import MapIcon from '../components/MapIcon.svelte';
11 import SearchSectionDetails from '../components/SearchSectionDetails.svelte';
12 import DetailsOneRow from '../components/DetailsOneRow.svelte';
13 import DetailsLink from '../components/DetailsLink.svelte';
14 import InfoRow from '../components/DetailsInfoRow.svelte';
15 import InfoRowList from '../components/DetailsInfoRowList.svelte';
16 import Map from '../components/Map.svelte';
19 let base_url = window.location.search;
20 let api_request_params;
21 let api_request_finished = false;
23 function loaddata(search_params) {
24 api_request_params = {
25 place_id: search_params.get('place_id'),
26 osmtype: search_params.get('osmtype'),
27 osmid: search_params.get('osmid'),
28 class: search_params.get('class'),
29 keywords: search_params.get('keywords'),
31 hierarchy: (search_params.get('hierarchy') === '1' ? 1 : 0),
36 api_request_finished = false;
38 if (api_request_params.place_id || (api_request_params.osmtype && api_request_params.osmid)) {
40 if (api_request_params.place_id) {
41 update_html_title('Details for ' + api_request_params.place_id);
43 update_html_title('Details for ' + api_request_params.osmtype + api_request_params.osmid);
46 fetch_from_api('details', api_request_params, function (data) {
47 window.scrollTo(0, 0);
48 api_request_finished = true;
49 aPlace = (data && !data.error) ? data : undefined;
58 if (pageinfo.tab === 'details') {
59 loaddata(pageinfo.params);
65 <SearchSectionDetails api_request_params={api_request_params}/>
68 <div class="container">
71 <div class="col-sm-10">
74 <small><DetailsLink feature={aPlace}>link to this page</DetailsLink></small>
77 <div class="col-sm-2 text-right">
78 <MapIcon aPlace={aPlace} />
82 <div class="col-md-6">
83 <table id="locationdetails" class="table table-striped">
85 <InfoRow title="Name"><InfoRowList items={aPlace.names} /></InfoRow>
86 <InfoRow title="Type">{aPlace.category}:{aPlace.type}</InfoRow>
87 <InfoRow title="Last Updated">{aPlace.indexed_date}</InfoRow>
88 {#if (isAdminBoundary(aPlace)) }
89 <InfoRow title="Admin Level">{aPlace.admin_level}</InfoRow>
91 <InfoRow title="Search Rank">{aPlace.rank_search}</InfoRow>
92 <InfoRow title="Address Rank">{aPlace.rank_address} ({formatAddressRank(aPlace.rank_address)})</InfoRow>
93 {#if aPlace.calculated_importance}
94 <InfoRow title="Importance">
95 {aPlace.calculated_importance}
96 {#if !aPlace.importance} (estimated){/if}
99 <InfoRow title="Coverage">{coverageType(aPlace)}</InfoRow>
100 <InfoRow title="Centre Point (lat,lon)">
101 {aPlace.centroid.coordinates[1]},{aPlace.centroid.coordinates[0]}
103 <InfoRow title="OSM">{@html osmLink(aPlace)}</InfoRow>
104 <InfoRow title="Place Id">
106 (<a href="https://nominatim.org/release-docs/develop/api/Output/#place_id-is-not-a-persistent-id">on this server</a>)
108 {#if aPlace.calculated_wikipedia}
109 <InfoRow title="Wikipedia Calculated">{@html wikipediaLink(aPlace)}</InfoRow>
111 <InfoRow title="Computed Postcode">{aPlace.calculated_postcode || ''}</InfoRow>
112 <InfoRow title="Address Tags"><InfoRowList items={aPlace.addresstags} /></InfoRow>
113 <InfoRow title="Extra Tags"><InfoRowList items={aPlace.extratags} /></InfoRow>
117 <div class="col-md-6">
118 <div id="map-wrapper">
119 <Map current_result={aPlace} />
124 <div class="col-md-12">
126 <table id="address" class="table table-striped table-small">
132 <th>Address rank</th>
140 {#each aPlace.address as addressLine}
141 <DetailsOneRow addressLine={addressLine} bDistanceInMeters=false />
145 {#if aPlace.linked_places}
146 <tr class="all-columns"><td colspan="6"><h2>Linked Places</h2></td></tr>
147 {#each aPlace.linked_places as addressLine}
148 <DetailsOneRow addressLine={addressLine} bDistanceInMeters=true />
152 <tr class="all-columns"><td colspan="6"><h2>Keywords</h2></td></tr>
153 {#if aPlace.keywords}
154 <tr class="all-columns"><td colspan="6"><h3>Name Keywords</h3></td></tr>
155 {#each aPlace.keywords.name as keyword}
157 <td>{formatKeywordToken(keyword.token)}</td>
159 <td>word id: {keyword.id}</td>
164 <tr class="all-columns"><td colspan="6"><h3>Address Keywords</h3></td></tr>
165 {#each aPlace.keywords.address as keyword}
167 <td>{formatKeywordToken(keyword.token)}</td>
169 <td>word id: {keyword.id}</td>
176 <a class="btn btn-outline-secondary btn-sm"
177 href="{base_url}&keywords=1">display keywords</a>
182 <tr class="all-columns"><td colspan="6"><h2>Parent Of</h2></td></tr>
183 {#if aPlace.hierarchy}
185 {#each Object.keys(aPlace.hierarchy) as type}
186 <tr class="all-columns"><td colspan="6"><h3>{type}</h3></td></tr>
187 {#each aPlace.hierarchy[type] as line}
188 <DetailsOneRow addressLine={line} bDistanceInMeters=true />
192 {#if Object.keys(aPlace.hierarchy) > 500}
193 <p>There are more child objects which are not shown.</p>
198 <a class="btn btn-outline-secondary btn-sm"
199 href="{base_url}&hierarchy=1">display child places</a>
207 {:else if (window.location.search !== '' && api_request_finished)}
220 h1 small :global(a) {
228 background-color: white;
236 background-color: white !important;
240 border-top: none !important;
241 padding-left: 0 !important;
251 border: 1px solid #666;