forked from OpenNavigationSurface/BAG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_bag_vrnodedescriptor.cpp
431 lines (399 loc) · 21.1 KB
/
test_bag_vrnodedescriptor.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
#include "test_utils.h"
#include <bag_dataset.h>
#include <bag_metadata.h>
#include <bag_vrnode.h>
#include <bag_vrnodedescriptor.h>
#include <catch2/catch_all.hpp>
using BAG::Dataset;
using BAG::Metadata;
using BAG::VRNodeDescriptor;
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
// std::tuple<float, float> getMinMaxHypStrength() const noexcept;
// void setMinMaxHypStrength(float minHypStrength, float maxHypStrength) noexcept;
TEST_CASE("test vr node descriptor min/max hyp strength",
"[vrnodedescriptor][getMinMaxHypStrength][setMinMaxHypStrength]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kChunkSize = 100;
constexpr unsigned int kCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kChunkSize, kCompressionLevel);
REQUIRE(pDataset);
pDataset->createVR(kChunkSize, kCompressionLevel, true);
auto pVrNode = pDataset->getVRNode();
REQUIRE(pVrNode);
auto pVrNodeDescriptor = std::dynamic_pointer_cast<VRNodeDescriptor>(
pVrNode->getDescriptor());
REQUIRE(pVrNodeDescriptor);
// Set some expected minimum hyp strength values and verify they are set.
UNSCOPED_INFO("Verify setting the min/max hyp strength does not throw.");
constexpr float kExpectedMinHypStrength = 1.1f;
constexpr float kExpectedMaxHypStrength = 2.2f;
CHECK_NOTHROW(pVrNodeDescriptor->setMinMaxHypStrength(kExpectedMinHypStrength,
kExpectedMaxHypStrength));
UNSCOPED_INFO("Verify the min/max hyp strength is expected.");
const auto minMaxHypStrength= pVrNodeDescriptor->getMinMaxHypStrength();
CHECK(minMaxHypStrength == std::tuple<float, float>(kExpectedMinHypStrength,
kExpectedMaxHypStrength));
}
// std::tuple<uint32_t, uint32_t> getMinNumHypotheses() const noexcept;
// void setMinMaxNumHypotheses(uint32_t minNumHypotheses, uint32_t maxNumHypotheses) noexcept;
TEST_CASE("test vr node descriptor min/max num hypotheses",
"[vrnodedescriptor][getMinMaxNumHypotheses][setMinMaxNumHypotheses]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kChunkSize = 100;
constexpr unsigned int kCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kChunkSize, kCompressionLevel);
REQUIRE(pDataset);
pDataset->createVR(kChunkSize, kCompressionLevel, true);
auto pVrNode = pDataset->getVRNode();
REQUIRE(pVrNode);
auto pVrNodeDescriptor = std::dynamic_pointer_cast<VRNodeDescriptor>(
pVrNode->getDescriptor());
REQUIRE(pVrNodeDescriptor);
// Set some expected min/max num hypotheses values and verify they are set.
UNSCOPED_INFO("Verify setting the min/max num hypotheses does not throw.");
constexpr uint32_t kExpectedMinNumHypotheses = 10;
constexpr uint32_t kExpectedMaxNumHypotheses = 20;
CHECK_NOTHROW(pVrNodeDescriptor->setMinMaxNumHypotheses(
kExpectedMinNumHypotheses, kExpectedMaxNumHypotheses));
UNSCOPED_INFO("Verify the min/max num hypotheses is expected.");
const auto minMaxNumHypotheses =
pVrNodeDescriptor->getMinMaxNumHypotheses();
CHECK(minMaxNumHypotheses == std::tuple<uint32_t, uint32_t>(
kExpectedMinNumHypotheses, kExpectedMaxNumHypotheses));
}
// std::tuple<uint32_t, uint32_t> getMinMaxNSamples() const noexcept;
// void setMinMaxNSamples(uint32_t minNSamples, uint32_t maxNSamples) noexcept;
TEST_CASE("test vr node descriptor min/max n samples",
"[vrnodedescriptor][getMinMaxNSamples][setMinMaxNSamples]")
{
TestUtils::RandomFileGuard tmpBagFile;
Metadata metadata;
metadata.loadFromBuffer(kMetadataXML);
constexpr uint64_t kChunkSize = 100;
constexpr unsigned int kCompressionLevel = 6;
auto pDataset = Dataset::create(tmpBagFile, std::move(metadata),
kChunkSize, kCompressionLevel);
REQUIRE(pDataset);
pDataset->createVR(kChunkSize, kCompressionLevel, true);
auto pVrNode = pDataset->getVRNode();
REQUIRE(pVrNode);
auto pVrNodeDescriptor = std::dynamic_pointer_cast<VRNodeDescriptor>(
pVrNode->getDescriptor());
REQUIRE(pVrNodeDescriptor);
// Set some expected min/max n samples values and verify they are set.
UNSCOPED_INFO("Verify setting the min/max n samples does not throw.");
constexpr uint32_t kExpectedMinNSamples = 100;
constexpr uint32_t kExpectedMaxNSamples = 200;
CHECK_NOTHROW(pVrNodeDescriptor->setMinMaxNSamples(
kExpectedMinNSamples, kExpectedMaxNSamples));
UNSCOPED_INFO("Verify the min/max n samples is expected.");
const auto minMaxNSamples =
pVrNodeDescriptor->getMinMaxNSamples();
CHECK(minMaxNSamples == std::tuple<uint32_t, uint32_t>(kExpectedMinNSamples,
kExpectedMaxNSamples));
}