Skip to content

Commit

Permalink
Merge pull request seandepagnier#197 from theeko74/safetyland
Browse files Browse the repository at this point in the history
Safetyland margin
  • Loading branch information
seandepagnier authored May 4, 2018
2 parents dbbadb5 + 3907c0b commit 122373f
Show file tree
Hide file tree
Showing 6 changed files with 366 additions and 25 deletions.
312 changes: 292 additions & 20 deletions WeatherRouting.fbp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/ConfigurationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ void ConfigurationDialog::Update()
GET_CHECKBOX(AvoidCycloneTracks);
GET_SPIN(CycloneMonths);
GET_SPIN(CycloneDays);
GET_SPIN(SafetyMarginLand);

GET_CHECKBOX(DetectLand);
GET_CHECKBOX(DetectBoundary);
Expand Down
43 changes: 42 additions & 1 deletion src/RouteMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,51 @@ bool Position::Propagate(IsoRouteList &routelist, RouteMapConfiguration &configu
/* landfall test */
if(configuration.DetectLand) {
double ndlon1 = dlon1;

// Check first if crossing land.
if (ndlon1 > 360) {
ndlon1 -= 360;
}
if (CrossesLand(dlat1, ndlon1)) {
if (CrossesLand(dlat1, ndlon1))
{
configuration.land_crossing = true;
continue;
}

// CUSTOMIZATION - Safety distance from land
// -----------------------------------------
// Modify the routing according to a safety
// margin defined by the user from the land.
// CONFIG: 2 NM as a security distance by default.
double distSecure = configuration.SafetyMarginLand;
double latBorderUp1, lonBorderUp1, latBorderUp2, lonBorderUp2;
double latBorderDown1, lonBorderDown1, latBorderDown2, lonBorderDown2;

// Test if land is found within a rectangle with
// dimensiosn (dist, distSecure). Tests borders, plus diag,
// and middle of each side...
// <- dist ->
// |-------------------------------|
// | | ^
// | | distSafety
// |-------------------------------| ^
// | |
// | |
// |-------------------------------|

// Fist, find the (lat,long) of each
// points of the rectangle
ll_gc_ll(lat, lon, heading_resolve(BG)-90, distSecure, &latBorderUp1, &lonBorderUp1);
ll_gc_ll(dlat1, dlon1, heading_resolve(BG)-90, distSecure, &latBorderUp2, &lonBorderUp2);
ll_gc_ll(lat, lon, heading_resolve(BG)+90, distSecure, &latBorderDown1, &lonBorderDown1);
ll_gc_ll(dlat1, dlon1, heading_resolve(BG)+90, distSecure, &latBorderDown2, &lonBorderDown2);

// Then, test if there is land
if (PlugIn_GSHHS_CrossesLand(latBorderUp1, lonBorderUp1, latBorderUp2, lonBorderUp2) ||
PlugIn_GSHHS_CrossesLand(latBorderDown1, lonBorderDown1, latBorderDown2, lonBorderDown2) ||
PlugIn_GSHHS_CrossesLand(latBorderUp1, lonBorderUp1, latBorderDown2, lonBorderDown2) ||
PlugIn_GSHHS_CrossesLand(latBorderDown1, lonBorderDown1, latBorderUp2, lonBorderUp2))
{
configuration.land_crossing = true;
continue;
}
Expand Down
1 change: 1 addition & 0 deletions src/RouteMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ struct RouteMapConfiguration {

double MaxDivertedCourse, MaxCourseAngle, MaxSearchAngle, MaxTrueWindKnots, MaxApparentWindKnots;
double MaxSwellMeters, MaxLatitude, TackingTime, WindVSCurrent;
double SafetyMarginLand;

bool AvoidCycloneTracks;
int CycloneMonths, CycloneDays;
Expand Down
29 changes: 26 additions & 3 deletions src/WeatherRoutingUI.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Feb 20 2018)
// C++ code generated with wxFormBuilder (version Mar 29 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
Expand Down Expand Up @@ -1032,7 +1032,7 @@ ConfigurationDialogBase::ConfigurationDialogBase( wxWindow* parent, wxWindowID i
m_staticText24->Wrap( -1 );
fgSizer1151->Add( m_staticText24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );

m_sTackingTime = new wxSpinCtrl( sbSizer29->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxSP_ARROW_KEYS, 0, 1000, 0 );
m_sTackingTime = new wxSpinCtrl( sbSizer29->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxSP_ARROW_KEYS, 0, 1000, 1 );
fgSizer1151->Add( m_sTackingTime, 0, wxALL, 5 );

m_staticText121 = new wxStaticText( sbSizer29->GetStaticBox(), wxID_ANY, _("Seconds"), wxDefaultPosition, wxDefaultSize, 0 );
Expand All @@ -1042,6 +1042,25 @@ ConfigurationDialogBase::ConfigurationDialogBase( wxWindow* parent, wxWindowID i

fgSizer113->Add( fgSizer1151, 1, wxEXPAND, 5 );

wxFlexGridSizer* fgSizer11511;
fgSizer11511 = new wxFlexGridSizer( 1, 0, 0, 0 );
fgSizer11511->SetFlexibleDirection( wxBOTH );
fgSizer11511->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

m_staticText241 = new wxStaticText( sbSizer29->GetStaticBox(), wxID_ANY, _("Safety Margin From Land"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText241->Wrap( -1 );
fgSizer11511->Add( m_staticText241, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );

m_sSafetyMarginLand = new wxSpinCtrl( sbSizer29->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 60,-1 ), wxSP_ARROW_KEYS, 0, 100, 2 );
fgSizer11511->Add( m_sSafetyMarginLand, 0, wxALL, 5 );

m_staticText1211 = new wxStaticText( sbSizer29->GetStaticBox(), wxID_ANY, _("NM"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1211->Wrap( -1 );
fgSizer11511->Add( m_staticText1211, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );


fgSizer113->Add( fgSizer11511, 1, wxEXPAND, 5 );


sbSizer29->Add( fgSizer113, 1, wxEXPAND, 5 );

Expand Down Expand Up @@ -1221,6 +1240,8 @@ ConfigurationDialogBase::ConfigurationDialogBase( wxWindow* parent, wxWindowID i
m_sTackingTime->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( ConfigurationDialogBase::EnableSpin ), NULL, this );
m_sTackingTime->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( ConfigurationDialogBase::EnableSpin ), NULL, this );
m_sTackingTime->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( ConfigurationDialogBase::OnUpdateSpin ), NULL, this );
m_sSafetyMarginLand->Connect( wxEVT_MOTION, wxMouseEventHandler( ConfigurationDialogBase::EnableSpin ), NULL, this );
m_sSafetyMarginLand->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( ConfigurationDialogBase::OnUpdateSpin ), NULL, this );
m_sFromDegree->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( ConfigurationDialogBase::OnUpdateSpin ), NULL, this );
m_sToDegree->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( ConfigurationDialogBase::OnUpdateSpin ), NULL, this );
m_tByDegrees->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( ConfigurationDialogBase::OnUpdate ), NULL, this );
Expand Down Expand Up @@ -1342,6 +1363,8 @@ ConfigurationDialogBase::~ConfigurationDialogBase()
m_sTackingTime->Disconnect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( ConfigurationDialogBase::EnableSpin ), NULL, this );
m_sTackingTime->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( ConfigurationDialogBase::EnableSpin ), NULL, this );
m_sTackingTime->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( ConfigurationDialogBase::OnUpdateSpin ), NULL, this );
m_sSafetyMarginLand->Disconnect( wxEVT_MOTION, wxMouseEventHandler( ConfigurationDialogBase::EnableSpin ), NULL, this );
m_sSafetyMarginLand->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( ConfigurationDialogBase::OnUpdateSpin ), NULL, this );
m_sFromDegree->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( ConfigurationDialogBase::OnUpdateSpin ), NULL, this );
m_sToDegree->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( ConfigurationDialogBase::OnUpdateSpin ), NULL, this );
m_tByDegrees->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( ConfigurationDialogBase::OnUpdate ), NULL, this );
Expand Down Expand Up @@ -2796,7 +2819,7 @@ EditPolarDialogBase::EditPolarDialogBase( wxWindow* parent, wxWindowID id, const

fgSizer93->Add( m_gPolar, 0, wxALL|wxEXPAND, 5 );

m_staticText1351 = new wxStaticText( m_panel19, wxID_ANY, _("Leave any cell blank to automatically interpolate from nearby values.\n View the polar plot in the boat dialog while editing the polar."), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1351 = new wxStaticText( m_panel19, wxID_ANY, _("Leave any cell blank to automatically interpolate from nearby values. Use a value of 0.0 to specify invalid (cannot be used)\n View the polar plot in the boat dialog while editing the polar."), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1351->Wrap( -1 );
fgSizer93->Add( m_staticText1351, 0, wxALL, 5 );

Expand Down
5 changes: 4 additions & 1 deletion src/WeatherRoutingUI.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Feb 20 2018)
// C++ code generated with wxFormBuilder (version Mar 29 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
Expand Down Expand Up @@ -276,6 +276,9 @@ class ConfigurationDialogBase : public wxDialog
wxStaticText* m_staticText24;
wxSpinCtrl* m_sTackingTime;
wxStaticText* m_staticText121;
wxStaticText* m_staticText241;
wxSpinCtrl* m_sSafetyMarginLand;
wxStaticText* m_staticText1211;
wxStaticText* m_staticText113;
wxStaticText* m_staticText115;
wxStaticText* m_staticText117;
Expand Down

0 comments on commit 122373f

Please sign in to comment.