{"id":21716694,"url":"https://github.com/postor/limited-polyline","last_synced_at":"2025-03-20T19:58:16.457Z","repository":{"id":230266475,"uuid":"483597790","full_name":"postor/limited-polyline","owner":"postor","description":"limit polyline points and keep the shape as possible | 在尽量保持形状的情况下限制 polyline 点的数量","archived":false,"fork":false,"pushed_at":"2022-05-09T03:28:55.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-04T02:25:44.505Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-04-20T09:53:05.000Z","updated_at":"2022-04-28T09:51:32.000Z","dependencies_parsed_at":"2024-03-28T19:17:32.301Z","dependency_job_id":"20efaefc-5e67-4e1e-81f2-4374f432e98b","html_url":"https://github.com/postor/limited-polyline","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"86b5eb0484fa05924e8062c2491ca6e65a0d9d1a"},"previous_names":["postor/limited-polyline"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postor%2Flimited-polyline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postor%2Flimited-polyline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postor%2Flimited-polyline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postor%2Flimited-polyline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postor","download_url":"https://codeload.github.com/postor/limited-polyline/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244679633,"owners_count":20492447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-26T01:12:47.387Z","updated_at":"2025-03-20T19:58:16.430Z","avatar_url":"https://github.com/postor.png","language":"TypeScript","readme":"# limited-polyline\nlimit polyline points and keep the shape as possible | 在尽量保持形状的情况下限制 polyline 点的数量\n\nuse case: draw track for moving thing on map, avoid costing too much memory\n\n场景：在地图上绘制运动物体的实时轨迹，避免占用内存过多内存\n\n\n[![https://youtube.com/shorts/unsaPHuP1Dk](https://img.youtube.com/vi/unsaPHuP1Dk/hqdefault.jpg)](https://youtube.com/shorts/unsaPHuP1Dk)\n\n\nexample: \n\n- limited: https://codesandbox.io/s/leaflet-limited-track-kkoud9\n- full: https://codesandbox.io/s/leaflet-full-track-v5dtbp\n\n## usage | 使用\n\nAPI:\n```\nclass LimitedPolyline\u003cT extends {}\u003e {\n  constructor(distanceFn: (p1: T, pMidF: T, p3: T) =\u003e number, limit?: number, points?: T[]);\n  add(point: T): void;\n  iterator(): Generator\u003cT, void, unknown\u003e;\n  removeNearest(): void;\n}\n```\n\nexample\n```\nimport LimitedPolyline from 'limited-polyline'\nlet lp = new LimitedPolyline(distance, 10000);\nline.add([x,y]) // add to end, if total points larger than limit drop one | 追加到末尾，如果总点数超出限制则丢掉一个不起眼的点\n\n```\n\n## example | 示例\n\n完整轨迹，没有使用 limited-polyline 直接绘制 polyline\nhttps://codesandbox.io/s/leaflet-full-track-v5dtbp?file=/src/index.js\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostor%2Flimited-polyline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostor%2Flimited-polyline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostor%2Flimited-polyline/lists"}