- ioBroker Community Home
- Deutsch
- Skripten / Logik
- Blockly
- [GELÖST] GPS-Koordinaten - Abstand berechnen
[GELÖST] GPS-Koordinaten - Abstand berechnen
-
Hallo,
ich versuche gerade den Abstand 2er Koordinaten zu berechnen.
Ich halte mich die die Formel dieser Seite:
https://www.kompf.de/gps/distcalc.htmldistance = 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 GradEingesetzt 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?

<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. -
Hallo,
ich versuche gerade den Abstand 2er Koordinaten zu berechnen.
Ich halte mich die die Formel dieser Seite:
https://www.kompf.de/gps/distcalc.htmldistance = 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 GradEingesetzt 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?

<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.@david-g Ich mache es so wobei auch die Erdkrümmung berücksichtigt wird (Ergebnis in Meter):

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

@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......
Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.
Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.
Mit deinem Input könnte dieser Beitrag noch besser werden 💗
Registrieren Anmelden