MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / geojsonCoordsToPoint2Ds

Function geojsonCoordsToPoint2Ds

src/common/wasm/util.js:3–19  ·  view source on GitHub ↗
(coords)

Source from the content-addressed store, hash-verified

1import { isObject } from '../util/BaseUtil';
2
3export 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
21export function geojsonCoords2UGDoubleArray(coords) {
22 if (!coords) {

Callers 2

computeConvexHullMethod · 0.90
geojson2UGGeometryFunction · 0.85

Calls 1

setMethod · 0.45

Tested by

no test coverage detected