]> git.openstreetmap.org Git - nominatim-ui.git/commitdiff
restructure rank display
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 2 Dec 2020 15:17:14 +0000 (16:17 +0100)
committermtmail <mtmail@gmx.net>
Wed, 2 Dec 2020 16:42:51 +0000 (17:42 +0100)
Search rank is not really bound to place types anymore, therefore
only display a number. Address rank is the more important rank now.
Add it to the display and return the equivalent place type there.

dist/deletable.html
dist/details.html
dist/handlebar_helpers.js
dist/polygons.html
dist/reverse.html
dist/search.html
src/handlebar_helpers.js
src/templates/detailspage.hbs

index a33aa38cbf21241827f5aafab30732bb2beecd24..14788099dfe9350b036451943e01d667066b3c73 100644 (file)
           <td>{{aPlace.admin_level}}</td>
         </tr>
         <tr>
-          <td>Rank</td>
-          <td>{{formatSearchRank aPlace.rank_search}}</td>
+          <td>Search Rank</td>
+          <td>{{aPlace.rank_search}}</td>
+        </tr>
+        <tr>
+          <td>Address Rank</td>
+          <td>{{aPlace.rank_address}} ({{formatAddressRank aPlace.rank_address}})</td>
         </tr>
         {{#if aPlace.calculated_importance}}
           <tr>
index a33aa38cbf21241827f5aafab30732bb2beecd24..14788099dfe9350b036451943e01d667066b3c73 100644 (file)
           <td>{{aPlace.admin_level}}</td>
         </tr>
         <tr>
-          <td>Rank</td>
-          <td>{{formatSearchRank aPlace.rank_search}}</td>
+          <td>Search Rank</td>
+          <td>{{aPlace.rank_search}}</td>
+        </tr>
+        <tr>
+          <td>Address Rank</td>
+          <td>{{aPlace.rank_address}} ({{formatAddressRank aPlace.rank_address}})</td>
         </tr>
         {{#if aPlace.calculated_importance}}
           <tr>
index 36deacd808d35f8aa435a4707cdd6dcdec608710..e07c3390142b2b47361a46f3f7f9e15c8bebe0c5 100644 (file)
@@ -233,28 +233,23 @@ Handlebars.registerHelper({
     }
     return '';
   },
-  formatSearchRank: function (iRank) {
-    // same as
-    // https://github.com/osm-search/Nominatim/blob/master/sql/functions.sql
-    // get_searchrank_label()
-
-    if (iRank < 2) return 'continent';
-    if (iRank < 4) return 'sea';
-    if (iRank < 8) return 'country';
-    if (iRank < 12) return 'state';
-    if (iRank < 16) return 'county';
-    if (iRank === 16) return 'city';
-    if (iRank === 17) return 'town / island';
-    if (iRank === 18) return 'village / hamlet';
-    if (iRank === 20) return 'suburb';
-    if (iRank === 21) return 'postcode area';
-    if (iRank === 22) return 'croft / farm / locality / islet';
-    if (iRank === 23) return 'postcode area';
-    if (iRank === 25) return 'postcode point';
-    if (iRank === 26) return 'street / major landmark';
+  formatAddressRank: function (iRank) {
+    if (iRank < 4) return 'other';
+    if (iRank < 6) return 'country';
+    if (iRank < 8) return 'region';
+    if (iRank < 10) return 'state';
+    if (iRank < 12) return 'state district';
+    if (iRank < 14) return 'county';
+    if (iRank < 16) return 'municipality';
+    if (iRank < 18) return 'city / town / village';
+    if (iRank < 20) return 'city / village district';
+    if (iRank < 22) return 'suburb / hamlet';
+    if (iRank < 24) return 'neighbourhood';
+    if (iRank < 26) return 'city block / square';
+    if (iRank === 26) return 'major street';
     if (iRank === 27) return 'minory street / path';
-    if (iRank === 28) return 'house / building';
-    return 'other: ' + iRank;
+    if (iRank <= 30) return 'house / building';
+    return 'other';
   },
   tooManyHierarchyLinesWarning: function (aPlace) {
     if (!aPlace.hierarchy) return '';
index a33aa38cbf21241827f5aafab30732bb2beecd24..14788099dfe9350b036451943e01d667066b3c73 100644 (file)
           <td>{{aPlace.admin_level}}</td>
         </tr>
         <tr>
-          <td>Rank</td>
-          <td>{{formatSearchRank aPlace.rank_search}}</td>
+          <td>Search Rank</td>
+          <td>{{aPlace.rank_search}}</td>
+        </tr>
+        <tr>
+          <td>Address Rank</td>
+          <td>{{aPlace.rank_address}} ({{formatAddressRank aPlace.rank_address}})</td>
         </tr>
         {{#if aPlace.calculated_importance}}
           <tr>
index a33aa38cbf21241827f5aafab30732bb2beecd24..14788099dfe9350b036451943e01d667066b3c73 100644 (file)
           <td>{{aPlace.admin_level}}</td>
         </tr>
         <tr>
-          <td>Rank</td>
-          <td>{{formatSearchRank aPlace.rank_search}}</td>
+          <td>Search Rank</td>
+          <td>{{aPlace.rank_search}}</td>
+        </tr>
+        <tr>
+          <td>Address Rank</td>
+          <td>{{aPlace.rank_address}} ({{formatAddressRank aPlace.rank_address}})</td>
         </tr>
         {{#if aPlace.calculated_importance}}
           <tr>
index a33aa38cbf21241827f5aafab30732bb2beecd24..14788099dfe9350b036451943e01d667066b3c73 100644 (file)
           <td>{{aPlace.admin_level}}</td>
         </tr>
         <tr>
-          <td>Rank</td>
-          <td>{{formatSearchRank aPlace.rank_search}}</td>
+          <td>Search Rank</td>
+          <td>{{aPlace.rank_search}}</td>
+        </tr>
+        <tr>
+          <td>Address Rank</td>
+          <td>{{aPlace.rank_address}} ({{formatAddressRank aPlace.rank_address}})</td>
         </tr>
         {{#if aPlace.calculated_importance}}
           <tr>
index 36deacd808d35f8aa435a4707cdd6dcdec608710..e07c3390142b2b47361a46f3f7f9e15c8bebe0c5 100644 (file)
@@ -233,28 +233,23 @@ Handlebars.registerHelper({
     }
     return '';
   },
-  formatSearchRank: function (iRank) {
-    // same as
-    // https://github.com/osm-search/Nominatim/blob/master/sql/functions.sql
-    // get_searchrank_label()
-
-    if (iRank < 2) return 'continent';
-    if (iRank < 4) return 'sea';
-    if (iRank < 8) return 'country';
-    if (iRank < 12) return 'state';
-    if (iRank < 16) return 'county';
-    if (iRank === 16) return 'city';
-    if (iRank === 17) return 'town / island';
-    if (iRank === 18) return 'village / hamlet';
-    if (iRank === 20) return 'suburb';
-    if (iRank === 21) return 'postcode area';
-    if (iRank === 22) return 'croft / farm / locality / islet';
-    if (iRank === 23) return 'postcode area';
-    if (iRank === 25) return 'postcode point';
-    if (iRank === 26) return 'street / major landmark';
+  formatAddressRank: function (iRank) {
+    if (iRank < 4) return 'other';
+    if (iRank < 6) return 'country';
+    if (iRank < 8) return 'region';
+    if (iRank < 10) return 'state';
+    if (iRank < 12) return 'state district';
+    if (iRank < 14) return 'county';
+    if (iRank < 16) return 'municipality';
+    if (iRank < 18) return 'city / town / village';
+    if (iRank < 20) return 'city / village district';
+    if (iRank < 22) return 'suburb / hamlet';
+    if (iRank < 24) return 'neighbourhood';
+    if (iRank < 26) return 'city block / square';
+    if (iRank === 26) return 'major street';
     if (iRank === 27) return 'minory street / path';
-    if (iRank === 28) return 'house / building';
-    return 'other: ' + iRank;
+    if (iRank <= 30) return 'house / building';
+    return 'other';
   },
   tooManyHierarchyLinesWarning: function (aPlace) {
     if (!aPlace.hierarchy) return '';
index e0225e866ed4504c3354f9cf06f027019296ebdd..410f3c82f41baf20847f98df955cfb63dca22b81 100644 (file)
           <td>{{aPlace.admin_level}}</td>
         </tr>
         <tr>
-          <td>Rank</td>
-          <td>{{formatSearchRank aPlace.rank_search}}</td>
+          <td>Search Rank</td>
+          <td>{{aPlace.rank_search}}</td>
+        </tr>
+        <tr>
+          <td>Address Rank</td>
+          <td>{{aPlace.rank_address}} ({{formatAddressRank aPlace.rank_address}})</td>
         </tr>
         {{#if aPlace.calculated_importance}}
           <tr>