Class: OSMAPI

OSMAPI

Create the angular service instance. The main idea is to provide only object and hide the XML related stuf. This is achieve using XML2JS.

new OSMAPI($http, $q, osmx2js, options)

Parameters:
Name Type Description
$http Object angular http
$q Object angular promise
osmx2js Object service
options Object to get set url of the API
Source:

Methods


closeChangeset()

Source:
Returns:
$http.put response of /0.6/changeset/CHANGESET_ID/close
Type
Promise

createChangeset(comment)

Parameters:
Name Type Description
comment string the comment assiociated to the changeset
Source:
Returns:
$http response
Type
Promise

createNode(node)

Parameters:
Name Type Description
node Object/string var node = {osm: {node: { _changeset: '12', _lat: '...', _lon: '...', tags: [ {_k: '...', _v: '...'} ] }}};
Source:
Returns:
$http.put response PUT /0.6/node/create
Type
Promise

createRelation(relation)

Parameters:
Name Type Description
relation Object/string var relation = {osm: {relation: { _changeset: '12', _lat: '...', _lon: '...', tags: [ {_k: '...', _v: '...'} ], member: [ {_type: 'node', _role: 'stop', 'ref': '123'}, {_type: 'way', 'ref': '234'} ] }}};
Source:
Returns:
$http.put response PUT /0.6/relation/create
Type
Promise

createWay(way)

Parameters:
Name Type Description
way Object/string var way = {osm: {way: { _changeset: '12', _lat: '...', _lon: '...', tags: [ {_k: '...', _v: '...'} ], nd: [ {_ref: '123'}, {_ref: '456'}, ] }}};
Source:
Returns:
$http.put response PUT /0.6/way/create
Type
Promise

delete(method, config)

send a delete request
Parameters:
Name Type Description
method string the api method
config Object the $http.delete config
Source:
Returns:
$http response
Type
Promise

deleteNode(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.delete response DELETE /0.6/node/#id
Type
Promise

deleteRelation(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.delete response DELETE /0.6/relation/#id
Type
Promise

deleteWay(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.delete response DELETE /0.6/way/#id
Type
Promise

get(method, config)

send a get request
Parameters:
Name Type Description
method string the api method
config Object the $http.get config
Source:
Returns:
$http response with XML as string
Type
Promise

getAuthAdapter()

Get the adapter used to do authenticated xhr
Source:
Returns:
Type
Object

getAuthenticated()

send a get request to OSM with
Source:
Returns:
$http response
Type
Promise

getLastOpenedChangesetId()

Source:
Returns:
$http response with the last changeset id or undefined if no changeset was opened
Type
Promise

getMap(bbox)

Parameters:
Name Type Description
bbox string left,bottom,right,top where: left is the longitude of the left (westernmost) side of the bounding box. bottom is the latitude of the bottom (southernmost) side of the bounding box. right is the longitude of the right (easternmost) side of the bounding box. top is the latitude of the top (northernmost) side of the bounding box.
Source:
Returns:
$http.get response /0.6/map?bbox=bbox
Type
Promise

getNode(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.get response GET /0.6/node/#id
Type
Promise

getNodeRelations(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.get response GET /0.6/node/#id/relations
Type
Promise

getNodes(ids)

Parameters:
Name Type Description
ids array ids
Source:
Returns:
$http.get response GET /0.6/node/#id
Type
Promise

getNodeWays(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.get response GET /0.6/node/#id/ways
Type
Promise

getNotes(bbox)

Parameters:
Name Type Description
bbox string left,bottom,right,top where: left is the longitude of the left (westernmost) side of the bounding box. bottom is the latitude of the bottom (southernmost) side of the bounding box. right is the longitude of the right (easternmost) side of the bounding box. top is the latitude of the top (northernmost) side of the bounding box.
Source:
Returns:
$http.get response
Type
Promise

getRelation(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.get response GET /0.6/relation/#id
Type
Promise

getRelationFull(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.get response GET /0.6/relation/#id/full
Type
Promise

getRelationRelations(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.get response GET /0.6/relation/#id/relations
Type
Promise

getRelations(ids)

Parameters:
Name Type Description
ids array ids
Source:
Returns:
$http.get response GET /0.6/relations?relations=ids
Type
Promise

getUserById(id)

Parameters:
Name Type Description
id string id of the user
Source:
Returns:
$http.get response /0.6/user/#id
Type
Promise

getUserDetails()

Source:
Returns:
$http.get response /0.6/user/details
Type
Promise

getUserPreferences()

Source:
Returns:
$http.get response /0.6/user/preferences
Type
Promise

getWay(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.get response GET /0.6/way/#id
Type
Promise

getWayFull(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.get response GET /0.6/way/#id/full
Type
Promise

getWayRelations(id)

Parameters:
Name Type Description
id string id
Source:
Returns:
$http.get response GET /0.6/way/#id/relations
Type
Promise

getWays(ids)

Parameters:
Name Type Description
ids array ids
Source:
Returns:
$http.get response GET /0.6/ways?ways=ids
Type
Promise

put(method, content, config)

send a put request
Parameters:
Name Type Description
method string the api method
content Object payload
config Object the $http.put config
Source:
Returns:
$http response
Type
Promise

putUserPreferences(key, value)

Parameters:
Name Type Description
key string the preference key
value string the preference value
Source:
Returns:
$http.get response /0.6/user/preferences
Type
Promise

setAuthAdapter(adapter)

Set the adapter to make authenticated request.
Parameters:
Name Type Description
adapter Object must provide xhr method. angular-osm provide two adapter: osmBase64 and osmAuthService
Source:

xhr(options)

Call the API
Parameters:
Name Type Description
options Object ``` var options = { method: 'GET', // POST, DELETE, PUT path: '/0.6/changesets', //without the /api data: content //if you need a payload }; osmAPI.xhr(options); ```
Source:
Returns:
the adapter response
Type
Promise