Changes between Version 2 and Version 3 of Help/Plugin/Scripting/Python/RCN_Route_Validator


Ignore:
Timestamp:
2011-11-11T19:39:56+01:00 (14 years ago)
Author:
Polyglot
Comment:

Made some changes so the script works in Germany with its many types of rcn networks, as well

Legend:

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

    v2 v3  
    207207    if 'removeNameRefKey_xx-yyAndcreated_by' in sideEffects:
    208208        commandsList = []
    209         reNumberDashNumber = re.compile(r'\d+-\d+')
     209        reNumberDashNumber = re.compile(r'\d+\s-\s\d+')
    210210        newRelation = Relation(route)
    211211        relationChanged = False
     
    697697                            if wayReferrer.getType() is dummy_relation.getType():
    698698                                aRelation = wayReferrer
    699                                 if aRelation.get('type') == 'route' and aRelation.get('network') == 'rcn':
     699                                rcnRelationWeWantToProcess = False # We need this again further on, when deciding whether or not to add this relation to the network
     700                                if aRelation.get('type') == 'route' and aRelation.get('network') == 'rcn' and not(aRelation.get('ref') in ['RUR','NRR','NRW','2LR','3LR','KAI','EHR','DFR','WBR','Nk']):
     701                                    # The check on the ref is for Germany, where many rcn networks run crisscross through another.
     702                                    # We wouldn't want to get entangled in that mess.
     703                                    # The list is continuously getting longer, of course. But it's the best we can do here
     704                                    rcnRelationWeWantToProcess = True
    700705                                    rcnNetworkCountForNode+=1
    701706                                    if aRelation.hasIncompleteMembers():
     
    721726                                        networkMembersList.append(routeRelation.getUniqueId())
    722727                                routeId = aRelation.getUniqueId()
    723                                 if not(routeId in networkMembersList):
    724                                     if aRelation.get('network') == 'rcn':
    725                                         roleFromRouteCheck, problemReported, wikiReport = checkRCNroute(aRelation, aDownloadWasNeeded)
    726                                         if problemReported and 'createWikiReport' in sideEffects:
    727                                             wikiReportOnRelations += wikiReport + '\n|-\n'
    728                                         if 'addRouteToNetwork' in sideEffects and not(aDownloadWasNeeded):
    729                                             newRelation = Relation(network)
    730                                             newmember = RelationMember(roleFromRouteCheck, aRelation)
    731                                             if logVerbosity > 9: print newRelation.getMembersCount(), ' ',i, ' ', newmember
    732                                             newRelation.addMember( i, newmember)
    733                                             commandsList = []
    734                                             commandsList.append(Command.ChangeCommand(network, newRelation))
    735                                             note = aRelation.get('note')
    736                                             if not(note):
    737                                                 note = ''
    738                                             Main.main.undoRedo.add(Command.SequenceCommand("Adding " + note + " to network", commandsList))
    739                                             commandsList = []
    740                                             if logVerbosity > 9: print 'Added newly found RCN route relation to network: ', note
    741                                             i+=1
     728                                if rcnRelationWeWantToProcess and not(routeId in networkMembersList):
     729                                    roleFromRouteCheck, problemReported, wikiReport = checkRCNroute(aRelation, aDownloadWasNeeded)
     730                                    if problemReported and 'createWikiReport' in sideEffects:
     731                                        wikiReportOnRelations += wikiReport + '\n|-\n'
     732                                    if 'addRouteToNetwork' in sideEffects and not(aDownloadWasNeeded):
     733                                        newRelation = Relation(network)
     734                                        newmember = RelationMember(roleFromRouteCheck, aRelation)
     735                                        if logVerbosity > 9: print newRelation.getMembersCount(), ' ',i, ' ', newmember
     736                                        newRelation.addMember( i, newmember)
     737                                        commandsList = []
     738                                        commandsList.append(Command.ChangeCommand(network, newRelation))
     739                                        note = aRelation.get('note')
     740                                        if not(note):
     741                                            note = ''
     742                                        Main.main.undoRedo.add(Command.SequenceCommand("Adding " + note + " to network", commandsList))
     743                                        commandsList = []
     744                                        if logVerbosity > 9: print 'Added newly found RCN route relation to network: ', note
     745                                        i+=1
    742746                if rcnNetworkCountForNode < expected_rcn_route_relations:
    743747                    if logVerbosity > 9: print 'Node ', rcn_ref, ' only has ', rcnNetworkCountForNode, ' rcn routes connected to it'