Changes between Version 16 and Version 17 of Help/Plugin/Scripting/Python


Ignore:
Timestamp:
2021-08-10T16:37:28+02:00 (5 years ago)
Author:
leni
Comment:

Table of Contents; Titles; https; back to

Legend:

Unmodified
Added
Removed
Modified
  • Help/Plugin/Scripting/Python

    v16 v17  
    11[[TranslatedPages]]
    22
     3= Plugin -> Scripting -> Python =
     4== Purpose ==
    35Some more examples in Python:
    46
     7[[PageOutline(2,Table of Contents)]]
     8
     9
     10== Convert a way that connects to an unsplit roundabout to a fork ==
    511Convert 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.
    612
    … …  
    114120
    115121
     122== Convert a way that connects to a split roundabout to a fork ==
    116123This 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.
    117124
    … …  
    270277
    271278
     279== Export a collection of routes to Garmin GPX file ==
    272280Export a collection of routes to Garmin GPX file (not a super example, as I don't think we do collection relations anymore):
    273281
    … …  
    279287
    280288The GPL v3 is accessible here:
    281 http://www.gnu.org/licenses/gpl.html
     289https://www.gnu.org/licenses/gpl.html
    282290
    283291It comes with no warranty whatsoever.
    … …  
    295303f = open('C:/export.gpx', 'w')
    296304f.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')
     305f.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')
     306f.write('<!-- All data by OpenStreetMap, licensed under cc-by-sa-2.0 (https://creativecommons.org/licenses/by-sa/2.0/). -->\n')
    299307
    300308editLayer = Main.getLayerManager().getEditLayer()
    … …  
    351359
    352360
    353 Download missing parent elements for the selected element:
    354 
     361== Download missing parent elements for the selected element ==
    355362
    356363{{{#!python
    … …  
    362369
    363370The GPL v3 is accessible here:
    364 http://www.gnu.org/licenses/gpl.html
     371https://www.gnu.org/licenses/gpl.html
    365372
    366373The GPL v2 is accessible here:
    367 http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     374https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    368375
    369376It comes with no warranty whatsoever.
    … …  
    388395
    389396
    390 Download missing relation members:
     397== Download missing relation members ==
    391398
    392399{{{
    … …  
    398405
    399406The GPL v3 is accessible here:
    400 http://www.gnu.org/licenses/gpl.html
     407https://www.gnu.org/licenses/gpl.html
    401408
    402409The GPL v2 is accessible here:
    403 http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     410https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    404411
    405412It comes with no warranty whatsoever.
    … …  
    434441
    435442
    436 Validate an rcn route relation:
    437 
     443== Validate an rcn route relation ==
    438444
    439445{{{
    … …  
    446452
    447453The GPL v3 is accessible here:
    448 http://www.gnu.org/licenses/gpl.html
     454https://www.gnu.org/licenses/gpl.html
    449455
    450456The GPL v2 is accessible here:
    451 http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     457https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    452458
    453459It comes with no warranty whatsoever.
    … …  
    634640}}}
    635641
    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 ==
    638646Remove extra ways resulting from Potlatch way split operations under turn restriction relations
    639647
    … …  
    648656
    649657The GPL v3 is accessible here:
    650 http://www.gnu.org/licenses/gpl.html
     658https://www.gnu.org/licenses/gpl.html
    651659
    652660It comes with no warranty whatsoever.
    … …  
    730738    """
    731739    if (way.isOneway() != 0 and reverse):
    732         return node == way.lastNode(True), way.firstNode(True) # True: auto process case whan isOneway == -1
     740        return node == way.lastNode(True), way.firstNode(True) # True: auto process case when isOneway == -1
    733741    if (way.isOneway() != 0):     # not reverse
    734742        return node == way.firstNode(True), way.lastNode(True)
    … …  
    843851        commandsList=[]
    844852}}}
     853
     854
     855----
     856Back to [wikitr:/Help/Plugin/Scripting Plugin Scripting] \\
     857Back to [wikitr:/Plugins Plugin Help] \\
     858Back to [wikitr:/Help Main Help]