- How to execute scripts
- How to write your own scripts
- Implementations details
- Advanced settings
- See also
Use it to automate small tasks for which no any existing plugin can do i.e.
- additional quality tests for which no validator test cases are available
- automatically entering data in very specific situations (i.e. sequences of house numbers)
- importing from a custom file format not supported by JOSM
- exporting to a custom file format not supported by JOSM
How to execute scripts
The scripting plugin allows you to run scripts within JOSM.
You can run scripts from console or from files. If you pick files, then latest scripts will appear in "scripting" menu. See also
How to write your own scripts
Please carefully inspect both resources:
- http://gubaer.github.io/josm-scripting-plugin/doc/documentation.html - follow all links here
- http://gubaer.github.io/josm-scripting-plugin/apidoc/modules/josm.html - scan what all classes, modules, mixins and namespaces can do.
To write functional scripts than "josm.alert(josm.menu.length);" you should combine examples from multiple pages, for example:
- Create an action using "JSAction" class, then attach it to menu as was shown at "Extending the JOSM menu and the JOSM toolbar" page
Alternatively, you can use any scripting language which provides a JSR-223 compatible scripting engine, in particular Groovy, Python, or Ruby.
- https://gist.github.com/Rub21/feb83f57a727ac0d8a34 - Expand abbreviations (US)
- https://gist.github.com/Rub21/47838797856566a8b6ba - Capitalize names and eliminate "name=S/N"
- https://gist.github.com/Rub21/cc055320c925c855926e - expand abbreviations (Peru); video demonstration
Scripts in Python
- Help/Plugin/Scripting/Python - various small scripts that are meant to illustrate how to do one thing.
- Help/Plugin/Scripting/Python/SurfaceTypesOfRoutes - (Interesting for cycle routes, both loops and linear ones). Short piece of code, but illustrates some interesting concepts and reports on OSM data. Doesn't make changes to the data
- Help/Plugin/Scripting/Python/RCN_Route_Validator - This is not a trivial script anymore. It does a lot in a complicated field (networks of cycle node routes with numbered nodes), makes changes to relations, writes to a file that can be pasted to the wiki. Analyzes routes, but also networks of routes or collections of networks of routes, depending on the selection in JOSM when the script was run.
- AutoAddIntersections (needs UtilsPlugin2) - Adds command queue listener that will perform utilsplugin2's AddNodesAtIntersections command after encountering Extrude command. (See #7991)
Run once per JOSM session.
Back to Main Help