forked from OpenNavigationSurface/BAG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_bag_simplelayerdescriptor.cpp
595 lines (519 loc) · 27.1 KB
/
test_bag_simplelayerdescriptor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
#include "test_utils.h"
#include <bag_dataset.h>
#include <bag_descriptor.h>
#include <bag_layer.h>
#include <bag_metadata.h>
#include <bag_simplelayerdescriptor.h>
#include <bag_types.h>
#include <catch2/catch_all.hpp>
#include <string>
using BAG::Dataset;
using BAG::Layer;
using BAG::Metadata;
using BAG::SimpleLayerDescriptor;
namespace {
const std::string kMetadataXML{R"(<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gmi:MI_Metadata xmlns:gmi="http://www.isotc211.org/2005/gmi"
xmlns:bag="http://www.opennavsurf.org/schema/bag"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opennavsurf.org/schema/bag http://www.opennavsurf.org/schema/bag/bag.xsd">
<gmd:fileIdentifier>
<gco:CharacterString>Unique Identifier</gco:CharacterString>
</gmd:fileIdentifier>
<gmd:language>
<gmd:LanguageCode codeList="http://www.loc.gov/standards/iso639-2/" codeListValue="eng">eng</gmd:LanguageCode>
</gmd:language>
<gmd:characterSet>
<gmd:MD_CharacterSetCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode" codeListValue="utf8">utf8</gmd:MD_CharacterSetCode>
</gmd:characterSet>
<gmd:hierarchyLevel>
<gmd:MD_ScopeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset">dataset</gmd:MD_ScopeCode>
</gmd:hierarchyLevel>
<gmd:contact>
<gmd:CI_ResponsibleParty>
<gmd:individualName>
<gco:CharacterString>Name of individual responsible for the BAG</gco:CharacterString>
</gmd:individualName>
<gmd:role>
<gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue="pointOfContact">pointOfContact</gmd:CI_RoleCode>
</gmd:role>
</gmd:CI_ResponsibleParty>
</gmd:contact>
<gmd:dateStamp>
<gco:Date>2012-01-27</gco:Date>
</gmd:dateStamp>
<gmd:metadataStandardName>
<gco:CharacterString>ISO 19115</gco:CharacterString>
</gmd:metadataStandardName>
<gmd:metadataStandardVersion>
<gco:CharacterString>2003/Cor.1:2006</gco:CharacterString>
</gmd:metadataStandardVersion>
<gmd:spatialRepresentationInfo>
<gmd:MD_Georectified>
<gmd:numberOfDimensions>
<gco:Integer>2</gco:Integer>
</gmd:numberOfDimensions>
<gmd:axisDimensionProperties>
<gmd:MD_Dimension>
<gmd:dimensionName>
<gmd:MD_DimensionNameTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_DimensionNameTypeCode" codeListValue="row">row</gmd:MD_DimensionNameTypeCode>
</gmd:dimensionName>
<gmd:dimensionSize>
<gco:Integer>100</gco:Integer>
</gmd:dimensionSize>
<gmd:resolution>
<gco:Measure uom="Metres">10</gco:Measure>
</gmd:resolution>
</gmd:MD_Dimension>
</gmd:axisDimensionProperties>
<gmd:axisDimensionProperties>
<gmd:MD_Dimension>
<gmd:dimensionName>
<gmd:MD_DimensionNameTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_DimensionNameTypeCode" codeListValue="column">column</gmd:MD_DimensionNameTypeCode>
</gmd:dimensionName>
<gmd:dimensionSize>
<gco:Integer>100</gco:Integer>
</gmd:dimensionSize>
<gmd:resolution>
<gco:Measure uom="Metres">10</gco:Measure>
</gmd:resolution>
</gmd:MD_Dimension>
</gmd:axisDimensionProperties>
<gmd:cellGeometry>
<gmd:MD_CellGeometryCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_CellGeometryCode" codeListValue="point">point</gmd:MD_CellGeometryCode>
</gmd:cellGeometry>
<gmd:transformationParameterAvailability>
<gco:Boolean>1</gco:Boolean>
</gmd:transformationParameterAvailability>
<gmd:checkPointAvailability>
<gco:Boolean>0</gco:Boolean>
</gmd:checkPointAvailability>
<gmd:cornerPoints>
<gml:Point gml:id="id1">
<gml:coordinates cs="," decimal="." ts=" ">687910.000000,5554620.000000 691590.000000,5562100.000000</gml:coordinates>
</gml:Point>
</gmd:cornerPoints>
<gmd:pointInPixel>
<gmd:MD_PixelOrientationCode>center</gmd:MD_PixelOrientationCode>
</gmd:pointInPixel>
</gmd:MD_Georectified>
</gmd:spatialRepresentationInfo>
<gmd:referenceSystemInfo>
<gmd:MD_ReferenceSystem>
<gmd:referenceSystemIdentifier>
<gmd:RS_Identifier>
<gmd:code>
<gco:CharacterString>PROJCS["UTM-19N-Nad83",
GEOGCS["unnamed",
DATUM["North_American_Datum_1983",
SPHEROID["North_American_Datum_1983",6378137,298.2572201434276],
TOWGS84[0,0,0,0,0,0,0]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
EXTENSION["Scaler","0,0,0,0.02,0.02,0.001"],
EXTENSION["Source","CARIS"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-69],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1]]</gco:CharacterString>
</gmd:code>
<gmd:codeSpace>
<gco:CharacterString>WKT</gco:CharacterString>
</gmd:codeSpace>
</gmd:RS_Identifier>
</gmd:referenceSystemIdentifier>
</gmd:MD_ReferenceSystem>
</gmd:referenceSystemInfo>
<gmd:referenceSystemInfo>
<gmd:MD_ReferenceSystem>
<gmd:referenceSystemIdentifier>
<gmd:RS_Identifier>
<gmd:code>
<gco:CharacterString>VERT_CS["Alicante height",
VERT_DATUM["Alicante",2000]]</gco:CharacterString>
</gmd:code>
<gmd:codeSpace>
<gco:CharacterString>WKT</gco:CharacterString>
</gmd:codeSpace>
</gmd:RS_Identifier>
</gmd:referenceSystemIdentifier>
</gmd:MD_ReferenceSystem>
</gmd:referenceSystemInfo>
<gmd:identificationInfo>
<bag:BAG_DataIdentification>
<gmd:citation>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>Name of dataset input</gco:CharacterString>
</gmd:title>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:Date>2008-10-21</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation">creation</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
<gmd:citedResponsibleParty>
<gmd:CI_ResponsibleParty>
<gmd:individualName>
<gco:CharacterString>Person responsible for input data</gco:CharacterString>
</gmd:individualName>
<gmd:role>
<gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue="originator">originator</gmd:CI_RoleCode>
</gmd:role>
</gmd:CI_ResponsibleParty>
</gmd:citedResponsibleParty>
</gmd:CI_Citation>
</gmd:citation>
<gmd:abstract>
<gco:CharacterString>Sample Metadata</gco:CharacterString>
</gmd:abstract>
<gmd:status>
<gmd:MD_ProgressCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ProgressCode" codeListValue="completed">completed</gmd:MD_ProgressCode>
</gmd:status>
<gmd:spatialRepresentationType>
<gmd:MD_SpatialRepresentationTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_SpatialRepresentationTypeCode" codeListValue="grid">grid</gmd:MD_SpatialRepresentationTypeCode>
</gmd:spatialRepresentationType>
<gmd:language>
<gmd:LanguageCode codeList="http://www.loc.gov/standards/iso639-2/" codeListValue="eng">eng</gmd:LanguageCode>
</gmd:language>
<gmd:characterSet>
<gmd:MD_CharacterSetCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode" codeListValue="utf8">utf8</gmd:MD_CharacterSetCode>
</gmd:characterSet>
<gmd:topicCategory>
<gmd:MD_TopicCategoryCode>elevation</gmd:MD_TopicCategoryCode>
</gmd:topicCategory>
<gmd:extent>
<gmd:EX_Extent>
<gmd:geographicElement>
<gmd:EX_GeographicBoundingBox>
<gmd:westBoundLongitude>
<gco:Decimal>-66.371629</gco:Decimal>
</gmd:westBoundLongitude>
<gmd:eastBoundLongitude>
<gco:Decimal>-66.316454</gco:Decimal>
</gmd:eastBoundLongitude>
<gmd:southBoundLatitude>
<gco:Decimal>50.114053</gco:Decimal>
</gmd:southBoundLatitude>
<gmd:northBoundLatitude>
<gco:Decimal>50.180077</gco:Decimal>
</gmd:northBoundLatitude>
</gmd:EX_GeographicBoundingBox>
</gmd:geographicElement>
</gmd:EX_Extent>
</gmd:extent>
<bag:verticalUncertaintyType>
<bag:BAG_VertUncertCode codeList="http://www.opennavsurf.org/schema/bag/bagCodelists.xml#BAG_VertUncertCode" codeListValue="rawStdDev">rawStdDev</bag:BAG_VertUncertCode>
</bag:verticalUncertaintyType>
<bag:depthCorrectionType>
<bag:BAG_DepthCorrectCode codeList="http://www.opennavsurf.org/schema/bag/bagCodelists.xml#BAG_DepthCorrectCode" codeListValue="trueDepth">trueDepth</bag:BAG_DepthCorrectCode>
</bag:depthCorrectionType>
<bag:elevationSolutionGroupType>
<bag:BAG_OptGroupCode codeList="http://www.opennavsurf.org/schema/bag/bagCodelists.xml#BAG_OptGroupCode" codeListValue="cube">cube</bag:BAG_OptGroupCode>
</bag:elevationSolutionGroupType>
<bag:nodeGroupType>
<bag:BAG_OptGroupCode codeList="http://www.opennavsurf.org/schema/bag/bagCodelists.xml#BAG_OptGroupCode" codeListValue="product">product</bag:BAG_OptGroupCode>
</bag:nodeGroupType>
</bag:BAG_DataIdentification>
</gmd:identificationInfo>
<gmd:dataQualityInfo>
<gmd:DQ_DataQuality>
<gmd:scope>
<gmd:DQ_Scope>
<gmd:level>
<gmd:MD_ScopeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset">dataset</gmd:MD_ScopeCode>
</gmd:level>
</gmd:DQ_Scope>
</gmd:scope>
<gmd:lineage>
<gmd:LI_Lineage>
<gmd:processStep>
<bag:BAG_ProcessStep>
<gmd:description>
<gco:CharacterString>List to be determined by WG. I.e. Product Creation</gco:CharacterString>
</gmd:description>
<gmd:dateTime>
<gco:DateTime>2008-10-21T12:21:53</gco:DateTime>
</gmd:dateTime>
<gmd:processor>
<gmd:CI_ResponsibleParty>
<gmd:individualName>
<gco:CharacterString>Name of the processor</gco:CharacterString>
</gmd:individualName>
<gmd:role>
<gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue="processor">processor</gmd:CI_RoleCode>
</gmd:role>
</gmd:CI_ResponsibleParty>
</gmd:processor>
<gmd:source>
<gmd:LI_Source>
<gmd:description>
<gco:CharacterString>Source</gco:CharacterString>
</gmd:description>
<gmd:sourceCitation>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>Name of dataset input</gco:CharacterString>
</gmd:title>
<gmd:date>
<gmd:CI_Date>
<gmd:date gco:nilReason="unknown"/>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation">creation</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</gmd:CI_Citation>
</gmd:sourceCitation>
</gmd:LI_Source>
</gmd:source>
<bag:trackingId>
<gco:CharacterString>1</gco:CharacterString>
</bag:trackingId>
</bag:BAG_ProcessStep>
</gmd:processStep>
</gmd:LI_Lineage>
</gmd:lineage>
</gmd:DQ_DataQuality>
</gmd:dataQualityInfo>
<gmd:metadataConstraints>
<gmd:MD_LegalConstraints>
<gmd:useConstraints>
<gmd:MD_RestrictionCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode" codeListValue="otherRestrictions">otherRestrictions</gmd:MD_RestrictionCode>
</gmd:useConstraints>
<gmd:otherConstraints>
<gco:CharacterString>some other constraints</gco:CharacterString>
</gmd:otherConstraints>
</gmd:MD_LegalConstraints>
</gmd:metadataConstraints>
<gmd:metadataConstraints>
<gmd:MD_SecurityConstraints>
<gmd:classification>
<gmd:MD_ClassificationCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ClassificationCode" codeListValue="unclassified">unclassified</gmd:MD_ClassificationCode>
</gmd:classification>
<gmd:userNote>
<gco:CharacterString>some user node</gco:CharacterString>
</gmd:userNote>
</gmd:MD_SecurityConstraints>
</gmd:metadataConstraints>
</gmi:MI_Metadata>
)"};
} // namespace
// NOTE The base class is also tested here.
// static std::shared_ptr<SimpleLayerDescriptor> create(LayerType type) noexcept;
TEST_CASE("test layer descriptor creation",
"[simplelayerdescriptor][create][getLayerType]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kExpectedChunkSize = 100;
constexpr unsigned int kExpectedCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDataset);
UNSCOPED_INFO("Check that creating a simple layer descriptor returns something.");
auto pDescriptor = SimpleLayerDescriptor::create(*pDataset, Elevation,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
UNSCOPED_INFO("Check that the layer descriptor type matches that was created.");
CHECK(pDescriptor->getLayerType() == Elevation);
UNSCOPED_INFO("Check the chunk size is read properly.");
CHECK(pDescriptor->getChunkSize() == kExpectedChunkSize);
UNSCOPED_INFO("Check the compression level is read properly.");
CHECK(pDescriptor->getCompressionLevel() == kExpectedCompressionLevel);
}
// const std::string& getName() const & noexcept;
// SimpleLayerDescriptor& setName(std::string inName) & noexcept;
TEST_CASE("test layer descriptor get/set name",
"[simplelayerdescriptor][getName][setName]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kExpectedChunkSize = 100;
constexpr unsigned int kExpectedCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDataset);
UNSCOPED_INFO("Check that creating a simple layer descriptor returns something.");
const auto pDescriptor = SimpleLayerDescriptor::create(*pDataset, Elevation,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
const std::string kExpectedName{"Expected Name"};
UNSCOPED_INFO("Verify setting the name of a layer descriptor does not throw.");
REQUIRE_NOTHROW(pDescriptor->setName(kExpectedName));
UNSCOPED_INFO("Verify the new name of Elevation is what it was set to.");
CHECK(pDescriptor->getName() == kExpectedName);
}
// DataType getDataType() const noexcept;
TEST_CASE("test layer descriptor get data type",
"[simplelayerdescriptor][getDataType]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kExpectedChunkSize = 100;
constexpr unsigned int kExpectedCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDataset);
UNSCOPED_INFO("Check that creating a simple layer descriptor returns something.");
auto pDescriptor = SimpleLayerDescriptor::create(*pDataset, Elevation,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
UNSCOPED_INFO("Verify the data type of an Elevation layer descriptor is correct.");
CHECK(pDescriptor->getDataType() == Layer::getDataType(Elevation));
pDescriptor = SimpleLayerDescriptor::create(*pDataset, Num_Hypotheses,
kExpectedChunkSize, kExpectedCompressionLevel);
UNSCOPED_INFO("Verify the data type of an Num_Hypotheses layer descriptor is correct.");
CHECK(pDescriptor->getDataType() == Layer::getDataType(Num_Hypotheses));
}
// LayerType getLayerType() const noexcept;
TEST_CASE("test layer descriptor get layer type",
"[simplelayerdescriptor][getLayerType]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kExpectedChunkSize = 100;
constexpr unsigned int kExpectedCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDataset);
UNSCOPED_INFO("Check that creating a simple layer descriptor returns something.");
auto pDescriptor = SimpleLayerDescriptor::create(*pDataset, Elevation,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
UNSCOPED_INFO("Verify the layer type of an Elevation layer descriptor is correct.");
CHECK(pDescriptor->getLayerType() == Elevation);
pDescriptor = SimpleLayerDescriptor::create(*pDataset, Std_Dev,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
UNSCOPED_INFO("Verify the layer type of an Std_Dev layer descriptor is correct.");
CHECK(pDescriptor->getDataType() == Layer::getDataType(Std_Dev));
}
// std::tuple<double, double> getMinMax() const noexcept;
// SimpleLayerDescriptor& setMinMax(std::tuple<double, double> inMinMax) & noexcept;
TEST_CASE("test layer descriptor get/set min max",
"[simplelayerdescriptor][getMinMax][setMinMax]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kExpectedChunkSize = 100;
constexpr unsigned int kExpectedCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDataset);
UNSCOPED_INFO("Check that creating a simple layer descriptor returns something.");
auto pDescriptor = SimpleLayerDescriptor::create(*pDataset, Elevation,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
UNSCOPED_INFO("Verify setting min max does not throw.");
const float kExpectedMin = 1.2345f;
const float kExpectedMax = 9876.54321f;
REQUIRE_NOTHROW(pDescriptor->setMinMax(kExpectedMin, kExpectedMax));
UNSCOPED_INFO("Verify the set min max value was set correctly.");
const auto actualMinMax = pDescriptor->getMinMax();
CHECK(actualMinMax == std::make_tuple(kExpectedMin, kExpectedMax));
}
// const std::string& getInternalPath() const & noexcept;
TEST_CASE("test layer descriptor get internal path",
"[simplelayerdescriptor][getInternalPath]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kExpectedChunkSize = 100;
constexpr unsigned int kExpectedCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDataset);
UNSCOPED_INFO("Check that creating a simple layer descriptor returns something.");
auto pDescriptor = SimpleLayerDescriptor::create(*pDataset,Elevation,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
UNSCOPED_INFO("Verify Elevation internal path is as expected.");
REQUIRE_NOTHROW(pDescriptor->getInternalPath());
CHECK(pDescriptor->getInternalPath() == Layer::getInternalPath(Elevation));
pDescriptor = SimpleLayerDescriptor::create(*pDataset, Uncertainty,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
UNSCOPED_INFO("Verify Uncertainty internal path is as expected.");
REQUIRE_NOTHROW(pDescriptor->getInternalPath());
CHECK(pDescriptor->getInternalPath() == Layer::getInternalPath(Uncertainty));
}
// uint8_t getElementSize() const noexcept override;
TEST_CASE("test layer descriptor get element size",
"[simplelayerdescriptor][getElementSize]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kExpectedChunkSize = 100;
constexpr unsigned int kExpectedCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDataset);
UNSCOPED_INFO("Check that creating a simple layer descriptor returns something.");
auto pDescriptor = SimpleLayerDescriptor::create(*pDataset, Elevation,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
UNSCOPED_INFO("Verify Elevation element size is as expected.");
REQUIRE_NOTHROW(pDescriptor->getElementSize());
CHECK(pDescriptor->getElementSize() ==
Layer::getElementSize(Layer::getDataType(Elevation)));
}
// uint64_t getChunkSize() const noexcept;
TEST_CASE("test descriptor get chunk size",
"[simplelayerdescriptor][getChunkSize]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kExpectedChunkSize = 100;
constexpr unsigned int kExpectedCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDataset);
UNSCOPED_INFO("Check that creating a simple layer descriptor returns something.");
auto pDescriptor = SimpleLayerDescriptor::create(*pDataset, Elevation,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
UNSCOPED_INFO("Verify getting the chunk size does not throw.");
REQUIRE_NOTHROW(pDescriptor->getChunkSize());
UNSCOPED_INFO("Verify getting the chunk size matches the expected.");
CHECK(pDescriptor->getChunkSize() == kExpectedChunkSize);
}
// unsigned int getCompressionLevel() const noexcept;
TEST_CASE("test descriptor get compression level",
"[simplelayerdescriptor][getCompressionLevel]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kExpectedChunkSize = 100;
constexpr unsigned int kExpectedCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDataset);
UNSCOPED_INFO("Check that creating a simple layer descriptor returns something.");
auto pDescriptor = SimpleLayerDescriptor::create(*pDataset, Elevation,
kExpectedChunkSize, kExpectedCompressionLevel);
REQUIRE(pDescriptor);
UNSCOPED_INFO("Verify getting the compression level does not throw.");
REQUIRE_NOTHROW(pDescriptor->getCompressionLevel());
UNSCOPED_INFO("Verify getting the compression level matches the expected.");
CHECK(pDescriptor->getCompressionLevel() == kExpectedCompressionLevel);
}