Allow raw latlng array in latLngToCoords/latLngsToCoords (#7436)

* Add Array traitment into latLngToCoords/latLngsToCoords

add array management into function latLngToCoords and coordsToLatLngs

Add array management into GeoJSON.latLngToCoords andGeoJSON.latLngToCoords

* Add tests

* minify code

* remove redundant code

* revert change

Co-authored-by: Dorian Benedetti <dorian.benedetti@etu.u-bordeaux.fr>
Co-authored-by: Florian Bischof <design.falke@gmail.com>
This commit is contained in:
Relkfaw
2022-04-15 14:27:51 +02:00
committed by GitHub
parent 25546fc04f
commit b3e1b241f1
2 changed files with 12 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import {Polyline} from './vector/Polyline';
import {Polygon} from './vector/Polygon';
import {LatLng} from '../geo/LatLng';
import * as LineUtil from '../geometry/LineUtil';
import {toLatLng} from '../geo/LatLng';
/*
@ -257,6 +258,7 @@ export function coordsToLatLngs(coords, levelsDeep, _coordsToLatLng) {
// Reverse of [`coordsToLatLng`](#geojson-coordstolatlng)
// Coordinates values are rounded with [`formatNum`](#util-formatnum) function.
export function latLngToCoords(latlng, precision) {
latlng = toLatLng(latlng);
return latlng.alt !== undefined ?
[Util.formatNum(latlng.lng, precision), Util.formatNum(latlng.lat, precision), Util.formatNum(latlng.alt, precision)] :
[Util.formatNum(latlng.lng, precision), Util.formatNum(latlng.lat, precision)];