diff --git a/modules/actions/split.js b/modules/actions/split.js index 24874f199..172ec59aa 100644 --- a/modules/actions/split.js +++ b/modules/actions/split.js @@ -140,7 +140,7 @@ export function actionSplit(nodeIds, newWayIds) { if (wayA.tags.step_count) { // divide up the the step count proportionally between the two ways - var stepCount = parseFloat(wayA.tags.step_count); + var stepCount = Number(wayA.tags.step_count); if (stepCount && // ensure a number isFinite(stepCount) && diff --git a/modules/behavior/breathe.js b/modules/behavior/breathe.js index 191165c2e..cf2392295 100644 --- a/modules/behavior/breathe.js +++ b/modules/behavior/breathe.js @@ -22,8 +22,8 @@ export function behaviorBreathe() { function ratchetyInterpolator(a, b, steps, units) { - a = parseFloat(a); - b = parseFloat(b); + a = Number(a); + b = Number(b); var sample = d3_scaleQuantize() .domain([0, 1]) .range(d3_quantize(d3_interpolateNumber(a, b), steps)); @@ -92,11 +92,11 @@ export function behaviorBreathe() { // determine base opacity and width if (tag === 'circle') { - opacity = parseFloat(s.style('fill-opacity') || 0.5); - width = parseFloat(s.style('r') || 15.5); + opacity = Number(s.style('fill-opacity') || 0.5); + width = Number(s.style('r') || 15.5); } else { - opacity = parseFloat(s.style('stroke-opacity') || 0.7); - width = parseFloat(s.style('stroke-width') || 10); + opacity = Number(s.style('stroke-opacity') || 0.7); + width = Number(s.style('stroke-width') || 10); } // calculate from/to interpolation params.. diff --git a/modules/behavior/lasso.js b/modules/behavior/lasso.js index 92ce6b46b..5cf08b89d 100644 --- a/modules/behavior/lasso.js +++ b/modules/behavior/lasso.js @@ -86,8 +86,8 @@ export function behaviorLasso(context) { sharedParentNodes.indexOf(node2.id); } else { // vertices do not share a way; group them by their respective parent ways - return parseFloat(parents1[0].id.slice(1)) - - parseFloat(parents2[0].id.slice(1)); + return Number(parents1[0].id.slice(1)) - + Number(parents2[0].id.slice(1)); } } else if (parents1.length || parents2.length) { diff --git a/modules/services/osm.js b/modules/services/osm.js index 37499926c..10646ad0f 100644 --- a/modules/services/osm.js +++ b/modules/services/osm.js @@ -86,7 +86,7 @@ function abortUnwantedRequests(cache, visibleTiles) { function getLoc(attrs) { var lon = attrs.lon && attrs.lon.value; var lat = attrs.lat && attrs.lat.value; - return [parseFloat(lon), parseFloat(lat)]; + return [Number(lon), Number(lat)]; } @@ -208,7 +208,7 @@ var jsonparsers = { timestamp: obj.timestamp, user: obj.user, uid: obj.uid && obj.uid.toString(), - loc: [parseFloat(obj.lon), parseFloat(obj.lat)], + loc: [Number(obj.lon), Number(obj.lat)], tags: obj.tags }); }, diff --git a/modules/services/taginfo.js b/modules/services/taginfo.js index 170ef14c2..bd6903cb4 100644 --- a/modules/services/taginfo.js +++ b/modules/services/taginfo.js @@ -71,7 +71,7 @@ function clean(params) { function filterKeys(type) { var count_type = type ? 'count_' + type : 'count_all'; return function(d) { - return parseFloat(d[count_type]) > 2500 || d.in_wiki; + return Number(d[count_type]) > 2500 || d.in_wiki; }; } @@ -99,7 +99,7 @@ function filterRoles(geometry) { return function(d) { if (d.role === '') return false; // exclude empty role if (d.role.match(/[A-Z*;,]/) !== null) return false; // exclude uppercase letters and some punctuation - return parseFloat(d[tag_members_fractions[geometry]]) > 0.0; + return Number(d[tag_members_fractions[geometry]]) > 0.0; }; } diff --git a/modules/ui/combobox.js b/modules/ui/combobox.js index 7d4963cac..7a1dc6916 100644 --- a/modules/ui/combobox.js +++ b/modules/ui/combobox.js @@ -340,7 +340,7 @@ export function uiCombobox(context, klass) { if (!val) return; // Don't autocomplete if user is typing a number - #4935 - if (!isNaN(parseFloat(val)) && isFinite(val)) return; + if (isFinite(val)) return; const suggestionValues = []; _suggestions.forEach(s => { diff --git a/modules/ui/sections/validation_rules.js b/modules/ui/sections/validation_rules.js index de2b895ef..4f1178d56 100644 --- a/modules/ui/sections/validation_rules.js +++ b/modules/ui/sections/validation_rules.js @@ -160,7 +160,7 @@ export function uiSectionValidationRules(context) { function changeSquare() { var input = d3_select(this); var degStr = utilGetSetValue(input).trim(); - var degNum = parseFloat(degStr, 10); + var degNum = Number(degStr); if (!isFinite(degNum)) { degNum = DEFAULTSQUARE; diff --git a/modules/util/detect.js b/modules/util/detect.js index 93a194fbf..dcab931d1 100644 --- a/modules/util/detect.js +++ b/modules/util/detect.js @@ -47,7 +47,7 @@ export function utilDetect(refresh) { // detect other browser capabilities // Legacy Opera has incomplete svg style support. See #715 - _detected.opera = (_detected.browser.toLowerCase() === 'opera' && parseFloat(_detected.version) < 15 ); + _detected.opera = (_detected.browser.toLowerCase() === 'opera' && Number(_detected.version) < 15 ); if (_detected.browser.toLowerCase() === 'msie') { _detected.ie = true; diff --git a/modules/validations/crossing_ways.js b/modules/validations/crossing_ways.js index bec80921f..0275418ce 100644 --- a/modules/validations/crossing_ways.js +++ b/modules/validations/crossing_ways.js @@ -523,7 +523,7 @@ export function validationCrossingWays(context) { var crossedWay = graph.hasEntity(crossedWayID); // use the explicit width of the crossed feature as the structure length, if available - var structLengthMeters = crossedWay && crossedWay.tags.width && parseFloat(crossedWay.tags.width); + var structLengthMeters = crossedWay && isFinite(crossedWay.tags.width) && Number(crossedWay.tags.width); if (!structLengthMeters) { // if no explicit width is set, approximate the width based on the tags structLengthMeters = crossedWay && crossedWay.impliedLineWidthMeters(); diff --git a/modules/validations/unsquare_way.js b/modules/validations/unsquare_way.js index ca0cfb8f1..9b19a2461 100644 --- a/modules/validations/unsquare_way.js +++ b/modules/validations/unsquare_way.js @@ -56,7 +56,7 @@ export function validationUnsquareWay(context) { // user-configurable square threshold var storedDegreeThreshold = prefs('validate-square-degrees'); - var degreeThreshold = isNaN(storedDegreeThreshold) ? DEFAULT_DEG_THRESHOLD : parseFloat(storedDegreeThreshold); + var degreeThreshold = isFinite(storedDegreeThreshold) ? Number(storedDegreeThreshold) : DEFAULT_DEG_THRESHOLD; var points = nodes.map(function(node) { return context.projection(node.loc); }); if (!geoOrthoCanOrthogonalize(points, isClosed, epsilon, degreeThreshold, true)) return [];