Skip to content

Commit

Permalink
add support for hogfish forward geocoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Natalia Kowalczyk committed Jan 25, 2025
1 parent 6aca200 commit 9ffeb5c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/service/hogfish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ function getUrl(url, types, op, query) {
q.push('radius=100');
q.push(...types[query.type]);
break;
default:
case 'forward':
q.push('q=' + encodeURIComponent(query.place));
if (query.bounds) {
q.push('sw=' + query.bounds[0].join(','));
q.push('ne=' + query.bounds[1].join(','));
}
break;
default:
// invalid operation
return;
}
Expand All @@ -35,7 +42,7 @@ function getUrl(url, types, op, query) {
}

function prepareRequest(types, op, query) {
return Boolean(types[query.type]);
return op === 'forward' || Boolean(types[query.type]);
}

function matchNames(n1, n2) {
Expand Down Expand Up @@ -115,6 +122,7 @@ function init(options) {
}
options = util.defaults(options, {
reverse: true,
forward: true,
url: getUrl.bind(undefined, options.hogfish_url, options.types),
status: getStatus,
prepareRequest: prepareRequest.bind(undefined, options.types),
Expand Down

0 comments on commit 9ffeb5c

Please sign in to comment.