MCPcopy
hub / github.com/apache/echarts / encode

Function encode

test/data/map/encode.js:21–58  ·  view source on GitHub ↗
(json)

Source from the content-addressed store, hash-verified

19
20
21function encode(json) {
22 if (json.UTF8Encoding) {
23 return;
24 }
25
26 json.UTF8Encoding = true;
27
28 var features = json.features;
29
30 features.forEach(function (feature){
31 var encodeOffsets = feature.geometry.encodeOffsets = [];
32 var coordinates = feature.geometry.coordinates;
33 if (feature.geometry.type === 'MultiPolygon') {
34 coordinates.forEach(function (polygon, idx1){
35 encodeOffsets[idx1] = [];
36 polygon.forEach(function (coordinate, idx2) {
37 coordinates[idx1][idx2] = encodeRing(
38 coordinate, encodeOffsets[idx1][idx2] = []
39 );
40 });
41 });
42 }
43 else if (feature.geometry.type == 'Polygon'
44 || feature.geometry.type == 'MultiLineString'
45 ) {
46 coordinates.forEach(function (coordinate, idx){
47 coordinates[idx] = encodeRing(
48 coordinate, encodeOffsets[idx] = []
49 );
50 });
51 }
52 else if (feature.geometry.type === 'LineString') {
53 feature.geometry.coordinates = encodeRing(coordinates, encodeOffsets)
54 }
55 });
56
57 return json;
58}
59
60function encodeRing(coordinates, encodeOffsets) {
61

Callers 1

cli.jsFile · 0.85

Calls 1

encodeRingFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…