Exemple #1
0
Fichier : osm.py Projet : KDE/silk
    def _process_main_list(self, data):
        """Process main list from xapi.openstreetmap.org

        @param data: downloaded data with main list
        @type data: str
        """
        try:
            source = QXmlInputSource()
            source.setData(data)
            self._reader.parse(source)
            self._has_list = True
            self._places = self._osm_hand.get_places()
        except Exception:
            self.send_error("Invalid Response.")
            return

        if len(self._places) == 0:
            self.send_error("No place found.")
            return

        for place in self._places:
            try:
                url = "http://nominatim.openstreetmap.org" \
                "/reverse?format=xml&osm_type=N&osm_id=%s" % place.get_osm_id()
                self._net_if.download(url)
                print "%s, %s" % (place.get_name(), place.get_amenity())
            except Exception:
                continue
Exemple #2
0
Fichier : osm.py Projet : KDE/silk
    def receive_data(self, data):
        """Method called from network interface with new data.

        @param data: downloaded data
        @type data: str
        """
        if not self._has_list:
            self._process_main_list(data)
            return
        source = QXmlInputSource()
        source.setData(data)

        try:
            self._reader.parse(source)
        except Exception:
            pass