73 for (
unsigned int n = 0; n <
m_VEdgeCell.size(); n++)
105 stack<CGeom2DIPoint> PtiStack;
113 while (! PtiStack.empty())
116 if (nRoundLoop++ > nRoundLoopMax)
122 int nX = Pti.
nGetX();
123 int const nY = Pti.
nGetY();
125 while ((nX >= 0) && (!
m_pRasterGrid->m_Cell[nX][nY].bBasementElevIsMissingValue()) && (
m_pRasterGrid->m_Cell[nX][nY].bIsInundated()))
130 bool bSpanAbove =
false;
131 bool bSpanBelow =
false;
150 m_pRasterGrid->m_Cell[nX][nY].SetWaveValuesToDeepWaterWaveValues();
166 m_pRasterGrid->m_Cell[nX][nY].SetWaveValuesToDeepWaterWaveValues();
185 if ((! bSpanAbove) && (nY > 0) && (!
m_pRasterGrid->m_Cell[nX][nY - 1].bBasementElevIsMissingValue()) && (
m_pRasterGrid->m_Cell[nX][nY - 1].bIsInundated()))
191 else if (bSpanAbove && (nY > 0) && (!
m_pRasterGrid->m_Cell[nX][nY - 1].bBasementElevIsMissingValue()) && (!
m_pRasterGrid->m_Cell[nX][nY - 1].bIsInundated()))
291 vector<bool> VbPossibleStartCellLHEdge;
292 vector<bool> VbTraced;
293 vector<int> VnSearchDirection;
294 vector<CGeom2DIPoint> V2DIPossibleStartCell;
297 for (
unsigned int n = 0; n <
m_VEdgeCell.size() - 1; n++)
317 bool const bThisCellIsSea =
m_pRasterGrid->m_Cell[nXThis][nYThis].bIsInContiguousSea();
318 bool const bNextCellIsSea =
m_pRasterGrid->m_Cell[nXNext][nYNext].bIsInContiguousSea();
321 if ((! bThisCellIsSea) && bNextCellIsSea)
324 if (!
m_pRasterGrid->m_Cell[nXThis][nYThis].bIsPossibleCoastStartCell())
327 m_pRasterGrid->m_Cell[nXThis][nYThis].SetPossibleCoastStartCell();
333 V2DIPossibleStartCell.push_back(
CGeom2DIPoint(nXThis, nYThis));
334 VbPossibleStartCellLHEdge.push_back(
true);
336 VbTraced.push_back(
false);
339 else if (bThisCellIsSea && (! bNextCellIsSea))
342 if (!
m_pRasterGrid->m_Cell[nXNext][nYNext].bIsPossibleCoastStartCell())
345 m_pRasterGrid->m_Cell[nXNext][nYNext].SetPossibleCoastStartCell();
351 V2DIPossibleStartCell.push_back(
CGeom2DIPoint(nXNext, nYNext));
352 VbPossibleStartCellLHEdge.push_back(
false);
354 VbTraced.push_back(
false);
360 if (V2DIPossibleStartCell.size() == 0)
362 LogStream <<
m_ulIter <<
": no coastline start/finish points found after grid edges searched.";
375 LogStream <<
m_ulIter <<
": " << V2DIPossibleStartCell.size() <<
" possible coastline start/finish points found" << endl;
378 for (
unsigned int n = 0; n < V2DIPossibleStartCell.size(); n++)
384 if (VbPossibleStartCellLHEdge[n])
406 cerr <<
m_ulIter <<
": no valid coasts found, see " <<
m_strLogFile <<
" for more information" << endl;
414int CSimulation::nTraceCoastLine(
unsigned int const nTraceFromStartCellIndex,
int const nStartSearchDirection,
int const nHandedness, vector<bool>* pVbTraced, vector<CGeom2DIPoint>
const* pV2DIPossibleStartCell)
416 bool bHitStartCell =
false;
417 bool bAtCoast =
false;
418 bool bHasLeftStartEdge =
false;
419 bool bTooLong =
false;
420 bool bOffEdge =
false;
421 bool bRepeating =
false;
423 int const nStartX = pV2DIPossibleStartCell->at(nTraceFromStartCellIndex).nGetX();
424 int const nStartY = pV2DIPossibleStartCell->at(nTraceFromStartCellIndex).nGetY();
427 int nSearchDirection = nStartSearchDirection;
438 ILTempGridCRS.
Append(&PtiStart);
466 if ((nRoundLoop > 10) && (ILTempGridCRS.
nGetSize() < 2))
475 if (! bHasLeftStartEdge)
478 if (((nStartSearchDirection ==
SOUTH) && (nY > nStartY)) || ((nStartSearchDirection ==
NORTH) && (nY < nStartY)) ||
479 ((nStartSearchDirection ==
EAST) && (nX > nStartX)) || ((nStartSearchDirection ==
WEST) && (nX < nStartX)))
480 bHasLeftStartEdge =
true;
490 for (
unsigned int nn = 0; nn < pVbTraced->size(); nn++)
492 if ((nn != nTraceFromStartCellIndex) && (! pVbTraced->at(nn)))
496 if (bAtCoast && (nX == pV2DIPossibleStartCell->at(nn).nGetX()) && (nY == pV2DIPossibleStartCell->at(nn).nGetY()))
499 LogStream <<
m_ulIter <<
": Possible coastline found, traced from [" << nStartX <<
"][" << nStartY <<
"] and hit another possible coast start cell at [" << nX <<
"][" << nY <<
"]" << endl;
501 pVbTraced->at(nn) =
true;
502 bHitStartCell =
true;
517 int nSeawardNewDirection = 0;
518 int nXStraightOn = 0;
519 int nYStraightOn = 0;
520 int nXAntiSeaward = 0;
521 int nYAntiSeaward = 0;
522 int nAntiSeawardNewDirection = 0;
525 int nGoBackNewDirection = 0;
535 switch (nSearchDirection)
541 nSeawardNewDirection =
EAST;
545 nYStraightOn = nY - 1;
548 nXAntiSeaward = nX - 1;
550 nAntiSeawardNewDirection =
WEST;
555 nGoBackNewDirection =
SOUTH;
563 nSeawardNewDirection =
SOUTH;
566 nXStraightOn = nX + 1;
571 nYAntiSeaward = nY - 1;
572 nAntiSeawardNewDirection =
NORTH;
577 nGoBackNewDirection =
WEST;
585 nSeawardNewDirection =
WEST;
589 nYStraightOn = nY + 1;
592 nXAntiSeaward = nX + 1;
594 nAntiSeawardNewDirection =
EAST;
599 nGoBackNewDirection =
NORTH;
607 nSeawardNewDirection =
NORTH;
610 nXStraightOn = nX - 1;
615 nYAntiSeaward = nY + 1;
616 nAntiSeawardNewDirection =
SOUTH;
621 nGoBackNewDirection =
EAST;
631 switch (nSearchDirection)
637 nSeawardNewDirection =
WEST;
641 nYStraightOn = nY - 1;
644 nXAntiSeaward = nX + 1;
646 nAntiSeawardNewDirection =
EAST;
651 nGoBackNewDirection =
SOUTH;
659 nSeawardNewDirection =
NORTH;
662 nXStraightOn = nX + 1;
667 nYAntiSeaward = nY + 1;
668 nAntiSeawardNewDirection =
SOUTH;
673 nGoBackNewDirection =
WEST;
681 nSeawardNewDirection =
EAST;
685 nYStraightOn = nY + 1;
688 nXAntiSeaward = nX - 1;
690 nAntiSeawardNewDirection =
WEST;
695 nGoBackNewDirection =
NORTH;
703 nSeawardNewDirection =
SOUTH;
706 nXStraightOn = nX - 1;
711 nYAntiSeaward = nY - 1;
712 nAntiSeawardNewDirection =
NORTH;
717 nGoBackNewDirection =
EAST;
729 if (
m_pRasterGrid->m_Cell[nXSeaward][nYSeaward].bIsInContiguousSea())
741 ILTempGridCRS.
Append(&Pti);
747 ILTempGridCRS.
Append(&Pti);
759 nSearchDirection = nSeawardNewDirection;
768 if (
m_pRasterGrid->m_Cell[nXStraightOn][nYStraightOn].bIsInContiguousSea())
780 ILTempGridCRS.
Append(&Pti);
786 ILTempGridCRS.
Append(&Pti);
806 if (
m_pRasterGrid->m_Cell[nXAntiSeaward][nYAntiSeaward].bIsInContiguousSea())
818 ILTempGridCRS.
Append(&Pti);
824 ILTempGridCRS.
Append(&Pti);
836 nSearchDirection = nAntiSeawardNewDirection;
848 nSearchDirection = nGoBackNewDirection;
860 int nCoastSize = ILTempGridCRS.
nGetSize();
878 LogStream <<
", it ended at [" << ILTempGridCRS[nCoastSize - 1].nGetX() <<
"][" << ILTempGridCRS[nCoastSize - 1].nGetY() <<
"] = {" <<
dGridCentroidXToExtCRSX(ILTempGridCRS[nCoastSize - 1].nGetX()) <<
", " <<
dGridCentroidYToExtCRSY(ILTempGridCRS[nCoastSize - 1].nGetY()) <<
"}";
893 LogStream <<
", it ended at [" << ILTempGridCRS[nCoastSize - 1].nGetX() <<
"][" << ILTempGridCRS[nCoastSize - 1].nGetY() <<
"] = {" <<
dGridCentroidXToExtCRSX(ILTempGridCRS[nCoastSize - 1].nGetX()) <<
", " <<
dGridCentroidYToExtCRSY(ILTempGridCRS[nCoastSize - 1].nGetY()) <<
"}";
920 int const nEndX = nX;
921 int const nEndY = nY;
922 int const nCoastEndX = ILTempGridCRS[nCoastSize - 1].nGetX();
923 int const nCoastEndY = ILTempGridCRS[nCoastSize - 1].nGetY();
925 if ((nCoastEndX != nEndX) || (nCoastEndY != nEndY))
928 if (!
m_pRasterGrid->m_Cell[nCoastEndX][nCoastEndY].bIsBoundingBoxEdge())
931 ILTempGridCRS.
Append(nEndX, nEndY);
937 int const nStartEdge =
m_pRasterGrid->m_Cell[nStartX][nStartY].nGetBoundingBoxEdge();
938 int const nEndEdge =
m_pRasterGrid->m_Cell[nEndX][nEndY].nGetBoundingBoxEdge();
943 for (
int j = 0; j < nCoastSize; j++)
967 int const nCoast =
static_cast<int>(
m_VCoast.size()) - 1;
970 for (
int n = 0; n < nCoastSize; n++)
971 m_pRasterGrid->m_Cell[ILTempGridCRS[n].nGetX()][ILTempGridCRS[n].nGetY()].SetAsCoastline(nCoast);
974 m_VCoast[nCoast].SetCoastlineExtCRS(<empExtCRS);
977 m_VCoast[nCoast].SetCoastlineGridCRS(&ILTempGridCRS);
995 m_VCoast[nCoast].SetSeaHandedness(nHandedness);
996 m_VCoast[nCoast].SetStartEdge(nStartEdge);
997 m_VCoast[nCoast].SetEndEdge(nEndEdge);
1003 LogStream <<
m_ulIter <<
": Smoothed coastline " << nCoast <<
" runs from {" << LTempExtCRS[0].dGetX() <<
", " << LTempExtCRS[0].dGetY() <<
"} to {" << LTempExtCRS[nCoastSize - 1].dGetX() <<
", " << LTempExtCRS[nCoastSize - 1].dGetY() <<
"} i.e. from the ";
1005 if (nStartEdge ==
NORTH)
1008 else if (nStartEdge ==
SOUTH)
1011 else if (nStartEdge ==
WEST)
1014 else if (nStartEdge ==
EAST)
1019 if (nEndEdge ==
NORTH)
1022 else if (nEndEdge ==
SOUTH)
1025 else if (nEndEdge ==
WEST)
1028 else if (nEndEdge ==
EAST)
1046 m_VCoast[nCoast].CreateProfilesAtCoastPoints();
1110 for (
unsigned int n = 0; n <
m_VEdgeCell.size(); n++)
Contains CGeom2DIPoint definitions.
int nGetSize(void) const
Returns the number of integer point in the vector which represents this 2D shape.
void Append(CGeom2DIPoint const *)
Appends a new integer point to the vector which represents this 2D shape.
void Append(CGeom2DPoint const *)
Appends a point to this 2D shape.
Geometry class used to represent 2D point objects with integer coordinates.
int nGetY(void) const
Returns the CGeom2DIPoint object's integer Y coordinate.
int nGetX(void) const
Returns the CGeom2DIPoint object's integer X coordinate.
Geometry class used to represent 2D vector integer line objects.
Geometry class used to represent 2D vector line objects.
Real-world class used to represent coastline objects.
int m_nLogFileDetail
The level of detail in the log file output. Can be LOG_FILE_LOW_DETAIL, LOG_FILE_MIDDLE_DETAIL,...
int m_nYMinBoundingBox
The minimum y value of the bounding box.
void FindAllSeaCells(void)
Finds and flags all sea areas which have at least one cell at a grid edge (i.e. does not flag 'inland...
CGeomLine LSmoothCoastRunningMean(CGeomLine *) const
Does running-mean smoothing of a CGeomLine coastline vector (is in external CRS coordinates)
int nLocateSeaAndCoasts(int &)
First find all connected sea areas, then locate the vector coastline(s), then put these onto the rast...
double m_dThisIterSWL
The still water level for this timestep (this includes tidal changes and any long-term SWL change)
CGeomRasterGrid * m_pRasterGrid
Pointer to the raster grid object.
int m_nXGridSize
The size of the grid in the x direction.
static int nGetOppositeDirection(int const)
Returns the opposite direction.
vector< CRWCoast > m_VFloodWaveSetupSurgeRunup
TODO 007 Info needed.
vector< CRWCoast > m_VCoast
The coastline objects.
int nLocateFloodAndCoasts(void)
First find all connected sea areas, then locate the vector coastline(s), then put these onto the rast...
int nTraceCoastLine(unsigned int const, int const, int const, vector< bool > *, vector< CGeom2DIPoint > const *)
Traces a coastline (which is defined to be just above still water level) on the grid using the 'wall ...
int nTraceAllFloodCoasts(void)
Locates all the potential coastline start points on the edges of the raster grid, then traces vector ...
void FloodFillLand(int const, int const)
Use the sealevel, wave set-up and run-up to evaluate flood hydraulically connected TODO 007 Not clear...
int m_nYGridSize
The size of the grid in the y direction.
double m_dThisIterTopElevMin
This-iteration lowest elevation of DEM.
void CalcCoastTangents(int const)
Calculates tangents to a coastline: the tangent is assumed to be the orientation of energy/sediment f...
vector< CRWCoast > m_VFloodWaveSetupSurge
TODO 007 Info needed.
int m_nCoastMax
Maximum valid coast length when searching for coasts.
int m_nXMaxBoundingBox
The maximum x value of the bounding box.
string m_strLogFile
Name of output log file.
bool m_bOmitSearchWestEdge
Omit the west edge of the grid from coast-end searches?
double dGridCentroidYToExtCRSY(int const) const
Given the integer Y-axis ordinate of a cell in the raster grid CRS, returns the external CRS Y-axis o...
int m_nCoastMin
Minimum valid coast length when searching for coasts.
bool m_bOmitSearchNorthEdge
Omit the north edge of the grid from coast-end searches?
vector< CGeom2DIPoint > m_VEdgeCell
Edge cells.
int m_nYMaxBoundingBox
The maximum y value of the bounding box.
unsigned long m_ulThisIterNumSeaCells
The number of grid cells which are marked as sea, for this iteration.
CGeomLine LSmoothCoastSavitzkyGolay(CGeomLine *, int const, int const) const
Does smoothing of a CGeomLine coastline vector (is in external CRS coordinates) using a Savitzky-Gola...
int m_nXMinBoundingBox
The minimum x value of the bounding box.
bool bIsWithinValidGrid(int const, int const) const
int m_nCoastSmooth
Which method to use for coast smoothing.
void DoCoastCurvature(int const, int const)
Calculates both detailed and smoothed curvature for every point on a coastline.
bool m_bOmitSearchSouthEdge
Omit the south edge of the grid from coast-end searches?
unsigned long m_ulIter
The number of the current iteration (time step)
double dGridCentroidXToExtCRSX(int const) const
int nTraceAllCoasts(int &)
Locates all the potential coastline start/finish points on the edges of the raster grid,...
void CellByCellFillSea(int const, int const)
Cell-by-cell fills all sea cells starting from a given cell. The cell-by-cell fill (aka 'floodfill') ...
bool bIsInterventionCell(int const, int const) const
Returns true if the cell is an intervention.
double m_dThisIterTopElevMax
This-iteration highest elevation of DEM.
int FindAllInundatedCells(void)
Finds and flags all sea areas which have at least one cell at a grid edge (i.e. does not flag 'inland...
int m_nLevel
TODO 007 Used in WAVESETUP + SURGE + RUNUP.
bool m_bOmitSearchEastEdge
Omit the east edge of the grid from coast-end searches?
vector< int > m_VEdgeCellEdge
The grid edge that each edge cell belongs to.
This file contains global definitions for CoastalME.
int const RTN_ERR_NOCOAST
int const LF_CAT_SEDIMENT_INPUT
int const LF_CAT_SEDIMENT_INPUT_SUBMERGED
int const RTN_ERR_TOO_LONG_TRACING_COAST
int const RTN_ERR_IGNORING_COAST
int const LOG_FILE_MIDDLE_DETAIL
bool bFPIsEqual(const T d1, const T d2, const T dEpsilon)
int const LOG_FILE_HIGH_DETAIL
int const RTN_ERR_NO_START_FINISH_POINTS_TRACING_COAST
int const SMOOTH_SAVITZKY_GOLAY
int const SMOOTH_RUNNING_MEAN
int const RTN_ERR_COAST_TOO_SMALL
int const RTN_ERR_NO_VALID_COAST
int const RTN_ERR_ZERO_LENGTH_COAST
int const LF_CAT_SEDIMENT_INPUT_NOT_SUBMERGED
int const RTN_ERR_REPEATING_WHEN_TRACING_COAST
Contains CRWCoast definitions.
Contains CGeomILine definitions.
Contains CGeomLine definitions.
Contains CGeomRasterGrid definitions.
Contains CSimulation definitions.