From aff3de23c65524b7bc9024eb0e01dd4ed316cf6c Mon Sep 17 00:00:00 2001 From: yihong Date: Tue, 26 Mar 2024 18:29:29 +0800 Subject: [PATCH 1/4] chore: Update package manager and ignore requirements-dev.txt (#632) Fix issue vercel error: spawn pip3 ENOENT by: - Update packageManager field from "pnpm@8.7.0" to "yarn@1.22.22" - Add `requirements-dev.txt` to `.vercelignore` close: #627 Signed-off-by: yihong0618 --- .vercelignore | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.vercelignore b/.vercelignore index 979f16f7011..8e294ae2f2e 100644 --- a/.vercelignore +++ b/.vercelignore @@ -1 +1,2 @@ requirements.txt +requirements-dev.txt diff --git a/package.json b/package.json index c707ff966fa..f8b660767c7 100644 --- a/package.json +++ b/package.json @@ -65,5 +65,5 @@ "prettier": "2.8.8", "typescript": "^5.1.6" }, - "packageManager": "pnpm@8.7.0" + "packageManager": "yarn@1.22.22" } From 1627dd7c60c33b6a1cad396e77a37059840550cb Mon Sep 17 00:00:00 2001 From: ben_29 Date: Wed, 27 Mar 2024 19:41:25 +0800 Subject: [PATCH 2/4] feat: add line color in China Geojson --- src/components/RunMap/index.tsx | 3 +-- src/static/run_countries.ts | 35 +++++++++++++++++++++++++++++++++ src/utils/utils.ts | 6 ++++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/components/RunMap/index.tsx b/src/components/RunMap/index.tsx index 88622c2ef69..a32ea1dc68e 100644 --- a/src/components/RunMap/index.tsx +++ b/src/components/RunMap/index.tsx @@ -7,7 +7,6 @@ import { MAP_LAYER_LIST, IS_CHINESE, ROAD_LABEL_DISPLAY, - MAIN_COLOR, MAPBOX_TOKEN, PROVINCE_FILL_COLOR, USE_DASH_LINE, @@ -149,7 +148,7 @@ const RunMap = ({ id="runs2" type="line" paint={{ - 'line-color': MAIN_COLOR, + 'line-color': ['get', 'color'], 'line-width': isBigMap && lights ? 1 : 2, 'line-dasharray': dash, 'line-opacity': isSingleRun || isBigMap || !lights ? 1 : LINE_OPACITY, diff --git a/src/static/run_countries.ts b/src/static/run_countries.ts index b0c9b8cb81b..47d8113fd73 100644 --- a/src/static/run_countries.ts +++ b/src/static/run_countries.ts @@ -1,4 +1,5 @@ import { FeatureCollection, LineString, Polygon, MultiPolygon } from 'geojson'; +import { MAIN_COLOR } from '@/utils/const'; export type RPGeometry = LineString | Polygon | MultiPolygon; @@ -13,6 +14,7 @@ export const chinaGeojson: FeatureCollection = { name: '新疆维吾尔自治区', cp: [84.9023, 42.148], childNum: 18, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -181,6 +183,7 @@ export const chinaGeojson: FeatureCollection = { name: '西藏自治区', cp: [87.8695, 31.6846], childNum: 7, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -345,6 +348,7 @@ export const chinaGeojson: FeatureCollection = { name: '内蒙古自治区', cp: [112.5977, 46.3408], childNum: 12, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -587,6 +591,7 @@ export const chinaGeojson: FeatureCollection = { name: '青海省', cp: [95.2402, 35.4199], childNum: 8, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -739,6 +744,7 @@ export const chinaGeojson: FeatureCollection = { name: '四川省', cp: [101.9199, 30.1904], childNum: 21, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -884,6 +890,7 @@ export const chinaGeojson: FeatureCollection = { name: '黑龙江省', cp: [126.1445, 48.7156], childNum: 13, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -1022,6 +1029,7 @@ export const chinaGeojson: FeatureCollection = { name: '甘肃省', cp: [99.7129, 38.166], childNum: 14, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -1214,6 +1222,7 @@ export const chinaGeojson: FeatureCollection = { name: '云南省', cp: [101.0652, 25.1807], childNum: 16, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -1357,6 +1366,7 @@ export const chinaGeojson: FeatureCollection = { name: '广西壮族自治区', cp: [107.7813, 23.6426], childNum: 14, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -1459,6 +1469,7 @@ export const chinaGeojson: FeatureCollection = { name: '湖南省', cp: [111.5332, 27.3779], childNum: 14, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -1551,6 +1562,7 @@ export const chinaGeojson: FeatureCollection = { name: '陕西省', cp: [109.5996, 35.7396], childNum: 10, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -1652,6 +1664,7 @@ export const chinaGeojson: FeatureCollection = { name: '广东省', cp: [113.4668, 22.8076], childNum: 21, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -1761,6 +1774,7 @@ export const chinaGeojson: FeatureCollection = { name: '吉林省', cp: [125.7746, 43.5938], childNum: 9, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -1857,6 +1871,7 @@ export const chinaGeojson: FeatureCollection = { name: '河北省', cp: [115.4004, 39.4688], childNum: 11, + color: MAIN_COLOR, }, geometry: { type: 'MultiPolygon', @@ -1989,6 +2004,7 @@ export const chinaGeojson: FeatureCollection = { name: '湖北省', cp: [112.2363, 31.1572], childNum: 17, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2083,6 +2099,7 @@ export const chinaGeojson: FeatureCollection = { name: '贵州省', cp: [106.6113, 26.9385], childNum: 9, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2179,6 +2196,7 @@ export const chinaGeojson: FeatureCollection = { name: '山东省', cp: [118.7402, 36.4307], childNum: 17, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2261,6 +2279,7 @@ export const chinaGeojson: FeatureCollection = { name: '江西省', cp: [116.0156, 27.29], childNum: 11, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2340,6 +2359,7 @@ export const chinaGeojson: FeatureCollection = { name: '河南省', cp: [113.0668, 33.8818], childNum: 17, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2420,6 +2440,7 @@ export const chinaGeojson: FeatureCollection = { name: '辽宁省', cp: [122.0438, 41.0889], childNum: 14, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2490,6 +2511,7 @@ export const chinaGeojson: FeatureCollection = { name: '山西省', cp: [112.4121, 37.6611], childNum: 11, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2559,6 +2581,7 @@ export const chinaGeojson: FeatureCollection = { name: '安徽省', cp: [117.2461, 32.0361], childNum: 17, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2644,6 +2667,7 @@ export const chinaGeojson: FeatureCollection = { name: '福建省', cp: [118.3008, 25.9277], childNum: 9, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2717,6 +2741,7 @@ export const chinaGeojson: FeatureCollection = { name: '浙江省', cp: [120.498, 29.0918], childNum: 11, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2781,6 +2806,7 @@ export const chinaGeojson: FeatureCollection = { name: '江苏省', cp: [118.8586, 32.915], childNum: 13, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2854,6 +2880,7 @@ export const chinaGeojson: FeatureCollection = { name: '重庆市', cp: [107.7539, 30.1904], childNum: 40, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2937,6 +2964,7 @@ export const chinaGeojson: FeatureCollection = { name: '宁夏回族自治区', cp: [105.9961, 37.3096], childNum: 5, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -2993,6 +3021,7 @@ export const chinaGeojson: FeatureCollection = { name: '海南省', cp: [109.9512, 19.2041], childNum: 18, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -3029,6 +3058,7 @@ export const chinaGeojson: FeatureCollection = { name: '台湾省', cp: [120.0254, 23.5986], childNum: 1, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -3062,6 +3092,7 @@ export const chinaGeojson: FeatureCollection = { name: '北京市', cp: [116.4551, 40.2539], childNum: 19, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -3103,6 +3134,7 @@ export const chinaGeojson: FeatureCollection = { name: '天津市', cp: [117.4219, 39.4189], childNum: 18, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -3143,6 +3175,7 @@ export const chinaGeojson: FeatureCollection = { name: '上海市', cp: [121.4648, 31.2891], childNum: 19, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -3170,6 +3203,7 @@ export const chinaGeojson: FeatureCollection = { name: '香港特别行政区', cp: [114.1178, 22.3242], childNum: 1, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', @@ -3198,6 +3232,7 @@ export const chinaGeojson: FeatureCollection = { name: '澳门特别行政区', cp: [111.5547, 22.1484], childNum: 1, + color: MAIN_COLOR, }, geometry: { type: 'Polygon', diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 1c980b35668..5dc8be39de7 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -3,7 +3,7 @@ import gcoord from 'gcoord'; import { WebMercatorViewport } from 'viewport-mercator-project'; import { chinaGeojson } from '@/static/run_countries'; import { chinaCities } from '@/static/city'; -import { MUNICIPALITY_CITIES_ARR, NEED_FIX_MAP, RUN_TITLES } from './const'; +import { MAIN_COLOR, MUNICIPALITY_CITIES_ARR, NEED_FIX_MAP, RUN_TITLES } from './const'; import { FeatureCollection, LineString } from 'geojson'; export type Coordinate = [number, number]; @@ -170,7 +170,9 @@ const geoJsonForRuns = (runs: Activity[]): FeatureCollection => ({ return { type: 'Feature', - properties: {}, + properties: { + color: MAIN_COLOR, + }, geometry: { type: 'LineString', coordinates: points, From f21832dc6c36fdbf613a7e7eac4ba3fb80832628 Mon Sep 17 00:00:00 2001 From: ben_29 Date: Wed, 27 Mar 2024 19:51:45 +0800 Subject: [PATCH 3/4] feat: fill countries that been there; only support Chinese user; --- package.json | 1 + pnpm-lock.yaml | 7 +++++++ src/components/RunMap/index.tsx | 15 ++++++++++++++- src/utils/const.ts | 2 ++ src/utils/utils.ts | 8 ++++++-- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f8b660767c7..6daca1d4585 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "dependencies": { "@mapbox/mapbox-gl-language": "^1.0.0", "@mapbox/polyline": "^1.1.1", + "@surbowl/world-geo-json-zh": "^2.1.3", "@svgr/plugin-svgo": "^8.1.0", "@vercel/analytics": "^0.1.6", "@vitejs/plugin-react": "^4.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 94cb3b52c33..c874b0a704d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ dependencies: '@mapbox/polyline': specifier: ^1.1.1 version: 1.2.0 + '@surbowl/world-geo-json-zh': + specifier: ^2.1.3 + version: 2.1.3 '@svgr/plugin-svgo': specifier: ^8.1.0 version: 8.1.0(@svgr/core@7.0.0) @@ -753,6 +756,10 @@ packages: picomatch: 2.3.1 dev: false + /@surbowl/world-geo-json-zh@2.1.3: + resolution:{integrity: sha512-6m/eVcSsWvFXYkaEQLHCxJqFSkTMVaDgfTg9weQr2lozyrxxH+SsRTq24DFfCqFX7L9zKtDQcP6+5VKemY1Rcg==,} + dev: false + /@svgr/babel-plugin-add-jsx-attribute@7.0.0(@babel/core@7.22.11): resolution: {integrity: sha512-khWbXesWIP9v8HuKCl2NU2HNAyqpSQ/vkIl36Nbn4HIwEYSRWL0H7Gs6idJdha2DkpFDWlsqMELvoCE8lfFY6Q==} engines: {node: '>=14'} diff --git a/src/components/RunMap/index.tsx b/src/components/RunMap/index.tsx index a32ea1dc68e..2fd074d3d0d 100644 --- a/src/components/RunMap/index.tsx +++ b/src/components/RunMap/index.tsx @@ -9,6 +9,7 @@ import { ROAD_LABEL_DISPLAY, MAPBOX_TOKEN, PROVINCE_FILL_COLOR, + COUNTRY_FILL_COLOR, USE_DASH_LINE, LINE_OPACITY, MAP_HEIGHT, @@ -41,7 +42,7 @@ const RunMap = ({ geoData, thisYear, }: IRunMapProps) => { - const { provinces } = useActivities(); + const { countries, provinces } = useActivities(); const mapRef = useRef(); const [lights, setLights] = useState(PRIVACY_MODE ? false : LIGHTS_ON); const keepWhenLightsOff = ['runs2'] @@ -83,8 +84,10 @@ const RunMap = ({ [mapRef, lights] ); const filterProvinces = provinces.slice(); + const filterCountries = countries.slice(); // for geojson format filterProvinces.unshift('in', 'name'); + filterCountries.unshift('in', 'name'); const initGeoDataLength = geoData.features.length; const isBigMap = (viewState.zoom ?? 0) <= 3; @@ -144,6 +147,16 @@ const RunMap = ({ }} filter={filterProvinces} /> + => ({ }), }); -const geoJsonForMap = () => chinaGeojson; +const geoJsonForMap = (): FeatureCollection => ({ + type: 'FeatureCollection', + features: worldGeoJson.features.concat(chinaGeojson.features), + }) const titleForRun = (run: Activity): string => { const runDistance = run.distance / 1000; From ddcd51e25236a63e12fc6c5d180af92d77b9c8a8 Mon Sep 17 00:00:00 2001 From: ben_29 Date: Wed, 27 Mar 2024 20:22:35 +0800 Subject: [PATCH 4/4] feat: fill countries that been there; only support Chinese user; --- pnpm-lock.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c874b0a704d..a1fc50b18b3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,9 +1,5 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - dependencies: '@mapbox/mapbox-gl-language': specifier: ^1.0.0 @@ -757,7 +753,7 @@ packages: dev: false /@surbowl/world-geo-json-zh@2.1.3: - resolution:{integrity: sha512-6m/eVcSsWvFXYkaEQLHCxJqFSkTMVaDgfTg9weQr2lozyrxxH+SsRTq24DFfCqFX7L9zKtDQcP6+5VKemY1Rcg==,} + resolution: {integrity: sha512-6m/eVcSsWvFXYkaEQLHCxJqFSkTMVaDgfTg9weQr2lozyrxxH+SsRTq24DFfCqFX7L9zKtDQcP6+5VKemY1Rcg==} dev: false /@svgr/babel-plugin-add-jsx-attribute@7.0.0(@babel/core@7.22.11): @@ -3630,3 +3626,7 @@ packages: dependencies: tachyons-custom: 4.9.8 dev: false + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false