Skip to content

Commit

Permalink
Merge pull request #426 from mapbox/geocoding-update
Browse files Browse the repository at this point in the history
Added parameters to geocoding service
  • Loading branch information
mpothier authored Sep 7, 2021
2 parents 060a9bd + 60c1c5a commit 0b67e0e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- **Revert:** add `driving-traffic` profile to Isochrone service.

## 0.13.2

**Add:** add `fuzzyMatch` and `worldview` parameters to the geocoding service

## 0.13.1

**Fix:** Update `got` depdendency to 10.7.0
Expand Down
3 changes: 3 additions & 0 deletions docs/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,8 @@ See the [public documentation][236].
Options are [IETF language tags][239] comprised of a mandatory
[ISO 639-1 language code][240] and optionally one or more IETF subtags for country or script.
- `config.routing` **[boolean][202]** Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features. (optional, default `false`)
- `config.fuzzyMatch` **[boolean][202]** Specify whether the Geocoding API should attempt approximate, as well as exact, matching. (optional, default `true`)
- `config.worldview` **[String][201]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`)

#### Examples

Expand Down Expand Up @@ -1592,6 +1594,7 @@ See the [public documentation][241].
[ISO 639-1 language code][240] and optionally one or more IETF subtags for country or script.
- `config.reverseMode` **(`"distance"` \| `"score"`)** Set the factors that are used to sort nearby results. (optional, default `'distance'`)
- `config.routing` **[boolean][202]** Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features. (optional, default `false`)
- `config.worldview` **[String][201]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`)

#### Examples

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions services/__tests__/geocoding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ describe('forwardGeocode', () => {
bbox: [1, 2, 3, 4],
limit: 3,
language: ['de', 'bs'],
routing: true
routing: true,
fuzzyMatch: true,
worldview: 'us'
});
expect(tu.requestConfig(geocoding)).toEqual({
method: 'GET',
Expand All @@ -52,7 +54,9 @@ describe('forwardGeocode', () => {
bbox: [1, 2, 3, 4],
limit: 3,
language: ['de', 'bs'],
routing: 'true'
routing: 'true',
fuzzyMatch: 'true',
worldview: 'us'
}
});
});
Expand Down Expand Up @@ -84,7 +88,8 @@ describe('reverseGeocode', () => {
limit: 3,
language: ['de', 'bs'],
reverseMode: 'distance',
routing: true
routing: true,
worldview: 'us'
});
expect(tu.requestConfig(geocoding)).toEqual({
method: 'GET',
Expand All @@ -100,7 +105,8 @@ describe('reverseGeocode', () => {
limit: 3,
language: ['de', 'bs'],
reverseMode: 'distance',
routing: 'true'
routing: 'true',
worldview: 'us'
}
});
});
Expand Down
17 changes: 13 additions & 4 deletions services/geocoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ var featureTypes = [
* Options are [IETF language tags](https://en.wikipedia.org/wiki/IETF_language_tag) comprised of a mandatory
* [ISO 639-1 language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) and optionally one or more IETF subtags for country or script.
* @param {boolean} [config.routing=false] - Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features.
* @param {boolean} [config.fuzzyMatch=true] - Specify whether the Geocoding API should attempt approximate, as well as exact, matching.
* @param {String} [config.worldview="us"] - Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups.
* @return {MapiRequest}
*
* @example
Expand Down Expand Up @@ -100,7 +102,9 @@ Geocoding.forwardGeocode = function(config) {
bbox: v.arrayOf(v.number),
limit: v.number,
language: v.arrayOf(v.string),
routing: v.boolean
routing: v.boolean,
fuzzyMatch: v.boolean,
worldview: v.string
})(config);

config.mode = config.mode || 'mapbox.places';
Expand All @@ -115,7 +119,9 @@ Geocoding.forwardGeocode = function(config) {
'bbox',
'limit',
'language',
'routing'
'routing',
'fuzzyMatch',
'worldview'
])
)
);
Expand Down Expand Up @@ -146,6 +152,7 @@ Geocoding.forwardGeocode = function(config) {
* [ISO 639-1 language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) and optionally one or more IETF subtags for country or script.
* @param {'distance'|'score'} [config.reverseMode='distance'] - Set the factors that are used to sort nearby results.
* @param {boolean} [config.routing=false] - Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features.
* @param {String} [config.worldview="us"] - Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups.
* @return {MapiRequest}
*
* @example
Expand All @@ -168,7 +175,8 @@ Geocoding.reverseGeocode = function(config) {
limit: v.number,
language: v.arrayOf(v.string),
reverseMode: v.oneOf('distance', 'score'),
routing: v.boolean
routing: v.boolean,
worldview: v.string
})(config);

config.mode = config.mode || 'mapbox.places';
Expand All @@ -183,7 +191,8 @@ Geocoding.reverseGeocode = function(config) {
'limit',
'language',
'reverseMode',
'routing'
'routing',
'worldview'
])
)
);
Expand Down

0 comments on commit 0b67e0e

Please sign in to comment.