Exemplo n.º 1
0
    def prepareRouteParameters(
        self,
        points,
        profile="auto",
        avoid_polygons=None,
        options=None,
        patrol_polygon=None,
    ):
        options = options or {}
        locale_name = localeName()
        params = dict(
            costing=profile,
            show_locations=True,
            locations=points,
            directions_options={"language": locale_name},
        )

        if options:
            params["costing_options"] = {profile: options}
        if avoid_polygons:
            params["avoid_polygons"] = avoid_polygons
        if patrol_polygon:
            params["chinese_postman_polygon"] = patrol_polygon
        LOG.debug(params)

        return params
Exemplo n.º 2
0
 def setWarningMessage(self, start, end):
     content = deepcopy(self.contents.get(localeName(),
                                          self.contents["en"]))
     content["description"] = content["description"].format(start=start,
                                                            end=end)
     html_message = self.html_template.format(**content)
     self.textBrowser.setHtml(html_message)
 def __init__(self, parent=None):
     super(DisclaimerDialog, self).__init__(parent)
     self.setupUi(self)
     indexes = ["en", "de", "fr", "it"]
     try:
         index = indexes.index(localeName())
     except ValueError:
         index = 0
     self.stackedWidget.setCurrentIndex(index)
     self.btnClose.clicked.connect(self.closeClicked)
Exemplo n.º 4
0
    def prepareRouteParameters(self, points, profile="auto", options=None):
        options = options or {}
        locale_name = localeName()
        params = dict(
            costing=profile,
            show_locations=True,
            locations=points,
            directions_options={"language": locale_name})
        if options:
            params["costing_options"] = {profile: options}

        return params
Exemplo n.º 5
0
import os

from qgis.PyQt.QtCore import QTranslator, QCoreApplication
from qgis.PyQt.QtWidgets import QMessageBox

from kadasrouting.utilities import localeName

# Setup internationalisation for the plugin.
#
# See if QGIS wants to override the system locale
# and then see if we can get a valid translation file
# for whatever locale is effectively being used.
# Adapted from: https://github.com/inasafe/inasafe/blob/develop/__init__.py

os.environ["LANG"] = str(localeName())

root = os.path.abspath(os.path.join(os.path.dirname(__file__)))
translation_path = os.path.join(root, "i18n",
                                "kadasrouting_" + str(localeName()) + ".qm")

if os.path.exists(translation_path):
    translator = QTranslator()
    result = translator.load(translation_path)
    if not result:
        message = "Failed to load translation for %s" % localeName()
        raise Exception(message)
    # noinspection PyTypeChecker,PyCallByClass
    QCoreApplication.installTranslator(translator)
elif not os.path.exists(translation_path) and localeName().lower() in [
        "it",