/** * 轨迹测试数据 */ // 轨迹数据类型定义 export interface TrackData { id: number name: string trackData: [number, number][] // 经纬度数组 color: string show?: boolean // 是否显示 } // 多边形数据类型定义 export interface PolygonData { id: number name: string coordinates: [number, number][] fillColor?: string strokeColor?: string strokeWidth?: number opacity?: number show?: boolean extData?: Record } /** * 生成随机轨迹点 * @param startPoint - 起始点 [经度, 纬度] * @param pointCount - 点的数量 * @param maxOffset - 最大偏移量(经纬度) * @returns 轨迹点数组 */ function generateRandomTrack( startPoint: [number, number], pointCount: number, maxOffset: number = 0.01, ): [number, number][] { const points: [number, number][] = [startPoint] let currentPoint = startPoint for (let i = 1; i < pointCount; i++) { // 生成随机偏移量,使用正态分布使轨迹更自然 const offsetLng = (Math.random() - 0.5) * maxOffset * (1 + Math.random() * 0.5) const offsetLat = (Math.random() - 0.5) * maxOffset * (1 + Math.random() * 0.5) // 添加一些随机性,使轨迹更自然 const randomFactor = Math.random() > 0.8 ? 2 : 1 // 偶尔会有较大的偏移 const newPoint: [number, number] = [ currentPoint[0] + offsetLng * randomFactor, currentPoint[1] + offsetLat * randomFactor, ] points.push(newPoint) currentPoint = newPoint } return points } // 测试数据 export const trackTestData: TrackData[] = [ { id: 1, name: '张三的轨迹', trackData: generateRandomTrack([108.948024, 34.263161], 1000, 0.005), color: '#FF0000', show: true, }, { id: 2, name: '李四的轨迹', trackData: generateRandomTrack([108.948024, 34.263161], 500, 0.003), color: '#00FF00', show: true, }, ] // 多边形测试数据 export const polygonTestData: PolygonData[] = [ { id: 1, name: '西安高新区', coordinates: [ [108.93, 34.25], [108.97, 34.25], [108.97, 34.28], [108.93, 34.28], [108.93, 34.25], ], fillColor: 'rgba(255, 0, 0, 0.3)', strokeColor: '#FF0000', strokeWidth: 2, show: true, extData: { type: 'district', population: 500000, area: '120平方公里', }, }, { id: 2, name: '曲江新区', coordinates: [ [108.95, 34.26], [108.99, 34.26], [108.99, 34.29], [108.95, 34.29], [108.95, 34.26], ], fillColor: 'rgba(0, 255, 0, 0.3)', strokeColor: '#00FF00', strokeWidth: 2, show: true, extData: { type: 'district', population: 300000, area: '80平方公里', }, }, { id: 3, name: '经开区', coordinates: [ [108.91, 34.24], [108.95, 34.24], [108.95, 34.27], [108.91, 34.27], [108.91, 34.24], ], fillColor: 'rgba(0, 0, 255, 0.3)', strokeColor: '#0000FF', strokeWidth: 2, show: true, extData: { type: 'district', population: 200000, area: '60平方公里', }, }, ]