CoastalME (Coastal Modelling Environment)
Simulates the long-term behaviour of complex coastlines
Loading...
Searching...
No Matches
gis_vector.cpp
Go to the documentation of this file.
1
12
13/* ===============================================================================================================================
14
15 This file is part of CoastalME, the Coastal Modelling Environment.
16
17 CoastalME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23===============================================================================================================================*/
24#include <cstdio>
25
26#include <cfloat>
27
28#include <iostream>
29using std::cerr;
30// using std::cout;
31using std::endl;
32using std::ios;
33
34#include <sstream>
35using std::stringstream;
36
37#include <gdal.h>
38#include <gdal_priv.h>
39#include <ogr_core.h>
40#include <ogrsf_frmts.h>
41#include <ogr_feature.h>
42#include <ogr_geometry.h>
43#include <cpl_error.h>
44
45#include "cme.h"
46#include "simulation.h"
47#include "coast.h"
48#include "cliff.h"
49
50//===============================================================================================================================
52//===============================================================================================================================
53int CSimulation::nReadVectorGISFile(int const nDataItem)
54{
55 int nMaxLayer = 0;
56 int nNeedGeometry = 0;
57
58 string strGISFile;
59 string strGeometry;
60
61 // Set up file name and constraints
62 switch (nDataItem)
63 {
68 break;
69
73
76
79
80 break;
81
82 case (FLOOD_LOCATION_VEC):
83 strGISFile = m_strFloodLocationShapefile;
84 nMaxLayer = FLOOD_LOCATION_MAX_LAYER;
85 nNeedGeometry = FLOOD_LOCATION_POINT_GEOMETRY;
86 break;
87 }
88
89 // Open the GDAL/OGR datasource
90 GDALDataset* pOGRDataSource = static_cast<GDALDataset*>(GDALOpenEx(strGISFile.c_str(), GDAL_OF_VECTOR, NULL, NULL, NULL));
91
92 if (pOGRDataSource == NULL)
93 {
94 // Can't open file (note will already have sent GDAL error message to stdout)
95 cerr << ERR << "cannot open " << strGISFile << " for input: " << CPLGetLastErrorMsg() << endl;
97 }
98
99 // Find out number of layers, and compare with the required number
100 int const nLayer = pOGRDataSource->GetLayerCount();
101
102 if (nLayer > nMaxLayer)
103 LogStream << WARN << "need " << nMaxLayer << (nMaxLayer > 1 ? "layers" : "layer") << " in " << strGISFile << ", " << nLayer << " found. Only the first " << nMaxLayer << (nMaxLayer > 1 ? "layers" : "layer") << " will be read." << endl;
104
105 for (int n = 0; n < nMaxLayer; n++)
106 {
107 // Open this layer
108 OGRLayer* pOGRLayer;
109 pOGRLayer = pOGRDataSource->GetLayer(n);
110
111 // Get features from the layer
112 OGRFeature* pOGRFeature;
113
114 // Make sure we are at the beginning of the layer
115 pOGRLayer->ResetReading();
116
117 // Now iterate for all features in the layer
118 while ((pOGRFeature = pOGRLayer->GetNextFeature()) != NULL)
119 {
120 // First get the geometry for this feature
121 OGRGeometry* pOGRGeometry;
122 pOGRGeometry = pOGRFeature->GetGeometryRef();
123
124 if (pOGRGeometry == NULL)
125 {
126 cerr << ERR << " null geometry in " << strGISFile << "." << endl;
128 }
129
130 // Now get the geometry type
131 int const nGeometry = wkbFlatten(pOGRGeometry->getGeometryType());
132 int nThisGeometry = 0;
133
134 switch (nGeometry)
135 {
136 case wkbPoint:
137 nThisGeometry = VEC_GEOMETRY_POINT;
138 strGeometry = "point";
139 break;
140
141 case wkbLineString:
142 nThisGeometry = VEC_GEOMETRY_LINE;
143 strGeometry = "line";
144 break;
145
146 case wkbPolygon:
147 nThisGeometry = VEC_GEOMETRY_POLYGON;
148 strGeometry = "polygon";
149 break;
150
151 default:
152 nThisGeometry = VEC_GEOMETRY_OTHER;
153 strGeometry = "other";
154 break;
155 }
156
157 // Have we got the expected geometry type?
158 if (nThisGeometry != nNeedGeometry)
159 {
160 // Error, we do not have the desired geometry
161 string strNeedGeometry;
162
163 switch (nNeedGeometry)
164 {
166 strNeedGeometry = "point";
167 break;
168
170 strNeedGeometry = "line";
171 break;
172
174 strNeedGeometry = "polygon";
175 break;
176
178 strNeedGeometry = "other";
179 break;
180 }
181
182 cerr << strGeometry << " data found in " << strGISFile << ", but " << strNeedGeometry << " data is needed" << endl;
184 }
185
186 // The geometry type is OK, so process the geometry data
187 int nPoints = 0;
188 OGRPoint* pOGRPoint;
189 OGRLineString* pOGRLineString;
190 double dPointGridX;
191 double dPointGridY;
192
193 switch (nDataItem)
194 {
196 // Point data: convert the wave station coordinates from ext CRS to grid CRS
197 pOGRPoint = static_cast<OGRPoint*>(pOGRGeometry);
198 dPointGridX = dExtCRSXToGridX(pOGRPoint->getX());
199 dPointGridY = dExtCRSYToGridY(pOGRPoint->getY());
200
201 // Safety check to ensure that point is inside the grid in the +ve direction
202 if (dPointGridX >= m_nXGridSize)
204
205 if (dPointGridY >= m_nYGridSize)
207
208 // Now store the wave station coordinates, we will use these in the spatial interpolation of deep water waves
209 m_VdDeepWaterWaveStationX.push_back(dExtCRSXToGridX(dPointGridX));
210 m_VdDeepWaterWaveStationY.push_back(dExtCRSYToGridY(dPointGridY));
211 break;
212
215 {
216 // Point data: convert the sediment input coordinates from ext CRS to grid CRS
217 pOGRPoint = static_cast<OGRPoint*>(pOGRGeometry);
218 dPointGridX = dExtCRSXToGridX(pOGRPoint->getX());
219 dPointGridY = dExtCRSYToGridY(pOGRPoint->getY());
220
221 // Check point data is inside the grid in the +ve direction
222 if (dPointGridX >= m_nXGridSize)
224
225 if (dPointGridY >= m_nYGridSize)
227
228 // Now store the sediment input coordinates
229 m_VdSedimentInputLocationX.push_back(dPointGridX);
230 m_VdSedimentInputLocationY.push_back(dPointGridY);
231 }
232
234 {
235 // Line data: convert the sediment input coordinates from ext CRS to grid CRS
236 pOGRLineString = static_cast<OGRLineString*>(pOGRGeometry);
237
238 nPoints = pOGRLineString->getNumPoints();
239
240 for (int i = 0; i < nPoints; i++)
241 {
242 double const dX = dExtCRSXToGridX(pOGRLineString->getX(i));
243 double const dY = dExtCRSYToGridY(pOGRLineString->getY(i));
244
245 // Check point data is inside the grid in the +ve direction
246 if (dX >= m_nXGridSize)
247 continue;
248
249 if (dY >= m_nYGridSize)
250 continue;
251
252 // Now store the sediment input coordinates
253 m_VdSedimentInputLocationX.push_back(dX);
254 m_VdSedimentInputLocationY.push_back(dY);
255 }
256 }
257
258 break;
259
260 case (FLOOD_LOCATION_VEC):
261 // Point data: convert the flood location coordinates from ext CRS to grid CRS
262 pOGRPoint = static_cast<OGRPoint*>(pOGRGeometry);
263 dPointGridX = dExtCRSXToGridX(pOGRPoint->getX());
264 dPointGridY = dExtCRSYToGridY(pOGRPoint->getY());
265
266 // Check point data is inside the grid in the +ve direction
267 if (dPointGridX >= m_nXGridSize)
269
270 if (dPointGridY >= m_nYGridSize)
272
273 // Now stote the flood location coordinates
274 m_VdFloodLocationX.push_back(dPointGridX);
275 m_VdFloodLocationY.push_back(dPointGridY);
276 break;
277 }
278
279 // Next get the attributes of this feature
280 OGRFeatureDefn* pOGRFeatureDefn = pOGRLayer->GetLayerDefn();
281
282 int nFieldIndex = -1;
283 int nID = -1;
284
285 switch (nDataItem)
286 {
288 // First get the station ID
289 nFieldIndex = pOGRFeatureDefn->GetFieldIndex(DEEP_WATER_WAVE_STATION_ID.c_str());
290
291 if (nFieldIndex == -1)
292 {
293 // Can't find this field in the vector file
294 cerr << ERR << "cannot find " << DEEP_WATER_WAVE_STATION_ID << " field in " << strGISFile << ": " << CPLGetLastErrorMsg() << endl;
296 }
297
298 // Get the Station ID for this point
299 nID = pOGRFeature->GetFieldAsInteger(nFieldIndex);
300 m_VnDeepWaterWaveStationID.push_back(nID);
301
302 break;
303
305 // First get the station ID
306 nFieldIndex = pOGRFeatureDefn->GetFieldIndex(SEDIMENT_INPUT_EVENT_LOCATION_ID.c_str());
307
308 if (nFieldIndex == -1)
309 {
310 // Can't find this field in the vector file
311 cerr << ERR << "cannot find " << SEDIMENT_INPUT_EVENT_LOCATION_ID << " field in " << strGISFile << ": " << CPLGetLastErrorMsg() << endl;
313 }
314
315 // Get the Station ID for this point (note that we read it as an integer, not caring what type of field is actually in the shapefile)
316 nID = pOGRFeature->GetFieldAsInteger(nFieldIndex);
317
319 // Save the ID for the point
320 m_VnSedimentInputLocationID.push_back(nID);
321
323 {
324 // Save the ID for every point in the line
325 for (int i = 0; i < nPoints; i++)
326 m_VnSedimentInputLocationID.push_back(nID);
327 }
328
329 break;
330
331 case (FLOOD_LOCATION_VEC):
332 // First get the station ID
333 nFieldIndex = pOGRFeatureDefn->GetFieldIndex(FLOOD_LOCATION_ID.c_str());
334
335 if (nFieldIndex == -1)
336 {
337 // Can't find this field in the vector file
338 cerr << ERR << "cannot find " << FLOOD_LOCATION_ID << " field in " << strGISFile << ": " << CPLGetLastErrorMsg() << endl;
340 }
341
342 // Get the Station ID for this point (note that we read it as an integer, not caring what type of field is actually in the shapefile)
343 nID = pOGRFeature->GetFieldAsInteger(nFieldIndex);
344
345 // Save the ID for the point
346 m_VnFloodLocationID.push_back(nID);
347 break;
348 }
349 }
350
351 // Get rid of the Feature object
352 OGRFeature::DestroyFeature(pOGRFeature);
353 }
354
355 // Save some info, to be shown in the text output
356 switch (nDataItem)
357 {
359 m_strOGRDWWVDriverCode = pOGRDataSource->GetDriverName();
360
361 for (auto&& oFeatureLayerPair : pOGRDataSource->GetFeatures())
362 {
363 m_strOGRDWWVDriverDesc += oFeatureLayerPair.layer->GetName();
365 }
366
367 m_strOGRDWWVDataType = "integer";
368 m_strOGRDWWVGeometry = strGeometry;
369 break;
370
372 m_strOGRSedInputDriverCode = pOGRDataSource->GetDriverName();
373
374 for (auto&& oFeatureLayerPair : pOGRDataSource->GetFeatures())
375 {
376 m_strOGRSedInputDriverDesc += oFeatureLayerPair.layer->GetName();
378 }
379
380 m_strOGRSedInputGeometry = "integer";
381 m_strOGRSedInputDataType = strGeometry;
382 break;
383
384 case (FLOOD_LOCATION_VEC):
385 m_strOGRFloodDriverCode = pOGRDataSource->GetDriverName();
386
387 for (auto&& oFeatureLayerPair : pOGRDataSource->GetFeatures())
388 {
389 m_strOGRFloodDriverDesc += oFeatureLayerPair.layer->GetName();
391 }
392
393 m_strOGRFloodGeometry = "integer";
394 m_strOGRFloodDataType = strGeometry;
395 break;
396 }
397
398 // Clean up: get rid of the data source object
399 GDALClose(pOGRDataSource);
400
401 return RTN_OK;
402}
403
404//===============================================================================================================================
406//===============================================================================================================================
407bool CSimulation::bWriteVectorGISFile(int const nDataItem, string const* strPlotTitle)
408{
409 // Begin constructing the file name for this save
410 string strFilePathName(m_strOutPath);
411 stringstream strstrFileName;
412
413 OGRwkbGeometryType eGType = wkbUnknown;
414 string strType = "unknown";
415
416 switch (nDataItem)
417 {
418 case (VECTOR_PLOT_COAST):
419 strFilePathName.append(VECTOR_COAST_NAME);
420 strstrFileName << VECTOR_COAST_NAME;
421
422 eGType = wkbLineString;
423 strType = "line";
424
425 break;
426
428 strFilePathName.append(VECTOR_CLIFF_EDGE_NAME);
429 strstrFileName << VECTOR_CLIFF_EDGE_NAME;
430
431 eGType = wkbLineString;
432 strType = "line";
433
434 break;
435
436 case (VECTOR_PLOT_NORMALS):
437 strFilePathName.append(VECTOR_NORMALS_NAME);
438 strstrFileName << VECTOR_NORMALS_NAME;
439
440 eGType = wkbLineString;
441 strType = "line";
442
443 break;
444
446 strFilePathName.append(VECTOR_INVALID_NORMALS_NAME);
447
448 eGType = wkbLineString;
449 strType = "line";
450
451 break;
452
454 strFilePathName.append(VECTOR_COAST_CURVATURE_NAME);
455
456 eGType = wkbPoint;
457 strType = "point";
458
459 break;
460
462 strFilePathName.append(VECTOR_WAVE_ANGLE_AND_HEIGHT_NAME);
463
464 eGType = wkbPoint;
465 strType = "point";
466
467 break;
468
470 strFilePathName.append(VECTOR_AVG_WAVE_ANGLE_AND_HEIGHT_NAME);
471
472 eGType = wkbPoint;
473 strType = "point";
474
475 break;
476
478 strFilePathName.append(VECTOR_WAVE_ENERGY_SINCE_COLLAPSE_NAME);
479
480 eGType = wkbPoint;
481 strType = "point";
482
483 break;
484
486 strFilePathName.append(VECTOR_MEAN_WAVE_ENERGY_NAME);
487
488 eGType = wkbPoint;
489 strType = "point";
490
491 break;
492
494 strFilePathName.append(VECTOR_BREAKING_WAVE_HEIGHT_NAME);
495
496 eGType = wkbPoint;
497 strType = "point";
498
499 break;
500
502 strFilePathName.append(VECTOR_POLYGON_NODE_NAME);
503
504 eGType = wkbPoint;
505 strType = "point";
506
507 break;
508
510 strFilePathName.append(VECTOR_POLYGON_BOUNDARY_NAME);
511
512 eGType = wkbLineString;
513 strType = "line";
514
515 break;
516
518 strFilePathName.append(VECTOR_CLIFF_NOTCH_SIZE_NAME);
519
520 eGType = wkbPoint;
521 strType = "point";
522
523 break;
524
526 strFilePathName.append(VECTOR_SHADOW_BOUNDARY_NAME);
527
528 eGType = wkbLineString;
529 strType = "line";
530
531 break;
532
534 strFilePathName.append(VECTOR_DOWNDRIFT_BOUNDARY_NAME);
535
536 eGType = wkbLineString;
537 strType = "line";
538
539 break;
540
542 strFilePathName.append(VECTOR_DEEP_WATER_WAVE_ANGLE_AND_HEIGHT_NAME);
543
544 eGType = wkbPoint;
545 strType = "point";
546
547 break;
548
550 strFilePathName.append(VECTOR_WAVE_SETUP_NAME);
551
552 eGType = wkbPoint;
553 strType = "point";
554
555 break;
556
558 strFilePathName.append(VECTOR_STORM_SURGE_NAME);
559
560 eGType = wkbPoint;
561 strType = "point";
562
563 break;
564
565 case (VECTOR_PLOT_RUN_UP):
566 strFilePathName.append(VECTOR_RUN_UP_NAME);
567
568 eGType = wkbPoint;
569 strType = "point";
570
571 break;
572
574 strFilePathName.append(VECTOR_FLOOD_LINE_NAME);
575 strstrFileName << VECTOR_FLOOD_LINE_NAME;
576
577 eGType = wkbLineString;
578 strType = "line";
579
580 break;
581
582 // case (VECTOR_PLOT_FLOOD_SWL_SETUP_SURGE_LINE):
583 // strFilePathName.append(VECTOR_FLOOD_SWL_SETUP_SURGE_LINE_NAME);
584 // strstrFileName << VECTOR_FLOOD_SWL_SETUP_SURGE_LINE_NAME;
585 // break;
586
587 // case (VECTOR_PLOT_FLOOD_SWL_SETUP_SURGE_RUNUP_LINE):
588 // strFilePathName.append(VECTOR_FLOOD_SWL_SETUP_SURGE_RUNUP_LINE_NAME);
589 // strstrFileName << VECTOR_FLOOD_SWL_SETUP_SURGE_RUNUP_LINE_NAME;
590 // break;
591 }
592
593 // Append the 'save number' to the filename, and prepend zeros to the save number
594 strFilePathName.append("_");
595 stringstream ststrTmp;
596
598 {
599 // Save number is sequential
600 ststrTmp << FillToWidth('0', m_nGISMaxSaveDigits) << m_nGISSave;
601 }
602
603 else
604 {
605 // Save number is iteration
606 ststrTmp << FillToWidth('0', m_nGISMaxSaveDigits) << m_ulIter;
607 }
608
609 strFilePathName.append(ststrTmp.str());
610 strstrFileName << ststrTmp.str();
611
612 // Make a copy of the filename without any extension
613 // string strFilePathNameNoExt = strFilePathName;
614
615 // If desired, append an extension
616 if (! m_strOGRVectorOutputExtension.empty())
617 strFilePathName.append(m_strOGRVectorOutputExtension);
618
619 // Set up the vector driver
620 GDALDriver* pGDALDriver = GetGDALDriverManager()->GetDriverByName(m_strVectorGISOutFormat.c_str());
621
622 if (pGDALDriver == NULL)
623 {
624 cerr << ERR << "vector GIS output driver " << m_strVectorGISOutFormat << CPLGetLastErrorMsg() << endl;
625 return false;
626 }
627
628 // Now create the dataset
629 GDALDataset* pGDALDataSet = pGDALDriver->Create(strFilePathName.c_str(), 0, 0, 0, GDT_Unknown, m_papszGDALVectorOptions);
630
631 if (pGDALDataSet == NULL)
632 {
633 cerr << ERR << "cannot create " << m_strVectorGISOutFormat << " named " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
634 return false;
635 }
636
637 // Create a spatial reference object
638 OGRSpatialReference OGRSpatialRef;
639
640 // And tell it about the coordinate system used by the basement raster layer
642 {
643 OGRSpatialRef.importFromWkt(m_strGDALBasementDEMProjection.c_str());
644 }
645
646 else
647 {
648 OGRSpatialRef.importFromEPSG(25830); // TODO 035 Also handle other EPSG for vector spatial reference systems
649 }
650
651 // Now create the output layer
652 // // OGRLayer* pOGRLayer = pGDALDataSet->CreateLayer(strFilePathNameNoExt.c_str(), &OGRSpatialRef, eGType, m_papszGDALVectorOptions);
653 // if (EQUAL(m_strVectorGISOutFormat.c_str(), "geojson"))
654 // {
655 // CPLSetConfigOption("GDAL_VALIDATE_CREATION_OPTIONS", "NO");
656 // m_papszGDALVectorOptions = CSLSetNameValue(m_papszGDALVectorOptions, "COORDINATE_PRECISION", "2");
657 // }
658
659 OGRLayer* pOGRLayer = pGDALDataSet->CreateLayer(strstrFileName.str().c_str(), &OGRSpatialRef, eGType, m_papszGDALVectorOptions);
660
661 if (pOGRLayer == NULL)
662 {
663 cerr << ERR << "cannot create '" << strType << "' layer in " << strFilePathName << endl
664 << CPLGetLastErrorMsg() << endl;
665 return false;
666 }
667
668 // Need to switch off GDAL/OGR error messages here, since real (floating point) fields in ESRI shapefiles are treated as width 24 with 15 decimal places of precision (unless an explicit width is given). If fields exceed this, then a "not successfully written. Possibly due to too larger number with respect to field width" error message is shown. Get this to fail silently
669 CPLPushErrorHandler(CPLQuietErrorHandler);
670
671 switch (nDataItem)
672 {
673 case (VECTOR_PLOT_COAST):
674 {
675 // The layer has been created, so create an integer-numbered value (the number of the coast object) for the multi-line
676 string const strFieldValue1 = "Coast";
677 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTInteger);
678
679 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
680 {
681 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
682 return false;
683 }
684
685 // OK, now do features
686 OGRLineString OGRls;
687
688 for (int i = 0; i < static_cast<int>(m_VCoast.size()); i++)
689 {
690 // Create a feature object, one per coast
691 OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
692
693 // Set the feature's attribute (the coast number)
694 pOGRFeature->SetField(strFieldValue1.c_str(), i);
695
696 // Now attach a geometry to the feature object
697 for (int j = 0; j < m_VCoast[i].pLGetCoastlineExtCRS()->nGetSize(); j++)
698 // In external CRS
699 OGRls.addPoint(m_VCoast[i].pPtGetCoastlinePointExtCRS(j)->dGetX(), m_VCoast[i].pPtGetCoastlinePointExtCRS(j)->dGetY());
700
701 pOGRFeature->SetGeometry(&OGRls);
702
703 // Create the feature in the output layer
704 if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
705 {
706 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for coast " << i << " in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
707 return false;
708 }
709
710 // Tidy up: empty the line string and get rid of the feature object
711 OGRls.empty();
712 OGRFeature::DestroyFeature(pOGRFeature);
713 }
714
715 break;
716 }
717
719 {
720 // The layer has been created, so create an integer-numbered value (the number of the coast object) for the multi-line
721 string const strFieldValue1 = "NMR";
722 string const strFieldValue2 = "tiempo";
723 string const strFieldValue3 = "surge_mm";
724 // string strFieldValue4 = "eta-surge(mm)";
725 string const strFieldValue4 = "runup_mm";
726
727 // Create a feature with general properties
728 // OGRLineString OGRls;
729 // OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
730
731 // Testing coordinate system
732 // if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
733 // {
734 // cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
735 // return false;
736 // }
737 // if (pOGRLayer->CreateField(&OGRField2) != OGRERR_NONE)
738 // {
739 // cerr << ERR << "cannot create " << strType << " attribute field 2 '" << strFieldValue2 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
740 // return false;
741 // }
742
743 // pOGRFeature->SetGeometry(&OGRls);
744 // Create the feature in the output layer
745 // if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
746 // {
747 // cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
748 // return false;
749 // }
750 // OGRFeature::DestroyFeature(pOGRFeature);
751 // Create a feature object, one per coast
752
753 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTReal);
754 OGRFieldDefn const OGRField2(strFieldValue2.c_str(), OFTReal);
755 OGRFieldDefn const OGRField3(strFieldValue3.c_str(), OFTInteger64);
756
757 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
758 {
759 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
760 return false;
761 }
762
763 if (pOGRLayer->CreateField(&OGRField2) != OGRERR_NONE)
764 {
765 cerr << ERR << "cannot create " << strType << " attribute field 2 '" << strFieldValue2 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
766 return false;
767 }
768
769 if (pOGRLayer->CreateField(&OGRField3) != OGRERR_NONE)
770 {
771 cerr << ERR << "cannot create " << strType << " attribute field 3 '" << strFieldValue3 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
772 return false;
773 }
774
775 // OK, now do features
776 OGRLineString const OGR2ls;
777
778 // for (int i = 0; i < static_cast<int>(m_VFloodWaveSetupSurge.size()); i++)
779 // {
780 // OGRFeature* pOGR2Feature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
781 // pOGR2Feature->SetField(strFieldValue1.c_str(), m_dThisIterSWL);
782 // pOGR2Feature->SetField(strFieldValue2.c_str(), m_ulIter);
783 // int setup_level = int(m_dThisIterDiffWaveSetupWaterLevel * 1000);
784 // pOGR2Feature->SetField(strFieldValue3.c_str(), setup_level);
785 // // Set the feature's attribute (the coast number)
786 // // Now attach a geometry to the feature object
787 // for (int j = 0; j < m_VFloodWaveSetup[i].pLGetCoastlineExtCRS()->nGetSize(); j++)
788 // {
789 // // In external CRS
790 // // Add SWL + wave setup line
791 // OGR2ls.addPoint(m_VFloodWaveSetup[i].pPtGetCoastlinePointExtCRS(j)->dGetX(), m_VFloodWaveSetup[i].pPtGetCoastlinePointExtCRS(j)->dGetY());
792 // }
793
794 // pOGR2Feature->SetGeometry(&OGR2ls);
795 // OGR2ls.empty();
796
797 // // Create the feature in the output layer
798 // if (pOGRLayer->CreateFeature(pOGR2Feature) != OGRERR_NONE)
799 // {
800 // cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for coast " << i << " in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
801 // return false;
802 // }
803
804 // // Tidy up: empty the line string and get rid of the feature object
805 // // OGRls.empty();
806 // OGRFeature::DestroyFeature(pOGR2Feature);
807 // }
809 {
810 // Create a feature object, one per coast
811 OGRFeature* pOGR3Feature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
812 OGRFieldDefn const OGRField6(strFieldValue1.c_str(), OFTReal);
813 OGRFieldDefn const OGRField7(strFieldValue2.c_str(), OFTReal);
814 OGRFieldDefn const OGRField4(strFieldValue3.c_str(), OFTInteger64);
815
816 if (pOGRLayer->CreateField(&OGRField6) != OGRERR_NONE)
817 {
818 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
819 return false;
820 }
821
822 if (pOGRLayer->CreateField(&OGRField7) != OGRERR_NONE)
823 {
824 cerr << ERR << "cannot create " << strType << " attribute field 2 '" << strFieldValue2 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
825 return false;
826 }
827
828 if (pOGRLayer->CreateField(&OGRField4) != OGRERR_NONE)
829 {
830 cerr << ERR << "cannot create " << strType << " attribute field 4 '" << strFieldValue4 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
831 return false;
832 }
833
834 // OK, now do features
835 OGRLineString OGR3ls;
836
837 for (int i = 0; i < static_cast<int>(m_VFloodWaveSetupSurge.size()); i++)
838 {
839 pOGR3Feature->SetField(strFieldValue1.c_str(), m_dThisIterSWL);
840 pOGR3Feature->SetField(strFieldValue2.c_str(), static_cast<double>(m_bGISSaveDigitsSequential ? m_nGISSave : m_ulIter));
841 int const surge_level = int(m_dThisIterDiffWaveSetupSurgeWaterLevel * 1000);
842 pOGR3Feature->SetField(strFieldValue3.c_str(), surge_level);
843
844 // Set the feature's attribute (the coast number)
845 // Now attach a geometry to the feature object
846 for (int j = 0; j < m_VFloodWaveSetupSurge[i].pLGetCoastlineExtCRS()->nGetSize(); j++)
847 {
848 // In external CRS
849 // Add SWL + wave setup + storm surge line
850 OGR3ls.addPoint(m_VFloodWaveSetupSurge[i].pPtGetCoastlinePointExtCRS(j)->dGetX(), m_VFloodWaveSetupSurge[i].pPtGetCoastlinePointExtCRS(j)->dGetY());
851 }
852
853 pOGR3Feature->SetGeometry(&OGR3ls);
854 OGR3ls.empty();
855
856 // Create the feature in the output layer
857 if (pOGRLayer->CreateFeature(pOGR3Feature) != OGRERR_NONE)
858 {
859 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for coast " << i << " in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
860 return false;
861 }
862
863 // Tidy up: empty the line string and get rid of the feature object
864 // OGRls.empty();
865 OGRFeature::DestroyFeature(pOGR3Feature);
866 }
867 }
868
870 {
871 // Create a feature object, one per coast
872 OGRFeature* pOGR4Feature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
873 OGRFieldDefn const OGRField8(strFieldValue1.c_str(), OFTReal);
874 OGRFieldDefn const OGRField9(strFieldValue2.c_str(), OFTReal);
875 OGRFieldDefn const OGRField5(strFieldValue4.c_str(), OFTInteger64);
876
877 if (pOGRLayer->CreateField(&OGRField8) != OGRERR_NONE)
878 {
879 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
880 return false;
881 }
882
883 if (pOGRLayer->CreateField(&OGRField9) != OGRERR_NONE)
884 {
885 cerr << ERR << "cannot create " << strType << " attribute field 2 '" << strFieldValue2 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
886 return false;
887 }
888
889 if (pOGRLayer->CreateField(&OGRField5) != OGRERR_NONE)
890 {
891 cerr << ERR << "cannot create " << strType << " attribute field 5 '" << strFieldValue4 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
892 return false;
893 }
894
895 // OK, now do features
896 OGRLineString OGR4ls;
897
898 for (int i = 0; i < static_cast<int>(m_VFloodWaveSetupSurgeRunup.size()); i++)
899 {
900 pOGR4Feature->SetField(strFieldValue1.c_str(), m_dThisIterSWL);
901 pOGR4Feature->SetField(strFieldValue2.c_str(), static_cast<double>(m_bGISSaveDigitsSequential ? m_nGISSave : m_ulIter));
902 int const runup_level = int(m_dThisIterDiffWaveSetupSurgeRunupWaterLevel * 1000);
903 pOGR4Feature->SetField(strFieldValue4.c_str(), runup_level);
904
905 // Set the feature's attribute (the coast number)
906 // Now attach a geometry to the feature object
907 for (int j = 0; j < m_VFloodWaveSetupSurgeRunup[i].pLGetCoastlineExtCRS()->nGetSize(); j++)
908 {
909 // In external CRS
910 // Add SWL + wave setup + surge + runup line
911 OGR4ls.addPoint(m_VFloodWaveSetupSurgeRunup[i].pPtGetCoastlinePointExtCRS(j)->dGetX(), m_VFloodWaveSetupSurgeRunup[i].pPtGetCoastlinePointExtCRS(j)->dGetY());
912 }
913
914 pOGR4Feature->SetGeometry(&OGR4ls);
915 OGR4ls.empty();
916
917 // Create the feature in the output layer
918 if (pOGRLayer->CreateFeature(pOGR4Feature) != OGRERR_NONE)
919 {
920 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for coast " << i << " in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
921 return false;
922 }
923
924 // Tidy up: empty the line string and get rid of the feature object
925 // OGRls.empty();
926 OGRFeature::DestroyFeature(pOGR4Feature);
927 }
928 }
929
930 // OGRls.empty();
931
932 break;
933 }
934
936 {
937 // The layer has been created, so create an integer-numbered value (the number of the cliff edge object) for the multi-line
938 string const strFieldValue1 = "CliffEdge";
939 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTInteger);
940
941 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
942 {
943 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
944 return false;
945 }
946
947 // OK, now do features
948 OGRLineString OGRls;
949
950 for (int i = 0; i < static_cast<int>(m_VCliffEdge.size()); i++)
951 {
952 // Create a feature object, one per cliff edge
953 OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
954
955 // Set the feature's attribute (the cliff edge number)
956 pOGRFeature->SetField(strFieldValue1.c_str(), i);
957
958 // Now attach a geometry to the feature object
959 for (int j = 0; j < m_VCliffEdge[i].nGetSize(); j++)
960 {
961 // Use external CRS coordinates directly (already smoothed)
962 OGRls.addPoint(m_VCliffEdge[i].dGetXAt(j), m_VCliffEdge[i].dGetYAt(j));
963 }
964
965 pOGRFeature->SetGeometry(&OGRls);
966
967 // Create the feature in the output layer
968 if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
969 {
970 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for cliff edge " << i << " in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
971 return false;
972 }
973
974 // Tidy up: empty the line string and destroy the feature object
975 OGRls.empty();
976 OGRFeature::DestroyFeature(pOGRFeature);
977 }
978
979 break;
980 }
981
982 case (VECTOR_PLOT_NORMALS):
984 {
985 // The layer has been created, so create an integer-numbered value (the number of the normal) associated with the line
986 string const strFieldValue1 = "NormalID";
987 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTInteger);
988
989 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
990 {
991 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
992 return false;
993 }
994
995 // Also create other integer-numbered values for the category codes of the coastline-normal profile
996 string const strFieldValue2 = "Coast";
997 string const strFieldValue3 = "StartCoast";
998 string const strFieldValue4 = "EndCoast";
999 string const strFieldValue5 = "HitLand";
1000 string const strFieldValue6 = "HitIntervention";
1001 string const strFieldValue7 = "HitCoast";
1002 string const strFieldValue8 = "HitNormal";
1003 string const strFieldValue9 = "TooShort";
1004 string const strFieldValue10 = "TruncSame";
1005 string const strFieldValue11 = "TruncDiff";
1006 string const strFieldValue12 = "CShore";
1007
1008 OGRFieldDefn const OGRField2(strFieldValue2.c_str(), OFTInteger);
1009 OGRFieldDefn const OGRField3(strFieldValue3.c_str(), OFTInteger);
1010 OGRFieldDefn const OGRField4(strFieldValue4.c_str(), OFTInteger);
1011 OGRFieldDefn const OGRField5(strFieldValue5.c_str(), OFTInteger);
1012 OGRFieldDefn const OGRField6(strFieldValue6.c_str(), OFTInteger);
1013 OGRFieldDefn const OGRField7(strFieldValue7.c_str(), OFTInteger);
1014 OGRFieldDefn const OGRField8(strFieldValue8.c_str(), OFTInteger);
1015 OGRFieldDefn const OGRField9(strFieldValue9.c_str(), OFTInteger);
1016 OGRFieldDefn const OGRField10(strFieldValue10.c_str(), OFTInteger);
1017 OGRFieldDefn const OGRField11(strFieldValue11.c_str(), OFTInteger);
1018 OGRFieldDefn const OGRField12(strFieldValue12.c_str(), OFTInteger);
1019
1020 if (pOGRLayer->CreateField(&OGRField2) != OGRERR_NONE)
1021 {
1022 cerr << ERR << "cannot create " << strType << " attribute field 2 '" << strFieldValue2 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1023 return false;
1024 }
1025
1026 if (pOGRLayer->CreateField(&OGRField3) != OGRERR_NONE)
1027 {
1028 cerr << ERR << "cannot create " << strType << " attribute field 3 '" << strFieldValue3 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1029 return false;
1030 }
1031
1032 if (pOGRLayer->CreateField(&OGRField4) != OGRERR_NONE)
1033 {
1034 cerr << ERR << "cannot create " << strType << " attribute field 4 '" << strFieldValue4 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1035 return false;
1036 }
1037
1038 if (pOGRLayer->CreateField(&OGRField5) != OGRERR_NONE)
1039 {
1040 cerr << ERR << "cannot create " << strType << " attribute field 5 '" << strFieldValue5 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1041 return false;
1042 }
1043
1044 if (pOGRLayer->CreateField(&OGRField6) != OGRERR_NONE)
1045 {
1046 cerr << ERR << "cannot create " << strType << " attribute field 6 '" << strFieldValue6 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1047 return false;
1048 }
1049
1050 if (pOGRLayer->CreateField(&OGRField7) != OGRERR_NONE)
1051 {
1052 cerr << ERR << "cannot create " << strType << " attribute field 7 '" << strFieldValue7 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1053 return false;
1054 }
1055
1056 if (pOGRLayer->CreateField(&OGRField8) != OGRERR_NONE)
1057 {
1058 cerr << ERR << "cannot create " << strType << " attribute field 8 '" << strFieldValue8 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1059 return false;
1060 }
1061
1062 if (pOGRLayer->CreateField(&OGRField9) != OGRERR_NONE)
1063 {
1064 cerr << ERR << "cannot create " << strType << " attribute field 9 '" << strFieldValue9 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1065 return false;
1066 }
1067
1068 if (pOGRLayer->CreateField(&OGRField10) != OGRERR_NONE)
1069 {
1070 cerr << ERR << "cannot create " << strType << " attribute field 10 '" << strFieldValue10 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1071 return false;
1072 }
1073
1074 if (pOGRLayer->CreateField(&OGRField11) != OGRERR_NONE)
1075 {
1076 cerr << ERR << "cannot create " << strType << " attribute field 11 '" << strFieldValue11 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1077 return false;
1078 }
1079
1080 if (pOGRLayer->CreateField(&OGRField12) != OGRERR_NONE)
1081 {
1082 cerr << ERR << "cannot create " << strType << " attribute field 12 '" << strFieldValue12 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1083 return false;
1084 }
1085
1086 // OK, now create features
1087 OGRLineString OGRls;
1088
1089 for (int i = 0; i < static_cast<int>(m_VCoast.size()); i++)
1090 {
1091 for (int j = 0; j < m_VCoast[i].nGetNumProfiles(); j++)
1092 {
1093 CGeomProfile* pProfile = m_VCoast[i].pGetProfile(j);
1094
1095 if (((nDataItem == VECTOR_PLOT_NORMALS) && (pProfile->bOKIncStartAndEndOfCoast())) || ((nDataItem == VECTOR_PLOT_INVALID_NORMALS) && (! pProfile->bOKIncStartAndEndOfCoast())))
1096 {
1097 // Create a feature object, one per profile
1098 OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
1099
1100 // Set the feature's attributes
1101 pOGRFeature->SetField(strFieldValue1.c_str(), j);
1102 pOGRFeature->SetField(strFieldValue2.c_str(), pProfile->nGetCoast());
1103 pOGRFeature->SetField(strFieldValue3.c_str(), pProfile->bStartOfCoast());
1104 pOGRFeature->SetField(strFieldValue4.c_str(), pProfile->bEndOfCoast());
1105 pOGRFeature->SetField(strFieldValue5.c_str(), pProfile->bHitLand());
1106 pOGRFeature->SetField(strFieldValue6.c_str(), pProfile->bHitIntervention());
1107 pOGRFeature->SetField(strFieldValue7.c_str(), pProfile->bHitCoast());
1108 pOGRFeature->SetField(strFieldValue8.c_str(), pProfile->bHitAnotherProfile());
1109 pOGRFeature->SetField(strFieldValue9.c_str(), pProfile->bTooShort());
1110 pOGRFeature->SetField(strFieldValue10.c_str(), pProfile->bTruncatedSameCoast());
1111 pOGRFeature->SetField(strFieldValue11.c_str(), pProfile->bTruncatedDifferentCoast());
1112 pOGRFeature->SetField(strFieldValue12.c_str(), pProfile->bCShoreProblem());
1113
1114 // Now attach a geometry to the feature object
1115 for (int k = 0; k < pProfile->nGetProfileSize(); k++)
1116 OGRls.addPoint(pProfile->pPtGetPointInProfile(k)->dGetX(), pProfile->pPtGetPointInProfile(k)->dGetY());
1117
1118 pOGRFeature->SetGeometry(&OGRls);
1119 OGRls.empty();
1120
1121 // Create the feature in the output layer
1122 if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
1123 {
1124 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for coast " << i << " and profile " << j << " in " << strFilePathName << endl
1125 << CPLGetLastErrorMsg() << endl;
1126 return false;
1127 }
1128
1129 // Tidy up: get rid of the feature object
1130 OGRFeature::DestroyFeature(pOGRFeature);
1131 }
1132 }
1133 }
1134
1135 break;
1136 }
1137
1146 case (VECTOR_PLOT_RUN_UP):
1147 {
1148 // The layer has been created, so create a real-numbered value associated with each point
1149 string strFieldValue1;
1150
1151 if (nDataItem == VECTOR_PLOT_COAST_CURVATURE)
1152 strFieldValue1 = "Curve";
1153
1154 else if (nDataItem == VECTOR_PLOT_WAVE_ENERGY_SINCE_COLLAPSE)
1155 strFieldValue1 = "SC_Energy";
1156
1157 else if (nDataItem == VECTOR_PLOT_MEAN_WAVE_ENERGY)
1158 strFieldValue1 = "MeanEnergy";
1159
1160 else if (nDataItem == VECTOR_PLOT_BREAKING_WAVE_HEIGHT)
1161 strFieldValue1 = "Height";
1162
1163 else if (nDataItem == VECTOR_PLOT_POLYGON_NODES)
1164 strFieldValue1 = "Node";
1165
1166 else if (nDataItem == VECTOR_PLOT_CLIFF_NOTCH_SIZE)
1167 strFieldValue1 = "Notch";
1168
1169 else if (nDataItem == VECTOR_PLOT_WAVE_SETUP)
1170 strFieldValue1 = "Wavesetup";
1171
1172 else if (nDataItem == VECTOR_PLOT_STORM_SURGE)
1173 strFieldValue1 = "Stormsurge";
1174
1175 else if (nDataItem == VECTOR_PLOT_RUN_UP)
1176 strFieldValue1 = "Runup";
1177
1178 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTReal);
1179
1180 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
1181 {
1182 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1183 return false;
1184 }
1185
1186 // OK, now create features
1187 OGRLineString const OGRls;
1188 OGRMultiLineString const OGRmls;
1189 OGRPoint OGRPt;
1190
1191 for (int i = 0; i < static_cast<int>(m_VCoast.size()); i++)
1192 {
1193 for (int j = 0; j < m_VCoast[i].pLGetCoastlineExtCRS()->nGetSize(); j++)
1194 {
1195 // Create a feature object, one per coastline point
1196 OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
1197
1198 // Set the feature's geometry (in external CRS)
1199 OGRPt.setX(m_VCoast[i].pPtGetCoastlinePointExtCRS(j)->dGetX());
1200 OGRPt.setY(m_VCoast[i].pPtGetCoastlinePointExtCRS(j)->dGetY());
1201 pOGRFeature->SetGeometry(&OGRPt);
1202
1203 if (nDataItem == VECTOR_PLOT_COAST_CURVATURE)
1204 {
1205 double const dCurvature = m_VCoast[i].dGetDetailedCurvature(j);
1206
1207 if (bFPIsEqual(dCurvature, DBL_NODATA, TOLERANCE))
1208 continue;
1209
1210 // Set the feature's attribute
1211 pOGRFeature->SetField(strFieldValue1.c_str(), dCurvature);
1212 }
1213
1214 else if (nDataItem == VECTOR_PLOT_WAVE_ENERGY_SINCE_COLLAPSE)
1215 {
1216 // Set the feature's attribute
1217 if (m_VCoast[i].pGetCoastLandform(j) == NULL)
1218 pOGRFeature->SetField(strFieldValue1.c_str(), DBL_NODATA);
1219
1220 else
1221 pOGRFeature->SetField(strFieldValue1.c_str(), m_VCoast[i].pGetCoastLandform(j)->dGetTotAccumWaveEnergy());
1222 }
1223
1224 else if (nDataItem == VECTOR_PLOT_MEAN_WAVE_ENERGY)
1225 {
1226 // Set the feature's attribute
1227 if (m_VCoast[i].pGetCoastLandform(j) == NULL)
1228 pOGRFeature->SetField(strFieldValue1.c_str(), DBL_NODATA);
1229
1230 else
1231 {
1232 double dEnergy = m_VCoast[i].pGetCoastLandform(j)->dGetTotAccumWaveEnergy();
1233 dEnergy *= 24;
1234 dEnergy /= m_dSimElapsed; // Is in energy units per day
1235
1236 pOGRFeature->SetField(strFieldValue1.c_str(), dEnergy);
1237 }
1238 }
1239
1240 else if (nDataItem == VECTOR_PLOT_BREAKING_WAVE_HEIGHT)
1241 {
1242 // Set the feature's attribute
1243 double const dHeight = m_VCoast[i].dGetBreakingWaveHeight(j);
1244 pOGRFeature->SetField(strFieldValue1.c_str(), dHeight);
1245 }
1246
1247 else if (nDataItem == VECTOR_PLOT_WAVE_SETUP)
1248 {
1249 // Set the feature's attribute
1250 double const dWaveSetupSurge = m_VCoast[i].dGetWaveSetupSurge(j);
1251 pOGRFeature->SetField(strFieldValue1.c_str(), dWaveSetupSurge);
1252 }
1253
1254 // else if (nDataItem == VECTOR_PLOT_STORM_SURGE)
1255 // {
1256 // // Set the feature's attribute
1257 // double dStormSurge = m_VCoast[i].dGetStormSurge(j);
1258 // pOGRFeature->SetField(strFieldValue1.c_str(), dStormSurge);
1259 // }
1260 else if (nDataItem == VECTOR_PLOT_RUN_UP)
1261 {
1262 // Set the feature's attribute
1263 double const dRunUp = m_VCoast[i].dGetRunUp(j);
1264 pOGRFeature->SetField(strFieldValue1.c_str(), dRunUp);
1265 }
1266
1267 else if (nDataItem == VECTOR_PLOT_POLYGON_NODES)
1268 {
1269 int const nNode = m_VCoast[i].nGetPolygonNode(j);
1270
1271 if (nNode == INT_NODATA)
1272 continue;
1273
1274 // Set the feature's attribute
1275 pOGRFeature->SetField(strFieldValue1.c_str(), nNode);
1276 }
1277
1278 else if (nDataItem == VECTOR_PLOT_CLIFF_NOTCH_SIZE)
1279 {
1280 CACoastLandform* pCoastLandform = m_VCoast[i].pGetCoastLandform(j);
1281
1282 if (pCoastLandform == NULL)
1283 pOGRFeature->SetField(strFieldValue1.c_str(), DBL_NODATA);
1284
1285 else
1286 {
1287 int const nCategory = pCoastLandform->nGetLandFormCategory();
1288 double dNotchDepth = 0.0;
1289
1290 if (nCategory == LF_CAT_CLIFF)
1291 {
1292 CRWCliff const* pCliff = reinterpret_cast<CRWCliff*>(pCoastLandform);
1293
1294 // Get attribute values from the cliff object
1295 dNotchDepth = pCliff->dGetNotchDepth();
1296 }
1297
1298 // Set the feature's attribute
1299 pOGRFeature->SetField(strFieldValue1.c_str(), dNotchDepth);
1300 }
1301 }
1302
1303 // Create the feature in the output layer
1304 if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
1305 {
1306 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for coast " << i << " point " << j << " in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1307 return false;
1308 }
1309
1310 // Get rid of the feature object
1311 OGRFeature::DestroyFeature(pOGRFeature);
1312 }
1313 }
1314
1315 break;
1316 }
1317
1319 {
1320 // The layer has been created, so create real-numbered values associated with each point
1321 string const strFieldValue1 = "Angle";
1322 string const strFieldValue2 = "Height";
1323
1324 // Create the first field
1325 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTReal);
1326
1327 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
1328 {
1329 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1330 return false;
1331 }
1332
1333 // Create the second field
1334 OGRFieldDefn const OGRField2(strFieldValue2.c_str(), OFTReal);
1335
1336 if (pOGRLayer->CreateField(&OGRField2) != OGRERR_NONE)
1337 {
1338 cerr << ERR << "cannot create " << strType << " attribute field 2 '" << strFieldValue2 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1339 return false;
1340 }
1341
1342 // OK, now create features
1343 OGRLineString const OGRls;
1344 OGRMultiLineString const OGRmls;
1345 OGRPoint OGRPt;
1346
1347 for (int nX = 0; nX < m_nXGridSize; nX++)
1348 {
1349 for (int nY = 0; nY < m_nYGridSize; nY++)
1350 {
1351 // Only output a value if the cell is a sea cell which is not in the active zone (wave height and angle values are meaningless if in the active zone)
1352 if ((m_pRasterGrid->m_Cell[nX][nY].bIsInContiguousSea()) && (!m_pRasterGrid->m_Cell[nX][nY].bIsInActiveZone()))
1353 {
1354 // Create a feature object, one per sea cell
1355 OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
1356
1357 // Set the feature's geometry (in external CRS)
1358 OGRPt.setX(dGridCentroidXToExtCRSX(nX));
1359 OGRPt.setY(dGridCentroidYToExtCRSY(nY));
1360 pOGRFeature->SetGeometry(&OGRPt);
1361
1362 double const dOrientation = m_pRasterGrid->m_Cell[nX][nY].dGetWaveAngle();
1363 double const dHeight = m_pRasterGrid->m_Cell[nX][nY].dGetWaveHeight();
1364
1365 if (bFPIsEqual(dHeight, DBL_NODATA, TOLERANCE) || bFPIsEqual(dOrientation, DBL_NODATA, TOLERANCE))
1366 continue;
1367
1368 // Set the feature's attributes
1369 pOGRFeature->SetField(strFieldValue1.c_str(), dOrientation);
1370 pOGRFeature->SetField(strFieldValue2.c_str(), dHeight);
1371
1372 // Create the feature in the output layer
1373 if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
1374 {
1375 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for cell [" << nX << "][" << nY << "] in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1376 return false;
1377 }
1378
1379 // Get rid of the feature object
1380 OGRFeature::DestroyFeature(pOGRFeature);
1381 }
1382 }
1383 }
1384
1385 break;
1386 }
1387
1389 {
1390 // The layer has been created, so create real-numbered values associated with each point
1391 string const strFieldValue1 = "Angle";
1392 string const strFieldValue2 = "Height";
1393
1394 // Create the first field
1395 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTReal);
1396
1397 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
1398 {
1399 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1400 return false;
1401 }
1402
1403 // Create the second field
1404 OGRFieldDefn const OGRField2(strFieldValue2.c_str(), OFTReal);
1405
1406 if (pOGRLayer->CreateField(&OGRField2) != OGRERR_NONE)
1407 {
1408 cerr << ERR << "cannot create " << strType << " attribute field 2 '" << strFieldValue2 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1409 return false;
1410 }
1411
1412 // OK, now create features
1413 OGRLineString const OGRls;
1414 OGRMultiLineString const OGRmls;
1415 OGRPoint OGRPt;
1416
1417 for (int nX = 0; nX < m_nXGridSize; nX++)
1418 {
1419 for (int nY = 0; nY < m_nYGridSize; nY++)
1420 {
1421 // Create a feature object, one per sea cell
1422 OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
1423
1424 // Set the feature's geometry (in external CRS)
1425 OGRPt.setX(dGridCentroidXToExtCRSX(nX));
1426 OGRPt.setY(dGridCentroidYToExtCRSY(nY));
1427 pOGRFeature->SetGeometry(&OGRPt);
1428
1429 double const dOrientation = m_pRasterGrid->m_Cell[nX][nY].dGetTotWaveAngle() / static_cast<double>(m_ulIter);
1430 double const dHeight = m_pRasterGrid->m_Cell[nX][nY].dGetWaveHeight() / static_cast<double>(m_ulIter);
1431
1432 if (bFPIsEqual(dHeight, DBL_NODATA, TOLERANCE) || bFPIsEqual(dOrientation, DBL_NODATA, TOLERANCE))
1433 continue;
1434
1435 // Set the feature's attributes
1436 pOGRFeature->SetField(strFieldValue1.c_str(), dOrientation);
1437 pOGRFeature->SetField(strFieldValue2.c_str(), dHeight);
1438
1439 // Create the feature in the output layer
1440 if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
1441 {
1442 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for cell [" << nX << "][" << nY << "] in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1443 return false;
1444 }
1445
1446 // Get rid of the feature object
1447 OGRFeature::DestroyFeature(pOGRFeature);
1448 }
1449 }
1450
1451 break;
1452 }
1453
1455 {
1456 // The layer has been created, so create two integer-numbered values (the number of the polygon object, and the number of the coast point which is the polygon's node) for the polygon
1457 string const strFieldValue1 = "Polygon";
1458 string const strFieldValue2 = "CoastNode";
1459 string const strFieldValue3 = "TotSedChng";
1460 string const strFieldValue4 = "FinSedChng";
1461 string const strFieldValue5 = "SndSedChng";
1462 string const strFieldValue6 = "CrsSedChng";
1463
1464 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTInteger);
1465
1466 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
1467 {
1468 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1469 return false;
1470 }
1471
1472 OGRFieldDefn const OGRField2(strFieldValue2.c_str(), OFTInteger);
1473
1474 if (pOGRLayer->CreateField(&OGRField2) != OGRERR_NONE)
1475 {
1476 cerr << ERR << "cannot create " << strType << " attribute field 2 '" << strFieldValue2 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1477 return false;
1478 }
1479
1480 OGRFieldDefn const OGRField3(strFieldValue3.c_str(), OFTReal);
1481
1482 if (pOGRLayer->CreateField(&OGRField3) != OGRERR_NONE)
1483 {
1484 cerr << ERR << "cannot create " << strType << " attribute field 3 '" << strFieldValue3 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1485 return false;
1486 }
1487
1488 OGRFieldDefn const OGRField4(strFieldValue4.c_str(), OFTReal);
1489
1490 if (pOGRLayer->CreateField(&OGRField4) != OGRERR_NONE)
1491 {
1492 cerr << ERR << "cannot create " << strType << " attribute field 4 '" << strFieldValue4 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1493 return false;
1494 }
1495
1496 OGRFieldDefn const OGRField5(strFieldValue5.c_str(), OFTReal);
1497
1498 if (pOGRLayer->CreateField(&OGRField5) != OGRERR_NONE)
1499 {
1500 cerr << ERR << "cannot create " << strType << " attribute field 5 '" << strFieldValue5 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1501 return false;
1502 }
1503
1504 OGRFieldDefn const OGRField6(strFieldValue6.c_str(), OFTReal);
1505
1506 if (pOGRLayer->CreateField(&OGRField6) != OGRERR_NONE)
1507 {
1508 cerr << ERR << "cannot create " << strType << " attribute field 6 '" << strFieldValue6 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1509 return false;
1510 }
1511
1512 // OK, now do features
1513 OGRLineString OGRls;
1514
1515 for (int i = 0; i < static_cast<int>(m_VCoast.size()); i++)
1516 {
1517 for (int j = 0; j < m_VCoast[i].nGetNumPolygons(); j++)
1518 {
1519 // Create a feature object, one per polygon
1520 OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
1521
1522 CGeomCoastPolygon* pPolygon = m_VCoast[i].pGetPolygon(j);
1523
1524 // Set the feature's attributes
1525 pOGRFeature->SetField(strFieldValue1.c_str(), j);
1526 pOGRFeature->SetField(strFieldValue2.c_str(), pPolygon->nGetNodeCoastPoint());
1527 pOGRFeature->SetField(strFieldValue3.c_str(), pPolygon->dGetBeachDepositionAndSuspensionAllUncons());
1528 pOGRFeature->SetField(strFieldValue4.c_str(), pPolygon->dGetSuspensionUnconsFine());
1529 pOGRFeature->SetField(strFieldValue5.c_str(), pPolygon->dGetBeachDepositionUnconsSand());
1530 pOGRFeature->SetField(strFieldValue6.c_str(), pPolygon->dGetBeachDepositionUnconsCoarse());
1531
1532 // Now attach a geometry to the feature object
1533 for (int n = 0; n < pPolygon->nGetBoundarySize(); n++)
1534 // In external CRS
1535 OGRls.addPoint(pPolygon->pPtGetBoundaryPoint(n)->dGetX(), pPolygon->pPtGetBoundaryPoint(n)->dGetY());
1536
1537 pOGRFeature->SetGeometry(&OGRls);
1538
1539 // Create the feature in the output layer
1540 if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
1541 {
1542 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for coast " << i << " polygon " << j << " in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1543 return false;
1544 }
1545
1546 // Tidy up: empty the line string and get rid of the feature object
1547 OGRls.empty();
1548 OGRFeature::DestroyFeature(pOGRFeature);
1549 }
1550 }
1551
1552 break;
1553 }
1554
1556 {
1557 // Create an integer-numbered value (the number of the shadow boundary line object) for the multi-line
1558 string const strFieldValue1 = "ShadowLine";
1559 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTInteger);
1560
1561 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
1562 {
1563 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1564 return false;
1565 }
1566
1567 // OK, now do features
1568 OGRLineString OGRls;
1569
1570 for (int i = 0; i < static_cast<int>(m_VCoast.size()); i++)
1571 {
1572 for (int j = 0; j < m_VCoast[i].nGetNumShadowBoundaries(); j++)
1573 {
1574 // Create a feature object, one per coast
1575 OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
1576
1577 // Set the feature's attribute (the shadow boundary line number)
1578 pOGRFeature->SetField(strFieldValue1.c_str(), j);
1579
1580 // Now attach a geometry to the feature object
1581 CGeomLine LShadow = *m_VCoast[i].pGetShadowBoundary(j);
1582
1583 for (int nn = 0; nn < LShadow.nGetSize(); nn++)
1584 OGRls.addPoint(LShadow.dGetXAt(nn), LShadow.dGetYAt(nn));
1585
1586 pOGRFeature->SetGeometry(&OGRls);
1587
1588 // Create the feature in the output layer
1589 if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
1590 {
1591 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << j << " for coast " << i << " in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1592 return false;
1593 }
1594
1595 // Tidy up: empty the line string and get rid of the feature object
1596 OGRls.empty();
1597 OGRFeature::DestroyFeature(pOGRFeature);
1598 }
1599 }
1600
1601 break;
1602 }
1603
1605 {
1606 // Create an integer-numbered value (the number of the downdrift boundary line object) for the multi-line
1607 string const strFieldValue1 = "DdriftLine";
1608 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTInteger);
1609
1610 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
1611 {
1612 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1613 return false;
1614 }
1615
1616 // OK, now do features
1617 OGRLineString OGRls;
1618
1619 for (int i = 0; i < static_cast<int>(m_VCoast.size()); i++)
1620 {
1621 for (int j = 0; j < m_VCoast[i].nGetNumShadowDowndriftBoundaries(); j++)
1622 {
1623 // Create a feature object, one per coast
1624 OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
1625
1626 // Set the feature's attribute (the downdrift boundary line number)
1627 pOGRFeature->SetField(strFieldValue1.c_str(), j);
1628
1629 // Now attach a geometry to the feature object
1630 CGeomLine LDowndrift = *m_VCoast[i].pGetShadowDowndriftBoundary(j);
1631
1632 for (int nn = 0; nn < LDowndrift.nGetSize(); nn++)
1633 OGRls.addPoint(LDowndrift.dGetXAt(nn), LDowndrift.dGetYAt(nn));
1634
1635 pOGRFeature->SetGeometry(&OGRls);
1636
1637 // Create the feature in the output layer
1638 if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
1639 {
1640 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << j << " for coast " << i << " in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1641 return false;
1642 }
1643
1644 // Tidy up: empty the line string and get rid of the feature object
1645 OGRls.empty();
1646 OGRFeature::DestroyFeature(pOGRFeature);
1647 }
1648 }
1649
1650 break;
1651 }
1652
1654 {
1655 // The layer has been created, so create real-numbered values associated with each point
1656 string const strFieldValue1 = "Angle";
1657 string const strFieldValue2 = "Height";
1658
1659 // Create the first field
1660 OGRFieldDefn const OGRField1(strFieldValue1.c_str(), OFTReal);
1661
1662 if (pOGRLayer->CreateField(&OGRField1) != OGRERR_NONE)
1663 {
1664 cerr << ERR << "cannot create " << strType << " attribute field 1 '" << strFieldValue1 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1665 return false;
1666 }
1667
1668 // Create the second field
1669 OGRFieldDefn const OGRField2(strFieldValue2.c_str(), OFTReal);
1670
1671 if (pOGRLayer->CreateField(&OGRField2) != OGRERR_NONE)
1672 {
1673 cerr << ERR << "cannot create " << strType << " attribute field 2 '" << strFieldValue2 << "' in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1674 return false;
1675 }
1676
1677 // OK, now create features
1678 OGRLineString const OGRls;
1679 OGRMultiLineString const OGRmls;
1680 OGRPoint OGRPt;
1681
1682 for (int nX = 0; nX < m_nXGridSize; nX++)
1683 {
1684 for (int nY = 0; nY < m_nYGridSize; nY++)
1685 {
1686 // Create a feature object, one per cell (does this whether the sea is a sea cell or a land cell)
1687 OGRFeature* pOGRFeature = OGRFeature::CreateFeature(pOGRLayer->GetLayerDefn());
1688
1689 // Set the feature's geometry (in external CRS)
1690 OGRPt.setX(dGridCentroidXToExtCRSX(nX));
1691 OGRPt.setY(dGridCentroidYToExtCRSY(nY));
1692 pOGRFeature->SetGeometry(&OGRPt);
1693
1694 double const dOrientation = m_pRasterGrid->m_Cell[nX][nY].dGetCellDeepWaterWaveAngle();
1695 double const dHeight = m_pRasterGrid->m_Cell[nX][nY].dGetCellDeepWaterWaveHeight();
1696
1697 if (bFPIsEqual(dHeight, DBL_NODATA, TOLERANCE) || bFPIsEqual(dOrientation, DBL_NODATA, TOLERANCE) || (!m_pRasterGrid->m_Cell[nX][nY].bIsInContiguousSea()))
1698 continue;
1699
1700 // Set the feature's attributes
1701 pOGRFeature->SetField(strFieldValue1.c_str(), dOrientation);
1702 pOGRFeature->SetField(strFieldValue2.c_str(), dHeight);
1703
1704 // Create the feature in the output layer
1705 if (pOGRLayer->CreateFeature(pOGRFeature) != OGRERR_NONE)
1706 {
1707 cerr << ERR << "cannot create " << strType << " feature " << strPlotTitle << " for cell [" << nX << "][" << nY << "] in " << strFilePathName << endl << CPLGetLastErrorMsg() << endl;
1708 return false;
1709 }
1710
1711 // Get rid of the feature object
1712 OGRFeature::DestroyFeature(pOGRFeature);
1713 }
1714 }
1715
1716 break;
1717 }
1718 }
1719
1720 CPLPopErrorHandler();
1721
1722 // Get rid of the dataset object
1723 GDALClose(pGDALDataSet);
1724
1725 return true;
1726}
int nGetSize(void) const
Definition 2d_shape.cpp:56
Abstract class, used as a base class for landform objects on the coastline.
int nGetLandFormCategory(void) const
Get the landform category.
double dGetY(void) const
Returns the CGeom2DPoint object's double Y coordinate.
Definition 2d_point.cpp:53
double dGetX(void) const
Returns the CGeom2DPoint object's double X coordinate.
Definition 2d_point.cpp:47
Geometry class used for coast polygon objects.
double dGetBeachDepositionUnconsSand(void) const
Returns the depth of sand-sized unconsolidated sediment deposited on this polygon during this timeste...
double dGetBeachDepositionUnconsCoarse(void) const
Returns the depth of coarse-sized unconsolidated sediment deposited on this polygon during this times...
CGeom2DPoint * pPtGetBoundaryPoint(int const)
Get the coordinates (external CRS) of a specified point on the polygon's boundary.
double dGetBeachDepositionAndSuspensionAllUncons(void) const
Returns this timestep's total (all size classes) deposition and to-suspension movement of unconsolida...
int nGetNodeCoastPoint(void) const
Get the coast node point.
int nGetBoundarySize(void) const
Get the number of points in the polygon's boundary.
double dGetSuspensionUnconsFine(void) const
Returns this timestep's to-suspension movement of fine unconsolidated sediment on this polygon,...
Geometry class used to represent 2D vector line objects.
Definition line.h:32
double dGetYAt(int const)
Returns the Y value at a given place in the line.
Definition line.cpp:64
double dGetXAt(int const)
Returns the X value at a given place in the line.
Definition line.cpp:58
Geometry class used to represent coast profile objects.
Definition profile.h:37
int nGetCoast(void) const
Returns this profile's coast.
Definition profile.cpp:74
bool bTruncatedDifferentCoast(void) const
Returns the switch which indicates whether this profile has been truncated, due to hitting another pr...
Definition profile.cpp:212
bool bHitAnotherProfile(void) const
Returns the switch which indicates whether this profile hits another profile badly.
Definition profile.cpp:224
bool bHitLand(void) const
Returns the switch which indicates whether this profile has hit land.
Definition profile.cpp:152
bool bTooShort(void) const
Returns the switch which indicates whether this profile is too short to be useful.
Definition profile.cpp:188
bool bHitCoast(void) const
Returns the switch which indicates whether this profile has hit a coast.
Definition profile.cpp:176
CGeom2DPoint * pPtGetPointInProfile(int const)
Returns a single point (external CRS) from the profile.
Definition profile.cpp:367
bool bOKIncStartAndEndOfCoast(void) const
Returns true if this is a problem-free profile (however it could be a start-of-coast or an end-of-coa...
Definition profile.cpp:265
int nGetProfileSize(void) const
Returns the number of external CRS points in the profile (only two, initally; and always just two for...
Definition profile.cpp:361
bool bStartOfCoast(void) const
Returns the switch to indicate whether this is a start-of-coast profile.
Definition profile.cpp:116
bool bTruncatedSameCoast(void) const
Returns the switch which indicates whether this profile has been truncated, due to hitting another pr...
Definition profile.cpp:200
bool bEndOfCoast(void) const
Returns the switch to indicate whether this is an end-of-coast profile.
Definition profile.cpp:128
bool bCShoreProblem(void) const
Returns the switch which indicates whether this profile has a CShore problem.
Definition profile.cpp:140
bool bHitIntervention(void) const
Returns the switch which indicates whether this profile has hit an intervention.
Definition profile.cpp:164
Real-world class used to represent the 'cliff' category of coastal landform object.
Definition cliff.h:33
double dGetNotchDepth(void) const
Returns the horizontal depth of the cliff's erosional notch (the 'overhang')
Definition cliff.cpp:96
int m_nGISMaxSaveDigits
The maximum number of digits in GIS filenames. These can be sequential, or the iteration number.
Definition simulation.h:499
string m_strOGRVectorOutputExtension
GDAL-OGR vector output drive file extension.
bool m_bFloodSWLSetupSurgeLine
Are we saving the flood still water level setup surge line? TODO 007.
Definition simulation.h:439
bool m_bSedimentInputAtPoint
Do we have sediment inputat a point?
Definition simulation.h:394
double m_dThisIterSWL
The still water level for this timestep (this includes tidal changes and any long-term SWL change)
Definition simulation.h:712
CGeomRasterGrid * m_pRasterGrid
Pointer to the raster grid object.
int m_nXGridSize
The size of the grid in the x direction.
Definition simulation.h:457
vector< double > m_VdDeepWaterWaveStationY
Y coordinate (grid CRS) for deep water wave station.
ofstream LogStream
char ** m_papszGDALVectorOptions
Options for GDAL when handling vector files.
Definition simulation.h:454
vector< CRWCoast > m_VFloodWaveSetupSurgeRunup
TODO 007 Info needed.
vector< CRWCoast > m_VCoast
The coastline objects.
string m_strOGRSedInputDataType
GDAL data type for the sediment input event locations vector file.
bool bWriteVectorGISFile(int const, string const *)
Writes vector GIS files using GDAL/OGR.
double m_dThisIterDiffWaveSetupSurgeWaterLevel
TODO 007 Info needed.
Definition simulation.h:733
vector< int > m_VnSedimentInputLocationID
ID for sediment input location, this corresponds with the ID in the sediment input time series file.
int m_nYGridSize
The size of the grid in the y direction.
Definition simulation.h:460
string m_strSedimentInputEventShapefile
The name of the sediment input events shape file.
string m_strVectorGISOutFormat
Base name for CME vector GIS output files.
string m_strDeepWaterWaveStationsShapefile
The name of the deep water wave stations shape file.
vector< CRWCoast > m_VFloodWaveSetupSurge
TODO 007 Info needed.
string m_strOGRFloodGeometry
GDAL geometry for the flood input locations point or vector file.
string m_strOGRSedInputDriverDesc
string m_strOGRDWWVDriverCode
GDAL code for the deep water wave stations vector file.
vector< double > m_VdFloodLocationX
X coordinate (grid CRS) for total water level flooding.
bool m_bSedimentInputAlongLine
Do we have sediment input along a line?
Definition simulation.h:400
int nReadVectorGISFile(int const)
Reads vector GIS datafiles using GDAL/OGR.
vector< CGeomLine > m_VCliffEdge
The traced cliff edge lines (in external CRS)
vector< double > m_VdDeepWaterWaveStationX
X coordinate (grid CRS) for deep water wave station.
vector< double > m_VdSedimentInputLocationX
X coordinate (grid CRS) for sediment input event.
bool m_bSedimentInputAtCoast
Do we have sediment input at the coast?
Definition simulation.h:397
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...
Definition gis_utils.cpp:78
string m_strOGRDWWVDriverDesc
string m_strOGRFloodDriverCode
GDAL code for the flood input locations point or vector file.
double m_dSimElapsed
Time simulated so far, in hours.
Definition simulation.h:679
vector< int > m_VnDeepWaterWaveStationID
ID for deep water wave station, this corresponds with the ID in the wave time series file.
vector< int > m_VnFloodLocationID
ID for flood location.
string m_strFloodLocationShapefile
The name of the flood loction events shape file.
bool m_bGISSaveDigitsSequential
Are the GIS save digits (which are part of each GIS file name) sequential, or are they the iteration ...
Definition simulation.h:445
double dExtCRSXToGridX(double const) const
string m_strOGRDWWVGeometry
GDAL geometry for the deep water wave stations vector file.
string m_strOutPath
Path for all output files.
vector< double > m_VdSedimentInputLocationY
X coordinate (grid CRS) for sediment input event.
int m_nGISSave
The save number for GIS files (can be sequential, or the iteration number)
Definition simulation.h:502
double dExtCRSYToGridY(double const) const
Transforms a Y-axis ordinate in the external CRS to the equivalent Y-axis ordinate in the raster grid...
string m_strOGRSedInputGeometry
GDAL geometry for the sediment input event locations vector file.
string m_strOGRSedInputDriverCode
GDAL code for the sediment input event locations vector file.
string m_strOGRFloodDriverDesc
string m_strOGRFloodDataType
GDAL data type for the flood input locations point or vector file.
string m_strGDALBasementDEMProjection
GDAL projection string for the basement DEM raster file.
unsigned long m_ulIter
The number of the current iteration (time step)
Definition simulation.h:598
double dGridCentroidXToExtCRSX(int const) const
Definition gis_utils.cpp:68
string m_strOGRDWWVDataType
GDAL data type for the deep water wave stations vector file.
double m_dThisIterDiffWaveSetupSurgeRunupWaterLevel
TODO 007 Info needed.
Definition simulation.h:736
vector< double > m_VdFloodLocationY
X coordinate (grid CRS) for total water level flooding.
bool m_bFloodSWLSetupSurgeRunupLine
Are we saving the flood still water level setup surge runup line? TODO 007.
Definition simulation.h:442
Contains CRWCliff definitions.
This file contains global definitions for CoastalME.
int const INT_NODATA
Definition cme.h:476
double const TOLERANCE
Definition cme.h:823
int const VECTOR_PLOT_STORM_SURGE
Definition cme.h:686
int const VECTOR_PLOT_BREAKING_WAVE_HEIGHT
Definition cme.h:670
int const VECTOR_PLOT_POLYGON_NODES
Definition cme.h:681
int const FLOOD_LOCATION_POINT_GEOMETRY
Definition cme.h:598
int const VECTOR_PLOT_NORMALS
Definition cme.h:679
string const VECTOR_WAVE_ANGLE_AND_HEIGHT_NAME
Definition cme.h:1146
int const SEDIMENT_INPUT_EVENT_LOCATION_MAX_LAYER
Definition cme.h:596
string const VECTOR_POLYGON_BOUNDARY_NAME
Definition cme.h:1158
int const SEDIMENT_INPUT_EVENT_LOCATION_VEC
Definition cme.h:595
string const ERR
Definition cme.h:902
int const RTN_ERR_WAVESTATION_LOCATION
Definition cme.h:759
string const VECTOR_BREAKING_WAVE_HEIGHT_NAME
Definition cme.h:1154
int const VECTOR_PLOT_DOWNDRIFT_BOUNDARY
Definition cme.h:676
int const VECTOR_PLOT_COAST_CURVATURE
Definition cme.h:673
string const VECTOR_COAST_NAME
Definition cme.h:1136
string const VECTOR_SHADOW_BOUNDARY_NAME
Definition cme.h:1162
bool bFPIsEqual(const T d1, const T d2, const T dEpsilon)
Definition cme.h:1303
int const VECTOR_PLOT_RUN_UP
Definition cme.h:687
int const VECTOR_PLOT_INVALID_NORMALS
Definition cme.h:677
string const FLOOD_LOCATION_ID
Definition cme.h:932
string const VECTOR_STORM_SURGE_NAME
Definition cme.h:1170
int const FLOOD_LOCATION_VEC
Definition cme.h:600
int const DEEP_WATER_WAVE_STATIONS_VEC
Definition cme.h:592
int const RTN_ERR_SEDIMENT_INPUT_EVENT_LOCATION
Definition cme.h:758
string const VECTOR_CLIFF_EDGE_NAME
Definition cme.h:1138
string const DEEP_WATER_WAVE_STATION_ID
Definition cme.h:930
string const VECTOR_AVG_WAVE_ANGLE_AND_HEIGHT_NAME
Definition cme.h:1147
string const VECTOR_RUN_UP_NAME
Definition cme.h:1172
int const VECTOR_PLOT_COAST
Definition cme.h:672
int const VECTOR_PLOT_FLOOD_LINE
Definition cme.h:688
string const VECTOR_FLOOD_LINE_NAME
Definition cme.h:1174
string const VECTOR_CLIFF_NOTCH_SIZE_NAME
Definition cme.h:1160
int const DEEP_WATER_WAVE_STATIONS_POINT_GEOMETRY
Definition cme.h:594
int const VECTOR_PLOT_CLIFF_NOTCH_SIZE
Definition cme.h:671
int const RTN_ERR_VECTOR_FILE_READ
Definition cme.h:709
string const VECTOR_WAVE_ENERGY_SINCE_COLLAPSE_NAME
Definition cme.h:1150
int const VEC_GEOMETRY_POLYGON
Definition cme.h:588
int const VECTOR_PLOT_WAVE_ENERGY_SINCE_COLLAPSE
Definition cme.h:684
string const WARN
Definition cme.h:903
int const VECTOR_PLOT_WAVE_ANGLE_AND_HEIGHT
Definition cme.h:683
string const VECTOR_DEEP_WATER_WAVE_ANGLE_AND_HEIGHT_NAME
Definition cme.h:1166
int const SEDIMENT_INPUT_EVENT_LOCATION_LINE_GEOMETRY
Definition cme.h:599
string const SEDIMENT_INPUT_EVENT_LOCATION_ID
Definition cme.h:931
int const VECTOR_PLOT_CLIFF_EDGE
Definition cme.h:674
int const VECTOR_PLOT_POLYGON_BOUNDARY
Definition cme.h:680
int const VEC_GEOMETRY_LINE
Definition cme.h:587
int const VECTOR_PLOT_MEAN_WAVE_ENERGY
Definition cme.h:678
int const RTN_OK
Definition cme.h:694
int const VEC_GEOMETRY_POINT
Definition cme.h:586
double const DBL_NODATA
Definition cme.h:834
string const VECTOR_COAST_CURVATURE_NAME
Definition cme.h:1144
int const VECTOR_PLOT_AVG_WAVE_ANGLE_AND_HEIGHT
Definition cme.h:669
int const VECTOR_PLOT_DEEP_WATER_WAVE_ANGLE_AND_HEIGHT
Definition cme.h:675
string const VECTOR_INVALID_NORMALS_NAME
Definition cme.h:1142
int const SEDIMENT_INPUT_EVENT_LOCATION_POINT_GEOMETRY
Definition cme.h:597
int const VECTOR_PLOT_WAVE_SETUP
Definition cme.h:685
int const LF_CAT_CLIFF
Definition cme.h:543
int const VEC_GEOMETRY_OTHER
Definition cme.h:589
int const DEEP_WATER_WAVE_STATIONS_MAX_LAYER
Definition cme.h:593
int const FLOOD_LOCATION_MAX_LAYER
Definition cme.h:601
string const VECTOR_POLYGON_NODE_NAME
Definition cme.h:1156
string const VECTOR_DOWNDRIFT_BOUNDARY_NAME
Definition cme.h:1164
string const VECTOR_NORMALS_NAME
Definition cme.h:1140
string const VECTOR_WAVE_SETUP_NAME
Definition cme.h:1168
int const VECTOR_PLOT_SHADOW_BOUNDARY
Definition cme.h:682
string const VECTOR_MEAN_WAVE_ENERGY_NAME
Definition cme.h:1152
char const SPACE
Definition cme.h:453
Contains CRWCoast definitions.
Contains CSimulation definitions.