perf: build map

This commit is contained in:
ccbikai
2024-06-08 14:34:34 +08:00
parent 5df2adc5b0
commit d0d0fc65e5
7 changed files with 23 additions and 15 deletions
+17
View File
@@ -0,0 +1,17 @@
import { writeFileSync } from 'fs'
import { join } from 'path'
import { WorldMapSimplestTopoJSON } from '@unovis/ts/maps.js'
import WorldMapTopoJSON from '../assets/location/world.json' with { type: "json" } // https://github.com/apache/echarts/blob/master/test/data/map/json/world.json
WorldMapTopoJSON.objects.states.geometries.map((state) => {
const name = state.properties.name
const country = WorldMapSimplestTopoJSON.objects.countries.geometries.find(country => country.properties.name === name)
state.id = state.name || ''
if (country) {
state.id = country.id || ''
state.properties = country.properties
}
return state
})
writeFileSync(join(import.meta.dirname, '../assets/location/world-topo.json'), JSON.stringify(WorldMapTopoJSON), 'utf8')