Fix closed coord's reference in latLngsToCoords (#7344)

Co-authored-by: Florian Bischof <design.falke@gmail.com>
This commit is contained in:
Marcin Lasecki
2022-10-30 10:30:52 +01:00
committed by GitHub
parent 9c980d085f
commit 6b90c169d6
2 changed files with 6 additions and 1 deletions

View File

@ -882,6 +882,11 @@ describe("L.GeoJSON functions", () => {
]
});
});
it("has no reference between first and last coordinates", () => {
const coords = L.GeoJSON.latLngsToCoords([[2, 1, 3], [5, 4, 6]], null, true);
expect(coords).to.eql([[1, 2, 3], [4, 5, 6], [1, 2, 3]]);
expect(coords[0] === coords[2]).to.not.ok();
});
});
describe("#asFeature", () => {

View File

@ -288,7 +288,7 @@ export function latLngsToCoords(latlngs, levelsDeep, closed, precision) {
}
if (!levelsDeep && closed) {
coords.push(coords[0]);
coords.push(coords[0].slice());
}
return coords;