Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark laylines do not appear for west longitude, north latitude #18

Open
3 tasks done
Rasbats opened this issue Jan 20, 2024 · 9 comments
Open
3 tasks done

Mark laylines do not appear for west longitude, north latitude #18

Rasbats opened this issue Jan 20, 2024 · 9 comments

Comments

@Rasbats
Copy link
Contributor

Rasbats commented Jan 20, 2024

Installation checklist (change to [X] when sure)

I have installed the software for which I am reporting the issues from:

Specifications

  • OpenCPN Version: 5.8.4
  • DashT Version: Latest source code from branch mnt151-frontend2, compiled with the ShipDriver template.
  • Operating System :
    • Windows
  • Operating System Version : Window 10

Expected Behavior

Mark laylines should appear for the area where the vessel is being sailed

Current Behavior

Mark laylines appear for east longitudes, north latitude. They do not appear for west longitude, north latitude.

Logic is not correct in the code for the intersection of lines.

Possible Solution

Use spherical trig to solve the intersection problem.
Code for solving the problem will be posted here. Unwilling to make a PR as review by Thomas_R and/or Canne is needed.

Steps/Code to Reproduce the Problem

See: https://www.cruisersforum.com/forums/f134/dashboard-tactics-dash-t-226601-16.html#post3862050

bad west
ok east

@Rasbats
Copy link
Contributor Author

Rasbats commented Jan 20, 2024

Revised code is here:
tactics_pi.cpp.txt
The important bit starts at line 1415.
The GCIntersectSegment function does the job of finding the intersect. There is probably a lot of extra code that could be removed from the if(goAhead)..else but I am reluctant to do that without peer review.
Results are shown here:

ok west
ok east2

@Rasbats
Copy link
Contributor Author

Rasbats commented Jan 20, 2024

Missed another intersection check later in the file. Updated tactics_pi.cpp.txt here:
tactics_pi.cpp.txt

@Rasbats
Copy link
Contributor Author

Rasbats commented Jan 20, 2024

https://www.codeguru.com/cplusplus/geographic-distance-and-azimuth-calculations/
Provided the code to make the intersection happen.

@rgleason
Copy link
Owner

Mike, Thanks, very much!!! I will try to make this change in both tactics and dashboard_tactics on my repo.
Very nice testing procedure with shipdriver! Glad you found that.

@rgleason
Copy link
Owner

rgleason commented Jan 25, 2024

@Rasbats Mike, I tried comparing your tactics_pi.cpp.txt to the one in my repo and it appears that the entire file is different.
You say that the change starts at line 1415. Since I can't determine easily, what the isolated change is, can you advise where it ends? Or perhaps which function? Or maybe there is a github source that I could do a dif or something?

I am reluctant to just copy over the entire original file.

I found this repo and file https://github.com/Rasbats/tactics_pi/blob/master/src/tactics_pi.cpp
This has been around for quite awhile in your repo and work has been done on it. Why not let me know about it?

@Rasbats
Copy link
Contributor Author

Rasbats commented Jan 25, 2024

Sorry, the line is 1206 in your repo mnt151-frontend2:

                wxRealPoint intersection_pos;
                intersection_pos = GetLineIntersection(c_end, c_end2, m_end, m_end2); 

The function GetLineIntersection is the problem.
Look at lines starting around 1447 in the .txt file above and you will find the code changes needed. GetLineIntersection is replaced by GCIntersectSegment et al.

@rgleason
Copy link
Owner

Mike, sorry I was not clear, I am using rgleason/tactics_pi/tactics_pi.cpp and am now comparing to https://github.com/Rasbats/tactics_pi/blob/master/src/tactics_pi.cpp.

There are a lot of differences, but it is a better comparison. I will try to find GetLineIntersection .

I notice that your version appears to be based upon an incomplete development and Tom and Petri had other commits afterwards, from what I can see. How would I test for this problem in my version? I think I should do that first, so I don't screw things up needlessly.

@rgleason
Copy link
Owner

rgleason commented Jan 25, 2024

Here are the find getlineintersection in my version of tactics_pi.cpp

Search "getlineintersection" (3 hits in 1 file of 1 searched) [Normal]
  C:\Users\fcgle\source\tactics_pi\src\tactics_pi.cpp (3 hits)
	Line  998: wxRealPoint GetLineIntersection(wxRealPoint line1point1, wxRealPoint line1point2, wxRealPoint line2point1, wxRealPoint line2point2)
	Line 1349: 					intersection_pos = GetLineIntersection(c_end, c_end2, m_end, m_end2);
	Line 1457: 				pIntersection_pos = GetLineIntersection(pc_end, pc_end2, pm_end, pm_end2);

Here are the getlineintersection in your version of tactics_pi.cpp (direct from your repo)

Search "getlineintersection" (1 hit in 1 file of 1 searched) [Normal]
  C:\Users\fcgle\Downloads\tactics_pi.cpp (1 hit)
	Line  777: wxRealPoint GetLineIntersection(wxRealPoint line1point1, wxRealPoint line1point2, wxRealPoint line2point1, wxRealPoint line2point2)

However I find not GCIntersectSegment In this file!

@Rasbats
Copy link
Contributor Author

Rasbats commented Jan 25, 2024

Lets take this to the bug in tactics_pi: rgleason/tactics_pi#48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants