python writer improvements

* flesh out roundtrip test case
* detect unordered tile writes and set clustered flag appropriately [#115]
This commit is contained in:
Brandon Liu
2023-06-23 11:18:07 +08:00
parent 56f5a7c179
commit 1940b4eff6
5 changed files with 76 additions and 41 deletions

View File

@@ -273,12 +273,16 @@ def serialize_header(h):
write_uint8(h["tile_type"].value)
write_uint8(h["min_zoom"])
write_uint8(h["max_zoom"])
write_int32(h["min_lon_e7"])
write_int32(h["min_lat_e7"])
write_int32(h["max_lon_e7"])
write_int32(h["max_lat_e7"])
write_uint8(h["center_zoom"])
write_int32(h["center_lon_e7"])
write_int32(h["center_lat_e7"])
min_lon_e7 = h.get("min_lon_e7",-180)
write_int32(min_lon_e7)
min_lat_e7 = h.get("min_lat_e7",-90)
write_int32(min_lat_e7)
max_lon_e7 = h.get("max_lon_e7",180)
write_int32(max_lon_e7)
max_lat_e7 = h.get("max_lat_e7",90)
write_int32(max_lat_e7)
write_uint8(h.get("center_zoom",h["min_zoom"]))
write_int32(h.get("center_lon_e7", round((min_lon_e7 + max_lon_e7) / 2)))
write_int32(h.get("center_lat_e7", round((min_lat_e7 + max_lat_e7) / 2)))
return b_io.getvalue()