MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / formatCoord

Function formatCoord

src/common/wasm/util.js:346–374  ·  view source on GitHub ↗
(pointList)

Source from the content-addressed store, hash-verified

344}
345
346export function formatCoord(pointList) {
347 let xList = [];
348 let yList = [];
349 if (isObject(pointList) && pointList.type === 'FeatureCollection') {
350 pointList.features.forEach((feature) => {
351 const coord = feature.geometry.coordinates;
352 xList.push(coord[0]);
353 yList.push(coord[1])
354 });
355 } else if (Array.isArray(pointList)) {
356 pointList.forEach((item) => {
357 if (item.type === 'Feature') {
358 const coord = item.geometry.coordinates;
359 xList.push(coord[0]);
360 yList.push(coord[1])
361 } else if (Array.isArray(item)) {
362 xList.push(item[0]);
363 yList.push(item[1])
364 } else if (isObject(item)) {
365 xList.push(item.x);
366 yList.push(item.y)
367 }
368 });
369 }
370 return {
371 xList,
372 yList
373 }
374}

Callers 3

Calls 3

isObjectFunction · 0.90
forEachMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected