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 Map from '../components/Map.svelte';
17 let base_url = window.location.search;
18 let api_request_params;
19 let api_request_finished = false;
21 function loaddata(search_params) {
22 api_request_params = {
23 place_id: search_params.get('place_id'),
24 osmtype: search_params.get('osmtype'),
25 osmid: search_params.get('osmid'),
26 class: search_params.get('class'),
27 keywords: search_params.get('keywords'),
29 hierarchy: (search_params.get('hierarchy') === '1' ? 1 : 0),
34 api_request_finished = false;
36 if (api_request_params.place_id || (api_request_params.osmtype && api_request_params.osmid)) {
38 if (api_request_params.place_id) {
39 update_html_title('Details for ' + api_request_params.place_id);
41 update_html_title('Details for ' + api_request_params.osmtype + api_request_params.osmid);
44 fetch_from_api('details', api_request_params, function (data) {
45 window.scrollTo(0, 0);
46 api_request_finished = true;
47 aPlace = (data && !data.error) ? data : undefined;
56 if (pageinfo.tab === 'details') {
57 loaddata(pageinfo.params);
63 <SearchSectionDetails api_request_params={api_request_params}/>
66 <div class="container">
69 <div class="col-sm-10">
72 <small><DetailsLink feature={aPlace}>link to this page</DetailsLink></small>
75 <div class="col-sm-2 text-right">
76 <MapIcon aPlace={aPlace} />
80 <div class="col-md-6">
81 <table id="locationdetails" class="table table-striped">
86 {#each Object.keys(aPlace.names) as name}
88 <span class="name">{aPlace.names[name]}</span> ({name})
95 <td>{aPlace.category}:{aPlace.type}</td>
99 <td>{aPlace.indexed_date}</td>
101 {#if (isAdminBoundary(aPlace)) }
104 <td>{aPlace.admin_level}</td>
109 <td>{aPlace.rank_search}</td>
112 <td>Address Rank</td>
113 <td>{aPlace.rank_address} ({formatAddressRank(aPlace.rank_address)})</td>
115 {#if aPlace.calculated_importance}
119 {aPlace.calculated_importance}
120 {#if !aPlace.importance} (estimated){/if}
126 <td>{coverageType(aPlace)}</td>
129 <td>Centre Point (lat,lon)</td>
131 {aPlace.centroid.coordinates[1]},{aPlace.centroid.coordinates[0]}
136 <td>{@html osmLink(aPlace)}
141 (<a href="https://nominatim.org/release-docs/develop/api/Output/#place_id-is-not-a-persistent-id">on this server</a>)
143 <td>{aPlace.place_id}</td>
145 {#if aPlace.calculated_wikipedia}
147 <td>Wikipedia Calculated</td>
148 <td>{@html wikipediaLink(aPlace)}</td>
152 <td>Computed Postcode</td>
153 <td>{aPlace.calculated_postcode}</td>
156 <td>Address Tags</td>
158 {#each Object.keys(aPlace.addresstags) as name}
160 <span class="name">{aPlace.addresstags[name]}</span> ({name})
168 {#each Object.keys(aPlace.extratags) as name}
170 <span class="name">{aPlace.extratags[name]}</span> ({name})
178 <div class="col-md-6">
179 <div id="map-wrapper">
180 <Map current_result={aPlace} />
185 <div class="col-md-12">
187 <table id="address" class="table table-striped table-small">
193 <th>Address rank</th>
201 {#each aPlace.address as addressLine}
202 <DetailsOneRow addressLine={addressLine} bDistanceInMeters=false />
206 {#if aPlace.linked_places}
207 <tr class="all-columns"><td colspan="6"><h2>Linked Places</h2></td></tr>
208 {#each aPlace.linked_places as addressLine}
209 <DetailsOneRow addressLine={addressLine} bDistanceInMeters=true />
213 <tr class="all-columns"><td colspan="6"><h2>Keywords</h2></td></tr>
214 {#if aPlace.keywords}
215 <tr class="all-columns"><td colspan="6"><h3>Name Keywords</h3></td></tr>
216 {#each aPlace.keywords.name as keyword}
218 <td>{formatKeywordToken(keyword.token)}</td>
220 <td>word id: {keyword.id}</td>
225 <tr class="all-columns"><td colspan="6"><h3>Address Keywords</h3></td></tr>
226 {#each aPlace.keywords.address as keyword}
228 <td>{formatKeywordToken(keyword.token)}</td>
230 <td>word id: {keyword.id}</td>
237 <a class="btn btn-outline-secondary btn-sm"
238 href="{base_url}&keywords=1">display keywords</a>
243 <tr class="all-columns"><td colspan="6"><h2>Parent Of</h2></td></tr>
244 {#if aPlace.hierarchy}
246 {#each Object.keys(aPlace.hierarchy) as type}
247 <tr class="all-columns"><td colspan="6"><h3>{type}</h3></td></tr>
248 {#each aPlace.hierarchy[type] as line}
249 <DetailsOneRow addressLine={line} bDistanceInMeters=true />
253 {#if Object.keys(aPlace.hierarchy) > 500}
254 <p>There are more child objects which are not shown.</p>
259 <a class="btn btn-outline-secondary btn-sm"
260 href="{base_url}&hierarchy=1">display child places</a>
268 {:else if (window.location.search !== '' && api_request_finished)}
281 h1 small :global(a) {
289 background-color: white;
297 background-color: white !important;
301 border-top: none !important;
302 padding-left: 0 !important;
311 .table>thead>tr>th, .table>tbody>tr>td {
321 border: 1px solid #666;