IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PyQt Python Discussion :

récupérer coordonnées d'un point depuis openstreetmap


Sujet :

PyQt Python

  1. #1
    Membre à l'essai
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Avril 2021
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Saône et Loire (Bourgogne)

    Informations professionnelles :
    Activité : Chargé d'affaire

    Informations forums :
    Inscription : Avril 2021
    Messages : 18
    Points : 11
    Points
    11
    Par défaut récupérer coordonnées d'un point depuis openstreetmap
    Bonjour tout le monde

    voila j'ai fait un petit programme pour calculer la distance orthodromique entre 2 points sur terre


    Pièce jointe 633421


    Pour l'instant je saisie les coordonnées du point de départ et d'arrivée manuellement dans mon code mais j'aimerai pouvoir le faire directement en cliquant sur la carte openstreetmap pour cela il faudrait que je puisse récupérer les coordonnées des points cliqués et je n'ai aucune idée de la façon de procéder

    voila mon code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    import io
    import folium
    from PyQt6.QtWebEngineWidgets import QWebEngineView
    from folium.plugins import MousePosition, BeautifyIcon
    from PyQt6 import QtCore, QtWidgets
    import numpy as np
     
     
    class Ui_Form(object):
        def setupUi(self, Form):
            Form.setObjectName("Form")
            Form.resize(900, 750)
            self.verticalLayoutWidget = QtWidgets.QWidget(Form)
            self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 0, 900, 600))
            self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
            self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
            self.verticalLayout.setContentsMargins(0, 0, 0, 0)
            self.verticalLayout.setObjectName("verticalLayout")
     
            self.depart = (16.90921, -25.11334)
            depart_name = "Mindelo"
     
            self.arrivee = (-33.91008, 18.44127)
            arrivee_name = "Cape Town"
     
            point_central = (self.depart[0]+self.arrivee[0])/2, (self.depart[1]+self.arrivee[1])/2
     
            mapObj = folium.Map(location=point_central, zoom_start=3, max_zoom=30)    ####    création carte    ####
            folium.Marker(self.depart, icon=BeautifyIcon(background_color='white', border_color='blue', border_width=2,
                                                    icon="arrow-down",
                                                    icon_shape="marker", number="D", text_color="red"),
                          tooltip=depart_name).add_to(mapObj)
            folium.Marker(self.arrivee,
                          icon=BeautifyIcon(background_color='white', border_color='black', border_width=2,
                                            icon="arrow-down",
                                            icon_shape="marker", number="A"), tooltip=arrivee_name).add_to(mapObj)
     
            MousePosition().add_to(mapObj)    ####    affichage des coordonnées en bas a droite    ####
     
     
            # enregistrement map data en data object
            data = io.BytesIO()
            mapObj.save(data, close_file=False)
     
            self.webView = QWebEngineView()    ####    affichage map dans layout    ####
            self.webView.setHtml(data.getvalue().decode())
            self.verticalLayout.addWidget(self.webView)
     
            self.pushButton = QtWidgets.QPushButton(Form)    ####    bouton calcul distance    ####
            self.pushButton.setGeometry(QtCore.QRect(110, 620, 160, 60))
            self.pushButton.setObjectName("pushButton")
            self.pushButton.setText("calcul distance ortho")
            self.pushButton.clicked.connect(self.calDisOrt)
     
            self.textBrowser = QtWidgets.QTextBrowser(Form)    ####    zone affichage distance    ####
            self.textBrowser.setGeometry(QtCore.QRect(360, 620, 380, 60))
            self.textBrowser.setObjectName("textBrowser")
            self.textBrowser.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
            self.retranslateUi(Form)
            QtCore.QMetaObject.connectSlotsByName(Form)
     
        def retranslateUi(self, Form):
            _translate = QtCore.QCoreApplication.translate
            Form.setWindowTitle(_translate("Form", "distance orthodromique"))
     
     
        def calDisOrt(self):    ####    fonction calcule distance    ####
            latAr = np.deg2rad(self.arrivee[0])
            lonAr = np.deg2rad(self.arrivee[1])
            latDep = np.deg2rad(self.depart[0])
            lonDep = np.deg2rad(self.depart[1])
            h = np.arcsin(np.sin(latDep)*np.sin(latAr)+np.cos(latDep)*np.cos(latAr)*np.cos(lonAr-lonDep))
            ortho = 60 * (90 - (h/np.pi*180))
            self.textBrowser.setText(f'{round(ortho, 2)} milles nautique')
     
     
    if __name__ == "__main__":
        import sys
        app = QtWidgets.QApplication(sys.argv)
        Form = QtWidgets.QWidget()
        ui = Ui_Form()
        ui.setupUi(Form)
        Form.show()
        sys.exit(app.exec())
    merci d'avance pour votre aide
    Images attachées Images attachées  

Discussions similaires

  1. Réponses: 1
    Dernier message: 15/12/2010, 14h54
  2. Réponses: 3
    Dernier message: 31/12/2008, 14h39
  3. Récupérer les coordonnées d'un point 3D
    Par johnnyjohnny dans le forum MATLAB
    Réponses: 3
    Dernier message: 22/05/2007, 15h16
  4. [GRAPHIQUE] Récupérer les coordonnées d'un point
    Par freud dans le forum Composants VCL
    Réponses: 6
    Dernier message: 29/09/2005, 12h31

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo