Skip to content

Commit

Permalink
feat(geosearch): search for standard string
Browse files Browse the repository at this point in the history
  • Loading branch information
james-rae committed Mar 31, 2015
1 parent 1a158b3 commit 4b9b5a0
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions src/js/RAMP/Modules/geoSearch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global define, console, RAMP */
/* global define, console, RAMP, escape */

/**
*
Expand Down Expand Up @@ -215,6 +215,10 @@ define([
}
}

if (params.q) {
query += "q=" + escape(params.q) + "&";
}

console.log("Executing Query: " + query);

//launch the search
Expand Down Expand Up @@ -248,6 +252,43 @@ define([
return defResult.promise;
}

/**
* Will trigger an basic name search, apply filters, and package the results
*
*
* @method generalSearch
* @private
* @param {String} name string to search on
* @param {Object} filters search filters, particarly lonlat and optional radius
* @param {Object} defResult a Deferred supplied by the caller. areaSearch will resolve or reject it
*/
function generalSearch(name, filters, defResult) {
filters.q = name;

var result = {},
//do an search on the name
defSearch = executeSearch(filters);

defSearch.then(
function (searchResult) {
//service returned. package results

if (searchResult.length > 0) {
result.status = statusType.list;
result.list = searchResult;
result.defItem = searchResult[0].lonlat; //default to first item in the list
} else {
result.status = statusType.none;
}

//resolve the promise
defResult.resolve(result);
},
function (error) {
defResult.reject(error);
});
}

/**
* Will trigger an area search and package the results
*
Expand Down Expand Up @@ -282,7 +323,7 @@ define([
}

/**
* Will search on user input string
* Will search on user input string. Public endpoint for searches, will orchestrate the appropriate search calls
*
*
* @method geoSearch
Expand Down Expand Up @@ -326,6 +367,8 @@ define([
case parseType.none:
//add all the valid filter things, plus wildcards

generalSearch(parse.data, filters, defResult);

break;
case parseType.fsa:
//search for the FSA
Expand Down

0 comments on commit 4b9b5a0

Please sign in to comment.