Changes between Version 16 and Version 17 of Help/Plugin/Scripting/Python
- Timestamp:
- 2021-08-10T16:37:28+02:00 (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Help/Plugin/Scripting/Python
v16 v17 1 1 [[TranslatedPages]] 2 2 3 = Plugin -> Scripting -> Python = 4 == Purpose == 3 5 Some more examples in Python: 4 6 7 [[PageOutline(2,Table of Contents)]] 8 9 10 == Convert a way that connects to an unsplit roundabout to a fork == 5 11 Convert a way that connects to a roundabout to a fork consisting of 2 oneway ways. Splitting the way on its last node and attaching to the 2 nodes adjacent to the common node of the roundabout way. This version only works on unsplit roundabouts. See the next example for an updated version. 6 12 … … 114 120 115 121 122 == Convert a way that connects to a split roundabout to a fork == 116 123 This script does the same as the previous one, but it also works on roundabouts where the ways are split. It's not taking care of the relations. 117 124 … … 270 277 271 278 279 == Export a collection of routes to Garmin GPX file == 272 280 Export a collection of routes to Garmin GPX file (not a super example, as I don't think we do collection relations anymore): 273 281 … … 279 287 280 288 The GPL v3 is accessible here: 281 http://www.gnu.org/licenses/gpl.html 289 https://www.gnu.org/licenses/gpl.html 282 290 283 291 It comes with no warranty whatsoever. … … 295 303 f = open('C:/export.gpx', 'w') 296 304 f.write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n') 297 f.write('<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="OSM Route Manager" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">\n') 298 f.write('<!-- All data by OpenStreetMap, licensed under cc-by-sa-2.0 (http://creativecommons.org/licenses/by-sa/2.0/). -->\n') 305 f.write('<gpx xmlns="https://www.topografix.com/GPX/1/1" creator="OSM Route Manager" version="1.1" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.topografix.com/GPX/1/1 https://www.topografix.com/GPX/1/1/gpx.xsd">\n') 306 f.write('<!-- All data by OpenStreetMap, licensed under cc-by-sa-2.0 (https://creativecommons.org/licenses/by-sa/2.0/). -->\n') 299 307 300 308 editLayer = Main.getLayerManager().getEditLayer() … … 351 359 352 360 353 Download missing parent elements for the selected element: 354 361 == Download missing parent elements for the selected element == 355 362 356 363 {{{#!python … … 362 369 363 370 The GPL v3 is accessible here: 364 http://www.gnu.org/licenses/gpl.html 371 https://www.gnu.org/licenses/gpl.html 365 372 366 373 The GPL v2 is accessible here: 367 http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 374 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html 368 375 369 376 It comes with no warranty whatsoever. … … 388 395 389 396 390 Download missing relation members :397 == Download missing relation members == 391 398 392 399 {{{ … … 398 405 399 406 The GPL v3 is accessible here: 400 http://www.gnu.org/licenses/gpl.html 407 https://www.gnu.org/licenses/gpl.html 401 408 402 409 The GPL v2 is accessible here: 403 http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 410 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html 404 411 405 412 It comes with no warranty whatsoever. … … 434 441 435 442 436 Validate an rcn route relation: 437 443 == Validate an rcn route relation == 438 444 439 445 {{{ … … 446 452 447 453 The GPL v3 is accessible here: 448 http://www.gnu.org/licenses/gpl.html 454 https://www.gnu.org/licenses/gpl.html 449 455 450 456 The GPL v2 is accessible here: 451 http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 457 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html 452 458 453 459 It comes with no warranty whatsoever. … … 634 640 }}} 635 641 636 [wiki:Python/RCN_Route_Validator] 637 642 [wiki:/Help/Plugin/Scripting/Python/RCN_Route_Validator] 643 644 645 == Remove extra ways resulting from Potlatch operations == 638 646 Remove extra ways resulting from Potlatch way split operations under turn restriction relations 639 647 … … 648 656 649 657 The GPL v3 is accessible here: 650 http://www.gnu.org/licenses/gpl.html 658 https://www.gnu.org/licenses/gpl.html 651 659 652 660 It comes with no warranty whatsoever. … … 730 738 """ 731 739 if (way.isOneway() != 0 and reverse): 732 return node == way.lastNode(True), way.firstNode(True) # True: auto process case wh an isOneway == -1740 return node == way.lastNode(True), way.firstNode(True) # True: auto process case when isOneway == -1 733 741 if (way.isOneway() != 0): # not reverse 734 742 return node == way.firstNode(True), way.lastNode(True) … … 843 851 commandsList=[] 844 852 }}} 853 854 855 ---- 856 Back to [wikitr:/Help/Plugin/Scripting Plugin Scripting] \\ 857 Back to [wikitr:/Plugins Plugin Help] \\ 858 Back to [wikitr:/Help Main Help]