TODO: One of the free bits could be used for a closed line flag to avoid storing identical first + last points.
| 350 | |
| 351 | // TODO: One of the free bits could be used for a closed line flag to avoid storing identical first + last points. |
| 352 | void FeatureType::ParseHeader2() |
| 353 | { |
| 354 | if (m_parsed.m_header2) |
| 355 | return; |
| 356 | |
| 357 | ParseCommon(); |
| 358 | |
| 359 | m_parsed.m_header2 = true; |
| 360 | |
| 361 | auto const headerGeomType = static_cast<HeaderGeomType>(Header(m_data) & HEADER_MASK_GEOMTYPE); |
| 362 | if (headerGeomType != HeaderGeomType::Line && headerGeomType != HeaderGeomType::Area) |
| 363 | { |
| 364 | m_offsets.m_relations = m_offsets.m_header2; |
| 365 | return; |
| 366 | } |
| 367 | |
| 368 | BitSource bitSource(m_data.data() + m_offsets.m_header2); |
| 369 | uint8_t elemsCount = bitSource.Read(4); |
| 370 | uint8_t geomScalesMask = 0; |
| 371 | |
| 372 | if (m_loadInfo->m_version == DatSectionHeader::Version::V0) |
| 373 | { |
| 374 | // For outer geometry read the geom scales (offsets) mask. |
| 375 | // For inner geometry remaining 4 bits are not used. |
| 376 | if (elemsCount == 0) |
| 377 | geomScalesMask = bitSource.Read(4); |
| 378 | } |
| 379 | else |
| 380 | { |
| 381 | ASSERT(m_loadInfo->m_version >= DatSectionHeader::Version::V1, ()); |
| 382 | bool const isOuter = (bitSource.Read(1) == 1); |
| 383 | if (isOuter) |
| 384 | { |
| 385 | geomScalesMask = elemsCount; |
| 386 | elemsCount = 0; |
| 387 | } |
| 388 | |
| 389 | m_hasRelations = (bitSource.Read(1) == 1); |
| 390 | } |
| 391 | |
| 392 | ArrayByteSource src(bitSource.RoundPtr()); |
| 393 | serial::GeometryCodingParams const & cp = m_loadInfo->GetDefGeometryCodingParams(); |
| 394 | |
| 395 | if (headerGeomType == HeaderGeomType::Line) |
| 396 | { |
| 397 | if (elemsCount > 0) |
| 398 | { |
| 399 | // Inner geometry. |
| 400 | // Number of bytes in simplification mask: |
| 401 | // first and last points are never simplified/discarded, |
| 402 | // 2 bits are used per each other point, i.e. |
| 403 | // 3-6 pts - 1 byte, 7-10 pts - 2b, 11-14 pts - 3b. |
| 404 | /// @see FeatureBuilder::SerializeForMwm |
| 405 | int const count = (elemsCount - 2 + 3) / 4; |
| 406 | ASSERT_LESS(count, 4, ()); |
| 407 | |
| 408 | for (int i = 0; i < count; ++i) |
| 409 | { |
nothing calls this directly
no test coverage detected