about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhanemile <hanemile@protonmail.com>2019-01-12 20:11:04 +0100
committerhanemile <hanemile@protonmail.com>2019-01-12 20:11:04 +0100
commit30fecdeaef86a04cad7a9f93a31ae9856ad4e473 (patch)
treef773daa127166493235ad5ebffb7e129fe297ec0
parent3396d8a7519e3d1180b42624165ee36eda63625c (diff)
using json to store the stars
-rw-r--r--quadtree.go12
1 files 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