83 for (
unsigned int n = 0; n <
m_VEdgeCell.size(); n++)
115 stack<CGeom2DIPoint> PtiStack;
123 while (! PtiStack.empty())
126 if (nRoundLoop++ > nRoundLoopMax)
132 int nX = Pti.
nGetX();
133 int const nY = Pti.
nGetY();
135 while ((nX >= 0) && (!
m_pRasterGrid->m_Cell[nX][nY].bBasementElevIsMissingValue()) && (
m_pRasterGrid->m_Cell[nX][nY].bIsInundated()))
140 bool bSpanAbove =
false;
141 bool bSpanBelow =
false;
160 m_pRasterGrid->m_Cell[nX][nY].SetWaveValuesToDeepWaterWaveValues();
176 m_pRasterGrid->m_Cell[nX][nY].SetWaveValuesToDeepWaterWaveValues();
195 if ((! bSpanAbove) && (nY > 0) && (!
m_pRasterGrid->m_Cell[nX][nY - 1].bBasementElevIsMissingValue()) && (
m_pRasterGrid->m_Cell[nX][nY - 1].bIsInundated()))
201 else if (bSpanAbove && (nY > 0) && (!
m_pRasterGrid->m_Cell[nX][nY - 1].bBasementElevIsMissingValue()) && (!
m_pRasterGrid->m_Cell[nX][nY - 1].bIsInundated()))
301 vector<bool> VbPossibleStartCellLHEdge;
302 vector<bool> VbTraced;
303 vector<int> VnSearchDirection;
304 vector<CGeom2DIPoint> V2DIPossibleStartCell;
307 for (
unsigned int n = 0; n <
m_VEdgeCell.size() - 1; n++)
327 bool const bThisCellIsSea =
m_pRasterGrid->m_Cell[nXThis][nYThis].bIsInContiguousSea();
328 bool const bNextCellIsSea =
m_pRasterGrid->m_Cell[nXNext][nYNext].bIsInContiguousSea();
331 if ((! bThisCellIsSea) && bNextCellIsSea)
334 if (!
m_pRasterGrid->m_Cell[nXThis][nYThis].bIsPossibleCoastStartCell())
337 m_pRasterGrid->m_Cell[nXThis][nYThis].SetPossibleCoastStartCell();
343 V2DIPossibleStartCell.push_back(
CGeom2DIPoint(nXThis, nYThis));
344 VbPossibleStartCellLHEdge.push_back(
true);
346 VbTraced.push_back(
false);
350 else if (bThisCellIsSea && (! bNextCellIsSea))
353 if (!
m_pRasterGrid->m_Cell[nXNext][nYNext].bIsPossibleCoastStartCell())
356 m_pRasterGrid->m_Cell[nXNext][nYNext].SetPossibleCoastStartCell();
362 V2DIPossibleStartCell.push_back(
CGeom2DIPoint(nXNext, nYNext));
363 VbPossibleStartCellLHEdge.push_back(
false);
365 VbTraced.push_back(
false);
371 if (V2DIPossibleStartCell.size() == 0)
373 LogStream <<
m_ulIter <<
": no coastline start/finish points found after grid edges searched.";
386 LogStream <<
m_ulIter <<
": " << V2DIPossibleStartCell.size() <<
" possible coastline start/finish points found" << endl;
389 for (
unsigned int n = 0; n < V2DIPossibleStartCell.size(); n++)
395 if (VbPossibleStartCellLHEdge[n])
419 cerr <<
m_ulIter <<
": no valid coasts found, see " <<
m_strLogFile <<
" for more information" << endl;
427int CSimulation::nTraceCoastLine(
unsigned int const nTraceFromStartCellIndex,
int const nStartSearchDirection,
int const nHandedness, vector<bool>*pVbTraced, vector<CGeom2DIPoint>
const* pV2DIPossibleStartCell)
429 bool bHitStartCell =
false;
430 bool bAtCoast =
false;
431 bool bHasLeftStartEdge =
false;
432 bool bTooLong =
false;
433 bool bOffEdge =
false;
434 bool bRepeating =
false;
436 int const nStartX = pV2DIPossibleStartCell->at(nTraceFromStartCellIndex).nGetX();
437 int const nStartY = pV2DIPossibleStartCell->at(nTraceFromStartCellIndex).nGetY();
440 int nSearchDirection = nStartSearchDirection;
450 m_pRasterGrid->m_Cell[nStartX][nStartY].SetAsCoastline(
true);
452 ILTempGridCRS.
Append(&PtiStart);
480 if ((nRoundLoop > 10) && (ILTempGridCRS.
nGetSize() < 2))
489 if (! bHasLeftStartEdge)
492 if (((nStartSearchDirection ==
SOUTH) && (nY > nStartY)) || ((nStartSearchDirection ==
NORTH) && (nY < nStartY)) ||
493 ((nStartSearchDirection ==
EAST) && (nX > nStartX)) || ((nStartSearchDirection ==
WEST) && (nX < nStartX)))
494 bHasLeftStartEdge =
true;
504 for (
unsigned int nn = 0; nn < pVbTraced->size(); nn++)
506 if ((nn != nTraceFromStartCellIndex) && (! pVbTraced->at(nn)))
510 if (bAtCoast && (nX == pV2DIPossibleStartCell->at(nn).nGetX()) && (nY == pV2DIPossibleStartCell->at(nn).nGetY()))
513 LogStream <<
m_ulIter <<
": Possible coastline found, traced from [" << nStartX <<
"][" << nStartY <<
"] and hit another coast start cell at [" << nX <<
"][" << nY <<
"]" << endl;
515 pVbTraced->at(nn) =
true;
516 bHitStartCell =
true;
531 int nSeawardNewDirection = 0;
532 int nXStraightOn = 0;
533 int nYStraightOn = 0;
534 int nXAntiSeaward = 0;
535 int nYAntiSeaward = 0;
536 int nAntiSeawardNewDirection = 0;
539 int nGoBackNewDirection = 0;
549 switch (nSearchDirection)
555 nSeawardNewDirection =
EAST;
559 nYStraightOn = nY - 1;
562 nXAntiSeaward = nX - 1;
564 nAntiSeawardNewDirection =
WEST;
569 nGoBackNewDirection =
SOUTH;
577 nSeawardNewDirection =
SOUTH;
580 nXStraightOn = nX + 1;
585 nYAntiSeaward = nY - 1;
586 nAntiSeawardNewDirection =
NORTH;
591 nGoBackNewDirection =
WEST;
599 nSeawardNewDirection =
WEST;
603 nYStraightOn = nY + 1;
606 nXAntiSeaward = nX + 1;
608 nAntiSeawardNewDirection =
EAST;
613 nGoBackNewDirection =
NORTH;
621 nSeawardNewDirection =
NORTH;
624 nXStraightOn = nX - 1;
629 nYAntiSeaward = nY + 1;
630 nAntiSeawardNewDirection =
SOUTH;
635 nGoBackNewDirection =
EAST;
645 switch (nSearchDirection)
651 nSeawardNewDirection =
WEST;
655 nYStraightOn = nY - 1;
658 nXAntiSeaward = nX + 1;
660 nAntiSeawardNewDirection =
EAST;
665 nGoBackNewDirection =
SOUTH;
673 nSeawardNewDirection =
NORTH;
676 nXStraightOn = nX + 1;
681 nYAntiSeaward = nY + 1;
682 nAntiSeawardNewDirection =
SOUTH;
687 nGoBackNewDirection =
WEST;
695 nSeawardNewDirection =
EAST;
699 nYStraightOn = nY + 1;
702 nXAntiSeaward = nX - 1;
704 nAntiSeawardNewDirection =
WEST;
709 nGoBackNewDirection =
NORTH;
717 nSeawardNewDirection =
SOUTH;
720 nXStraightOn = nX - 1;
725 nYAntiSeaward = nY - 1;
726 nAntiSeawardNewDirection =
NORTH;
731 nGoBackNewDirection =
EAST;
743 if (
m_pRasterGrid->m_Cell[nXSeaward][nYSeaward].bIsInContiguousSea())
756 ILTempGridCRS.
Append(&Pti);
763 ILTempGridCRS.
Append(&Pti);
775 nSearchDirection = nSeawardNewDirection;
784 if (
m_pRasterGrid->m_Cell[nXStraightOn][nYStraightOn].bIsInContiguousSea())
797 ILTempGridCRS.
Append(&Pti);
804 ILTempGridCRS.
Append(&Pti);
824 if (
m_pRasterGrid->m_Cell[nXAntiSeaward][nYAntiSeaward].bIsInContiguousSea())
837 ILTempGridCRS.
Append(&Pti);
844 ILTempGridCRS.
Append(&Pti);
856 nSearchDirection = nAntiSeawardNewDirection;
868 nSearchDirection = nGoBackNewDirection;
880 int nCoastSize = ILTempGridCRS.
nGetSize();
888 for (
int n = 0; n < nCoastSize; n++)
889 m_pRasterGrid->m_Cell[ILTempGridCRS[n].nGetX()][ILTempGridCRS[n].nGetY()].SetAsCoastline(
false);
902 LogStream <<
", it ended at [" << ILTempGridCRS[nCoastSize - 1].nGetX() <<
"][" << ILTempGridCRS[nCoastSize - 1].nGetY() <<
"] = {" <<
dGridCentroidXToExtCRSX(ILTempGridCRS[nCoastSize - 1].nGetX()) <<
", " <<
dGridCentroidYToExtCRSY(ILTempGridCRS[nCoastSize - 1].nGetY()) <<
"}";
908 for (
int n = 0; n < nCoastSize; n++)
909 m_pRasterGrid->m_Cell[ILTempGridCRS[n].nGetX()][ILTempGridCRS[n].nGetY()].SetAsCoastline(
false);
921 LogStream <<
", it ended at [" << ILTempGridCRS[nCoastSize - 1].nGetX() <<
"][" << ILTempGridCRS[nCoastSize - 1].nGetY() <<
"] = {" <<
dGridCentroidXToExtCRSX(ILTempGridCRS[nCoastSize - 1].nGetX()) <<
", " <<
dGridCentroidYToExtCRSY(ILTempGridCRS[nCoastSize - 1].nGetY()) <<
"}";
927 for (
int n = 0; n < nCoastSize; n++)
928 m_pRasterGrid->m_Cell[ILTempGridCRS[n].nGetX()][ILTempGridCRS[n].nGetY()].SetAsCoastline(
false);
949 for (
int n = 0; n < nCoastSize; n++)
950 m_pRasterGrid->m_Cell[ILTempGridCRS[n].nGetX()][ILTempGridCRS[n].nGetY()].SetAsCoastline(
false);
956 int const nEndX = nX;
957 int const nEndY = nY;
958 int const nCoastEndX = ILTempGridCRS[nCoastSize - 1].nGetX();
959 int const nCoastEndY = ILTempGridCRS[nCoastSize - 1].nGetY();
961 if ((nCoastEndX != nEndX) || (nCoastEndY != nEndY))
964 if (!
m_pRasterGrid->m_Cell[nCoastEndX][nCoastEndY].bIsBoundingBoxEdge())
967 ILTempGridCRS.
Append(nEndX, nEndY);
975 int const nStartEdge =
m_pRasterGrid->m_Cell[nStartX][nStartY].nGetBoundingBoxEdge();
976 int const nEndEdge =
m_pRasterGrid->m_Cell[nEndX][nEndY].nGetBoundingBoxEdge();
981 for (
int j = 0; j < nCoastSize; j++)
1005 int const nCoast =
static_cast<int>(
m_VCoast.size()) - 1;
1008 m_VCoast[nCoast].SetCoastlineExtCRS(<empExtCRS);
1011 m_VCoast[nCoast].SetCoastlineGridCRS(&ILTempGridCRS);
1029 m_VCoast[nCoast].SetSeaHandedness(nHandedness);
1030 m_VCoast[nCoast].SetStartEdge(nStartEdge);
1031 m_VCoast[nCoast].SetEndEdge(nEndEdge);
1037 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 ";
1039 if (nStartEdge ==
NORTH)
1042 else if (nStartEdge ==
SOUTH)
1045 else if (nStartEdge ==
WEST)
1048 else if (nStartEdge ==
EAST)
1053 if (nEndEdge ==
NORTH)
1056 else if (nEndEdge ==
SOUTH)
1059 else if (nEndEdge ==
WEST)
1062 else if (nEndEdge ==
EAST)
1080 m_VCoast[nCoast].CreateProfilesAtCoastPoints();
1144 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, actually is COAST_LENGTH_MAX * tMax(m_nXGridSiz...
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 legth when searching for coass, actualli is tMin(m_nXGridSize,...
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
Checks whether the supplied point (an x-y pair, in the grid CRS) is within the raster grid,...
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
Given the integer X-axis ordinate of a cell in the raster grid CRS, returns the external CRS X-axis o...
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 LOG_FILE_MIDDLE_DETAIL
bool bFPIsEqual(const T d1, const T d2, const T dEpsilon)
int const LOG_FILE_HIGH_DETAIL
int const SMOOTH_SAVITZKY_GOLAY
int const SMOOTH_RUNNING_MEAN
int const LF_CAT_SEDIMENT_INPUT_NOT_SUBMERGED
int const RTN_ERR_TRACING_COAST
Contains CRWCoast definitions.
Contains CGeomILine definitions.
Contains CGeomLine definitions.
Contains CGeomRasterGrid definitions.
Contains CSimulation definitions.