| 139 | } |
| 140 | |
| 141 | EncodedGeoStatistics Encode() const { |
| 142 | if (!is_valid_) { |
| 143 | return {}; |
| 144 | } |
| 145 | |
| 146 | const geospatial::BoundingBox::XYZM& mins = bounder_.Bounds().min; |
| 147 | const geospatial::BoundingBox::XYZM& maxes = bounder_.Bounds().max; |
| 148 | |
| 149 | EncodedGeoStatistics out; |
| 150 | |
| 151 | if (has_geometry_types_) { |
| 152 | out.geospatial_types = bounder_.GeometryTypes(); |
| 153 | } |
| 154 | |
| 155 | bool write_x = !bound_empty(0) && bound_valid(0); |
| 156 | bool write_y = !bound_empty(1) && bound_valid(1); |
| 157 | bool write_z = write_x && write_y && !bound_empty(2) && bound_valid(2); |
| 158 | bool write_m = write_x && write_y && !bound_empty(3) && bound_valid(3); |
| 159 | |
| 160 | if (write_x && write_y) { |
| 161 | out.xmin = mins[0]; |
| 162 | out.xmax = maxes[0]; |
| 163 | out.ymin = mins[1]; |
| 164 | out.ymax = maxes[1]; |
| 165 | out.xy_bounds_present = true; |
| 166 | } |
| 167 | |
| 168 | if (write_z) { |
| 169 | out.zmin = mins[2]; |
| 170 | out.zmax = maxes[2]; |
| 171 | out.z_bounds_present = true; |
| 172 | } |
| 173 | |
| 174 | if (write_m) { |
| 175 | out.mmin = mins[3]; |
| 176 | out.mmax = maxes[3]; |
| 177 | out.m_bounds_present = true; |
| 178 | } |
| 179 | |
| 180 | return out; |
| 181 | } |
| 182 | |
| 183 | void Decode(const EncodedGeoStatistics& encoded) { |
| 184 | Reset(); |
nothing calls this directly
no test coverage detected