Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-osm-api-test

galta958ISC1.0.3TypeScript support: included

easy communication with osm api

readme

node-osm-api

Easy Node.js, TypeScript communication with OpenStreetMap api

import { Apiv6 } from '@map-colonies/node-osm-api';

const api = new Apiv6('https://www.openstreetmap.org', USER_NAME, PASSWORD);

Installation

$ npm install @map-colonies/node-osm-api

Usage

  • Right now we only support create/upload/close changesets

In Node.js TypeScript:

Performing Create changeset:

let changesetID: number;

async function createChangeset() {
  try {
    changesetID = await api.createChangeset(CREATE_CHANGESET_BODY_XML);
  } catch (e) {
    console.error(e);
  }
}

Possibble error types:

  • UnauthorizedError
  • BadXmlError

Performing Upload changeset:

let diffRes: string;

async function uploadChangeset() {
  try {
    // returns osm xml diff result as string
    diffRes = await api.uploadChangeset(CHANGESET_ID, OSC_XML);
  } catch (e) {
    console.error(e);
  }
}

Possibble error types:

  • UnauthorizedError
  • BadXmlError
  • ChangesetOrDiffElementsNotFoundError
  • ChangesetAlreadyClosedError
  • OwnerMismatchError
  • MismatchChangesetError

Performing Close changeset:

async function closeChangeset() {
  try {
    await api.closeChangeset(CHANGESET_ID);
  } catch (e) {
    console.error(e);
  }
}

Possibble error types:

  • UnauthorizedError
  • NotAllowedError
  • ChangesetNotFoundError
  • ChangesetAlreadyClosedError
  • OwnerMismatchError

JavaScript

const nodeOsmApi = require('node-osm-api');

const api = new nodeOsmApi.Apiv6('https://www.openstreetmap.org', USER_NAME, PASSWORD);

async function createChangeset() {
  try {
    changesetID = await api.createChangeset(CREATE_CHANGESET_BODY_XML);
  } catch (e) {
    console.error(e);
  }
}

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.0.3 (2020-12-10)

1.0.2 (2020-12-09)

1.0.2 (2020-12-09)

1.0.1 (2020-12-09)

1.0.0 (2020-12-09)

Features