Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. [GELÖST] GPS-Koordinaten - Abstand berechnen

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    [GELÖST] GPS-Koordinaten - Abstand berechnen

    This topic has been deleted. Only users with topic management privileges can see it.
    • David G.
      David G. last edited by David G.

      Hallo,

      ich versuche gerade den Abstand 2er Koordinaten zu berechnen.
      Ich halte mich die die Formel dieser Seite:
      https://www.kompf.de/gps/distcalc.html

      distance = sqrt(dx * dx + dy * dy)
      
      mit distance: Entfernung in km 
      dx = 71.5 * (lon1 - lon2)
      dy = 111.3 * (lat1 - lat2)
      lat1, lat2, lon1, lon2: Breite, Länge in Grad
      

      Eingesetzt habe ich die Beispielkoordinaten der Webseite.
      Da müsste ich auf ca 1500km kommen. Ich erhalte allerdings nur ca 500km als Ergebniss.

      Sieht jemand meinen Fehler?

      Screenshot_20220324-204412_Chrome.jpg

      <xml xmlns="https://developers.google.com/blockly/xml">
       <variables>
         <variable id="s23wr,?T!YMWI{$/K95U">lat1</variable>
         <variable id="M4/Wn|i$]dHtZ2ZxPRp:">lon1</variable>
         <variable id="Os7Y)TI0lAlL0Bh6H}Dx">lat2</variable>
         <variable id="ASU?1[(gkMns.zuH`zES">lon2</variable>
         <variable id="x4ZxMrWn=cQnz|zuY!*-">dx</variable>
         <variable id="Z/`MKv!-.a?SVSl|[e[B">dy</variable>
         <variable id="^T$8exquU4#`GcjdTrvT">entfernung</variable>
       </variables>
       <block type="variables_set" id="D~3AwLQs%ha2M|R:`e=u" x="68" y="46">
         <field name="VAR" id="s23wr,?T!YMWI{$/K95U">lat1</field>
         <value name="VALUE">
           <block type="math_number" id="byOiNCIdVOb$egGZvY|W">
             <field name="NUM">49.9917</field>
           </block>
         </value>
         <next>
           <block type="variables_set" id="ArwJmmM`rL0UR%Q5w8~v">
             <field name="VAR" id="M4/Wn|i$]dHtZ2ZxPRp:">lon1</field>
             <value name="VALUE">
               <block type="math_number" id=";#vgpN5e$~-GZtZTm2#=">
                 <field name="NUM">8.41321</field>
               </block>
             </value>
             <next>
               <block type="variables_set" id="FFn0l4;bZ53!-~dY:WL|">
                 <field name="VAR" id="Os7Y)TI0lAlL0Bh6H}Dx">lat2</field>
                 <value name="VALUE">
                   <block type="math_number" id="wY;7;%gP(tI2ISWEAkXW">
                     <field name="NUM">52.5164</field>
                   </block>
                 </value>
                 <next>
                   <block type="variables_set" id="sTim%+gS)5p_,g`jHT)e">
                     <field name="VAR" id="ASU?1[(gkMns.zuH`zES">lon2</field>
                     <value name="VALUE">
                       <block type="math_number" id="AXaHX$Qf3ZZSJfhcxN%R">
                         <field name="NUM">13.3777</field>
                       </block>
                     </value>
                     <next>
                       <block type="variables_set" id="!OErS46^gpTE#M/FxY5T">
                         <field name="VAR" id="x4ZxMrWn=cQnz|zuY!*-">dx</field>
                         <value name="VALUE">
                           <block type="math_arithmetic" id="uI2dHjpdMt*F|7^d6U9k">
                             <field name="OP">MULTIPLY</field>
                             <value name="A">
                               <shadow type="math_number" id="V6b)I3!oPD_L+qV?bpuV">
                                 <field name="NUM">71.5</field>
                               </shadow>
                             </value>
                             <value name="B">
                               <shadow type="math_number" id="2AfBt!!03v5=kc56;B^|">
                                 <field name="NUM">1</field>
                               </shadow>
                               <block type="math_arithmetic" id="{|4nb{Q@W3B,Op0ajnHF" inline="false">
                                 <field name="OP">MINUS</field>
                                 <value name="A">
                                   <shadow type="math_number" id="8gyt,nAC-egbblOy58zx">
                                     <field name="NUM">1</field>
                                   </shadow>
                                   <block type="variables_get" id="J-y,3g#MSa:`VszAeufH">
                                     <field name="VAR" id="M4/Wn|i$]dHtZ2ZxPRp:">lon1</field>
                                   </block>
                                 </value>
                                 <value name="B">
                                   <shadow type="math_number" id="BNnF_.%w!LOKH2|eyuoY">
                                     <field name="NUM">1</field>
                                   </shadow>
                                   <block type="variables_get" id="#*EgdcT|QBfVzD(X.lin">
                                     <field name="VAR" id="ASU?1[(gkMns.zuH`zES">lon2</field>
                                   </block>
                                 </value>
                               </block>
                             </value>
                           </block>
                         </value>
                         <next>
                           <block type="variables_set" id="G}_ppSQ][Pd+@^e6ve_8">
                             <field name="VAR" id="Z/`MKv!-.a?SVSl|[e[B">dy</field>
                             <value name="VALUE">
                               <block type="math_arithmetic" id="zm24.9~J!lM@av4$w+jg">
                                 <field name="OP">MULTIPLY</field>
                                 <value name="A">
                                   <shadow type="math_number" id=")aB_Izw8=}pp5iiK61wW">
                                     <field name="NUM">111.3</field>
                                   </shadow>
                                 </value>
                                 <value name="B">
                                   <shadow type="math_number">
                                     <field name="NUM">1</field>
                                   </shadow>
                                   <block type="math_arithmetic" id="BLDA(_r-gs/{z?N~cNq5" inline="false">
                                     <field name="OP">MINUS</field>
                                     <value name="A">
                                       <shadow type="math_number" id="o+t~;lvuaCU588Pl8{k1">
                                         <field name="NUM">1</field>
                                       </shadow>
                                       <block type="variables_get" id="0DNhK7T?@wC3sw=//4~a">
                                         <field name="VAR" id="s23wr,?T!YMWI{$/K95U">lat1</field>
                                       </block>
                                     </value>
                                     <value name="B">
                                       <shadow type="math_number" id="Kb4~z|3*Er%BBd[*|$,/">
                                         <field name="NUM">1</field>
                                       </shadow>
                                       <block type="variables_get" id="_UiN%Fb/XBYAX3BkhmvZ">
                                         <field name="VAR" id="Os7Y)TI0lAlL0Bh6H}Dx">lat2</field>
                                       </block>
                                     </value>
                                   </block>
                                 </value>
                               </block>
                             </value>
                             <next>
                               <block type="variables_set" id="Kzmkj2d2=al/G%=`YW@(">
                                 <field name="VAR" id="^T$8exquU4#`GcjdTrvT">entfernung</field>
                                 <value name="VALUE">
                                   <block type="math_single" id="^~h%6|)U^qC@PC}EV9/9">
                                     <field name="OP">ROOT</field>
                                     <value name="NUM">
                                       <shadow type="math_number" id="5Rc:KG~NV,s*W/[,Gm5S">
                                         <field name="NUM">9</field>
                                       </shadow>
                                       <block type="math_arithmetic" id="DkT[*fg{xs@ZhA0FskVz">
                                         <field name="OP">ADD</field>
                                         <value name="A">
                                           <shadow type="math_number" id="b}}_ycZmgS1C48ioDTA2">
                                             <field name="NUM">1</field>
                                           </shadow>
                                           <block type="math_arithmetic" id="lxop7?6]}*CzEqs{I6mf">
                                             <field name="OP">MULTIPLY</field>
                                             <value name="A">
                                               <shadow type="math_number" id="t)GyA`3YW+4Pf$Z|6v%/">
                                                 <field name="NUM">1</field>
                                               </shadow>
                                               <block type="variables_get" id="l2Xi@*nl-UkFTq%yteLf">
                                                 <field name="VAR" id="x4ZxMrWn=cQnz|zuY!*-">dx</field>
                                               </block>
                                             </value>
                                             <value name="B">
                                               <shadow type="math_number" id="=E}rcTC!gEM-mp8^qmNU">
                                                 <field name="NUM">1</field>
                                               </shadow>
                                               <block type="variables_get" id="#7qp$h0?pRfp:a2fkltn">
                                                 <field name="VAR" id="x4ZxMrWn=cQnz|zuY!*-">dx</field>
                                               </block>
                                             </value>
                                           </block>
                                         </value>
                                         <value name="B">
                                           <shadow type="math_number" id="MH[OMS3)#Zg/Df`nFvE;">
                                             <field name="NUM">1</field>
                                           </shadow>
                                           <block type="math_arithmetic" id="-h!.EXX5)#O`JhmQ#,_R">
                                             <field name="OP">MULTIPLY</field>
                                             <value name="A">
                                               <shadow type="math_number" id="-ZdShf;/?qDqVrP^!n{|">
                                                 <field name="NUM">1</field>
                                               </shadow>
                                               <block type="variables_get" id="$rO6rq?nA-z5/vmx%?De">
                                                 <field name="VAR" id="Z/`MKv!-.a?SVSl|[e[B">dy</field>
                                               </block>
                                             </value>
                                             <value name="B">
                                               <shadow type="math_number">
                                                 <field name="NUM">1</field>
                                               </shadow>
                                               <block type="variables_get" id=";`wsJ`blteaAIupcDMhf">
                                                 <field name="VAR" id="Z/`MKv!-.a?SVSl|[e[B">dy</field>
                                               </block>
                                             </value>
                                           </block>
                                         </value>
                                       </block>
                                     </value>
                                   </block>
                                 </value>
                                 <next>
                                   <block type="telegram" id="rO:jfC-k@vx-buUyJs[o">
                                     <field name="INSTANCE">.0</field>
                                     <field name="LOG"></field>
                                     <field name="SILENT">FALSE</field>
                                     <field name="PARSEMODE">default</field>
                                     <field name="DISABLE_WEB_PAGE_PREVIEW">FALSE</field>
                                     <value name="MESSAGE">
                                       <shadow type="text" id="Q@IcmXRFE.C.0`7a~C!(">
                                         <field name="TEXT">text</field>
                                       </shadow>
                                       <block type="variables_get" id="Ik?`YHxr@PglmP=eUd{b">
                                         <field name="VAR" id="^T$8exquU4#`GcjdTrvT">entfernung</field>
                                       </block>
                                     </value>
                                   </block>
                                 </next>
                               </block>
                             </next>
                           </block>
                         </next>
                       </block>
                     </next>
                   </block>
                 </next>
               </block>
             </next>
           </block>
         </next>
       </block>
      </xml>
      

      Edit:
      Fehler gefunden. Hatte einen Fehler in den Koordinaten.

      Dr. Bakterius 1 Reply Last reply Reply Quote 0
      • Dr. Bakterius
        Dr. Bakterius Most Active @David G. last edited by

        @david-g Ich mache es so wobei auch die Erdkrümmung berücksichtigt wird (Ergebnis in Meter):
        blockly.png

        David G. 1 Reply Last reply Reply Quote 0
        • David G.
          David G. @Dr. Bakterius last edited by David G.

          @dr-bakterius

          Dann werde ich mir das mal nachbauen ^^.
          (Auch wenn bei den bei mir berechneten Entfernungen kaum ein Unterschied raus kommen sollte Für die verschiedenen Methoden stehen Beispiele mit Entfernungen auf der genannten Seite).

          Es geht aber scheinbar auch noch genauer mit

          6378.388 * acos(sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1))
          

          Das war die genauste Variante von der genannten Website. War mir allerdings was zu hoch für Blockly und meine Mathefähigkeiten.
          Und dieser Hinweis war mir dann viel zu hoch 😅

          Bei der Berechnung mittels eines Computers ist zu bedenken, dass die meisten Programmiersprachen zwar die Kosinusfunktion zur Verfügung stellen, diese in der Regel den Winkel jedoch im Bogenmaß (Radiant) erwartet. Die Umrechnung von Grad in Radiant erfolgt nach der Beziehung...... 
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Support us

          ioBroker
          Community Adapters
          Donate

          412
          Online

          31.9k
          Users

          80.3k
          Topics

          1.3m
          Posts

          2
          3
          293
          Loading More Posts
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes
          Reply
          • Reply as topic
          Log in to reply
          Community
          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
          The ioBroker Community 2014-2023
          logo