mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Allow network, genus, taxon, species lookups to expect uppercase values
(closes #3377) In most cases we prefer taginfo value results with lowercase letters. A few OSM keys expect values to contain uppercase values This is not an exhaustive list (e.g. `name` also has uppercase values) but these are the fields where taginfo value lookup is most useful.
This commit is contained in:
@@ -191,7 +191,13 @@ export function init() {
|
||||
page: 1
|
||||
}, parameters)), debounce, function(err, d) {
|
||||
if (err) return callback(err);
|
||||
var f = filterValues(parameters.key === 'cycle_network' || parameters.key === 'network');
|
||||
// In most cases we prefer taginfo value results with lowercase letters.
|
||||
// A few OSM keys expect values to contain uppercase values (see #3377).
|
||||
// This is not an exhaustive list (e.g. `name` also has uppercase values)
|
||||
// but these are the fields where taginfo value lookup is most useful.
|
||||
var re = /network|taxon|genus|species/;
|
||||
var allowUpperCase = (parameters.key.match(re) !== null);
|
||||
var f = filterValues(allowUpperCase);
|
||||
callback(null, d.data.filter(f).map(valKeyDescription));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -195,6 +195,42 @@ describe('iD.serviceTaginfo', function() {
|
||||
{'value':'US:MD','title':'State highways in the U.S. state of Maryland.'}
|
||||
]);
|
||||
});
|
||||
|
||||
it('includes biological genus values with capital letters', function() {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({key: 'genus', query: 'qu'}, callback);
|
||||
|
||||
server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/key/values'),
|
||||
[200, { 'Content-Type': 'application/json' },
|
||||
'{"data":[{"value":"Quercus","description":"Oak", "fraction":0.5}]}']);
|
||||
server.respond();
|
||||
|
||||
expect(callback).to.have.been.calledWith(null, [{'value':'Quercus','title':'Oak'}]);
|
||||
});
|
||||
|
||||
it('includes biological taxon values with capital letters', function() {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({key: 'taxon', query: 'qu'}, callback);
|
||||
|
||||
server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/key/values'),
|
||||
[200, { 'Content-Type': 'application/json' },
|
||||
'{"data":[{"value":"Quercus robur","description":"Oak", "fraction":0.5}]}']);
|
||||
server.respond();
|
||||
|
||||
expect(callback).to.have.been.calledWith(null, [{'value':'Quercus robur','title':'Oak'}]);
|
||||
});
|
||||
|
||||
it('includes biological species values with capital letters', function() {
|
||||
var callback = sinon.spy();
|
||||
taginfo.values({key: 'species', query: 'qu'}, callback);
|
||||
|
||||
server.respondWith('GET', new RegExp('https://taginfo.openstreetmap.org/api/4/key/values'),
|
||||
[200, { 'Content-Type': 'application/json' },
|
||||
'{"data":[{"value":"Quercus robur","description":"Oak", "fraction":0.5}]}']);
|
||||
server.respond();
|
||||
|
||||
expect(callback).to.have.been.calledWith(null, [{'value':'Quercus robur','title':'Oak'}]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#roles', function() {
|
||||
|
||||
Reference in New Issue
Block a user