|
@@ -27,6 +27,13 @@ function search(req, res, next) {
|
|
|
const lon = req.query.lon;
|
|
const lon = req.query.lon;
|
|
|
|
|
|
|
|
function translateSearchResultItems(results) {
|
|
function translateSearchResultItems(results) {
|
|
|
|
|
+ var classCity = [
|
|
|
|
|
+ 'city',
|
|
|
|
|
+ 'town',
|
|
|
|
|
+ 'village',
|
|
|
|
|
+ 'hamlet'
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
var classBusiness = [
|
|
var classBusiness = [
|
|
|
'fast_food',
|
|
'fast_food',
|
|
|
'restaurant',
|
|
'restaurant',
|
|
@@ -38,17 +45,27 @@ function search(req, res, next) {
|
|
|
'retail'
|
|
'retail'
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
- return results.map(function (r) {
|
|
|
|
|
|
|
+ return results.filter(function (r) {
|
|
|
|
|
+ if (r.type === 'political') return false;
|
|
|
|
|
+ if (r.type === 'house') return false;
|
|
|
|
|
+ if (r.type === 'motorway_junction') return false;
|
|
|
|
|
+ if (r.class === 'boundary') return false;
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }).map(function (r) {
|
|
|
var tmp = {
|
|
var tmp = {
|
|
|
icon: 'fa-address-card',
|
|
icon: 'fa-address-card',
|
|
|
address: r.address,
|
|
address: r.address,
|
|
|
lat: r.lat,
|
|
lat: r.lat,
|
|
|
lon: r.lon,
|
|
lon: r.lon,
|
|
|
type: r.type,
|
|
type: r.type,
|
|
|
- class: classBusiness.indexOf(r.type) !== -1 ? 'business' : '',
|
|
|
|
|
- display_name: r.display_name
|
|
|
|
|
|
|
+ nativeClass: r.class,
|
|
|
|
|
+ class: '',
|
|
|
|
|
+ displayName: r.display_name
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ if (classBusiness.indexOf(r.type) !== -1) tmp.class = 'business';
|
|
|
|
|
+ if (classCity.indexOf(r.type) !== -1) tmp.class = 'city';
|
|
|
|
|
+
|
|
|
// icons
|
|
// icons
|
|
|
if (r.type === 'fast_food' || r.type === 'restaurant') tmp.icon = 'fa-utensils';
|
|
if (r.type === 'fast_food' || r.type === 'restaurant') tmp.icon = 'fa-utensils';
|
|
|
if (r.type === 'doctors') tmp.icon = 'fa-user-md';
|
|
if (r.type === 'doctors') tmp.icon = 'fa-user-md';
|
|
@@ -62,13 +79,14 @@ function search(req, res, next) {
|
|
|
if (r.type === 'school') tmp.icon = 'fa-graduation-cap';
|
|
if (r.type === 'school') tmp.icon = 'fa-graduation-cap';
|
|
|
if (r.type === 'post_box' || r.type === 'post_office') tmp.icon = 'fa-envelope-square';
|
|
if (r.type === 'post_box' || r.type === 'post_office') tmp.icon = 'fa-envelope-square';
|
|
|
if (r.type === 'canal' || r.type === 'river' || r.type === 'water') tmp.icon = 'fa-water';
|
|
if (r.type === 'canal' || r.type === 'river' || r.type === 'water') tmp.icon = 'fa-water';
|
|
|
- if (r.type === 'station' || r.type === 'stop') tmp.icon = 'fa-subway';
|
|
|
|
|
|
|
+ if (r.type === 'station' || r.type === 'stop' || r.type === 'bus_stop') tmp.icon = 'fa-subway';
|
|
|
if (r.type === 'attraction') tmp.icon = 'fa-monument';
|
|
if (r.type === 'attraction') tmp.icon = 'fa-monument';
|
|
|
- if (r.type === 'city' || r.type === 'village' || r.type === 'administrative') tmp.icon = 'fa-city';
|
|
|
|
|
|
|
+ if (r.type === 'city' || r.type === 'village' || r.type === 'town' || r.type === 'hamlet') tmp.icon = 'fa-city';
|
|
|
if (r.type === 'administrative' || r.class === 'office') tmp.icon = 'fa-building';
|
|
if (r.type === 'administrative' || r.class === 'office') tmp.icon = 'fa-building';
|
|
|
if (r.type === 'pub' || r.type === 'bar') tmp.icon = 'fa-beer';
|
|
if (r.type === 'pub' || r.type === 'bar') tmp.icon = 'fa-beer';
|
|
|
if (r.type === 'hotel' || r.type === 'hostel') tmp.icon = 'fa-bed';
|
|
if (r.type === 'hotel' || r.type === 'hostel') tmp.icon = 'fa-bed';
|
|
|
if (r.type === 'supermarket' || r.type === 'retail') tmp.icon = 'fa-shopping-cart';
|
|
if (r.type === 'supermarket' || r.type === 'retail') tmp.icon = 'fa-shopping-cart';
|
|
|
|
|
+ if (r.class === 'highway') tmp.icon = 'fa-road';
|
|
|
|
|
|
|
|
// ensure we have some city if only town is mentioned
|
|
// ensure we have some city if only town is mentioned
|
|
|
if (!tmp.address.city) tmp.address.city = tmp.address.town;
|
|
if (!tmp.address.city) tmp.address.city = tmp.address.town;
|
|
@@ -77,6 +95,9 @@ function search(req, res, next) {
|
|
|
tmp.name = r.display_name.split(',')[0];
|
|
tmp.name = r.display_name.split(',')[0];
|
|
|
if (r.class === 'place' || r.class === 'building') tmp.name = r.address.road + ' ' + r.address.house_number;
|
|
if (r.class === 'place' || r.class === 'building') tmp.name = r.address.road + ' ' + r.address.house_number;
|
|
|
if (r.type === 'city') tmp.name = r.address.city;
|
|
if (r.type === 'city') tmp.name = r.address.city;
|
|
|
|
|
+ if (r.type === 'town') tmp.name = r.address.town;
|
|
|
|
|
+ if (r.type === 'village') tmp.name = r.address.village;
|
|
|
|
|
+ if (r.type === 'hamlet') tmp.name = r.address.hamlet;
|
|
|
|
|
|
|
|
// fallback to display name
|
|
// fallback to display name
|
|
|
if (!tmp.name) tmp.name = r.display_name;
|
|
if (!tmp.name) tmp.name = r.display_name;
|