| | 16 | |
| | 17 | == How to execute scripts == |
| | 18 | The [https://gubaer.github.io/josm-scripting-plugin scripting plugin] allows you to run scripts within JOSM. |
| | 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 |
| | 21 | |
| | 22 | |
| | 23 | == How to write your own scripts == |
| | 24 | Please carefully inspect both resources: |
| | 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. |
| | 27 | |
| | 28 | To write functional scripts than "josm.alert(josm.menu.length);" you should combine examples from multiple pages, for example: |
| | 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 | |
| | 31 | |
| | 32 | == Implementations details == |
| 23 | | == Example scripts in Python == |
| 24 | | Here are some more examples: |
| 25 | | * [wiki:Help/Plugin/Scripting/Python]\\ |
| 26 | | Various small scripts that are meant to illustrate how to do one thing. |
| | 41 | == Scripts == |
| | 42 | === Scripts in JavaScript === |
| | 43 | * https://gist.github.com/Rub21/feb83f57a727ac0d8a34 - Expand abbreviations (US) |
| | 44 | * https://gist.github.com/Rub21/47838797856566a8b6ba - Capitalize names and eliminate "name=S/N" |
| | 45 | * https://gist.github.com/Rub21/cc055320c925c855926e - expand abbreviations (Peru); [https://www.youtube.com/watch?v=Cpi_5dB1NLQ video demonstration] |
| 28 | | * [wiki:Help/Plugin/Scripting/Python/SurfaceTypesOfRoutes] (Interesting for cycle routes, both loops and linear ones)\\ |
| 29 | | Short piece of code, but illustrates some interesting concepts and reports on OSM data. Doesn't make changes to the data |
| 30 | | |
| 31 | | * [wiki:Help/Plugin/Scripting/Python/RCN_Route_Validator]\\ |
| 32 | | 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. |
| 33 | | |
| 34 | | * [attachment:ticket:7991:AutoAddIntersections.py AutoAddIntersections] (needs [wiki:Plugin/UtilsPlugin2 UtilsPlugin2])\\ |
| 35 | | Adds command queue listener that will perform utilsplugin2's AddNodesAtIntersections command after encountering Extrude command. (See #7991)\\ |
| | 47 | === Scripts in Python === |
| | 48 | * [wikitr:/Help/Plugin/Scripting/Python] - various small scripts that are meant to illustrate how to do one thing. |
| | 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 |
| | 50 | * [wikitr:/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. |
| | 51 | * [attachment:ticket:7991:AutoAddIntersections.py AutoAddIntersections] (needs [wikitr:/Help/Plugin/UtilsPlugin2 UtilsPlugin2]) - Adds command queue listener that will perform utilsplugin2's AddNodesAtIntersections command after encountering Extrude command. (See #7991)\\ |