import { countryCodeMapping } from "@/lib/geo";
import { GetNezhaData } from "@/lib/serverFetch";
import { geoEqualEarth, geoPath } from "d3-geo";
import { geoJsonString } from "../../../lib/geo-json-string";
import GlobalInfo from "./GlobalInfo";
interface GlobalProps {
countries?: string[];
}
export default async function ServerGlobal() {
const nezhaServerList = await GetNezhaData();
const countrytList: string[] = [];
nezhaServerList.result.forEach((server) => {
if (server.host.CountryCode) {
server.host.CountryCode = server.host.CountryCode.toUpperCase();
if (!countrytList.includes(server.host.CountryCode)) {
countrytList.push(server.host.CountryCode);
}
}
});
return ;
}
export async function Global({ countries = [] }: GlobalProps) {
const width = 900;
const height = 500;
const projection = geoEqualEarth()
.scale(180)
.translate([width / 2, height / 2])
.rotate([0, 0]); // 调整旋转以优化显示效果
const path = geoPath().projection(projection);
const geoJson = JSON.parse(geoJsonString);
const countries_alpha3 = countries
.map((code) => countryCodeMapping[code])
.filter((code) => code !== undefined);
const filteredFeatures = geoJson.features.filter(
(feature: any) => feature.properties.iso_a3 !== "",
);
return (
);
}