Link Search Menu Expand Document

JOSM Scripting Plugin

Run scripts in the Open Street Map editor JOSM

The JOSM Scripting Plugin is a plugin for the Open Street Map editor JOSM.

It can execute scripts using the Graal.JS scripting engine for Javascript and the API V3 to manipulate JOSMs internal application objects with JavaScript.

For historical reasons it also includes

  • the Rhino scripting engine for Javascript and the API V1 to manipulate JOSMs internal application objects with JavaScript. This API is deprecated. The Rhino engine and the API V1 will be removed from the scripting plugin end of 2022.

  • the API V2 based on CommonJS-Modules and used in Graal.JS. API V2 is deprecated. It will be removed from the scripting plugin end of 2022.

import josm from 'josm'
import { buildAddCommand } from 'josm/command'
import { NodeBuilder } from 'josm/builder'
const layer = josm.layers.addDataLayer('Obstberg')
const restaurant = NodeBuilder
  .withTags({amenity: 'restaurant'})
  .withPosition(12.34,45.67)
  .create()
buildAddCommand(restaurant)
  .applyTo(layer)
josm.alert('Added restaurant Obstberg')

The plugin can execute scripts written in Groovy, Ruby, or any other language for which a JSR-223 compatible script engine is available.