Load the map cell from a binary chunk.
1047 {
1048 std::shared_ptr<PyramidMapMatrix> matrix =
1049 std::dynamic_pointer_cast<PyramidMapMatrix>(base_matrix);
1050
1051 size_t binary_size = sizeof(unsigned int) * 4;
1052 const unsigned int* uint_p =
1053 reinterpret_cast<const unsigned int*>(buf);
1054 unsigned int resolution_num = *uint_p;
1055 ++uint_p;
1056 unsigned int ratio = *uint_p;
1057 ++uint_p;
1058 unsigned int rows = *uint_p;
1059 ++uint_p;
1060 unsigned int cols = *uint_p;
1061 ++uint_p;
1062
1063
1064 binary_size += sizeof(unsigned char) * 4;
1065 const unsigned char* uc_p = reinterpret_cast<const unsigned char*>(uint_p);
1066 ++uc_p;
1067 ++uc_p;
1068 ++uc_p;
1069 unsigned char has_flag = *uc_p;
1070 ++uc_p;
1071 bool has_intensity = (has_flag & 1);
1072 bool has_intensity_var = (has_flag & 2);
1073 bool has_altitude = (has_flag & 4);
1074 bool has_altitude_var = (has_flag & 8);
1075 bool has_ground_altitude = (has_flag & 16);
1076 bool has_count = (has_flag & 32);
1077 bool has_ground_count = (has_flag & 64);
1078
1079
1080 if (resolution_num == matrix->GetResolutionNum() &&
1081 ratio == matrix->GetResolutionRatio() && rows == matrix->GetRowsSafe() &&
1082 cols == matrix->GetColsSafe() &&
1083 has_intensity == matrix->HasIntensity() &&
1084 has_intensity_var == matrix->HasIntensityVar() &&
1085 has_altitude == matrix->HasAltitude() &&
1086 has_altitude_var == matrix->HasAltitudeVar() &&
1087 has_ground_altitude == matrix->HasGroundAltitude() &&
1088 has_count == matrix->HasCount() &&
1089 has_ground_count == matrix->HasGroundCount()) {
1090 matrix->Reset();
1091 } else {
1092 matrix->Init(rows, cols, has_intensity, has_intensity_var, has_altitude,
1093 has_altitude_var, has_ground_altitude, has_count,
1094 has_ground_count, resolution_num, ratio);
1095 }
1096
1097
1098 const float* float_p =
1099 reinterpret_cast<const float*>(reinterpret_cast<const void*>(uc_p));
1100 for (unsigned int l = 0; l < resolution_num; ++l) {
1101 unsigned int matrix_size = matrix->GetRowsSafe(l) * matrix->GetColsSafe(l);
1102 if (matrix->HasIntensity()) {
1103 binary_size += sizeof(float) * matrix_size;
1104 matrix->SetIntensityMatrix(float_p, matrix_size, 0, l);
1105 float_p += matrix_size;
1106 }
1107 if (matrix->HasIntensityVar()) {
1108 binary_size += sizeof(float) * matrix_size;
1109 matrix->SetIntensityVarMatrix(float_p, matrix_size, 0, l);
1110 float_p += matrix_size;
1111 }
1112 if (matrix->HasAltitude()) {
1113 binary_size += sizeof(float) * matrix_size;
1114 matrix->SetAltitudeMatrix(float_p, matrix_size, 0, l);
1115 float_p += matrix_size;
1116 }
1117 if (matrix->HasAltitudeVar()) {
1118 binary_size += sizeof(float) * matrix_size;
1119 matrix->SetAltitudeVarMatrix(float_p, matrix_size, 0, l);
1120 float_p += matrix_size;
1121 }
1122 if (matrix->HasGroundAltitude()) {
1123 binary_size += sizeof(float) * matrix_size;
1124 matrix->SetGroundAltitudeMatrix(float_p, matrix_size, 0, l);
1125 float_p += matrix_size;
1126 }
1127
1128 uint_p = reinterpret_cast<const unsigned int*>(
1129 reinterpret_cast<const void*>(float_p));
1130 if (matrix->HasCount()) {
1131 binary_size += sizeof(unsigned int) * matrix_size;
1132 matrix->SetCountMatrix(uint_p, matrix_size, 0, l);
1133 uint_p += matrix_size;
1134 }
1135 if (matrix->HasGroundCount()) {
1136 binary_size += sizeof(unsigned int) * matrix_size;
1137 matrix->SetGroundCountMatrix(uint_p, matrix_size, 0, l);
1138 uint_p += matrix_size;
1139 }
1140 float_p =
1141 reinterpret_cast<const float*>(reinterpret_cast<const void*>(uint_p));
1142 }
1143
1144 return binary_size;
1145}