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';
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);
60 base_url = window.location.search;
66 <SearchSectionDetails api_request_params={api_request_params}/>
69 <div class="container">
72 <div class="col-sm-10">
75 <small><DetailsLink feature={aPlace}>link to this page</DetailsLink></small>
78 <div class="col-sm-2 text-right">
79 <MapIcon aPlace={aPlace} />
83 <div class="col-md-6">
84 <table id="locationdetails" class="table table-striped table-responsive">
86 <InfoRow title="Name"><InfoRowList items={aPlace.names} /></InfoRow>
87 <InfoRow title="Type">{aPlace.category}:{aPlace.type}</InfoRow>
88 <InfoRow title="Last Updated">{aPlace.indexed_date}</InfoRow>
89 {#if (isAdminBoundary(aPlace)) }
90 <InfoRow title="Admin Level">{aPlace.admin_level}</InfoRow>
92 <InfoRow title="Search Rank">{aPlace.rank_search}</InfoRow>
93 <InfoRow title="Address Rank">{aPlace.rank_address} ({formatAddressRank(aPlace.rank_address)})</InfoRow>
94 {#if aPlace.calculated_importance}
95 <InfoRow title="Importance">
96 {aPlace.calculated_importance}
97 {#if !aPlace.importance} (estimated){/if}
100 <InfoRow title="Coverage">{coverageType(aPlace)}</InfoRow>
101 <InfoRow title="Centre Point (lat,lon)">
102 {aPlace.centroid.coordinates[1]},{aPlace.centroid.coordinates[0]}
104 <InfoRow title="OSM">{@html osmLink(aPlace)}</InfoRow>
105 <InfoRow title="Place Id">
107 (<a href="https://nominatim.org/release-docs/develop/api/Output/#place_id-is-not-a-persistent-id">on this server</a>)
109 {#if aPlace.calculated_wikipedia}
110 <InfoRow title="Wikipedia Calculated">{@html wikipediaLink(aPlace)}</InfoRow>
112 <InfoRow title="Computed Postcode">{aPlace.calculated_postcode || ''}</InfoRow>
113 <InfoRow title="Address Tags"><InfoRowList items={aPlace.addresstags} /></InfoRow>
114 <InfoRow title="Extra Tags"><InfoRowList items={aPlace.extratags} /></InfoRow>
118 <div class="col-md-6">
119 <div id="map-wrapper">
120 <Map current_result={aPlace} />
125 <div class="col-md-12">
127 <table id="address" class="table table-striped table-small">
133 <th>Address rank</th>
141 {#each aPlace.address as addressLine}
142 <DetailsOneRow addressLine={addressLine} bMarkUnusedLines=true bDistanceInMeters=false />
146 {#if aPlace.linked_places}
147 <tr class="all-columns"><td colspan="6"><h2>Linked Places</h2></td></tr>
148 {#each aPlace.linked_places as addressLine}
149 <DetailsOneRow addressLine={addressLine} bMarkUnusedLines=true bDistanceInMeters=true />
153 <tr class="all-columns"><td colspan="6"><h2>Keywords</h2></td></tr>
154 {#if aPlace.keywords}
155 <tr class="all-columns"><td colspan="6"><h3>Name Keywords</h3></td></tr>
156 {#each aPlace.keywords.name as keyword}
158 <td>{formatKeywordToken(keyword.token)}</td>
160 <td>word id: {keyword.id}</td>
165 {#if aPlace.keywords.address}
166 <tr class="all-columns"><td colspan="6"><h3>Address Keywords</h3></td></tr>
167 {#each aPlace.keywords.address as keyword}
169 <td>{formatKeywordToken(keyword.token)}</td>
171 <td>word id: {keyword.id}</td>
179 <a class="btn btn-outline-secondary btn-sm"
180 href="{base_url}&keywords=1">display keywords</a>
185 <tr class="all-columns"><td colspan="6"><h2>Parent Of</h2></td></tr>
186 {#if aPlace.hierarchy}
188 {#each Object.keys(aPlace.hierarchy) as type}
189 <tr class="all-columns"><td colspan="6"><h3>{type}</h3></td></tr>
190 {#each aPlace.hierarchy[type] as line}
191 <DetailsOneRow addressLine={line} bDistanceInMeters=true />
195 {#if Object.keys(aPlace.hierarchy) > 500}
196 <p>There are more child objects which are not shown.</p>
201 <a class="btn btn-outline-secondary btn-sm"
202 href="{base_url}&hierarchy=1">display child places</a>
210 {:else if (window.location.search !== '' && api_request_finished)}
223 h1 small :global(a) {
231 background-color: white;
239 background-color: white !important;
243 border-top: none !important;
244 padding-left: 0 !important;
251 border: 1px solid #666;