From 30fecdeaef86a04cad7a9f93a31ae9856ad4e473 Mon Sep 17 00:00:00 2001 From: hanemile Date: Sat, 12 Jan 2019 20:11:04 +0100 Subject: using json to store the stars --- quadtree.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/quadtree.go b/quadtree.go index a9e60e6..eaca299 100644 --- a/quadtree.go +++ b/quadtree.go @@ -1,6 +1,7 @@ package structs import ( + "encoding/json" "fmt" "io/ioutil" "os/exec" @@ -169,14 +170,19 @@ for tree={,draw, s sep+=0.25em} } // GetAllStars returns all the stars in the tree it is called on in an array -func (n Node) GetAllStars() []Star2D { +func (n Node) GetAllStars() []string { // define a list to store the stars - listOfNodes := []Star2D{} + listOfNodes := []string{} // if there is a star in the node, append the star to the list if n.Star != (Star2D{}) { - listOfNodes = append(listOfNodes, n.Star) + starJson, err := json.Marshal(n.Star) + if err != nil { + panic(err) + } + + listOfNodes = append(listOfNodes, string(starJson)) } // iterate over all the subtrees -- cgit 1.4.1