• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

antvis / L7Plot / 3763448570

pending completion
3763448570

Pull #262

github

GitHub
Merge 3128c703f into da129e8ec
Pull Request #262: refactor: 图层属性更新逻辑性能优化

723 of 1953 branches covered (37.02%)

Branch coverage included in aggregate %.

8 of 8 new or added lines in 1 file covered. (100.0%)

3049 of 4601 relevant lines covered (66.27%)

177.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.56
/packages/l7plot/src/plots/choropleth/layer.ts
1
import { deepAssign } from '../../utils';
2
import { ChinaBoundaryStyle, ChoroplethOptions, FeatureCollection } from './types';
127✔
3
import { PathLayer } from '../../layers/path-layer';
127✔
4
import { CHINA_BOUNDARY_STYLE } from './constants';
127✔
5

127✔
6
/**
127✔
7
 * 创建中国国界线图层
8
 */
9
export const createCountryBoundaryLayer = (data: FeatureCollection, plotConfig?: ChoroplethOptions) => {
10
  const { visible, minZoom, maxZoom, zIndex = 0, chinaBorder } = plotConfig || {};
127✔
11
  const borderStyle: Required<ChinaBoundaryStyle> =
×
12
    typeof chinaBorder === 'object' ? deepAssign({}, CHINA_BOUNDARY_STYLE, chinaBorder) : CHINA_BOUNDARY_STYLE;
×
13
  const chinaBoundaryFeatures = data.features.filter(({ properties }) =>
×
14
    ['coast', 'national'].includes(properties?.['type'])
×
15
  );
×
16
  const disputeBoundaryFeatures = data.features.filter(({ properties }) => properties?.['type'] === 'dispute');
17
  const hkmBoundaryFeatures = data.features.filter(({ properties }) => properties?.['type'] === 'hkm');
×
18

×
19
  const chinaBoundaryLayer = new PathLayer({
×
20
    name: 'chinaBoundaryLayer',
21
    visible,
×
22
    minZoom,
×
23
    maxZoom,
×
24
    zIndex: zIndex + 0.1,
25
    source: {
×
26
      data: { type: 'FeatureCollection', features: chinaBoundaryFeatures },
27
      parser: { type: 'geojson' },
28
    },
29
    color: {
30
      field: 'type',
31
      value: ({ type }) => {
32
        return borderStyle[type].color;
33
      },
34
    },
35
    size: {
36
      field: 'type',
37
      value: ({ type }) => {
38
        return borderStyle[type].width;
×
39
      },
×
40
    },
41
    style: {
42
      opacity: ['type', (type) => borderStyle[type].opacity],
43
    },
44
  });
45
  const chinaHkmBoundaryLayer = new PathLayer({
×
46
    name: 'chinaHkmBoundaryLayer',
×
47
    visible,
48
    minZoom,
49
    maxZoom,
50
    zIndex: zIndex + 0.1,
×
51
    source: {
52
      data: { type: 'FeatureCollection', features: hkmBoundaryFeatures },
53
      parser: { type: 'geojson' },
×
54
    },
55
    color: borderStyle.hkm.color,
56
    size: borderStyle.hkm.width,
57
    style: {
58
      opacity: borderStyle.hkm.opacity,
59
      lineType: 'dash',
60
      dashArray: borderStyle.hkm.dashArray as [number, number],
61
    },
62
  });
63
  const chinaDisputeBoundaryLayer = new PathLayer({
64
    name: 'chinaDisputeBoundaryLayer',
65
    visible,
66
    minZoom,
67
    maxZoom,
68
    zIndex: zIndex + 0.1,
69
    source: {
70
      data: { type: 'FeatureCollection', features: disputeBoundaryFeatures },
71
      parser: { type: 'geojson' },
×
72
    },
73
    color: borderStyle.dispute.color,
74
    size: borderStyle.dispute.width,
75
    style: {
76
      opacity: borderStyle.dispute.opacity,
77
      lineType: 'dash',
78
      dashArray: borderStyle.dispute.dashArray as [number, number],
79
    },
80
  });
81

82
  return { chinaBoundaryLayer, chinaHkmBoundaryLayer, chinaDisputeBoundaryLayer };
83
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc