found = False
                for i in range(19, 0, -1):
                    time.sleep(i / 3)
                    params = '?action=wbsearchentities&search=' + URLEncoder.encode(
                        name, "UTF-8") + '&language=en&format=json'
                    url = baseurl + 'api.php' + params
                    r1 = HttpClient.create(URL(url), "GET")
                    r2 = r1.setHeader("Content-Type",
                                      "application/x-www-form-urlencoded"
                                      ).connect().fetchContent()
                    #print dir(r2)
                    print i, r2
                    Q_school = QinJSONRE.search(r2)
                    if Q_school:
                        print Q_school.group('qid')
                        break
                    else:
                        print 'not found yet'

                break
            else:
                print 'already in Wikidata'
        newSchool = Node(element)
        newSchool.put('wikidata', Q_school.group('qid'))
        newSchool.put('isced:level', isced)

        CommandsList = [Command.ChangeCommand(element, newSchool)]
        Main.main.undoRedo.add(
            Command.SequenceCommand(
                "Add wikidata and isced:level tags to school", CommandsList))
    USERNAME = Main.pref.get("wikidata.username")
    PASSWORD = Main.pref.get("wikidata.password")
    EDIT_AS_BOT = False


WD_QrefRE = re.compile(r'^([Qq]\d+)$')
WD_PrefRE = re.compile(r'^([Pp]\d+)$')

siteIri = ""
NEWITEM = ItemIdValue.NULL
mapper = ObjectMapper()

osm_account =        'Polyglot'
osm_import_account = 'Polyglot_Import'

dummyNode = Node()
dummyWay = Way()
dummyRelation = Relation()

class WbSearchEntitiesAction:
    def __init__(self, connection, siteUri):
        self.connection = connection
        self.siteIri = siteUri
    # def WbSearchEntities(properties):
        # return WbSearchEntities(self, properties.ids, properties.sites, properties.titles, properties.props, properties.languages, properties.sitefilter)

    def WbSearchEntities(self, searchString, props=None, language='en', sitefilter=None):
        parameters = {ApiConnection.PARAM_ACTION: "wbsearchentities"}

        if searchString == None:
            raise IllegalArgumentException("Please provide a string to search for")
import java.net.CookieHandler as CookieHandler
import java.io.InputStream as InputStream

import re, time, json, pprint

# uploadSelection = UploadSelectionAction()
# print dir(uploadSelection)

osm_account =        'Polyglot'
osm_import_account = 'Polyglot_Import'

latlonRE = re.compile(r'LatLon\[lat=(?P<lat>-*\d+(\.\d\d\d\d\d\d)?)\d*,lon=(?P<lon>-*\d+(\.\d\d\d\d\d\d)?)\d*\]')
PrimarySchoolRE = re.compile(r'\s[Pp]r*\\*(im|imary)*\.*\s*[Ss]chool')
NurseryAndPrimarySchoolRE = re.compile(r'.*\sN/\s*[Pp]r*(im|imary)*\.*\s*[Ss]chool')

dummyNode = Node()
dummyWay = Way()
dummyRelation = Relation()

cookieManager = CookieManager()
CookieHandler.setDefault(cookieManager)

def getMapView():
    if Main.main and Main.main.map:
        return Main.main.map.mapView
    else:
        return None

class DataType():
    def __init__(self, type='', value=''):
        self.type=type
                
                found = False
                for i in range(19, 0, -1):
                    time.sleep(i/3)
                    params  = '?action=wbsearchentities&search=' + URLEncoder.encode(name, "UTF-8") + '&language=en&format=json'
                    url = baseurl + 'api.php' + params
                    r1 = HttpClient.create(URL(url), "GET")
                    r2 = r1.setHeader("Content-Type", "application/x-www-form-urlencoded").connect().fetchContent()
                    #print dir(r2)
                    print i, r2
                    Q_school = QinJSONRE.search(r2)
                    if Q_school:
                        print Q_school.group('qid')
                        break
                    else:
                        print 'not found yet'

                break
            else:
                print 'already in Wikidata'
        newSchool = Node(element)
        newSchool.put('wikidata', Q_school.group('qid'))
        newSchool.put('isced:level', isced)

        CommandsList=[Command.ChangeCommand( element, newSchool)]
        Main.main.undoRedo.add(Command.SequenceCommand("Add wikidata and isced:level tags to school", CommandsList))




Example #5
0
    selectedNodes = mv.editLayer.data.getSelectedNodes()
    selectedWays = mv.editLayer.data.getSelectedWays()
    selectedRelations = mv.editLayer.data.getSelectedRelations()

    if not(selectedNodes or selectedWays or selectedRelations):
        JOptionPane.showMessageDialog(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.")
Example #6
0
import re, time, json, pprint

# uploadSelection = UploadSelectionAction()
# print dir(uploadSelection)

osm_account = 'Polyglot'
osm_import_account = 'Polyglot_Import'

latlonRE = re.compile(
    r'LatLon\[lat=(?P<lat>-*\d+(\.\d\d\d\d\d\d)?)\d*,lon=(?P<lon>-*\d+(\.\d\d\d\d\d\d)?)\d*\]'
)
PrimarySchoolRE = re.compile(r'\s[Pp]r*\\*(im|imary)*\.*\s*[Ss]chool')
NurseryAndPrimarySchoolRE = re.compile(
    r'.*\sN/\s*[Pp]r*(im|imary)*\.*\s*[Ss]chool')

dummyNode = Node()
dummyWay = Way()
dummyRelation = Relation()

cookieManager = CookieManager()
CookieHandler.setDefault(cookieManager)


def getMapView():
    if Main.main and Main.main.map:
        return Main.main.map.mapView
    else:
        return None


class DataType():
import org.openstreetmap.josm.data.osm.RelationMember as RelationMember
import org.openstreetmap.josm.actions.search.SearchAction as SearchAction
import re, time, sys
import codecs

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()
Example #8
0
'''

forceNameCA = False
'''
if True name:ca will be same as name on checked nodes/ways/relations
'''


def getMapView():
    if Main.main and Main.main.map:
        return Main.main.map.mapView
    else:
        return None


dummy_node = Node()
dummy_way = Way()
dummy_relation = Relation()
commandsList = []

pattern = re.compile("^(L'|El |La |Els |Les |Los |Lo |S'|Es |Sa |Ses )")

mv = getMapView()

if mv and mv.editLayer and mv.editLayer.data:
    selectedNodes = mv.editLayer.data.getSelectedNodes()
    selectedWays = mv.editLayer.data.getSelectedWays()
    selectedRelations = mv.editLayer.data.getSelectedRelations()

    if not (selectedNodes or selectedWays or selectedRelations):
        JOptionPane.showMessageDialog(
Example #9
0
import re, time, sys
import codecs


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()