mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
Compare commits
6 Commits
5a7c716df6
...
4eeed6691a
Author | SHA1 | Date | |
---|---|---|---|
|
4eeed6691a | ||
|
fc6c367f97 | ||
|
e5e2d2b02d | ||
|
b8d6e83169 | ||
|
62cdb7e18c | ||
|
7e1a818dc2 |
@ -29,7 +29,6 @@ export default async function ServerGlobal() {
|
||||
}
|
||||
|
||||
export async function Global({ countries = [] }: GlobalProps) {
|
||||
// const t = useTranslations("Global");
|
||||
const map = new DottedMap({ map: JSON.parse(mapJsonString) });
|
||||
|
||||
const countries_alpha3 = countries
|
||||
@ -44,6 +43,42 @@ export async function Global({ countries = [] }: GlobalProps) {
|
||||
);
|
||||
|
||||
if (feature) {
|
||||
if (countryCode === "RUS") {
|
||||
// 获取俄罗斯的多个边界
|
||||
const bboxList = feature.geometry.coordinates.map((polygon: any) =>
|
||||
turf.bbox({ type: "Polygon", coordinates: polygon }),
|
||||
);
|
||||
|
||||
const spacing = 20; // 单位为千米
|
||||
const options = { units: "kilometers" };
|
||||
|
||||
bboxList.forEach((bbox: any) => {
|
||||
// @ts-expect-error ignore
|
||||
const pointGrid = turf.pointGrid(bbox, spacing, options);
|
||||
|
||||
// 过滤出位于当前多边形内部的点
|
||||
const pointsWithin = turf.pointsWithinPolygon(pointGrid, feature);
|
||||
|
||||
if (pointsWithin.features.length === 0) {
|
||||
const centroid = turf.centroid(feature);
|
||||
const [lng, lat] = centroid.geometry.coordinates;
|
||||
map.addPin({
|
||||
lat,
|
||||
lng,
|
||||
svgOptions: { color: "#FF4500", radius: 0.3 },
|
||||
});
|
||||
} else {
|
||||
pointsWithin.features.forEach((point: any) => {
|
||||
const [lng, lat] = point.geometry.coordinates;
|
||||
map.addPin({
|
||||
lat,
|
||||
lng,
|
||||
svgOptions: { color: "#FF4500", radius: 0.3 },
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// 获取国家的边界框
|
||||
const bbox = turf.bbox(feature);
|
||||
|
||||
|
183
lib/dev-geo.ts
Normal file
183
lib/dev-geo.ts
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nezha-dash",
|
||||
"version": "1.4.4-fix",
|
||||
"version": "1.4.5",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3040",
|
||||
@ -25,7 +25,7 @@
|
||||
"@turf/turf": "^7.1.0",
|
||||
"@types/luxon": "^3.4.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
||||
"caniuse-lite": "^1.0.30001680",
|
||||
"caniuse-lite": "^1.0.30001683",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "^2.1.1",
|
||||
"country-flag-icons": "^1.5.13",
|
||||
|
Loading…
Reference in New Issue
Block a user