Module: josm/api

This module provides functions to retrieve data from and upload data to an OSM server.
Source:

Example

import {Api, ChangesetApi, ApiConfig} from 'josm/api'

Classes

Api
Collection of static methods to download objects from and upload objects to the OSM server
ChangesetApi
Provides methods to open, close, get, update, etc. changesets on the OSM API server.
ApiConfig
ApiConfig provides methods and properties for configuring API parameters

Methods


<static> buildBounds(obj)

Creates a Bounds instance from a javascript object.
Parameters:
Name Type Description
obj BoundsSpec1 | BoundsSpec2 a javascript object
Source:
Returns:
the bounds
Type
Bounds
Example
import { buildBounds } from 'josm/api'
const bounds1 = buildBounds({
   minlat: 46.9479186, minlon: 7.4619484,
   maxlat: 46.9497642, maxlon: 7.4660683
})

const bounds2 = buildBounds({
   min: {lat: 46.9479186, lon: 7.4619484},
   max: {lat: 46.9497642, lon: 7.4660683}
})

<static> buildLatLon(obj)

Create a LatLon from a javascript object.

Creates a LatLon from a javascript object.
Parameters:
Name Type Description
obj module:josm/api~LatLonSpec a specification of the position
Source:
Returns:
Type
LatLon
Example
import { buildLatLon } from 'josm/api'
const pos = buildLatLon({lat: 1, lon: 2});

Type Definitions


BasicCredentials

Basic credentials replied by getCredentials
Properties:
Name Type Description
host string the host name
user string the user name
password string the password
Source:

BoundsSpec1

Specification of a bounds as JavaScript object.
Properties:
Name Type Description
minlat number
minlon number
maxlat number
maxlon number
Source:
Example
const bounds = {
   minlat: 46.9479186, minlon: 7.4619484,
   maxlat: 46.9497642, maxlon: 7.4660683
}

BoundsSpec2

Specification of a bounds as JavaScript object.
Properties:
Name Type Description
min module:josm/api~LatLonSpec the upper left point
max module:josm/api~LatLonSpec the lower right point
Source:
Example
const bounds = {
   min: {lat: 46.9479186, lon: 7.4619484},
   max: {lat: 46.9497642, lon: 7.4660683}
}

DownloadObjectOptions

Options for the method downloadObject()
Properties:
Name Type Argument Default Description
full boolean <optional>
false if true, the object and its immediate children are downloaded, i.e. the nodes of a way and the relation members of a relation. Default: false.
version number <optional>
if present, the specified version of the object is downloaded. If missing, the current version is downloaded. If present, the option full is ignored.
Source:

DownloadReferrerOptions

Options for the method donwloadReferrers()
Properties:
Name Type Argument Default Description
full boolean <optional>
false If true, the full objects are retrieved using multi-gets. If missing or false, only proxy objects are downloaded. Default: false
Source:

LatLonSpec

Specification of position as lat/lon-pair.
Properties:
Name Type Description
lat number the latitude
lon number the longitude
Source:

OAuthCredentials

OAuth credentials replied by getCredentials
Properties:
Name Type Description
key string the OAuth key
secret string the OAuth secret
Source:

SetOrGetCredentialOptions

Options for the method setCredentials
Source:

UploadOptions

Options for the method upload()
Properties:
Name Type Argument Default Description
strategy string | UploadStrategy <optional>
Indicates how the data is uploaded. Either one of the strings
  • individualobjects
  • chunked
  • singlerequest
or one of the enumeration values in {@class org.openstreetmap.josm.io.UploadStrategy}. Default value: UploadStrategy.DEFAULT_UPLOAD_STRATEGY
changeset number | Changeset <optional>
The changeset to which the data is uploaded. Default: creates a new changeset
chunkSize number <optional>
the size of an upload chunk if the data is uploaded with the upload strategy {@class org.openstreetmap.josm.io.UploadStrategy}.CHUNKED_DATASET_STRATEGY.
closeChangeset boolean <optional>
true if true, closes the changeset after the upload
Source: