The Junction Number field now appears by default on Motorway Link and Trunk Link presets (re: #4178)

Fields with a prerequisiteTag property no longer count against the fields count buildtime check
This commit is contained in:
Quincy Morgan
2019-01-18 11:03:21 -05:00
parent bc81a62a58
commit 4f650ad2f9
3 changed files with 27 additions and 13 deletions
+25 -11
View File
@@ -5,6 +5,7 @@ const _forEach = requireESM('lodash-es/forEach').default;
const _isEmpty = requireESM('lodash-es/isEmpty').default;
const _merge = requireESM('lodash-es/merge').default;
const _toPairs = requireESM('lodash-es/toPairs').default;
const _filter = requireESM('lodash-es/filter').default;
const colors = require('colors/safe');
const fs = require('fs');
@@ -488,17 +489,6 @@ function validatePresetFields(presets, fields) {
var maxFieldsBeforeWarning = 8;
for (var presetID in presets) {
var preset = presets[presetID];
if (preset.fields) {
// since `moreFields` is available, check that `fields` doesn't get too cluttered
var fieldCount = Object.keys(preset.fields).length;
if (fieldCount > maxFieldsBeforeError) {
console.error(fieldCount + ' values in "fields" of "' + preset.name + '" (' + presetID + '). Limit: ' + maxFieldsBeforeError + '. Please move lower-priority fields to "moreFields".');
process.exit(1);
}
else if (fieldCount > maxFieldsBeforeWarning) {
console.log('Warning: ' + fieldCount + ' values in "fields" of "' + preset.name + '" (' + presetID + '). Recommended: ' + maxFieldsBeforeWarning + ' or fewer. Consider moving lower-priority fields to "moreFields".');
}
}
// the keys for properties that contain arrays of field ids
var fieldKeys = ['fields', 'moreFields'];
for (var fieldsKey in fieldKeys) {
@@ -520,6 +510,30 @@ function validatePresetFields(presets, fields) {
}
}
}
if (preset.fields) {
// since `moreFields` is available, check that `fields` doesn't get too cluttered
var fieldCount = preset.fields.length;
if (fieldCount > maxFieldsBeforeWarning) {
// Fields with `prerequisiteTag` probably won't show up initially,
// so don't count them against the limits.
var fieldsWithoutPrerequisites = _filter(preset.fields, function(fieldID) {
if (fields[fieldID] && fields[fieldID].prerequisiteTag) {
return false;
}
return true;
});
fieldCount = fieldsWithoutPrerequisites.length;
}
if (fieldCount > maxFieldsBeforeError) {
console.error(fieldCount + ' values in "fields" of "' + preset.name + '" (' + presetID + '). Limit: ' + maxFieldsBeforeError + '. Please move lower-priority fields to "moreFields".');
process.exit(1);
}
else if (fieldCount > maxFieldsBeforeWarning) {
console.log('Warning: ' + fieldCount + ' values in "fields" of "' + preset.name + '" (' + presetID + '). Recommended: ' + maxFieldsBeforeWarning + ' or fewer. Consider moving lower-priority fields to "moreFields".');
}
}
}
}
+1 -1
View File
@@ -425,7 +425,7 @@
"highway/milestone": {"icon": "temaki-milestone", "geometry": ["point", "vertex"], "fields": ["distance", "direction_vertex"], "tags": {"highway": "milestone"}, "terms": ["milestone", "marker"], "name": "Highway Milestone"},
"highway/mini_roundabout": {"icon": "maki-circle-stroked", "geometry": ["vertex"], "tags": {"highway": "mini_roundabout"}, "fields": ["direction_clock"], "name": "Mini-Roundabout"},
"highway/motorway_junction": {"icon": "temaki-junction", "fields": ["ref_highway_junction", "name"], "geometry": ["vertex"], "tags": {"highway": "motorway_junction"}, "terms": ["exit"], "name": "Motorway Junction / Exit"},
"highway/motorway_link": {"icon": "iD-highway-motorway-link", "fields": ["destination_oneway", "destination/ref_oneway", "oneway", "maxspeed", "lanes", "surface", "structure", "access"], "moreFields": ["covered", "destination/symbol_oneway", "junction/ref_oneway", "lit", "maxheight", "maxspeed/advisory", "name", "ref_road_number", "smoothness", "toll"], "geometry": ["line"], "tags": {"highway": "motorway_link"}, "addTags": {"highway": "motorway_link", "oneway": "yes"}, "removeTags": {"highway": "motorway_link", "oneway": "yes"}, "terms": ["exit", "ramp", "road", "street", "on ramp", "off ramp"], "name": "Motorway Link"},
"highway/motorway_link": {"icon": "iD-highway-motorway-link", "fields": ["destination_oneway", "destination/ref_oneway", "junction/ref_oneway", "oneway", "maxspeed", "lanes", "surface", "structure", "access"], "moreFields": ["covered", "destination/symbol_oneway", "lit", "maxheight", "maxspeed/advisory", "name", "ref_road_number", "smoothness", "toll"], "geometry": ["line"], "tags": {"highway": "motorway_link"}, "addTags": {"highway": "motorway_link", "oneway": "yes"}, "removeTags": {"highway": "motorway_link", "oneway": "yes"}, "terms": ["exit", "ramp", "road", "street", "on ramp", "off ramp"], "name": "Motorway Link"},
"highway/motorway": {"icon": "iD-highway-motorway", "fields": ["name", "ref_road_number", "oneway_yes", "maxspeed", "lanes", "surface", "structure", "access"], "moreFields": ["toll", "maxheight", "covered", "lit", "smoothness", "minspeed"], "geometry": ["line"], "tags": {"highway": "motorway"}, "terms": ["autobahn", "expressway", "freeway", "highway", "interstate", "parkway", "road", "street", "thruway", "turnpike"], "name": "Motorway"},
"highway/passing_place": {"icon": "maki-circle-stroked", "geometry": ["vertex"], "tags": {"highway": "passing_place"}, "terms": ["turnout, pullout"], "name": "Passing Place"},
"highway/path": {"icon": "iD-highway-path", "fields": ["name", "surface", "width", "structure", "access", "incline"], "moreFields": ["wheelchair", "lit", "smoothness", "trail_visibility", "sac_scale", "mtb/scale", "mtb/scale/uphill", "mtb/scale/imba", "horse_scale", "covered", "ref", "dog"], "geometry": ["line"], "terms": ["hike", "hiking", "trackway", "trail", "walk"], "tags": {"highway": "path"}, "name": "Path"},
@@ -3,6 +3,7 @@
"fields": [
"destination_oneway",
"destination/ref_oneway",
"junction/ref_oneway",
"oneway",
"maxspeed",
"lanes",
@@ -13,7 +14,6 @@
"moreFields": [
"covered",
"destination/symbol_oneway",
"junction/ref_oneway",
"lit",
"maxheight",
"maxspeed/advisory",