From 2a73bb34acb7ed22b214609cbc94a315a2a4aaba Mon Sep 17 00:00:00 2001 From: Lily He Date: Wed, 19 Jul 2017 10:38:07 -0400 Subject: [PATCH] combined checks for boundary circle radius into one block --- query/reverse.js | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/query/reverse.js b/query/reverse.js index dba05935..a9c1d25c 100644 --- a/query/reverse.js +++ b/query/reverse.js @@ -65,25 +65,24 @@ function generateQuery( clean ){ // where point.lan/point.lon are provided in the // absense of boundary.circle.lat/boundary.circle.lon if( check.number(clean['boundary.circle.lat']) && - check.number(clean['boundary.circle.lon']) && - check.number(clean['boundary.circle.radius']) ){ - vs.set({ - 'boundary:circle:lat': clean['boundary.circle.lat'], - 'boundary:circle:lon': clean['boundary.circle.lon'], - 'boundary:circle:radius': clean['boundary.circle.radius'] + 'km' - }); - logStr += '[param:boundary_circle] '; - } - - // for coarse reverse when boundary circle radius is undefined - if( check.number(clean['boundary.circle.lat']) && - check.number(clean['boundary.circle.lon']) && - check.undefined(clean['boundary.circle.radius']) ){ - vs.set({ - 'boundary:circle:lat': clean['boundary.circle.lat'], - 'boundary:circle:lon': clean['boundary.circle.lon'], - 'boundary:circle:radius': defaults['boundary:circle:radius'] - }); + check.number(clean['boundary.circle.lon']) ){ + + vs.set({ + 'boundary:circle:lat': clean['boundary.circle.lat'], + 'boundary:circle:lon': clean['boundary.circle.lon'] + }); + + if (check.undefined(clean['boundary.circle.radius'])){ + // for coarse reverse when boundary circle radius is undefined + vs.set({ + 'boundary:circle:radius': defaults['boundary:circle:radius'] + }); + } else if (check.number(clean['boundary.circle.radius'])){ + // plain reverse where boundary circle is a valid number + vs.set({ + 'boundary:circle:radius': clean['boundary.circle.radius'] + 'km' + }); + } logStr += '[param:boundary_circle] '; }