reduce use of parseFloat

as it silently strips non-numeric suffixes (e.g. a value of "123 foo" is transformed into a numeric value of 123 by `parseFloat`, which is typically not what we desire)
This commit is contained in:
Martin Raifer
2022-11-24 19:18:27 +01:00
parent fc75d5f2a1
commit 41aa127d23
10 changed files with 18 additions and 18 deletions
+1 -1
View File
@@ -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();
+1 -1
View File
@@ -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 [];