(
rings: number[][][], // Polygons include exterior and interiors. Or polylines.
createStream: (outStream: ProjectionStream) => ProjectionStream,
isLine?: boolean
)
| 838 | } |
| 839 | |
| 840 | function 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 | |
| 882 | function isGeoModel(mapOrGeoModel: MapOrGeoModel): mapOrGeoModel is GeoModel { |
| 883 | return mapOrGeoModel.mainType === 'geo'; |
no test coverage detected
searching dependent graphs…