ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ShpDBFFields.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #ifdef CV_SHP_SUPPORT
9 
10 #include "ShpDBFFields.h"
11 
12 // system
13 #include <assert.h>
14 
15 bool IntegerDBFField::save(DBFHandle handle, int fieldIndex) const {
16  if (!handle || fieldIndex < 0) {
17  assert(false);
18  return false;
19  }
20 
21  for (size_t i = 0; i < values.size(); ++i)
22  DBFWriteIntegerAttribute(handle, static_cast<int>(i), fieldIndex,
23  values[i]);
24 
25  return true;
26 }
27 
28 bool DoubleDBFField::save(DBFHandle handle, int fieldIndex) const {
29  if (!handle || fieldIndex < 0) {
30  assert(false);
31  return false;
32  }
33 
34  for (size_t i = 0; i < values.size(); ++i)
35  DBFWriteDoubleAttribute(handle, static_cast<int>(i), fieldIndex,
36  values[i]);
37 
38  return true;
39 }
40 
41 bool DoubleDBFField3D::save(DBFHandle handle,
42  int xFieldIndex,
43  int yFieldIndex,
44  int zFieldIndex) const {
45  if (!handle || xFieldIndex < 0 || yFieldIndex < 0 || zFieldIndex < 0) {
46  assert(false);
47  return false;
48  }
49 
50  for (size_t i = 0; i < values.size(); ++i) {
51  DBFWriteDoubleAttribute(handle, static_cast<int>(i), xFieldIndex,
52  values[i].x);
53  DBFWriteDoubleAttribute(handle, static_cast<int>(i), yFieldIndex,
54  values[i].y);
55  DBFWriteDoubleAttribute(handle, static_cast<int>(i), zFieldIndex,
56  values[i].z);
57  }
58 
59  return true;
60 }
61 
62 #endif // CV_SHP_SUPPORT
int DBFWriteIntegerAttribute(DBFHandle psDBF, int iRecord, int iField, int nValue)
Definition: dbfopen.c:1654
int DBFWriteDoubleAttribute(DBFHandle psDBF, int iRecord, int iField, double dValue)
Definition: dbfopen.c:1640
normal_z y
normal_z x
normal_z z