def runSearch(self, searchString, selectedGazetteer):
        self.clearResults()
        gazetteer_config = self.gazetteers[str(selectedGazetteer)]
        gazetteer = self.getGazetteerModule(gazetteer_config)
        url = common.prepareURL(gazetteer.url, gazetteer.params, searchString)
        
        try:
            data = common.search(url)
        except URLError:
            self.results = []
            self.widget.addError('Problem connecting to "%s"' % selectedGazetteer)
        else:
            try:
                results = list(gazetteer.parseRequestResults(data))
            except ValueError:
                self.results = []
                
            if len(results) == 0:
                self.widget.addError('No results found for "%s"' % searchString)

            else:
                for res in results:
                    r = Result(self.iface, res.description, res.x, res.y, res.zoom, res.epsg)
                    self.widget.addResult(r.description)
                    r.index = self.widget.getListCount()-1
                    r.visible = True
                    self.results.append(r)
    def runSearch(self, searchString, selectedGazetteer):
        searchString = searchString.encode('utf-8')
        gazetteer_config = self.gazetteers[str(selectedGazetteer)]
        gazetteer = self.getGazetteerModule(gazetteer_config)
        url = common.prepareURL(gazetteer.url, gazetteer.params, searchString)

        def callback(data):
            try:
                self.results = list(gazetteer.parseRequestResults(data, self.iface))
            except:
                self.results = []

            if len(self.results) == 0:
                self.widget.addError('No results found for "%s"' % searchString)

            for res in self.results:
                self.widget.addResult(res.description)

        common.search(url, callback)
    def runSearch(self, searchString, selectedGazetteer):
        gazetteer_config = self.gazetteers[str(selectedGazetteer)]
        gazetteer = self.getGazetteerModule(gazetteer_config)
        url = common.prepareURL(gazetteer.url, gazetteer.params, searchString)
        data = common.search(url)

        try:
            self.results = list(gazetteer.parseRequestResults(data))
        except ValueError:
            self.results = []

        if len(self.results) == 0:
            self.widget.addError('No results found for "%s"' % searchString)

        for res in self.results:
            self.widget.addResult(res.description)
Пример #4
0
    def runSearch(self, searchString, selectedGazetteer):
        gazetteer_config = self.gazetteers[str(selectedGazetteer)]
        gazetteer = self.getGazetteerModule(gazetteer_config)
        url = common.prepareURL(gazetteer.url, gazetteer.params, searchString)
        data = common.search(url)

        try:
            self.results = list(gazetteer.parseRequestResults(data))
        except ValueError:
            self.results = []

        if len(self.results) == 0:
            self.widget.addError('No results found for "%s"' % searchString)

        for res in self.results:
            self.widget.addResult(res.description)