用于多段线点处理的各种实用函数,由Leaflet内部使用,使多段线快速生成。
Functions
Function | Returns | Description |
---|---|---|
simplify(<Point[]> points, <Number> tolerance) | Point[] | Dramatically reduces the number of points in a polyline while retaining its shape and returns a new array of simplified points, using the Ramer-Douglas-Peucker algorithm. Used for a huge performance boost when processing/displaying Leaflet polylines for each zoom level and also reducing visual noise. tolerance affects the amount of simplification (lesser value means higher quality but slower and with more points). Also released as a separated micro-library Simplify.js. 使用Ramer-Douglas Peucker算法,在保持折线形状的同时,大幅减少折线中的点数,并返回一个新的简化点阵列。用于在处理/显示每个缩放级别的Leaflet多段线时大幅提高性能,并减少视觉噪音。公差影响简化的数量(值越小意味着质量越高,但速度越慢,点数越多)。也作为单独的微库Simplify.js发布。 |
pointToSegmentDistance(<Point> p, <Point> p1, <Point> p2) | Number | Returns the distance between point p and segment p1 to p2 .返回点p和线段p1到p2之间的距离。 |
closestPointOnSegment(<Point> p, <Point> p1, <Point> p2) | Number | Returns the closest point from a point p on a segment p1 to p2 .返回从线段p1上的点p到p2的最近点。 |
clipSegment(<Point> a, <Point> b, <Bounds> bounds, <Boolean> useLastCode?, <Boolean> round?) | Point[]|Boolean | Clips the segment a to b by rectangular bounds with the Cohen-Sutherland algorithm (modifying the segment points directly!). Used by Leaflet to only show polyline points that are on the screen or near, increasing performance. 使用Cohen Sutherland算法(直接修改线段点!)通过矩形边界剪裁线段a到b。由传单用于仅显示屏幕上或附近的多段线点,从而提高性能。 |
isFlat(<LatLng[]> latlngs) | Boolean | Returns true if latlngs is a flat array, false is nested.如果latlngs是平面数组,则返回true,如果嵌套,则返回false。 |
polylineCenter(<LatLng[]> latlngs, <CRS> crs) | LatLng | Returns the center (centroid) of the passed LatLngs (first ring) from a polyline. 返回从多段线传递的LatLngs(第一个环)的中心(质心)。 |