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 }