1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/
 
var echarts = require('../../dist/echarts');
// var v8 = require('v8');
// v8.setFlagsFromString('--max-old-space-size=4096');
 
var { createCanvas } = require('canvas');
var fs = require('fs');
var ProgressBar = require('progress');
 
echarts.setCanvasCreator(function () {
    return createCanvas(100, 100);
});
 
var canvas = createCanvas();
canvas.width = 2048;
canvas.height = 1024;
 
var worldJson = JSON.parse(fs.readFileSync('.././data/map/json/world.json', 'utf-8'));
echarts.registerMap('world', worldJson);
 
var chart = echarts.init(canvas);
chart.setOption({
    backgroundColor: '#000',
    geo: {
        map: 'world',
        roam: true,
        label: {
            emphasis: {
                show: false
            }
        },
        silent: true,
        itemStyle: {
            normal: {
                areaColor: '#323c48',
                borderColor: '#111'
            },
            emphasis: {
                areaColor: '#2a333d'
            }
        }
    },
    series: [{
        name: '弱',
        type: 'scatter',
        progressive: 1e5,
        coordinateSystem: 'geo',
        symbolSize: 0.5,
        blendMode: 'lighter',
        large: true,
        itemStyle: {
            normal: {
                color: 'rgb(20, 15, 2)'
            }
        },
        postEffect: {
            enable: true
        },
        silent: true,
        dimensions: ['lng', 'lat'],
        data: new Float32Array()
    }]
});
 
 
// var CHUNK_COUNT = 277;
var CHUNK_COUNT = 229;
// https://blog.openstreetmap.org/2012/04/01/bulk-gps-point-data/
function fetchData(idx) {
    if (idx >= CHUNK_COUNT) {
        setTimeout(function () {
            fs.writeFile('out.png', canvas.toBuffer());
            chart.dispose();
        });
        return;
    }
 
    fs.readFile(`../../../echarts-gl/test/data/gps/gps_${idx}.bin`, function (err, buffer) {
        var arr = new Uint8Array(buffer.length);
        for (var i = 0; i < buffer.length; i++) {
            arr[i] = buffer[i];
        }
 
        var rawData = new Int32Array(arr.buffer);
        var data = new Float32Array(rawData.length);
        for (var i = 0; i < rawData.length; i += 2) {
            data[i] = rawData[i+1] / 1e7;
            data[i+1] = rawData[i] / 1e7;
        }
 
        chart.appendData({
            seriesIndex: 0,
            data: data
        });
 
        fetchData(idx + 1);
 
        progress.tick();
    });
}
var progress = new ProgressBar('Generating [:bar] :percent :etas', {
    complete: '=',
    incomplete: ' ',
    width: 50,
    total: CHUNK_COUNT
});
 
fetchData(0);