Skip to content

Commit

Permalink
increase matchScores of custom presets (#24)
Browse files Browse the repository at this point in the history
ref #22
  • Loading branch information
maxgrossman authored Dec 14, 2018
1 parent c4df520 commit 6cc28d0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
27 changes: 24 additions & 3 deletions adapters/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ exports.AREA = 'area';
exports.POINT = 'point';
exports.LINE = 'line';

exports.ID_DEFAULTS = { point: ['point'], line: ['line'], area: ['area'], vertex: ['vertex'] };
exports.ID_DEFAULTS = { point: ['point'], line: ['line'], area: ['area'], vertex: ['vertex'], relation: ['relation'] };

// default geometry iD presets!
exports.ID_GEOM_PRESETS = {
point: { fields: ['name'], geometry: ['point'], tags: {}, name: 'Point', matchScore: 0.1},
point: { fields: ['name'], geometry: ['point'], tags: {}, name: 'Point', matchScore: 0.1} ,
line: { fields: ['name'], geometry: ['line'], tags: {}, name: 'Line', matchScore: 0.1},
area: { fields: ['name'], geometry: ['area'], tags: { 'area': 'yes' }, name: 'Area', matchScore: 0.1},
vertex: { fields: [ 'name' ], geometry: [ 'vertex' ], tags: {}, name: 'Other', matchScore: 0.1},
relation: { icon: 'iD-relation', fields: [ 'name', 'relation' ], geometry: [ 'relation' ], tags: {}, name: 'Relation' }
relation: { icon: 'iD-relation', fields: [ 'name', 'relation' ], geometry: [ 'relation' ], tags: {}, name: 'Relation', matchScore: 0.1}
};
exports.ID_GENERIC_FIELDS = {
name: {
Expand Down Expand Up @@ -64,3 +64,24 @@ exports.ID_GENERIC_FIELDS = {
placeholder: '#example'
}
};

exports.ID_DEFAULT_CATEGORIES = {
'category-area': {
icon: 'maki-natural',
geometry: 'area',
name: 'MapRules Area Features',
members: ['area']
},
'category-point': {
icon: 'maki-natural',
geometry: 'point',
name: 'MapRules Point Features',
members: ['point']
},
'category-line': {
icon: 'maki-natural',
geometry: 'line',
name: 'MapRules Point Features',
members: ['line']
}
};
22 changes: 5 additions & 17 deletions adapters/iDPresets/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const buildiDPreset = require('./preset');
const ID_DEFAULT_CATEGORIES = require('../constants').ID_DEFAULT_CATEGORIES;
const ID_GENERIC_FIELDS = require('../constants').ID_GENERIC_FIELDS;
const ID_GEOM_PRESETS = require('../constants').ID_GEOM_PRESETS;

Expand All @@ -9,6 +10,9 @@ const getiDDefaults = require('./helpers').getiDDefaults;
module.exports = (config) => {
try {
const iDPresets = { categories: {}, presets: {}, fields: {}, defaults: getiDDefaults() };

iDPresets.categories = ID_DEFAULT_CATEGORIES;

config.presets.forEach(configPreset => {
if (configPreset.hasOwnProperty('fields')) {
const {preset, fields} = buildiDPreset(configPreset);
Expand All @@ -22,24 +26,8 @@ module.exports = (config) => {

preset[presetName].geometry.forEach(g => {
iDPresets.defaults[g.toLowerCase()].push(presetName);

const geomCategory = `category-${g.toLowerCase()}`;
const first = !iDPresets.categories.hasOwnProperty(geomCategory);

if (first) {
iDPresets.categories[geomCategory] = {};
};

iDPresets.categories[geomCategory] = Object.assign(iDPresets.categories[geomCategory], {
icon: 'maki-natural',
geometry: g.toLowerCase(),
name: `MapRules ${g} Features`,
members: (() => {
const members = first ? [] : iDPresets.categories[geomCategory].members;
members.push(presetName);
return members;
})()
});
iDPresets.categories[geomCategory].members.push(presetName);
});
}
});
Expand Down
3 changes: 2 additions & 1 deletion adapters/iDPresets/preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module.exports = (preset) => {
tags: getTags(preset.primary),
icon: 'maki-natural',
name: preset.name,
fields: []
fields: [],
matchScore: 2
};

const iDFields = [];
Expand Down

0 comments on commit 6cc28d0

Please sign in to comment.