Module: Utils

Classes

Utils

Methods

(static) downloadFile(url, parameters, callback, errorCallback)

Send an ajax POST request to download a file
Parameters:
Name Type Description
url string A string or any other object with a stringifier — including a URL object — that provides the URL of the resource to send the request to.
parameters Array Parameters that will be serialize as a Query string
callback function optional callback executed when download ends
errorCallback function optional callback executed when error event occurs
Source:

(static) downloadFileFromString(text, fileType, fileName)

Download a file provided as a string
Parameters:
Name Type Description
text string file content
fileType string file's MIME type
fileName string file'name with extension
Source:

(static) fetch(resource, options) → {Promise}

Fetching a resource from the network, returning a promise that is fulfilled once the response is successful.
Parameters:
Name Type Description
resource string This defines the resource that you wish to fetch. A string or any other object with a stringifier — including a URL object — that provides the URL of the resource you want to fetch.
options object An object containing any custom settings you want to apply to the request.
Source:
See:
Throws:
  • In case of not successful response (status not in the range 200 – 299)
    Type
    HttpError
  • In case of catch exceptions
    Type
    NetworkError
Returns:
A Promise that resolves to a successful Response object (status in the range 200 – 299)
Type
Promise

(static) fetchHTML(resource, options) → {Promise}

Fetching a resource from the network, which is HTML, returning a promise that resolves with a text representation of the response body.
Parameters:
Name Type Description
resource string This defines the resource that you wish to fetch. A string or any other object with a stringifier — including a URL object — that provides the URL of the resource you want to fetch.
options object An object containing any custom settings you want to apply to the request.
Source:
See:
Throws:
  • In case of invalid content type (not text/html)
    Type
    ResponseError
  • In case of not successful response (status not in the range 200 – 299)
    Type
    HttpError
  • In case of catch exceptions
    Type
    NetworkError
Returns:
A Promise that resolves with a text representation of the response body.
Type
Promise

(static) fetchJSON(resource, options) → {Promise}

Fetching a resource from the network, which is JSON or GeoJSON, returning a promise that resolves with the result of parsing the response body text as JSON.
Parameters:
Name Type Description
resource string This defines the resource that you wish to fetch. A string or any other object with a stringifier — including a URL object — that provides the URL of the resource you want to fetch.
options object An object containing any custom settings you want to apply to the request.
Source:
See:
Throws:
  • In case of invalid content type (not application/json or application/vnd.geo+json) or Invalid JSON
    Type
    ResponseError
  • In case of not successful response (status not in the range 200 – 299)
    Type
    HttpError
  • In case of catch exceptions
    Type
    NetworkError
Returns:
A Promise that resolves with the result of parsing the response body text as JSON.
Type
Promise

(static) getResolutionFromScale(scale, metersPerUnit) → {number}

Get the corresponding resolution for the scale with meters per unit
Parameters:
Name Type Description
scale number The scale
metersPerUnit number The meters per unit
Source:
See:
Returns:
The corresponding resolution
Type
number

(static) getScaleFromResolution(resolution, metersPerUnit) → {number}

Get the corresponding scale for the resolution with meters per unit
Parameters:
Name Type Description
resolution number The scale
metersPerUnit number The meters per unit
Source:
See:
  • getResolutionFromScale
Returns:
The corresponding scale
Type
number