time.sleep(i/11.0)
     itemDocuments = wbsea.WbSearchEntities(searchString = name)
     if 'success' in itemDocuments and itemDocuments['search']:
         for res in itemDocuments['search']:
             print res
             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)
     result = wd.search(valueOrDescription = name)
     # pprint.pprint(result)
     if 'success' in result and result['search']:
         for res in result['search']:
             print res
             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
                 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
def getMapView():
    if Main.main and Main.main.map:
        return Main.main.map.mapView
    else:
        return None

mv = getMapView()
if mv and mv.editLayer and mv.editLayer.data:

    selectedNodes = mv.editLayer.data.getSelectedNodes()
    platform = Node()

    # Find stop_position nodes
    for platform in selectedNodes:
        if (platform.get('public_transport') == 'platform'):

            print platform.getId()

            # Check if stop position is alrady in a stop area relation
            nodeInRelation = False
            exampleRoute = Relation()
            stop_position = Node()
            distance = 0.00000006

            for parent in platform.getReferrers():
                parentTags = parent.getKeys()

                if (parentTags.get('public_transport') == 'stop_area'):
                    print 'Platform already has a stop area relation'
                    nodeInRelation = True
Beispiel #4
0
 # pprint.pprint(result)
 if 'success' in result and result['search']:
     for res in result['search']:
         print res
         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
             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
Beispiel #5
0
def getMapView():
    if Main.main and Main.main.map:
        return Main.main.map.mapView
    else:
        return None


mv = getMapView()
if mv and mv.editLayer and mv.editLayer.data:

    selectedNodes = mv.editLayer.data.getSelectedNodes()
    platform = Node()

    # Find stop_position nodes
    for platform in selectedNodes:
        if (platform.get('public_transport') == 'platform'):

            print platform.getId()

            # Check if stop position is alrady in a stop area relation
            nodeInRelation = False
            exampleRoute = Relation()
            stop_position = Node()
            distance = 0.00000006

            for parent in platform.getReferrers():
                parentTags = parent.getKeys()

                if (parentTags.get('public_transport') == 'stop_area'):
                    print 'Platform already has a stop area relation'
                    nodeInRelation = True