Skip to content

Commit

Permalink
fix here reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanocudini committed Oct 12, 2022
1 parent 2a82ee2 commit aaf9abe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
24 changes: 16 additions & 8 deletions geocoder/utils/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,29 @@ module.exports = (config, _) => {

lang = lang || config.default_lang;

const items = _.get(data,'body.Response.View[0].Result');
//const items = _.get(data,'body.Response.View[0].Result');
const items = _.get(data,'items');

return _.compact(_.map(items, (item)=> {
console.log('HERE RETURN',JSON.stringify(items,null,4))

let lat = _.get(item,"Location.DisplayPosition.Latitude"),
return _.compact(_.map(items, item => {

/* let lat = _.get(item,"Location.DisplayPosition.Latitude"),
lon = _.get(item,"Location.DisplayPosition.Longitude"),
a = _.get(item,"Location.Address"),
text = _.compact([a.Street, a.HouseNumber, a.City]).join(', ');
text = _.compact([a.Street, a.HouseNumber, a.City]).join(', ');*/

let lat = _.get(item,"position.lat")
, lon = _.get(item,"position.lng")
, text = _.get(item,"address.label");
console.log(item.id,lat,lon,text)
if (lat && lon) {

return createHit({
id: _.get(item,'Location.LocationId'),
text: text,
lat: lat,
lon: lon,
id: item.id,
text,
lat,
lon,
source: 'here',
layer: config.endpoints.here.layer
});
Expand Down
5 changes: 2 additions & 3 deletions geocoder/utils/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const heremap = {
+`&apiKey=${api_key}`
+`&q=${text}`
//+`&lang=${lang}`
+'&result_types=address,place'
//+'&result_types=address,place'
+`&in=bbox:${bbox}`
//+`&in=countryCode:${country}`
+`&limit=${limit}`;
Expand All @@ -47,8 +47,7 @@ const heremap = {
res.on('end', () => {
try {
const data = JSON.parse(str);
console.log('RETURN',JSON.stringify(data,null,4))
resolve({});
resolve(data);
}
catch(err) {
console.error(`Error "${err}" to connect endpoint ${endpoint.hostname}${endpoint.path}`);
Expand Down

0 comments on commit aaf9abe

Please sign in to comment.