From 4f650ad2f96c87c5a42066b745bcf0be7f94faa8 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Fri, 18 Jan 2019 11:03:21 -0500 Subject: [PATCH] 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 --- build_data.js | 36 +++++++++++++------ data/presets/presets.json | 2 +- .../presets/highway/motorway_link.json | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/build_data.js b/build_data.js index 67f90664f..deb949b89 100644 --- a/build_data.js +++ b/build_data.js @@ -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".'); + } + } } } diff --git a/data/presets/presets.json b/data/presets/presets.json index 086f26034..ac5fbab17 100644 --- a/data/presets/presets.json +++ b/data/presets/presets.json @@ -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"}, diff --git a/data/presets/presets/highway/motorway_link.json b/data/presets/presets/highway/motorway_link.json index 92155320c..9e12a8ed9 100644 --- a/data/presets/presets/highway/motorway_link.json +++ b/data/presets/presets/highway/motorway_link.json @@ -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",