File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ const CUSTOM2 = 7;
2727
2828const Num = typeof BigInt !== "undefined" ? BigInt : Number ;
2929
30- function decode ( encoded ) {
30+ function decode ( encoded , params = { geojson : false } ) {
31+ const { geojson } = params
3132 const decoder = decodeUnsignedValues ( encoded ) ;
3233 const header = decodeHeader ( decoder [ 0 ] , decoder [ 1 ] ) ;
3334
@@ -46,14 +47,22 @@ function decode(encoded) {
4647 const deltaLng = toSigned ( decoder [ i + 1 ] ) / factorDegree ;
4748 lastLat += deltaLat ;
4849 lastLng += deltaLng ;
50+
51+ let point
52+
53+ if ( geojson ) {
54+ point = [ lastLng , lastLat ]
55+ } else {
56+ point = [ lastLat , lastLng ]
57+ }
4958
5059 if ( thirdDim ) {
5160 const deltaZ = toSigned ( decoder [ i + 2 ] ) / factorZ ;
5261 lastZ += deltaZ ;
53- res . push ( [ lastLat , lastLng , lastZ ] ) ;
62+ res . push ( [ ... point , lastZ ] ) ;
5463 i += 3 ;
5564 } else {
56- res . push ( [ lastLat , lastLng ] ) ;
65+ res . push ( point ) ;
5766 i += 2 ;
5867 }
5968 }
You can’t perform that action at this time.
0 commit comments