Changes between Version 18 and Version 19 of Help/Plugin/Scripting
- Timestamp:
- 2021-08-08T13:48:25+02:00 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Help/Plugin/Scripting
v18 v19 1 1 [[TranslatedPages]] 2 = Scripting =2 = Plugin -> Scripting = 3 3 4 [[Image(https://josm.openstreetmap.de/pluginicon/scripting.jar/images/script-engine.png,link=,48)]] 4 5 [[PageOutline(2-4,,inline)]] 5 6 … … 13 14 * exporting to a custom file format not supported by JOSM 14 15 16 15 17 == How to execute scripts == 16 17 18 The [https://gubaer.github.io/josm-scripting-plugin scripting plugin] allows you to run scripts within JOSM. 18 19 19 20 You can run scripts from console or from files. If you pick files, then latest scripts will appear in "scripting" menu. See also 20 21 22 21 23 == How to write your own scripts == 22 23 24 Please carefully inspect both resources: 24 * http ://gubaer.github.io/josm-scripting-plugin/doc/documentation.html - follow all links here25 * http ://gubaer.github.io/josm-scripting-plugin/apidoc/modules/josm.html - scan what all classes, modules, mixins and namespaces can do.25 * https://gubaer.github.io/josm-scripting-plugin/doc/documentation.html - follow all links here 26 * https://gubaer.github.io/josm-scripting-plugin/apidoc/modules/josm.html - scan what all classes, modules, mixins and namespaces can do. 26 27 27 28 To write functional scripts than "josm.alert(josm.menu.length);" you should combine examples from multiple pages, for example: 28 * [http://gubaer.github.io/josm-scripting-plugin/apidoc/classes/JSAction.html Create an action using "JSAction" class], then [http://gubaer.github.io/josm-scripting-plugin/doc/menu.html attach it to menu as was shown at "Extending the JOSM menu and the JOSM toolbar" page] 29 * [https://gubaer.github.io/josm-scripting-plugin/apidoc/classes/JSAction.html Create an action using "JSAction" class], then [https://gubaer.github.io/josm-scripting-plugin/doc/menu.html attach it to menu as was shown at "Extending the JOSM menu and the JOSM toolbar" page] 30 29 31 30 32 == Implementations details == 31 32 33 The plugin includes a embedded scripting engine for Javascript based on Mozilla Rhino and a 33 34 [https://gubaer.github.io/josm-scripting-plugin/apidoc/modules/josm.html Javascript API] for the JOSM application objects.\\ 34 35 Alternatively, you can use any scripting language which provides a JSR-223 compatible scripting engine, in particular 35 [http ://groovy-lang.org/index.html Groovy], [http://www.jython.org/ Python], or [http://jruby.org/ Ruby].\\36 [https://groovy-lang.org/index.html Groovy], [https://www.jython.org/ Python], or [https://www.jruby.org/ Ruby].\\ 36 37 37 38 [https://github.com/gubaer/josm-scripting-plugin Source code at GitHub]. 38 39 40 39 41 == Scripts == 40 42 === Scripts in JavaScript === 41 42 43 * https://gist.github.com/Rub21/feb83f57a727ac0d8a34 - Expand abbreviations (US) 43 44 * https://gist.github.com/Rub21/47838797856566a8b6ba - Capitalize names and eliminate "name=S/N" … … 45 46 46 47 === Scripts in Python === 47 48 48 * [wikitr:/Help/Plugin/Scripting/Python] - various small scripts that are meant to illustrate how to do one thing. 49 49 * [wikitr:/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 … … 52 52 Run once per JOSM session. 53 53 54 54 55 == Advanced settings == 55 56 56 Search for {{{scripting.}}} substring. 57 57 58 {{{#!comment 58 59 == See also == 59 * [wikitr:/Plugins Plugin Help] 60 }}} 60 61 61 62 ---- 63 Back to [wikitr:/Plugins Plugin Help] \\ 62 64 Back to [wikitr:/Help Main Help]