Skip to content

Commit

Permalink
feat: added latitude longitude to graph (#450)
Browse files Browse the repository at this point in the history
Co-authored-by: Расул <[email protected]>
  • Loading branch information
Rassl and Расул authored Sep 28, 2023
1 parent 4996f61 commit da64b0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/transformers/earthGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export type NodeExtended = Node & {
x?: number
y?: number
z?: number
longitude?: number
latitude?: number
coordinates?: Coordinates
}

Expand Down

0 comments on commit da64b0b

Please sign in to comment.