new Services( [options])
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
options |
Mapspace.nvdb.ServicesOptions |
<optional> |
Options. |
- Source:
- mapspace-nvdb/services.js
Extends
- ol.Object
Members
-
accessToken :string
-
Other token from NVDB.
- Source:
- mapspace-nvdb/services.js
-
<nullable> filter :string
-
When objectType is ITEM, the filter to apply to requests. It is not needed to URL encode the special chars as this is done by default in each request.
- Source:
- mapspace-nvdb/services.js
-
limits :Object
-
When objectType is ITEM, the object with the params to add to requests to filter results by limits.
- Source:
- mapspace-nvdb/services.js
-
objectType :Mapspace.nvdb.ObjectType
-
Type of object to retrieve from server when reading: ROAD for road segments and ITEM for road items. Do not modify this value. Only use options.
- Source:
- mapspace-nvdb/services.js
-
<nullable> objectTypeDescriptor :Mapspace.nvdb.ObjectTypeDescriptor
-
Descriptor object with all metadata for the current road item (if objectType is ITEM). Do not modify this value. It is filled through 'getObjectTypeDescriptor'.
- Source:
- mapspace-nvdb/services.js
-
objectTypeId :number
-
When objectType is ITEM, the ID of the type of road items to retrieve in reading. Do not modify this value. Only use options.
- Source:
- mapspace-nvdb/services.js
-
refreshToken :string
-
Other token from NVDB.
- Source:
- mapspace-nvdb/services.js
-
usertoken :string
-
Authentication user token from NVDB. It is possible to modify this value if needed. It is filled when calling 'login' if login succeded or set to null if failed. It is also set to null when calling 'validateToken' and validation fails.
- Source:
- mapspace-nvdb/services.js
Methods
-
callWriteService(url, headers, data, uuid, useToken, isJSON)
-
Returns a Promise that executes a request to the NVDB Write service.
Parameters:
Name Type Argument Description url
string The url.
headers
Object The headers.
data
Object <nullable>
An optional JSON object to send.
uuid
string <nullable>
An optional UUID to send.
useToken
boolean If the request must include the NVDB userotken.
isJSON
boolean If the expected response is a JSON.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that passes a JSON object in the resolve function if isJSON is true, or true if isJSON is false, and an Error for the reject function.
- Type
- Promise
-
doPostRequest(url, headers, data, uuid, useToken, successFn, errorFn)
-
Does a 'POST' request executing an url.
Parameters:
Name Type Argument Description url
string The url.
headers
Object The headers.
data
Object | string An optional JSON object or string. If string data is the NVDB token.
uuid
string <nullable>
An optional UUID.
useToken
boolean If the request must include the NVDB userotken.
successFn
function The function to call on success.
errorFn
function The function to call on error.
- Source:
- mapspace-nvdb/services.js
-
doRequest(url, headers, successFn, errorFn)
-
Does a 'GET' request executing an url.
Parameters:
Name Type Description url
string The url.
headers
Object The headers.
successFn
function The function to call on success.
errorFn
function The function to call on error.
- Source:
- mapspace-nvdb/services.js
-
getAllChangesetsStatus(onlyInProgress)
-
Returns a Promise that never rejects and gets all the status reports for all changesets of the user.
Parameters:
Name Type Description onlyInProgress
boolean If get status of all changesets or only of those changesets in progress.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of
Mapspace.nvdb.ChangesetReport
for the resolve function.- Type
- Promise
-
getAllChildFeatures(feature)
-
Returns a Promise that requests a list of all child features of a given feature traversing the full hierachy of the feature. Features are requested either to NVDB service or Terratec storage service and return them as features with geometry in Spherical Mercator.
Parameters:
Name Type Description feature
ol.Feature The feature to request childs for.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of
ol.Feature
with the resolve function. The array is empty if the feature has no childs. This promise never rejects. If an error happened requesting an object then the feature of that object won't be in the returned array.- Type
- Promise
-
getBasicParams()
-
Returns the basic params to be used for requests.
- Source:
- mapspace-nvdb/services.js
Returns:
- Type
- Object
-
getBoundaries(type)
-
Returns a Promise that requests the array of boundary objects of the given type.
Parameters:
Name Type Description type
Mapspace.nvdb.NameFilterType Type of boundary.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of objects for the resolve function or an Error for the reject function.
- Type
- Promise
-
getChangesetStatus(uuid)
-
Executes a status query in the NVDB Write services about a given changeset sent.
Parameters:
Name Type Description uuid
string The UUID of the changeset shipped.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns a
Mapspace.nvdb.Report
for the resolve function or an Error for the reject function.- Type
- Promise
-
getChangesetStatusRetrying(uuid, maxAttemps, timeout)
-
Executes several attempts of status queries in the NVDB Write services about a given changeset sent.
Parameters:
Name Type Argument Description uuid
string The UUID of the changeset shipped.
maxAttemps
number <nullable>
Optional number of attempts to execute. By default are 6.
timeout
number <nullable>
Optional milliseconds between each attempt. By default are 10000, 10 seconds.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns
Mapspace.nvdb.Report
for the resolve function when Write services returned either a READY or REJECTED code, or and Error when all attempts are consumed without a READY or REJECTED code.- Type
- Promise
-
getChildFeatures(feature)
-
Returns a Promise that requests a list of child features of a given feature. Features are requested either to NVDB service or Terratec storage service and return them as features with geometry in Spherical Mercator.
Parameters:
Name Type Description feature
ol.Feature The feature to request childs for.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of
ol.Feature
with the resolve function. The array is empty if the feature has no childs. This promise never rejects. If an error happened requesting an object then the feature of that object won't be in the returned array.- Type
- Promise
-
getFeaturesByExtent(extent)
-
Returns a Promise that requests objects to NVDB service and Terratec storage service using an extent and return them as
features
with geometry in Spherical Mercator.Features returned that are mofified ones stored in Terratec backup services, their NVDB originals are also saved in
Mapspace.nvdb.Cache
.Parameters:
Name Type Description extent
Mapspace.Extent The extent in LonLat WGS84 coordinates. NVDB only accepts two projections as explained in https://api.vegdata.no/verdi/geometri.html, and we only support WGS84 in this function.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of
features
for the resolve function, or an Error for the reject function.- Type
- Promise
-
getFeaturesByIDs(IDs, useBackupCache)
-
Returns a Promise that requests objects to NVDB service and Terratec storage service using the IDs and return them as
features
with geometry in Spherical Mercator. Only works for road objects. If this services object is configured for road segments, the promise returned always resolves with an empty array.The IDs must have the following format:
- 'NVDB
- ' for features stored in NVDB services, where must be equal to the objectTypeId
property set for this Services instance. - 'BU
' for features stored in Terratec services.
Features returned that are mofified ones stored in Terratec backup services, their NVDB originals are also saved in
Mapspace.nvdb.Cache
.For requesting an heterogeneous mix of features of different
use Mapspace.nvdb.Services#getMixedFeaturesByIDs
instead.Parameters:
Name Type Argument Description IDs
Array.<string> The array of ID to request.
useBackupCache
boolean <nullable>
An optional boolean. If true features will be returned from backup cache if they exists there. If false features will be returned from original features cache if they exist there. By default is true.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of
ol.Feature
with the data for the resolve function. This promise never rejects. If an error happened requesting an object then the feature of that object won't be in the returned array.- Type
- Promise
- 'NVDB
-
getFormat()
-
Returns the format that reads and writes features.
- Source:
- mapspace-nvdb/services.js
Returns:
-
getLinearReference(coordinate, distance, max)
-
Returns a Promise that requests a linear reference in the NVDB road catalog.
Parameters:
Name Type Argument Description coordinate
Mapspace.Coordinate The coordinate in WGS84 lonlat.
distance
number <nullable>
An optional distance where search for a reference. If not provided the default is 200 meters.
max
number <nullable>
An optional maximum number of results. Default is 1.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns and array of
Mapspace.nvdb.LinearReferenceResultV3
for the resolve function or an Error for the reject function (when a reference is not found in the passed coordinate).- Type
- Promise
-
getLocation(stedfest)
-
Returns the location information (stedfesting) that is required to add to a given object.
Parameters:
Name Type Description stedfest
Object A Stedfest object. https://nvdbapiskriv.atlas.vegvesen.no/rest/v3/stedfest/stedfest.xsd
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns a
Mapspace.nvdb.???
for the resolve function or aMapspace.nvdb.???
for the reject function.- Type
- Promise
-
getMixedFeaturesByIDs(IDs, useBackupCache)
-
Returns a Promise that requests objects to NVDB service and Terratec storage service using the IDs and return them as features with geometry in Spherical Mercator. Only works for road objects. If this services object is configured for road segments, the promise returned always resolves with an empty array.
The IDs must have the following format: 'NVDB
- ' for features stored in NVDB services, and 'BU ' for features stored in Terratec services. do not need to be equal to the objectTypeId
property set for this Services instance.Parameters:
Name Type Argument Description IDs
Array.<string> The array of ID to request.
useBackupCache
boolean <nullable>
An optional boolean. If true features will be returned from backup cache if they exists there. If false features will be returned from original features cache if they exist there. By default is true.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of
ol.Feature
with the data for the resolve function. This promise never rejects. If an error happened requesting an object then the feature of that object won't be in the returned array.- Type
- Promise
-
getObjectCategories()
-
Returns a Promise that requests all categories from NVDB catalog the first time is called, or a cached object next times.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of
Mapspace.nvdb.Category
, or an Error for the reject function.- Type
- Promise
-
getObjectsByExtent(extent)
-
Returns a Promise that requests objects to NVDB service using a extent.
Parameters:
Name Type Description extent
Mapspace.Extent The extent in LonLat WGS84 coordinates. NVDB only accepts two projections as explained in https://api.vegdata.no/verdi/geometri.html, and we only support WGS84 in this function.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of objects with the data for the resolve function, or an Error for the reject function.
- Type
- Promise
-
getObjectsByID(ID)
-
Returns a Promise that requests objects to NVDB service using one ID.
Parameters:
Name Type Description ID
string The ID to request. The ID must be the NVDB ObjectID as string.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an object with the data for the resolve function or and Error for the resolve function.
- Type
- Promise
-
getObjectsLenght()
-
Returns a Promise that requests the number of objects that comply with current settings.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns a number for the resolve function, or an Error for the reejct function.
- Type
- Promise
-
getObjectTypeDescriptor()
-
Returns a Promise that requests the description of an object type to NVDB service.
- Source:
- mapspace-nvdb/services.js
Returns:
A promise that returns a
Mapspace.nvdb.ObjectTypeDescriptor
for the resolve function, or an Error for the reject function.- Type
- Promise
-
getObjectTypes()
-
Returns a Promise that requests all objects types to NVDB service the first time is called, or a cached object next times.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of
Mapspace.nvdb.ObjectTypeDefinition
object type definitions for the resolve function, or an Error for the reject function.- Type
- Promise
-
getObjectTypesForCategory(category)
-
Returns a Promise that requests all object types under a category.
Parameters:
Name Type Description category
number Category ID.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of
Mapspace.nvdb.ObjectTypeDefinition
object type definitions for the resolve function, or an Error for the reject function.- Type
- Promise
-
getParentFeatures(feature)
-
Returns a Promise that requests a list of parent features of a given feature. Features are requested either to NVDB service or Terratec storage service and return them as features with geometry in Spherical Mercator.
Parameters:
Name Type Description feature
ol.Feature The feature to request parents for.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an array of
ol.Feature
with the resolve function. The array is empty if the feature has no parents. This promise never rejects. If an error happened requesting an object then the feature of that object won't be in the returned array.- Type
- Promise
-
getStatus()
-
Returns a Promise that requests the current version and transaction date of the NVDB catalog.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns an object (with properties version and transactionDate) for the resolve function or an Error for the reject function.
- Type
- Promise
-
getSubPath()
-
Returns the subpath to be used for requests.
- Source:
- mapspace-nvdb/services.js
Returns:
- Type
- string
-
login(username, password)
-
Returns a Promise that logs in the writing service of NVDB.
Parameters:
Name Type Description username
string The user name.
password
string The password.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns true for the resolve function or an Error for the reject function.
- Type
- Promise
-
parseJSONObjects(jsonObjects)
-
Parses an array of JSON objects and convert them to features.
Parameters:
Name Type Description jsonObjects
Array.<Object> Array of JSON objects.
- Source:
- mapspace-nvdb/services.js
Returns:
- Type
- Array.<ol.Feature>
-
sendChangeset(changeset)
-
Sends a changeset in the NVDB Write services, returning a UUID for the changeset.
Parameters:
Name Type Description changeset
Mapspace.nvdb.ChangeSet The changeset to send.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns a string with the UUID for the chageset for the resolve function or an Error for the reject function.
- Type
- Promise
-
startChangeset(uuid)
-
Starts the proccessing of a changeset in the NVDB Write services.
Parameters:
Name Type Description uuid
string The UUID of the changeset shipped.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns a string with the UUID for the changeset for the resolve function or an Error for the reject function.
- Type
- Promise
-
validateChangeset(changeset)
-
Validates a changeset in the NVDB Write services. Only validity is done and whether the road objects are described in line with the data directory. Verification of relational control parameters and other more complex validation requiring comparison with existing data in NVDB is not performed. Therefore, a change set approved by this endpoint may still be rejected by deeper validation during processing.
Parameters:
Name Type Description changeset
Mapspace.nvdb.ChangeSet The changeset to validate.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns a
Mapspace.nvdb.Report
for the resolve function or an Error for the reject function.- Type
- Promise
-
validateToken()
-
Returns a Promise that validates a usertoken to detect if it hasn't expired. User tokens in NVDB Write service have a validity of 6 hours.
- Source:
- mapspace-nvdb/services.js
Returns:
A Promise that returns a boolean for the resolve function or an Error for the reject function. The boolean indicates if the token is valid o not.
- Type
- Promise