Plotting a location given a starting LatLon and distance and bearing









up vote
0
down vote

favorite












So, I found a project on Reddit that uses a raspberry pi and hat + mqtt server to show locations on an led matrix. Link to project here. Link to source code can be found on the same page. Long story short, the code is a little outdated, so I've spent the better part of a week updating/revising the code to work properly and I am happy to report that it is (mostly) working.



Essentially, I am trying to make a single led light up from based off a origin point (lat, lon) and using distance and bearing. I used PyGeodesy to calculate my distance and bearing to the input lat and lon. So I have everything I need. However, I can't seem to get it to work properly. I believe it is because my distance is too large; when my input is closer to my origin point, it works flawlessly. To be frank, this is my first time working with python, json data, and pygeodesy. I don't need a complete answer, so if someone could point me in the right direction, that would be awesome!



It seems my hang up is all in the find_points function.



def find_points(dist, bear):
dist_adj = 63 / 10.71
bear = (bear - 90 - 29 + 360) % 360
print (bear)
bear_rad = radians(bear)
print (bear_rad)
adj_mat = [[cos(bear_rad) * dist_adj, -sin(bear_rad) * dist_adj],[sin(bear_rad) * dist_adj, cos(bear_rad) * dist_adj]]
start_mat = [dist, 0]
xy = np.matmul(adj_mat , start_mat)
return xy[0], xy[1]


the respective values for dist and bear going into this function are 12050.054(meters) and 341.386 (decimal degrees). I guess my real question here is that I don't understand what the dist_adj is for/based off of (very little info was provided at source).



EDIT: I was able to reach out to the original coder for clarification on this variable and he was kind enough to help me.



The dist_adj variable was the led matrix length (64) divided by the map length in km. I still ended up being off by 5km in both axes but was able to troubleshoot it and come up with a solution.



All these these formulas (not to mention python, mqtt servers, and json data) were all new to me. I feel a little silly not realizing what that variable was for, but I think too much new stuff at once temporarily fried my brain.



Anyways, count this one solved. :)










share|improve this question



























    up vote
    0
    down vote

    favorite












    So, I found a project on Reddit that uses a raspberry pi and hat + mqtt server to show locations on an led matrix. Link to project here. Link to source code can be found on the same page. Long story short, the code is a little outdated, so I've spent the better part of a week updating/revising the code to work properly and I am happy to report that it is (mostly) working.



    Essentially, I am trying to make a single led light up from based off a origin point (lat, lon) and using distance and bearing. I used PyGeodesy to calculate my distance and bearing to the input lat and lon. So I have everything I need. However, I can't seem to get it to work properly. I believe it is because my distance is too large; when my input is closer to my origin point, it works flawlessly. To be frank, this is my first time working with python, json data, and pygeodesy. I don't need a complete answer, so if someone could point me in the right direction, that would be awesome!



    It seems my hang up is all in the find_points function.



    def find_points(dist, bear):
    dist_adj = 63 / 10.71
    bear = (bear - 90 - 29 + 360) % 360
    print (bear)
    bear_rad = radians(bear)
    print (bear_rad)
    adj_mat = [[cos(bear_rad) * dist_adj, -sin(bear_rad) * dist_adj],[sin(bear_rad) * dist_adj, cos(bear_rad) * dist_adj]]
    start_mat = [dist, 0]
    xy = np.matmul(adj_mat , start_mat)
    return xy[0], xy[1]


    the respective values for dist and bear going into this function are 12050.054(meters) and 341.386 (decimal degrees). I guess my real question here is that I don't understand what the dist_adj is for/based off of (very little info was provided at source).



    EDIT: I was able to reach out to the original coder for clarification on this variable and he was kind enough to help me.



    The dist_adj variable was the led matrix length (64) divided by the map length in km. I still ended up being off by 5km in both axes but was able to troubleshoot it and come up with a solution.



    All these these formulas (not to mention python, mqtt servers, and json data) were all new to me. I feel a little silly not realizing what that variable was for, but I think too much new stuff at once temporarily fried my brain.



    Anyways, count this one solved. :)










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      So, I found a project on Reddit that uses a raspberry pi and hat + mqtt server to show locations on an led matrix. Link to project here. Link to source code can be found on the same page. Long story short, the code is a little outdated, so I've spent the better part of a week updating/revising the code to work properly and I am happy to report that it is (mostly) working.



      Essentially, I am trying to make a single led light up from based off a origin point (lat, lon) and using distance and bearing. I used PyGeodesy to calculate my distance and bearing to the input lat and lon. So I have everything I need. However, I can't seem to get it to work properly. I believe it is because my distance is too large; when my input is closer to my origin point, it works flawlessly. To be frank, this is my first time working with python, json data, and pygeodesy. I don't need a complete answer, so if someone could point me in the right direction, that would be awesome!



      It seems my hang up is all in the find_points function.



      def find_points(dist, bear):
      dist_adj = 63 / 10.71
      bear = (bear - 90 - 29 + 360) % 360
      print (bear)
      bear_rad = radians(bear)
      print (bear_rad)
      adj_mat = [[cos(bear_rad) * dist_adj, -sin(bear_rad) * dist_adj],[sin(bear_rad) * dist_adj, cos(bear_rad) * dist_adj]]
      start_mat = [dist, 0]
      xy = np.matmul(adj_mat , start_mat)
      return xy[0], xy[1]


      the respective values for dist and bear going into this function are 12050.054(meters) and 341.386 (decimal degrees). I guess my real question here is that I don't understand what the dist_adj is for/based off of (very little info was provided at source).



      EDIT: I was able to reach out to the original coder for clarification on this variable and he was kind enough to help me.



      The dist_adj variable was the led matrix length (64) divided by the map length in km. I still ended up being off by 5km in both axes but was able to troubleshoot it and come up with a solution.



      All these these formulas (not to mention python, mqtt servers, and json data) were all new to me. I feel a little silly not realizing what that variable was for, but I think too much new stuff at once temporarily fried my brain.



      Anyways, count this one solved. :)










      share|improve this question















      So, I found a project on Reddit that uses a raspberry pi and hat + mqtt server to show locations on an led matrix. Link to project here. Link to source code can be found on the same page. Long story short, the code is a little outdated, so I've spent the better part of a week updating/revising the code to work properly and I am happy to report that it is (mostly) working.



      Essentially, I am trying to make a single led light up from based off a origin point (lat, lon) and using distance and bearing. I used PyGeodesy to calculate my distance and bearing to the input lat and lon. So I have everything I need. However, I can't seem to get it to work properly. I believe it is because my distance is too large; when my input is closer to my origin point, it works flawlessly. To be frank, this is my first time working with python, json data, and pygeodesy. I don't need a complete answer, so if someone could point me in the right direction, that would be awesome!



      It seems my hang up is all in the find_points function.



      def find_points(dist, bear):
      dist_adj = 63 / 10.71
      bear = (bear - 90 - 29 + 360) % 360
      print (bear)
      bear_rad = radians(bear)
      print (bear_rad)
      adj_mat = [[cos(bear_rad) * dist_adj, -sin(bear_rad) * dist_adj],[sin(bear_rad) * dist_adj, cos(bear_rad) * dist_adj]]
      start_mat = [dist, 0]
      xy = np.matmul(adj_mat , start_mat)
      return xy[0], xy[1]


      the respective values for dist and bear going into this function are 12050.054(meters) and 341.386 (decimal degrees). I guess my real question here is that I don't understand what the dist_adj is for/based off of (very little info was provided at source).



      EDIT: I was able to reach out to the original coder for clarification on this variable and he was kind enough to help me.



      The dist_adj variable was the led matrix length (64) divided by the map length in km. I still ended up being off by 5km in both axes but was able to troubleshoot it and come up with a solution.



      All these these formulas (not to mention python, mqtt servers, and json data) were all new to me. I feel a little silly not realizing what that variable was for, but I think too much new stuff at once temporarily fried my brain.



      Anyways, count this one solved. :)







      python






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 at 8:48

























      asked Nov 9 at 19:03









      dreamsofhabit

      14




      14



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231851%2fplotting-a-location-given-a-starting-latlon-and-distance-and-bearing%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231851%2fplotting-a-location-given-a-starting-latlon-and-distance-and-bearing%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo