From da64b0b3fc1d1f053f1217e4bb51a54181223db4 Mon Sep 17 00:00:00 2001 From: Rassl Date: Thu, 28 Sep 2023 17:52:59 +0300 Subject: [PATCH] feat: added latitude longitude to graph (#450) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Расул --- src/transformers/earthGraph.ts | 6 ++++-- src/types/index.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/transformers/earthGraph.ts b/src/transformers/earthGraph.ts index c811e020f..51c206360 100644 --- a/src/transformers/earthGraph.ts +++ b/src/transformers/earthGraph.ts @@ -36,8 +36,10 @@ export const getPositionFromLngLat = (lng: number, lat: number, radius: number) export const generateEarthGraphPositions = (nodes: NodeExtended[]) => { const updatedNodes = nodes.map((node: NodeExtended) => { - const { lng, lat } = node.coordinates ? node.coordinates : { lng: getRandomLngLat(), lat: getRandomLngLat() } - const position = getPositionFromLngLat(lng, lat, dataRadius) + const { longitude, latitude } = + node.longitude && node.latitude ? node : { longitude: getRandomLngLat(), latitude: getRandomLngLat() } + + const position = getPositionFromLngLat(longitude as number, latitude as number, dataRadius) const updatedNode = { ...node, ...position } diff --git a/src/types/index.ts b/src/types/index.ts index 3e5e74d0c..848dfa494 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -86,6 +86,8 @@ export type NodeExtended = Node & { x?: number y?: number z?: number + longitude?: number + latitude?: number coordinates?: Coordinates }