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