if 'description' in res and res['description'] == description:
                 Q_school = res['id']
                 print Q_school
                 if type=='node':
                     newSchool = Node(element)
                 elif type=='way':
                     newSchool = Way(element)
                 else:
                     newSchool = Relation(element)
                 dirty =False
                 if newSchool.get('wikidata') != Q_school:
                     newSchool.put('wikidata', Q_school); dirty=True
                 for tag in tagsToSet:
                     if tagsToSet[tag]: newSchool.put(tag, tagsToSet[tag]); dirty=True
                 if dirty:
                     CommandsList=[Command.ChangeCommand( element, newSchool)]
                     Main.main.undoRedo.add(Command.SequenceCommand("Add wikidata and isced:level tags to school", CommandsList))
                 found = True
                 break
         if found: break
     else:
         print 'not found yet'
 if element.isNew(): noNewSchools=False
 if Q_school:
     wbdf = WikibaseDataFetcher.getWikidataDataFetcher()
     wikidataCoords = wbdf.getEntityDocument(Q_school)
     # print dir(wikidataCoords)
     pprint.pprint(wikidataCoords)
     hasCoords = wikidataCoords.hasStatement("P625")
     print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
     print(hasCoords)
Exemplo n.º 2
0
            Main.parent, "Please select some node, way, or relation.")
    else:

        if (selectedNodes):

            for node in selectedNodes:
                nodeChanged = False
                oldname = node.get('name')
                if not (oldname): oldname = ''
                if pattern.match(oldname):
                    newNode = Node(node)
                    newname = oldname
                    newname = re.sub("^E", "e", newname)
                    newname = re.sub("^L", "l", newname)
                    newname = re.sub("^S", "s", newname)
                    newNode.put("name", newname)
                    if (forceNameCA): newNode.put("name:ca", newname)

                    commandsList.append(Command.ChangeCommand(node, newNode))
                    Main.main.undoRedo.add(
                        Command.SequenceCommand("Changed name " + oldname,
                                                commandsList))
                    commandsList = []

        if (selectedWays):
            JOptionPane.showMessageDialog(Main.parent,
                                          "You have selected some way.")
        if (selectedRelations):
            JOptionPane.showMessageDialog(Main.parent,
                                          "You have selected some relation.")
Exemplo n.º 3
0
                     newSchool = Node(element)
                 elif type == 'way':
                     newSchool = Way(element)
                 else:
                     newSchool = Relation(element)
                 dirty = False
                 if newSchool.get('wikidata') != Q_school:
                     newSchool.put('wikidata', Q_school)
                     dirty = True
                 if not (isced_level) and isced and newSchool.get(
                         'isced:level') != isced_level:
                     newSchool.put('isced:level', isced)
                     dirty = True
                 if dirty:
                     CommandsList = [
                         Command.ChangeCommand(element, newSchool)
                     ]
                     Main.main.undoRedo.add(
                         Command.SequenceCommand(
                             "Add wikidata and isced:level tags to school",
                             CommandsList))
                 found = True
                 break
         if found: break
     else:
         print 'not found yet'
 if element.isNew(): noNewSchools = False
 if Q_school:
     wikidataCoords = wd.fetchCoordinates(Q_school)
     print wikidataCoords
     if not (wikidataCoords['claims']):
                if reNumberDashNumber.match(name):
                    print 'removing name when it is of the form ##-##'
                    newRelation.remove('name')
                    relationChanged = True
            else:
                name = ''
            ref = route.get('ref')
            if ref:
                if reNumberDashNumber.match(ref):
                    print 'removing ref when it is of the form ##-##'
                    newRelation.remove('ref')
                    relationChanged = True
            else:
                ref = ''
            if relationChanged:
                commandsList.append(Command.ChangeCommand(route, newRelation))
                
                Main.main.undoRedo.add(Command.SequenceCommand("Removing name and/or ref " + name + '/' + ref, commandsList))
                commandsList = []

            rcn_refs = []; route_relation_names = []; memberslist = []
            endnodes = []; prev_endnodes = []
            continuous_forward = True; continuous_backward = True
            prev_role = None; prev_endnodes_before_forward = None; last_endnodes_before_backward = None
            for member in route.getMembers():
                if member.isWay():
                    role = member.getRole()
                    memberslist.append(member)
                    way = member.getWay()
                    #JOptionPane.showMessageDialog(Main.parent, 'way is selected')
                    endnodes = [way.getNode(0), way.getNode(way.nodesCount-1)]