add getTileJson method to PMTiles class [#239, #247] (#453)

* add getTileJson method to PMTiles class [#239, #247]
* update docs related to FetchSource and headers [#397]
This commit is contained in:
Brandon Liu
2024-09-18 15:57:14 +08:00
committed by GitHub
parent 6ed85a28fb
commit 6f5479439b
7 changed files with 121 additions and 56 deletions

View File

@@ -12,7 +12,7 @@ import {
Source,
TileType,
} from "../../../js/index";
import { pmtiles_path, tileJSON, tile_path } from "../../shared/index";
import { pmtiles_path, tile_path } from "../../shared/index";
import { createHash } from "crypto";
import zlib from "zlib";
@@ -177,15 +177,13 @@ export const handlerRaw = async (
}
headers["Content-Type"] = "application/json";
const t = tileJSON(
header,
await p.getMetadata(),
process.env.PUBLIC_HOSTNAME ||
const t = await p.getTileJson(
`https://${
process.env.PUBLIC_HOSTNAME ||
event.headers["x-distribution-domain-name"] ||
"",
name
""
}/${name}`
);
return apiResp(200, JSON.stringify(t), false, headers);
}