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

Function projectPolys

src/component/helper/MapDraw.ts:840–880  ·  view source on GitHub ↗
(
    rings: number[][][], // Polygons include exterior and interiors. Or polylines.
    createStream: (outStream: ProjectionStream) => ProjectionStream,
    isLine?: boolean
)

Source from the content-addressed store, hash-verified

838}
839
840function projectPolys(
841 rings: number[][][], // Polygons include exterior and interiors. Or polylines.
842 createStream: (outStream: ProjectionStream) => ProjectionStream,
843 isLine?: boolean
844) {
845 const polygons: number[][][] = [];
846 let curPoly: number[][];
847
848 function startPolygon() {
849 curPoly = [];
850 }
851 function endPolygon() {
852 if (curPoly.length) {
853 polygons.push(curPoly);
854 curPoly = [];
855 }
856 }
857 const stream = createStream({
858 polygonStart: startPolygon,
859 polygonEnd: endPolygon,
860 lineStart: startPolygon,
861 lineEnd: endPolygon,
862 point(x, y) {
863 // May have NaN values from stream.
864 if (isFinite(x) && isFinite(y)) {
865 curPoly.push([x, y]);
866 }
867 },
868 sphere() {}
869 });
870 !isLine && stream.polygonStart();
871 zrUtil.each(rings, ring => {
872 stream.lineStart();
873 for (let i = 0; i < ring.length; i++) {
874 stream.point(ring[i][0], ring[i][1]);
875 }
876 stream.lineEnd();
877 });
878 !isLine && stream.polygonEnd();
879 return polygons;
880}
881
882function isGeoModel(mapOrGeoModel: MapOrGeoModel): mapOrGeoModel is GeoModel {
883 return mapOrGeoModel.mainType === 'geo';

Callers 1

_buildGeoJSONMethod · 0.85

Calls 6

polygonStartMethod · 0.80
lineStartMethod · 0.80
lineEndMethod · 0.80
polygonEndMethod · 0.80
pointMethod · 0.65
eachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…