(coords)
| 1 | import { isObject } from '../util/BaseUtil'; |
| 2 | |
| 3 | export function geojsonCoordsToPoint2Ds(coords) { |
| 4 | if (!coords) { |
| 5 | throw new Error('No GeoJSON coords provided'); |
| 6 | } |
| 7 | |
| 8 | if (!coords || coords.length === 0) { |
| 9 | return null; |
| 10 | } |
| 11 | const length = coords.length; |
| 12 | const dim = 2; // coords[0].length |
| 13 | const coordArr = new Float64Array(coords.flat()); |
| 14 | const coordPtr = window.ugcModule._malloc(length * dim * 8); |
| 15 | window.ugcModule.HEAPF64.set(coordArr, coordPtr / 8); |
| 16 | const seqPtr = window.ugcModule._UGCWasm_Geometry_CreatePoint2DsFromBuffer(coordPtr, length); |
| 17 | window.ugcModule._free(coordPtr); |
| 18 | return seqPtr; |
| 19 | } |
| 20 | |
| 21 | export function geojsonCoords2UGDoubleArray(coords) { |
| 22 | if (!coords) { |
no test coverage detected