Skip to content
Snippets Groups Projects
Commit 125e06e4 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

NominatimRequest documented

parent 913ef0dd
No related branches found
No related tags found
No related merge requests found
......@@ -215,6 +215,8 @@ WsValidationType.get = function(pKey)
this.additionalInfo.user = project.getPreferenceValue("custom." + this.webserviceName + ".user");
if (!this.additionalInfo.password)
this.additionalInfo.password = project.getPreferenceValue("custom." + this.webserviceName + ".pw");
if (this.additionalInfo.resultLimit === undefined) //can be explicitly null
this.additionalInfo.resultLimit = project.getPreferenceValue("custom." + this.webserviceName + ".resultLimit");
if (!this.additionalInfo.url)
throw new Error("if the webservice '" + this.key + "' is enabled, you have to provide the url");
......@@ -227,6 +229,9 @@ WsValidationType.get = function(pKey)
if (this.additionalInfo.user && this.additionalInfo.password)
nominatimRequest.setUser(this.additionalInfo.user, this.additionalInfo.password);
if (this.additionalInfo.resultLimit)
nominatimRequest.setResultLimit(this.additionalInfo.resultLimit);
// call webservice
var ret = nominatimRequest.get();
......@@ -506,6 +511,9 @@ WsValidationFieldUtils.wsOnValueChangeProcess = function(pWsType, pMainField)
}
}
/**
* Object for handling nominatim requests
*/
function NominatimRequest (pUrl)
{
this.url = pUrl;
......@@ -516,6 +524,12 @@ function NominatimRequest (pUrl)
};
}
/**
* Changes if additional address details should be loaded.
*
* @param {boolean} [pInclude=true] if the details should be included
* @return {NominatimRequest} current object
*/
NominatimRequest.prototype.includeAddressDetails = function (pInclude)
{
if (pInclude === false)
......@@ -525,6 +539,13 @@ NominatimRequest.prototype.includeAddressDetails = function (pInclude)
return this;
}
/**
* Changes the user for the webservice auth.
*
* @param {String} pUser the username
* @param {String} pPassword the password of the user
* @return {NominatimRequest} current object
*/
NominatimRequest.prototype.setUser = function (pUser, pPassword)
{
this.user = pUser;
......@@ -532,18 +553,35 @@ NominatimRequest.prototype.setUser = function (pUser, pPassword)
return this;
}
/**
* Adds parameters to the request.
*
* @param {Object} pParameters object containing the parameters that should be set
* @return {NominatimRequest} current object
*/
NominatimRequest.prototype.setParameters = function (pParameters)
{
Object.assign(this.parameters, pParameters);
return this;
}
/**
* Sets the result limit of the request.
*
* @param {Number} pLimit the max amount of rows the webservice should return (default is 10, max is 50)
* @return {NominatimRequest} current object
*/
NominatimRequest.prototype.setResultLimit = function (pLimit)
{
this.parameters.limit = pLimit.toString();
return this;
}
/**
* Calls the webservice and returns the result.
*
* @return {Object} webservice result
*/
NominatimRequest.prototype.get = function ()
{
var restConf = net.createConfigForRestWebserviceCall()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment