| 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Project: S-57 Translator |
| 4 | * Purpose: Implements S57Writer class. |
| 5 | * Author: Frank Warmerdam, [email protected] |
| 6 | * |
| 7 | ****************************************************************************** |
| 8 | * Copyright (c) 2003, Frank Warmerdam |
| 9 | * Copyright (c) 2013, Even Rouault <even dot rouault at spatialys.com> |
| 10 | * |
| 11 | * SPDX-License-Identifier: MIT |
| 12 | ****************************************************************************/ |
| 13 | |
| 14 | #include "cpl_conv.h"cxx . . $ `<file>/port/cpl_conv.h`/ |
| 15 | #include "cpl_string.h"cxx . . $ `<file>/port/cpl_string.h`/ |
| 16 | #include "ogr_api.h"cxx . . $ `<file>/ogr/ogr_api.h`/ |
| 17 | #include "s57.h"cxx . . $ `<file>/ogr/ogrsf_frmts/s57/s57.h`/ |
| 18 | |
| 19 | /************************************************************************/ |
| 20 | /* S57Writer() */ |
| 21 | /************************************************************************/ |
| 22 | |
| 23 | S57Writercxx . . $ S57Writer#::S57Writercxx . . $ S57Writer#S57Writer(49f6e7a06ebc5aa8).() |
| 24 | : poModulecxx . . $ S57Writer#poModule.(nullptr), nNext0001Indexcxx . . $ S57Writer#nNext0001Index.(0), poRegistrarcxx . . $ S57Writer#poRegistrar.(nullptr), |
| 25 | poClassContentExplorercxx . . $ S57Writer#poClassContentExplorer.(nullptr), m_nCOMFcxx . . $ S57Writer#m_nCOMF.(nDEFAULT_COMFcxx . . $ S57Writer#nDEFAULT_COMF.), |
| 26 | m_nSOMFcxx . . $ S57Writer#m_nSOMF.(nDEFAULT_SOMFcxx . . $ S57Writer#nDEFAULT_SOMF.) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | /************************************************************************/ |
| 31 | /* ~S57Writer() */ |
| 32 | /************************************************************************/ |
| 33 | |
| 34 | S57Writercxx . . $ S57Writer#::~cxx . . $ S57Writer#`~S57Writer`(ced63f7c635d850d).S57Writercxx . . $ S57Writer#() |
| 35 | |
| 36 | { |
| 37 | Closecxx . . $ S57Writer#Close(c9857a73d68e59ba).(); |
| 38 | } |
| 39 | |
| 40 | /************************************************************************/ |
| 41 | /* Close() */ |
| 42 | /* */ |
| 43 | /* Close the current S-57 dataset. */ |
| 44 | /************************************************************************/ |
| 45 | |
| 46 | bool S57Writercxx . . $ S57Writer#::Closecxx . . $ S57Writer#Close(c9857a73d68e59ba).() |
| 47 | |
| 48 | { |
| 49 | if (poModulecxx . . $ S57Writer#poModule. != nullptr) |
| 50 | { |
| 51 | poModulecxx . . $ S57Writer#poModule.->Closecxx . . $ DDFModule#Close(49f6e7a06ebc5aa8).(); |
| 52 | delete poModulecxx . . $ S57Writer#poModule.; |
| 53 | poModulecxx . . $ S57Writer#poModule. = nullptr; |
| 54 | } |
| 55 | return true; |
| 56 | } |
| 57 | |
| 58 | /************************************************************************/ |
| 59 | /* CreateS57File() */ |
| 60 | /* */ |
| 61 | /* Create a new output ISO8211 file with all the S-57 data */ |
| 62 | /* definitions. */ |
| 63 | /************************************************************************/ |
| 64 | |
| 65 | bool S57Writercxx . . $ S57Writer#::CreateS57Filecxx . . $ S57Writer#CreateS57File(c5f7da30cbc0f4e9).(const char *pszFilename) |
| 66 | |
| 67 | { |
| 68 | // TODO: What was oModule for if it was unused? |
| 69 | // DDFModule oModule; |
| 70 | Closecxx . . $ S57Writer#Close(c9857a73d68e59ba).(); |
| 71 | |
| 72 | nNext0001Indexcxx . . $ S57Writer#nNext0001Index. = 1; |
| 73 | |
| 74 | /* -------------------------------------------------------------------- */ |
| 75 | /* Create and initialize new module. */ |
| 76 | /* -------------------------------------------------------------------- */ |
| 77 | poModulecxx . . $ S57Writer#poModule. = new DDFModulecxx . . $ DDFModule#(); |
| 78 | poModulecxx . . $ S57Writer#poModule.->Initializecxx . . $ DDFModule#Initialize(997fb2c548f24c92).(); |
| 79 | |
| 80 | /* -------------------------------------------------------------------- */ |
| 81 | /* Create the '0000' definition. */ |
| 82 | /* -------------------------------------------------------------------- */ |
| 83 | auto poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 84 | |
| 85 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("0000", "", |
| 86 | "0001DSIDDSIDDSSI0001DSPM0001VRIDVRIDATTVVRIDVRPCVRID" |
| 87 | "VRPTVRIDSGCCVRIDSG2DVRIDSG3D0001FRIDFRIDFOIDFRIDATTF" |
| 88 | "FRIDNATFFRIDFFPCFRIDFFPTFRIDFSPCFRIDFSPT", |
| 89 | dsc_elementarycxx . . $ dsc_elementary., dtc_char_stringcxx . . $ dtc_char_string.); |
| 90 | |
| 91 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 92 | |
| 93 | /* -------------------------------------------------------------------- */ |
| 94 | /* Create the '0001' definition. */ |
| 95 | /* -------------------------------------------------------------------- */ |
| 96 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 97 | |
| 98 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("0001", "ISO 8211 Record Identifier", "", dsc_elementarycxx . . $ dsc_elementary., |
| 99 | dtc_bit_stringcxx . . $ dtc_bit_string., "(b12)"); |
| 100 | |
| 101 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 102 | |
| 103 | /* -------------------------------------------------------------------- */ |
| 104 | /* Create the DSID field. */ |
| 105 | /* -------------------------------------------------------------------- */ |
| 106 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 107 | |
| 108 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("DSID", "Data set identification field", "", dsc_vectorcxx . . $ dsc_vector., |
| 109 | dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 110 | |
| 111 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RCNM", "b11"); |
| 112 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RCID", "b14"); |
| 113 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("EXPP", "b11"); |
| 114 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("INTU", "b11"); |
| 115 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("DSNM", "A"); |
| 116 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("EDTN", "A"); |
| 117 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("UPDN", "A"); |
| 118 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("UADT", "A(8)"); |
| 119 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("ISDT", "A(8)"); |
| 120 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("STED", "R(4)"); |
| 121 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("PRSP", "b11"); |
| 122 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("PSDN", "A"); |
| 123 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("PRED", "A"); |
| 124 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("PROF", "b11"); |
| 125 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("AGEN", "b12"); |
| 126 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("COMT", "A"); |
| 127 | |
| 128 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 129 | |
| 130 | /* -------------------------------------------------------------------- */ |
| 131 | /* Create the DSSI field. */ |
| 132 | /* -------------------------------------------------------------------- */ |
| 133 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 134 | |
| 135 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("DSSI", "Data set structure information field", "", |
| 136 | dsc_vectorcxx . . $ dsc_vector., dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 137 | |
| 138 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("DSTR", "b11"); |
| 139 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("AALL", "b11"); |
| 140 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NALL", "b11"); |
| 141 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NOMR", "b14"); |
| 142 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NOCR", "b14"); |
| 143 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NOGR", "b14"); |
| 144 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NOLR", "b14"); |
| 145 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NOIN", "b14"); |
| 146 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NOCN", "b14"); |
| 147 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NOED", "b14"); |
| 148 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NOFA", "b14"); |
| 149 | |
| 150 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 151 | |
| 152 | /* -------------------------------------------------------------------- */ |
| 153 | /* Create the DSPM field. */ |
| 154 | /* -------------------------------------------------------------------- */ |
| 155 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 156 | |
| 157 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("DSPM", "Data set parameter field", "", dsc_vectorcxx . . $ dsc_vector., |
| 158 | dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 159 | |
| 160 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RCNM", "b11"); |
| 161 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RCID", "b14"); |
| 162 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("HDAT", "b11"); |
| 163 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("VDAT", "b11"); |
| 164 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("SDAT", "b11"); |
| 165 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("CSCL", "b14"); |
| 166 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("DUNI", "b11"); |
| 167 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("HUNI", "b11"); |
| 168 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("PUNI", "b11"); |
| 169 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("COUN", "b11"); |
| 170 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("COMF", "b14"); |
| 171 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("SOMF", "b14"); |
| 172 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("COMT", "A"); |
| 173 | |
| 174 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 175 | |
| 176 | /* -------------------------------------------------------------------- */ |
| 177 | /* Create the VRID field. */ |
| 178 | /* -------------------------------------------------------------------- */ |
| 179 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 180 | |
| 181 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("VRID", "Vector record identifier field", "", dsc_vectorcxx . . $ dsc_vector., |
| 182 | dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 183 | |
| 184 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RCNM", "b11"); |
| 185 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RCID", "b14"); |
| 186 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RVER", "b12"); |
| 187 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RUIN", "b11"); |
| 188 | |
| 189 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 190 | |
| 191 | /* -------------------------------------------------------------------- */ |
| 192 | /* Create the VRPC field. */ |
| 193 | /* -------------------------------------------------------------------- */ |
| 194 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 195 | |
| 196 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("VRPC", "Vector Record Pointer Control field", "", |
| 197 | dsc_vectorcxx . . $ dsc_vector., dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 198 | |
| 199 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("VPUI", "b11"); |
| 200 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("VPIX", "b12"); |
| 201 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NVPT", "b12"); |
| 202 | |
| 203 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 204 | |
| 205 | /* -------------------------------------------------------------------- */ |
| 206 | /* Create the VRPT field. */ |
| 207 | /* -------------------------------------------------------------------- */ |
| 208 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 209 | |
| 210 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("VRPT", "Vector record pointer field", "*", dsc_arraycxx . . $ dsc_array., |
| 211 | dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 212 | |
| 213 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NAME", "B(40)"); |
| 214 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("ORNT", "b11"); |
| 215 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("USAG", "b11"); |
| 216 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("TOPI", "b11"); |
| 217 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("MASK", "b11"); |
| 218 | |
| 219 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 220 | |
| 221 | /* -------------------------------------------------------------------- */ |
| 222 | /* Create the ATTV field. */ |
| 223 | /* -------------------------------------------------------------------- */ |
| 224 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 225 | |
| 226 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("ATTV", "Vector record attribute field", "*", dsc_arraycxx . . $ dsc_array., |
| 227 | dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 228 | |
| 229 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("ATTL", "b12"); |
| 230 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("ATVL", "A"); |
| 231 | |
| 232 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 233 | |
| 234 | /* -------------------------------------------------------------------- */ |
| 235 | /* Create the SGCC field. */ |
| 236 | /* -------------------------------------------------------------------- */ |
| 237 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 238 | |
| 239 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("SGCC", "Coordinate Control Field", "", dsc_vectorcxx . . $ dsc_vector., |
| 240 | dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 241 | |
| 242 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("CCUI", "b11"); |
| 243 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("CCIX", "b12"); |
| 244 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("CCNC", "b12"); |
| 245 | |
| 246 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 247 | |
| 248 | /* -------------------------------------------------------------------- */ |
| 249 | /* Create the SG2D field. */ |
| 250 | /* -------------------------------------------------------------------- */ |
| 251 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 252 | |
| 253 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("SG2D", "2-D coordinate field", "*", dsc_arraycxx . . $ dsc_array., |
| 254 | dtc_bit_stringcxx . . $ dtc_bit_string.); |
| 255 | |
| 256 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("YCOO", "b24"); |
| 257 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("XCOO", "b24"); |
| 258 | |
| 259 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 260 | |
| 261 | /* -------------------------------------------------------------------- */ |
| 262 | /* Create the SG3D field. */ |
| 263 | /* -------------------------------------------------------------------- */ |
| 264 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 265 | |
| 266 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("SG3D", "3-D coordinate (sounding array) field", "*", |
| 267 | dsc_arraycxx . . $ dsc_array., dtc_bit_stringcxx . . $ dtc_bit_string.); |
| 268 | |
| 269 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("YCOO", "b24"); |
| 270 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("XCOO", "b24"); |
| 271 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("VE3D", "b24"); |
| 272 | |
| 273 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 274 | |
| 275 | /* -------------------------------------------------------------------- */ |
| 276 | /* Create the FRID field. */ |
| 277 | /* -------------------------------------------------------------------- */ |
| 278 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 279 | |
| 280 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("FRID", "Feature record identifier field", "", dsc_vectorcxx . . $ dsc_vector., |
| 281 | dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 282 | |
| 283 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RCNM", "b11"); |
| 284 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RCID", "b14"); |
| 285 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("PRIM", "b11"); |
| 286 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("GRUP", "b11"); |
| 287 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("OBJL", "b12"); |
| 288 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RVER", "b12"); |
| 289 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RUIN", "b11"); |
| 290 | |
| 291 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 292 | |
| 293 | /* -------------------------------------------------------------------- */ |
| 294 | /* Create the FOID field. */ |
| 295 | /* -------------------------------------------------------------------- */ |
| 296 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 297 | |
| 298 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("FOID", "Feature object identifier field", "", dsc_vectorcxx . . $ dsc_vector., |
| 299 | dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 300 | |
| 301 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("AGEN", "b12"); |
| 302 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("FIDN", "b14"); |
| 303 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("FIDS", "b12"); |
| 304 | |
| 305 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 306 | |
| 307 | /* -------------------------------------------------------------------- */ |
| 308 | /* Create the ATTF field. */ |
| 309 | /* -------------------------------------------------------------------- */ |
| 310 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 311 | |
| 312 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("ATTF", "Feature record attribute field", "*", dsc_arraycxx . . $ dsc_array., |
| 313 | dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 314 | |
| 315 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("ATTL", "b12"); |
| 316 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("ATVL", "A"); |
| 317 | |
| 318 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 319 | |
| 320 | /* -------------------------------------------------------------------- */ |
| 321 | /* Create the NATF field. */ |
| 322 | /* -------------------------------------------------------------------- */ |
| 323 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 324 | |
| 325 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("NATF", "Feature record national attribute field", "*", |
| 326 | dsc_arraycxx . . $ dsc_array., dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 327 | |
| 328 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("ATTL", "b12"); |
| 329 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("ATVL", "A"); |
| 330 | |
| 331 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 332 | |
| 333 | /* -------------------------------------------------------------------- */ |
| 334 | /* Create the FFPC field. */ |
| 335 | /* -------------------------------------------------------------------- */ |
| 336 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 337 | |
| 338 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("FFPC", |
| 339 | "Feature record to feature object pointer control field", |
| 340 | "", dsc_vectorcxx . . $ dsc_vector., dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 341 | |
| 342 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("FFUI", "b11"); |
| 343 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("FFIX", "b12"); |
| 344 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NFPT", "b12"); |
| 345 | |
| 346 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 347 | |
| 348 | /* -------------------------------------------------------------------- */ |
| 349 | /* Create the FFPT field. */ |
| 350 | /* -------------------------------------------------------------------- */ |
| 351 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 352 | |
| 353 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("FFPT", "Feature record to feature object pointer field", |
| 354 | "*", dsc_arraycxx . . $ dsc_array., dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 355 | |
| 356 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("LNAM", "B(64)"); |
| 357 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("RIND", "b11"); |
| 358 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("COMT", "A"); |
| 359 | |
| 360 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 361 | |
| 362 | /* -------------------------------------------------------------------- */ |
| 363 | /* Create the FSPC field. */ |
| 364 | /* -------------------------------------------------------------------- */ |
| 365 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 366 | |
| 367 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("FSPC", |
| 368 | "Feature record to spatial record pointer control field", |
| 369 | "", dsc_vectorcxx . . $ dsc_vector., dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 370 | |
| 371 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("FSUI", "b11"); |
| 372 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("FSIX", "b12"); |
| 373 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NSPT", "b12"); |
| 374 | |
| 375 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 376 | |
| 377 | /* -------------------------------------------------------------------- */ |
| 378 | /* Create the FSPT field. */ |
| 379 | /* -------------------------------------------------------------------- */ |
| 380 | poFDefn = stdcxx . . $ std/::make_unique<DDFFieldDefncxx . . $ DDFFieldDefn#>(); |
| 381 | |
| 382 | poFDefn->Createcxx . . $ DDFFieldDefn#Create(da2b48624d73f166).("FSPT", "Feature record to spatial record pointer field", |
| 383 | "*", dsc_arraycxx . . $ dsc_array., dtc_mixed_data_typecxx . . $ dtc_mixed_data_type.); |
| 384 | |
| 385 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("NAME", "B(40)"); |
| 386 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("ORNT", "b11"); |
| 387 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("USAG", "b11"); |
| 388 | poFDefn->AddSubfieldcxx . . $ DDFFieldDefn#AddSubfield(2fa786934fe80e24).("MASK", "b11"); |
| 389 | |
| 390 | poModulecxx . . $ S57Writer#poModule.->AddFieldcxx . . $ DDFModule#AddField(dd78d41ac1d024ec).(stdcxx . . $ std/::move(poFDefn)); |
| 391 | |
| 392 | /* -------------------------------------------------------------------- */ |
| 393 | /* Create file. */ |
| 394 | /* -------------------------------------------------------------------- */ |
| 395 | if (!poModulecxx . . $ S57Writer#poModule.->Createcxx . . $ DDFModule#Create(5c4306d8553b3696).(pszFilename)) |
| 396 | { |
| 397 | delete poModulecxx . . $ S57Writer#poModule.; |
| 398 | poModulecxx . . $ S57Writer#poModule. = nullptr; |
| 399 | return false; |
| 400 | } |
| 401 | |
| 402 | return true; |
| 403 | } |
| 404 | |
| 405 | /************************************************************************/ |
| 406 | /* WriteDSID() */ |
| 407 | /************************************************************************/ |
| 408 | |
| 409 | bool S57Writercxx . . $ S57Writer#::WriteDSIDcxx . . $ S57Writer#WriteDSID(7134875eb7a60e9a).(int nEXPP, int nINTU, const char *pszDSNM, |
| 410 | const char *pszEDTN, const char *pszUPDN, |
| 411 | const char *pszUADT, const char *pszISDT, |
| 412 | const char *pszSTED, int nAGEN, const char *pszCOMT, |
| 413 | int nAALL, int nNALL, int nNOMR, int nNOGR, int nNOLR, |
| 414 | int nNOIN, int nNOCN, int nNOED) |
| 415 | |
| 416 | { |
| 417 | /* -------------------------------------------------------------------- */ |
| 418 | /* Default values. */ |
| 419 | /* -------------------------------------------------------------------- */ |
| 420 | if (pszDSNM == nullptr) |
| 421 | pszDSNM = ""; |
| 422 | if (pszEDTN == nullptr) |
| 423 | pszEDTN = "2"; |
| 424 | if (pszUPDN == nullptr) |
| 425 | pszUPDN = "0"; |
| 426 | if (pszISDT == nullptr) |
| 427 | pszISDT = "20030801"; |
| 428 | if (pszUADT == nullptr) |
| 429 | pszUADT = pszISDT; |
| 430 | if (pszSTED == nullptr) |
| 431 | pszSTED = "03.1"; |
| 432 | if (pszCOMT == nullptr) |
| 433 | pszCOMT = ""; |
| 434 | |
| 435 | /* -------------------------------------------------------------------- */ |
| 436 | /* Add the DSID field. */ |
| 437 | /* -------------------------------------------------------------------- */ |
| 438 | DDFRecordcxx . . $ DDFRecord# *poRec = MakeRecordcxx . . $ S57Writer#MakeRecord(f2d6de17037c9049).(); |
| 439 | |
| 440 | // DDFField *poField = |
| 441 | poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("DSID")); |
| 442 | |
| 443 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSID", 0, "RCNM", 0, 10); |
| 444 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSID", 0, "RCID", 0, 1); |
| 445 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSID", 0, "EXPP", 0, nEXPP); |
| 446 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSID", 0, "INTU", 0, nINTU); |
| 447 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("DSID", 0, "DSNM", 0, pszDSNM); |
| 448 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("DSID", 0, "EDTN", 0, pszEDTN); |
| 449 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("DSID", 0, "UPDN", 0, pszUPDN); |
| 450 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("DSID", 0, "UADT", 0, pszUADT); |
| 451 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("DSID", 0, "ISDT", 0, pszISDT); |
| 452 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("DSID", 0, "STED", 0, pszSTED); |
| 453 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSID", 0, "PRSP", 0, 1); |
| 454 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("DSID", 0, "PSDN", 0, ""); |
| 455 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("DSID", 0, "PRED", 0, "2.0"); |
| 456 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSID", 0, "PROF", 0, 1); |
| 457 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSID", 0, "AGEN", 0, nAGEN); |
| 458 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("DSID", 0, "COMT", 0, pszCOMT); |
| 459 | |
| 460 | /* -------------------------------------------------------------------- */ |
| 461 | /* Add the DSSI record. Eventually we will need to return and */ |
| 462 | /* correct these when we are finished writing. */ |
| 463 | /* -------------------------------------------------------------------- */ |
| 464 | /* poField = */ poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("DSSI")); |
| 465 | |
| 466 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "DSTR", 0, 2); // "Chain node" |
| 467 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "AALL", 0, nAALL); |
| 468 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "NALL", 0, nNALL); |
| 469 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "NOMR", 0, nNOMR); // Meta records |
| 470 | // Cartographic records are not permitted in ENC. |
| 471 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "NOCR", 0, 0); |
| 472 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "NOGR", 0, nNOGR); // Geo records |
| 473 | // Collection records. |
| 474 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "NOLR", 0, nNOLR); |
| 475 | // Isolated node records. |
| 476 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "NOIN", 0, nNOIN); |
| 477 | // Connected node records. |
| 478 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "NOCN", 0, nNOCN); |
| 479 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "NOED", 0, nNOED); // Edge records |
| 480 | // Face are not permitted in chain node structure. |
| 481 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSSI", 0, "NOFA", 0, 0); |
| 482 | |
| 483 | /* -------------------------------------------------------------------- */ |
| 484 | /* Write out the record. */ |
| 485 | /* -------------------------------------------------------------------- */ |
| 486 | poRec->Writecxx . . $ DDFRecord#Write(b126dc7c1de90089).(); |
| 487 | delete poRec; |
| 488 | |
| 489 | return true; |
| 490 | } |
| 491 | |
| 492 | /************************************************************************/ |
| 493 | /* WriteDSPM() */ |
| 494 | /************************************************************************/ |
| 495 | |
| 496 | bool S57Writercxx . . $ S57Writer#::WriteDSPMcxx . . $ S57Writer#WriteDSPM(33820514f83722bc).(int nHDAT, int nVDAT, int nSDAT, int nCSCL, int nCOMF, |
| 497 | int nSOMF) |
| 498 | |
| 499 | { |
| 500 | m_nCOMFcxx . . $ S57Writer#m_nCOMF. = nCOMF; |
| 501 | m_nSOMFcxx . . $ S57Writer#m_nSOMF. = nSOMF; |
| 502 | |
| 503 | /* -------------------------------------------------------------------- */ |
| 504 | /* Add the DSID field. */ |
| 505 | /* -------------------------------------------------------------------- */ |
| 506 | DDFRecordcxx . . $ DDFRecord# *poRec = MakeRecordcxx . . $ S57Writer#MakeRecord(f2d6de17037c9049).(); |
| 507 | |
| 508 | // DDFField *poField = |
| 509 | poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("DSPM")); |
| 510 | |
| 511 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "RCNM", 0, 20); |
| 512 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "RCID", 0, 1); |
| 513 | // Must be 2 for ENC. |
| 514 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "HDAT", 0, nHDAT); |
| 515 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "VDAT", 0, nVDAT); |
| 516 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "SDAT", 0, nSDAT); |
| 517 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "CSCL", 0, nCSCL); |
| 518 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "DUNI", 0, 1); |
| 519 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "HUNI", 0, 1); |
| 520 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "PUNI", 0, 1); |
| 521 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "COUN", 0, 1); |
| 522 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "COMF", 0, nCOMF); |
| 523 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("DSPM", 0, "SOMF", 0, nSOMF); |
| 524 | |
| 525 | /* -------------------------------------------------------------------- */ |
| 526 | /* Write out the record. */ |
| 527 | /* -------------------------------------------------------------------- */ |
| 528 | poRec->Writecxx . . $ DDFRecord#Write(b126dc7c1de90089).(); |
| 529 | delete poRec; |
| 530 | |
| 531 | return true; |
| 532 | } |
| 533 | |
| 534 | /************************************************************************/ |
| 535 | /* MakeRecord() */ |
| 536 | /* */ |
| 537 | /* Create a new empty record, and append a 0001 field with a */ |
| 538 | /* properly set record index in it. */ |
| 539 | /************************************************************************/ |
| 540 | |
| 541 | DDFRecordcxx . . $ DDFRecord# *S57Writercxx . . $ S57Writer#::MakeRecordcxx . . $ S57Writer#MakeRecord(f2d6de17037c9049).() |
| 542 | |
| 543 | { |
| 544 | unsigned char abyData[2] = { |
| 545 | static_cast<unsigned char>(nNext0001Indexcxx . . $ S57Writer#nNext0001Index. % 256), |
| 546 | static_cast<unsigned char>(nNext0001Indexcxx . . $ S57Writer#nNext0001Index. / 256)}; |
| 547 | |
| 548 | DDFRecordcxx . . $ DDFRecord# *poRec = new DDFRecordcxx . . $ DDFRecord#DDFRecord(a480bbf58053517e).(poModulecxx . . $ S57Writer#poModule.); |
| 549 | DDFFieldcxx . . $ DDFField# *poField = poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("0001")); |
| 550 | poRec->SetFieldRawcxx . . $ DDFRecord#SetFieldRaw(7aaa9f8a2c532a63).(poField, 0, (const char *)abyData, 2); |
| 551 | |
| 552 | nNext0001Indexcxx . . $ S57Writer#nNext0001Index.++; |
| 553 | |
| 554 | return poRec; |
| 555 | } |
| 556 | |
| 557 | /************************************************************************/ |
| 558 | /* WriteGeometry() */ |
| 559 | /************************************************************************/ |
| 560 | |
| 561 | bool S57Writercxx . . $ S57Writer#::WriteGeometrycxx . . $ S57Writer#WriteGeometry(4a6abc6f16830172).(DDFRecordcxx . . $ DDFRecord# *poRec, int nVertCount, |
| 562 | const double *padfX, const double *padfY, |
| 563 | const double *padfZ) |
| 564 | |
| 565 | { |
| 566 | const char *pszFieldName = "SG2D"; |
| 567 | |
| 568 | if (padfZ != nullptr) |
| 569 | pszFieldName = "SG3D"; |
| 570 | |
| 571 | DDFFieldcxx . . $ DDFField# *poField = poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).(pszFieldName)); |
| 572 | |
| 573 | const int nRawDataSize = padfZ ? 12 * nVertCount : 8 * nVertCount; |
| 574 | |
| 575 | unsigned char *pabyRawData = |
| 576 | static_cast<unsigned char *>(CPLMalloc(nRawDataSize)); |
| 577 | |
| 578 | for (int i = 0; i < nVertCount; i++) |
| 579 | { |
| 580 | const GInt32cxx . . $ GInt32# nXCOO = |
| 581 | CPL_LSBWORD32cxx . . $ `port/cpl_port.h:749:9`!(static_cast<GInt32>(floor(padfX[i] * m_nCOMF + 0.5))); |
| 582 | const GInt32cxx . . $ GInt32# nYCOO = |
| 583 | CPL_LSBWORD32cxx . . $ `port/cpl_port.h:749:9`!(static_cast<GInt32>(floor(padfY[i] * m_nCOMF + 0.5))); |
| 584 | |
| 585 | if (padfZ == nullptr) |
| 586 | { |
| 587 | memcpy(pabyRawData + i * 8, &nYCOO, 4); |
| 588 | memcpy(pabyRawData + i * 8 + 4, &nXCOO, 4); |
| 589 | } |
| 590 | else |
| 591 | { |
| 592 | const GInt32cxx . . $ GInt32# nVE3D = CPL_LSBWORD32cxx . . $ `port/cpl_port.h:749:9`!( |
| 593 | static_cast<GInt32>(floor(padfZ[i] * m_nSOMF + 0.5))); |
| 594 | memcpy(pabyRawData + i * 12, &nYCOO, 4); |
| 595 | memcpy(pabyRawData + i * 12 + 4, &nXCOO, 4); |
| 596 | memcpy(pabyRawData + i * 12 + 8, &nVE3D, 4); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | const bool nSuccess = CPL_TO_BOOL(poRec->SetFieldRawcxx . . $ DDFRecord#SetFieldRaw(7aaa9f8a2c532a63).( |
| 601 | poField, 0, reinterpret_cast<const char *>(pabyRawData), nRawDataSize)); |
| 602 | |
| 603 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pabyRawData); |
| 604 | |
| 605 | return nSuccess; |
| 606 | } |
| 607 | |
| 608 | /************************************************************************/ |
| 609 | /* WritePrimitive() */ |
| 610 | /************************************************************************/ |
| 611 | |
| 612 | bool S57Writercxx . . $ S57Writer#::WritePrimitivecxx . . $ S57Writer#WritePrimitive(9d38d33a35b5766a).(OGRFeaturecxx . . $ OGRFeature# *poFeature) |
| 613 | |
| 614 | { |
| 615 | DDFRecordcxx . . $ DDFRecord# *poRec = MakeRecordcxx . . $ S57Writer#MakeRecord(f2d6de17037c9049).(); |
| 616 | const OGRGeometrycxx . . $ OGRGeometry# *poGeom = poFeature->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).(); |
| 617 | |
| 618 | /* -------------------------------------------------------------------- */ |
| 619 | /* Add the VRID field. */ |
| 620 | /* -------------------------------------------------------------------- */ |
| 621 | |
| 622 | // DDFField *poField = |
| 623 | poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("VRID")); |
| 624 | |
| 625 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRID", 0, "RCNM", 0, |
| 626 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("RCNM")); |
| 627 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRID", 0, "RCID", 0, |
| 628 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("RCID")); |
| 629 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRID", 0, "RVER", 0, 1); |
| 630 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRID", 0, "RUIN", 0, 1); |
| 631 | |
| 632 | bool bRet = true; |
| 633 | |
| 634 | /* -------------------------------------------------------------------- */ |
| 635 | /* Handle simple point. */ |
| 636 | /* -------------------------------------------------------------------- */ |
| 637 | if (poGeom != nullptr && wkbFlattencxx . . $ `ogr/ogr_core.h:576:9`!(poGeom->getGeometryType()) == wkbPoint) |
| 638 | { |
| 639 | const OGRPointcxx . . $ OGRPoint# *poPoint = poGeom->toPointcxx . . $ OGRGeometry#toPoint(fc69dde5c23f420e).(); |
| 640 | |
| 641 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poFeature->GetFieldAsInteger("RCNM") == RCNM_VI || |
| 642 | poFeature->GetFieldAsInteger("RCNM") == RCNM_VC); |
| 643 | |
| 644 | const double adfX[1] = {poPoint->getXcxx . . $ OGRPoint#getX(21b6c25e127938e2).()}; |
| 645 | const double adfY[1] = {poPoint->getYcxx . . $ OGRPoint#getY(21b6c25e127938e2).()}; |
| 646 | const double adfZ[1] = {poPoint->getZcxx . . $ OGRPoint#getZ(21b6c25e127938e2).()}; |
| 647 | |
| 648 | if (adfZ[0] == 0.0) |
| 649 | bRet = WriteGeometrycxx . . $ S57Writer#WriteGeometry(4a6abc6f16830172).(poRec, 1, &adfX[0], &adfY[0], nullptr); |
| 650 | else |
| 651 | bRet = WriteGeometrycxx . . $ S57Writer#WriteGeometry(4a6abc6f16830172).(poRec, 1, &adfX[0], &adfY[0], &adfZ[0]); |
| 652 | } |
| 653 | |
| 654 | /* -------------------------------------------------------------------- */ |
| 655 | /* For multipoints we assuming SOUNDG, and write out as SG3D. */ |
| 656 | /* -------------------------------------------------------------------- */ |
| 657 | else if (poGeom != nullptr && |
| 658 | wkbFlattencxx . . $ `ogr/ogr_core.h:576:9`!(poGeom->getGeometryType()) == wkbMultiPoint) |
| 659 | { |
| 660 | const OGRMultiPointcxx . . $ OGRMultiPoint# *poMP = poGeom->toMultiPointcxx . . $ OGRGeometry#toMultiPoint(41b38423b1fffc20).(); |
| 661 | const int nVCount = poMP->getNumGeometriescxx . . $ OGRGeometryCollection#getNumGeometries(455f465bc33b4cdf).(); |
| 662 | |
| 663 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poFeature->GetFieldAsInteger("RCNM") == RCNM_VI || |
| 664 | poFeature->GetFieldAsInteger("RCNM") == RCNM_VC); |
| 665 | |
| 666 | double *padfX = (double *)CPLMalloc(sizeof(double) * nVCount); |
| 667 | double *padfY = (double *)CPLMalloc(sizeof(double) * nVCount); |
| 668 | double *padfZ = (double *)CPLMalloc(sizeof(double) * nVCount); |
| 669 | |
| 670 | for (int i = 0; i < nVCount; i++) |
| 671 | { |
| 672 | const OGRPointcxx . . $ OGRPoint# *poPoint = poMP->getGeometryRefcxx . . $ OGRMultiPoint#getGeometryRef(3026a26a37d74de6).(i); |
| 673 | padfX[i] = poPoint->getXcxx . . $ OGRPoint#getX(21b6c25e127938e2).(); |
| 674 | padfY[i] = poPoint->getYcxx . . $ OGRPoint#getY(21b6c25e127938e2).(); |
| 675 | padfZ[i] = poPoint->getZcxx . . $ OGRPoint#getZ(21b6c25e127938e2).(); |
| 676 | } |
| 677 | |
| 678 | bRet = WriteGeometrycxx . . $ S57Writer#WriteGeometry(4a6abc6f16830172).(poRec, nVCount, padfX, padfY, padfZ); |
| 679 | |
| 680 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(padfX); |
| 681 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(padfY); |
| 682 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(padfZ); |
| 683 | } |
| 684 | |
| 685 | /* -------------------------------------------------------------------- */ |
| 686 | /* Handle LINESTRINGs (edge) geometry. */ |
| 687 | /* -------------------------------------------------------------------- */ |
| 688 | else if (poGeom != nullptr && |
| 689 | wkbFlattencxx . . $ `ogr/ogr_core.h:576:9`!(poGeom->getGeometryType()) == wkbLineString) |
| 690 | { |
| 691 | const OGRLineStringcxx . . $ OGRLineString# *poLS = poGeom->toLineStringcxx . . $ OGRGeometry#toLineString(cbbe9b6449dd4d8b).(); |
| 692 | const int nVCount = poLS->getNumPointscxx . . $ OGRSimpleCurve#getNumPoints(455f465bc33b4cdf).(); |
| 693 | |
| 694 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poFeature->GetFieldAsInteger("RCNM") == RCNM_VE); |
| 695 | |
| 696 | double *padfX = (double *)CPLMalloc(sizeof(double) * nVCount); |
| 697 | double *padfY = (double *)CPLMalloc(sizeof(double) * nVCount); |
| 698 | |
| 699 | for (int i = 0; i < nVCount; i++) |
| 700 | { |
| 701 | padfX[i] = poLS->getXcxx . . $ OGRSimpleCurve#getX(8bbae5fb2e9ef7ac).(i); |
| 702 | padfY[i] = poLS->getYcxx . . $ OGRSimpleCurve#getY(8bbae5fb2e9ef7ac).(i); |
| 703 | } |
| 704 | |
| 705 | if (nVCount) |
| 706 | bRet = WriteGeometrycxx . . $ S57Writer#WriteGeometry(4a6abc6f16830172).(poRec, nVCount, padfX, padfY, nullptr); |
| 707 | |
| 708 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(padfX); |
| 709 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(padfY); |
| 710 | } |
| 711 | |
| 712 | /* -------------------------------------------------------------------- */ |
| 713 | /* edge node linkages. */ |
| 714 | /* -------------------------------------------------------------------- */ |
| 715 | if (poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()->GetFieldIndexcxx . . $ OGRFeatureDefn#GetFieldIndex(78f035161ffa9fe2).("NAME_RCNM_0") >= 0) |
| 716 | { |
| 717 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poFeature->GetFieldAsInteger("NAME_RCNM_0") == RCNM_VC); |
| 718 | |
| 719 | // DDFField *poField = |
| 720 | poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("VRPT")); |
| 721 | |
| 722 | const int nRCID0 = poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("NAME_RCID_0"); |
| 723 | char szName0[5] = {RCNM_VCcxx . . $ `ogr/ogrsf_frmts/s57/s57.h:62:9`!, static_cast<char>(nRCID0 & 0xff), |
| 724 | static_cast<char>((nRCID0 & 0xff00) >> 8), |
| 725 | static_cast<char>((nRCID0 & 0xff0000) >> 16), |
| 726 | static_cast<char>((nRCID0 & 0xff000000) >> 24)}; |
| 727 | |
| 728 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("VRPT", 0, "NAME", 0, szName0, 5); |
| 729 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRPT", 0, "ORNT", 0, |
| 730 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("ORNT_0")); |
| 731 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRPT", 0, "USAG", 0, |
| 732 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("USAG_0")); |
| 733 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRPT", 0, "TOPI", 0, |
| 734 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("TOPI_0")); |
| 735 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRPT", 0, "MASK", 0, |
| 736 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("MASK_0")); |
| 737 | |
| 738 | const int nRCID1 = poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("NAME_RCID_1"); |
| 739 | const char szName1[5] = { |
| 740 | RCNM_VCcxx . . $ `ogr/ogrsf_frmts/s57/s57.h:62:9`!, static_cast<char>(nRCID1 & 0xff), |
| 741 | static_cast<char>((nRCID1 & 0xff00) >> 8), |
| 742 | static_cast<char>((nRCID1 & 0xff0000) >> 16), |
| 743 | static_cast<char>((nRCID1 & 0xff000000) >> 24)}; |
| 744 | |
| 745 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("VRPT", 0, "NAME", 1, szName1, 5); |
| 746 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRPT", 0, "ORNT", 1, |
| 747 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("ORNT_1")); |
| 748 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRPT", 0, "USAG", 1, |
| 749 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("USAG_1")); |
| 750 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRPT", 0, "TOPI", 1, |
| 751 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("TOPI_1")); |
| 752 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("VRPT", 0, "MASK", 1, |
| 753 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("MASK_1")); |
| 754 | } |
| 755 | |
| 756 | /* -------------------------------------------------------------------- */ |
| 757 | /* Write out the record. */ |
| 758 | /* -------------------------------------------------------------------- */ |
| 759 | if (!poRec->Writecxx . . $ DDFRecord#Write(b126dc7c1de90089).()) |
| 760 | bRet = false; |
| 761 | delete poRec; |
| 762 | |
| 763 | return bRet; |
| 764 | } |
| 765 | |
| 766 | /************************************************************************/ |
| 767 | /* GetHEXChar() */ |
| 768 | /************************************************************************/ |
| 769 | |
| 770 | static char GetHEXCharcxx . . $ GetHEXChar(7686fc5bdd0412e).(const char *pszSrcHEXString) |
| 771 | |
| 772 | { |
| 773 | if (pszSrcHEXString[0] == '\0' || pszSrcHEXString[1] == '\0') |
| 774 | return (char)0; |
| 775 | |
| 776 | int nResult = 0; |
| 777 | |
| 778 | if (pszSrcHEXString[0] >= '0' && pszSrcHEXString[0] <= '9') |
| 779 | nResult += (pszSrcHEXString[0] - '0') * 16; |
| 780 | else if (pszSrcHEXString[0] >= 'a' && pszSrcHEXString[0] <= 'f') |
| 781 | nResult += (pszSrcHEXString[0] - 'a' + 10) * 16; |
| 782 | else if (pszSrcHEXString[0] >= 'A' && pszSrcHEXString[0] <= 'F') |
| 783 | nResult += (pszSrcHEXString[0] - 'A' + 10) * 16; |
| 784 | |
| 785 | if (pszSrcHEXString[1] >= '0' && pszSrcHEXString[1] <= '9') |
| 786 | nResult += pszSrcHEXString[1] - '0'; |
| 787 | else if (pszSrcHEXString[1] >= 'a' && pszSrcHEXString[1] <= 'f') |
| 788 | nResult += pszSrcHEXString[1] - 'a' + 10; |
| 789 | else if (pszSrcHEXString[1] >= 'A' && pszSrcHEXString[1] <= 'F') |
| 790 | nResult += pszSrcHEXString[1] - 'A' + 10; |
| 791 | |
| 792 | return (char)nResult; |
| 793 | } |
| 794 | |
| 795 | /************************************************************************/ |
| 796 | /* WriteCompleteFeature() */ |
| 797 | /************************************************************************/ |
| 798 | |
| 799 | bool S57Writercxx . . $ S57Writer#::WriteCompleteFeaturecxx . . $ S57Writer#WriteCompleteFeature(9d38d33a35b5766a).(OGRFeaturecxx . . $ OGRFeature# *poFeature) |
| 800 | |
| 801 | { |
| 802 | const OGRFeatureDefncxx . . $ OGRFeatureDefn# *poFDefn = poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).(); |
| 803 | |
| 804 | /* -------------------------------------------------------------------- */ |
| 805 | /* We handle primitives in a separate method. */ |
| 806 | /* -------------------------------------------------------------------- */ |
| 807 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poFDefn->GetName(), OGRN_VIcxx . . $ `ogr/ogrsf_frmts/s57/s57.h:68:9`!) || |
| 808 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(poFDefn->GetName(), OGRN_VCcxx . . $ `ogr/ogrsf_frmts/s57/s57.h:69:9`!) || |
| 809 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(poFDefn->GetName(), OGRN_VEcxx . . $ `ogr/ogrsf_frmts/s57/s57.h:70:9`!)) |
| 810 | return WritePrimitivecxx . . $ S57Writer#WritePrimitive(9d38d33a35b5766a).(poFeature); |
| 811 | |
| 812 | /* -------------------------------------------------------------------- */ |
| 813 | /* Create the record. */ |
| 814 | /* -------------------------------------------------------------------- */ |
| 815 | DDFRecordcxx . . $ DDFRecord# *poRec = MakeRecordcxx . . $ S57Writer#MakeRecord(f2d6de17037c9049).(); |
| 816 | |
| 817 | /* -------------------------------------------------------------------- */ |
| 818 | /* Add the FRID. */ |
| 819 | /* -------------------------------------------------------------------- */ |
| 820 | // DDFField *poField = |
| 821 | poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("FRID")); |
| 822 | |
| 823 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FRID", 0, "RCNM", 0, 100); |
| 824 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FRID", 0, "RCID", 0, |
| 825 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("RCID")); |
| 826 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FRID", 0, "PRIM", 0, |
| 827 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("PRIM")); |
| 828 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FRID", 0, "GRUP", 0, |
| 829 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("GRUP")); |
| 830 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FRID", 0, "OBJL", 0, |
| 831 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("OBJL")); |
| 832 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FRID", 0, "RVER", 0, 1); /* always new insert*/ |
| 833 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FRID", 0, "RUIN", 0, 1); |
| 834 | |
| 835 | /* -------------------------------------------------------------------- */ |
| 836 | /* Add the FOID */ |
| 837 | /* -------------------------------------------------------------------- */ |
| 838 | /*poField = */ poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("FOID")); |
| 839 | |
| 840 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FOID", 0, "AGEN", 0, |
| 841 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("AGEN")); |
| 842 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FOID", 0, "FIDN", 0, |
| 843 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("FIDN")); |
| 844 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FOID", 0, "FIDS", 0, |
| 845 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(78f035161ffa9fe2).("FIDS")); |
| 846 | |
| 847 | /* -------------------------------------------------------------------- */ |
| 848 | /* ATTF support. */ |
| 849 | /* -------------------------------------------------------------------- */ |
| 850 | |
| 851 | if (poRegistrarcxx . . $ S57Writer#poRegistrar. != nullptr && |
| 852 | poClassContentExplorercxx . . $ S57Writer#poClassContentExplorer.->SelectClasscxx . . $ S57ClassContentExplorer#SelectClass(c5f7da30cbc0f4e9).( |
| 853 | poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).()) && |
| 854 | !WriteATTFcxx . . $ S57Writer#WriteATTF(d3b4ea62619e9c64).(poRec, poFeature)) |
| 855 | { |
| 856 | delete poRec; |
| 857 | return false; |
| 858 | } |
| 859 | |
| 860 | /* -------------------------------------------------------------------- */ |
| 861 | /* Add the FSPT if needed. */ |
| 862 | /* -------------------------------------------------------------------- */ |
| 863 | if (poFeature->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).(poFeature->GetFieldIndexcxx . . $ OGRFeature#GetFieldIndex(78f035161ffa9fe2).("NAME_RCNM"))) |
| 864 | { |
| 865 | int nItemCount = 0; |
| 866 | |
| 867 | const int *panRCNM = |
| 868 | poFeature->GetFieldAsIntegerListcxx . . $ OGRFeature#GetFieldAsIntegerList(9850a22aefc347de).("NAME_RCNM", &nItemCount); |
| 869 | const int *panRCID = |
| 870 | poFeature->GetFieldAsIntegerListcxx . . $ OGRFeature#GetFieldAsIntegerList(9850a22aefc347de).("NAME_RCID", &nItemCount); |
| 871 | const int *panORNT = |
| 872 | poFeature->GetFieldAsIntegerListcxx . . $ OGRFeature#GetFieldAsIntegerList(9850a22aefc347de).("ORNT", &nItemCount); |
| 873 | const int *panUSAG = |
| 874 | poFeature->GetFieldAsIntegerListcxx . . $ OGRFeature#GetFieldAsIntegerList(9850a22aefc347de).("USAG", &nItemCount); |
| 875 | const int *panMASK = |
| 876 | poFeature->GetFieldAsIntegerListcxx . . $ OGRFeature#GetFieldAsIntegerList(9850a22aefc347de).("MASK", &nItemCount); |
| 877 | |
| 878 | // cppcheck-suppress duplicateExpression |
| 879 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(sizeof(int) == sizeof(GInt32)); |
| 880 | |
| 881 | const int nRawDataSize = nItemCount * 8; |
| 882 | unsigned char *pabyRawData = (unsigned char *)CPLMalloc(nRawDataSize); |
| 883 | |
| 884 | for (int i = 0; i < nItemCount; i++) |
| 885 | { |
| 886 | GInt32cxx . . $ GInt32# nRCID = CPL_LSBWORD32cxx . . $ `port/cpl_port.h:749:9`!(panRCID[i]); |
| 887 | |
| 888 | pabyRawData[i * 8 + 0] = (GBytecxx . . $ GByte#)panRCNM[i]; |
| 889 | memcpy(pabyRawData + i * 8 + 1, &nRCID, 4); |
| 890 | pabyRawData[i * 8 + 5] = (GBytecxx . . $ GByte#)panORNT[i]; |
| 891 | pabyRawData[i * 8 + 6] = (GBytecxx . . $ GByte#)panUSAG[i]; |
| 892 | pabyRawData[i * 8 + 7] = (GBytecxx . . $ GByte#)panMASK[i]; |
| 893 | } |
| 894 | |
| 895 | DDFFieldcxx . . $ DDFField# *poField = poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("FSPT")); |
| 896 | poRec->SetFieldRawcxx . . $ DDFRecord#SetFieldRaw(7aaa9f8a2c532a63).(poField, 0, (const char *)pabyRawData, nRawDataSize); |
| 897 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pabyRawData); |
| 898 | } |
| 899 | |
| 900 | /* -------------------------------------------------------------------- */ |
| 901 | /* Add the FFPT if needed. */ |
| 902 | /* -------------------------------------------------------------------- */ |
| 903 | char **papszLNAM_REFS = poFeature->GetFieldAsStringListcxx . . $ OGRFeature#GetFieldAsStringList(e5c0a17ddea5f7b).("LNAM_REFS"); |
| 904 | |
| 905 | if (CSLCount(papszLNAM_REFS) > 0) |
| 906 | { |
| 907 | int i, nRefCount = CSLCount(papszLNAM_REFS); |
| 908 | const int *panRIND = |
| 909 | poFeature->GetFieldAsIntegerListcxx . . $ OGRFeature#GetFieldAsIntegerList(9850a22aefc347de).("FFPT_RIND", nullptr); |
| 910 | |
| 911 | poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("FFPT")); |
| 912 | |
| 913 | for (i = 0; i < nRefCount; i++) |
| 914 | { |
| 915 | char szLNAM[9]; |
| 916 | |
| 917 | if (strlen(papszLNAM_REFS[i]) < 16) |
| 918 | continue; |
| 919 | |
| 920 | // AGEN |
| 921 | szLNAM[1] = GetHEXCharcxx . . $ GetHEXChar(7686fc5bdd0412e).(papszLNAM_REFS[i] + 0); |
| 922 | szLNAM[0] = GetHEXCharcxx . . $ GetHEXChar(7686fc5bdd0412e).(papszLNAM_REFS[i] + 2); |
| 923 | |
| 924 | // FIDN |
| 925 | szLNAM[5] = GetHEXCharcxx . . $ GetHEXChar(7686fc5bdd0412e).(papszLNAM_REFS[i] + 4); |
| 926 | szLNAM[4] = GetHEXCharcxx . . $ GetHEXChar(7686fc5bdd0412e).(papszLNAM_REFS[i] + 6); |
| 927 | szLNAM[3] = GetHEXCharcxx . . $ GetHEXChar(7686fc5bdd0412e).(papszLNAM_REFS[i] + 8); |
| 928 | szLNAM[2] = GetHEXCharcxx . . $ GetHEXChar(7686fc5bdd0412e).(papszLNAM_REFS[i] + 10); |
| 929 | |
| 930 | // FIDS |
| 931 | szLNAM[7] = GetHEXCharcxx . . $ GetHEXChar(7686fc5bdd0412e).(papszLNAM_REFS[i] + 12); |
| 932 | szLNAM[6] = GetHEXCharcxx . . $ GetHEXChar(7686fc5bdd0412e).(papszLNAM_REFS[i] + 14); |
| 933 | |
| 934 | szLNAM[8] = '\0'; |
| 935 | |
| 936 | poRec->SetStringSubfieldcxx . . $ DDFRecord#SetStringSubfield(c57ed4df41dbf58e).("FFPT", 0, "LNAM", i, (char *)szLNAM, 8); |
| 937 | poRec->SetIntSubfieldcxx . . $ DDFRecord#SetIntSubfield(253c242b94eabd44).("FFPT", 0, "RIND", i, panRIND[i]); |
| 938 | } |
| 939 | } |
| 940 | |
| 941 | /* -------------------------------------------------------------------- */ |
| 942 | /* Write out the record. */ |
| 943 | /* -------------------------------------------------------------------- */ |
| 944 | poRec->Writecxx . . $ DDFRecord#Write(b126dc7c1de90089).(); |
| 945 | delete poRec; |
| 946 | |
| 947 | return true; |
| 948 | } |
| 949 | |
| 950 | /************************************************************************/ |
| 951 | /* SetClassBased() */ |
| 952 | /************************************************************************/ |
| 953 | |
| 954 | void S57Writercxx . . $ S57Writer#::SetClassBasedcxx . . $ S57Writer#SetClassBased(4eb7ef4256a122e9).(S57ClassRegistrarcxx . . $ S57ClassRegistrar# *poReg, |
| 955 | S57ClassContentExplorercxx . . $ S57ClassContentExplorer# *poClassContentExplorerIn) |
| 956 | |
| 957 | { |
| 958 | poRegistrarcxx . . $ S57Writer#poRegistrar. = poReg; |
| 959 | poClassContentExplorercxx . . $ S57Writer#poClassContentExplorer. = poClassContentExplorerIn; |
| 960 | } |
| 961 | |
| 962 | /************************************************************************/ |
| 963 | /* WriteATTF() */ |
| 964 | /************************************************************************/ |
| 965 | |
| 966 | bool S57Writercxx . . $ S57Writer#::WriteATTFcxx . . $ S57Writer#WriteATTF(d3b4ea62619e9c64).(DDFRecordcxx . . $ DDFRecord# *poRec, OGRFeaturecxx . . $ OGRFeature# *poFeature) |
| 967 | { |
| 968 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poRegistrar != nullptr); |
| 969 | |
| 970 | /* -------------------------------------------------------------------- */ |
| 971 | /* Loop over all attributes. */ |
| 972 | /* -------------------------------------------------------------------- */ |
| 973 | int nRawSize = 0; |
| 974 | int nACount = 0; |
| 975 | char achRawData[5000] = {}; |
| 976 | |
| 977 | char **papszAttrList = poClassContentExplorercxx . . $ S57Writer#poClassContentExplorer.->GetAttributeListcxx . . $ S57ClassContentExplorer#GetAttributeList(9945f7050fb66ac).(nullptr); |
| 978 | |
| 979 | for (int iAttr = 0; papszAttrList[iAttr] != nullptr; iAttr++) |
| 980 | { |
| 981 | const int iField = poFeature->GetFieldIndexcxx . . $ OGRFeature#GetFieldIndex(78f035161ffa9fe2).(papszAttrList[iAttr]); |
| 982 | if (iField < 0) |
| 983 | continue; |
| 984 | |
| 985 | const OGRFieldType eFldType = |
| 986 | poFeature->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).()->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(53a8093e6b73def).(iField)->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).(); |
| 987 | |
| 988 | if (!poFeature->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).(iField)) |
| 989 | continue; |
| 990 | |
| 991 | const int nATTLInt = |
| 992 | poRegistrarcxx . . $ S57Writer#poRegistrar.->FindAttrByAcronymcxx . . $ S57ClassRegistrar#FindAttrByAcronym(5c4306d8553b3696).(papszAttrList[iAttr]); |
| 993 | if (nATTLInt == -1) |
| 994 | continue; |
| 995 | |
| 996 | GUInt16cxx . . $ GUInt16# nATTL = (GUInt16cxx . . $ GUInt16#)nATTLInt; |
| 997 | CPL_LSBPTR16cxx . . $ `port/cpl_port.h:754:9`!(&nATTL); |
| 998 | memcpy(achRawData + nRawSize, &nATTL, 2); |
| 999 | nRawSize += 2; |
| 1000 | |
| 1001 | CPLString osATVL; |
| 1002 | if (eFldType == OFTStringList) |
| 1003 | { |
| 1004 | const char *const *papszTokens = |
| 1005 | poFeature->GetFieldAsStringListcxx . . $ OGRFeature#GetFieldAsStringList(824a51168b013904).(iField); |
| 1006 | for (auto papszIter = papszTokens; papszIter && *papszIter; |
| 1007 | ++papszIter) |
| 1008 | { |
| 1009 | if (!osATVL.empty()) |
| 1010 | osATVL += ','; |
| 1011 | osATVL += *papszIter; |
| 1012 | } |
| 1013 | } |
| 1014 | else |
| 1015 | { |
| 1016 | osATVL = poFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(afbf07f2bc1a9437).(iField); |
| 1017 | } |
| 1018 | |
| 1019 | // Special hack to handle special "empty" marker in integer fields. |
| 1020 | if ((eFldType == OFTInteger || eFldType == OFTReal) && |
| 1021 | atoicxx . . $ atoi(f5ecf3191ed0cd93).(osATVL) == EMPTY_NUMBER_MARKERcxx . . $ `ogr/ogrsf_frmts/s57/s57.h:28:9`!) |
| 1022 | osATVL.clear(); |
| 1023 | |
| 1024 | // Watch for really long data. |
| 1025 | if (osATVL.size() + nRawSize + 10 > sizeof(achRawData)) |
| 1026 | { |
| 1027 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1028 | "Too much ATTF data for fixed buffer size."); |
| 1029 | return false; |
| 1030 | } |
| 1031 | |
| 1032 | // copy data into record buffer. |
| 1033 | if (!osATVL.empty()) |
| 1034 | { |
| 1035 | memcpy(achRawData + nRawSize, osATVL.data(), osATVL.size()); |
| 1036 | nRawSize += static_cast<int>(osATVL.size()); |
| 1037 | } |
| 1038 | achRawData[nRawSize++] = DDF_UNIT_TERMINATORcxx . . $ `frmts/iso8211/iso8211.h:47:9`!; |
| 1039 | |
| 1040 | nACount++; |
| 1041 | } |
| 1042 | |
| 1043 | /* -------------------------------------------------------------------- */ |
| 1044 | /* If we got no attributes, return without adding ATTF. */ |
| 1045 | /* -------------------------------------------------------------------- */ |
| 1046 | if (nACount == 0) |
| 1047 | return true; |
| 1048 | |
| 1049 | /* -------------------------------------------------------------------- */ |
| 1050 | /* Write the new field value. */ |
| 1051 | /* -------------------------------------------------------------------- */ |
| 1052 | DDFFieldcxx . . $ DDFField# *poField = poRec->AddFieldcxx . . $ DDFRecord#AddField(257e1805b6894a58).(poModulecxx . . $ S57Writer#poModule.->FindFieldDefncxx . . $ DDFModule#FindFieldDefn(f33cf9c6593354ab).("ATTF")); |
| 1053 | |
| 1054 | return CPL_TO_BOOL(poRec->SetFieldRawcxx . . $ DDFRecord#SetFieldRaw(7aaa9f8a2c532a63).(poField, 0, achRawData, nRawSize)); |
| 1055 | } |